00001 <?php
00002
00003
00004
00005
00006
00007 class DAOVotes extends DataObjectBase {
00008 public $id;
00009 public $instance;
00010 public $value;
00011 public $weight;
00012 public $voterid;
00013 public $creationdate;
00014
00015
00016 protected function create_table_object() {
00017 return new DBTable(
00018 'votes',
00019 array(
00020 new DBFieldInt('id', null, DBFieldInt::AUTOINCREMENT | DBFieldInt::UNSIGNED | DBFieldInt::NOT_NULL),
00021 new DBFieldInstanceReference('instance'),
00022 new DBFieldInt('value'),
00023 new DBFieldInt('weight'),
00024 new DBFieldText('voterid', 30),
00025 new DBFieldDateTime('creationdate', null, DBFieldDateTime::TIMESTAMP),
00026 ),
00027 'id'
00028 );
00029 }
00030
00031
00032
00033
00034
00035
00036 public function validate() {
00037 $ret = parent::validate();
00038 if ($this->value < 0 || $this->value > 100) {
00039 $ret->append(tr('Vote must be between 0 and 100', 'voting'));
00040 }
00041 if (empty($this->weight)) {
00042 $this->weight = 1;
00043 }
00044 return $ret;
00045 }
00046
00047
00048 }