Files
fdn2/private/lib/dao/models/CommentoModel.php
T
Riccardo Di Dato b015b44ec7 Aggiunti warning mail per commenti
Aggiunte nuove mail al mail helper
Correzioni grafiche alle pagine di cancellazione in amministrazione
Modificata pagina di validazione commento
2016-03-17 23:00:26 +01:00

58 lines
1.4 KiB
PHP

<?php
class CommentoModel extends Model{
const STATUS_PENDING = 1;
const STATUS_ACCEPTED = 2;
const STATUS_REJECTED = 3;
public static $COMMENTO_STATUS = array(
self::STATUS_PENDING=>array("label"=>"Valutazione"),
self::STATUS_ACCEPTED=>array("label"=>"Accettata"),
self::STATUS_REJECTED=>array("label"=>"Respinta")
);
/**
* saveableObject deve avere alemeno il campo notizia = notiziaId e il campo user = userId;
* @param stdClass $saveableObject
* @throws CoreException
*/
public function __construct($saveableObject){
parent::__construct($saveableObject);
if (!$this->hasProperty("notizia") || strcmp($this->notizia,"")==0){
throw new CoreException("Impossible to build CommentoModel without field notizia");
}
if (!$this->hasProperty("user") || strcmp($this->user,"")==0){
throw new CoreException("Impossible to build CommentoModel without field user");
}
if (!$this->hasProperty("status") || strcmp($this->status,"")==0){
$this->status = self::STATUS_PENDING;
}
if (!$this->hasProperty("mailSent")){
$this->mailSent = false;
}
if (!$this->hasProperty("date")){
$this->date = new MongoDate();
}
}
public function __set($attr,$value){
if (strcmp("status", $attr)==0){
$value = intval($value);
}
return parent::__set($attr, $value);
}
public static function getCollectionName(){
return "commenti";
}
}
?>