Files
fdn2/private/lib/dao/models/CommentoModel.php
T

54 lines
1.3 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;
* @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("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";
}
}
?>