Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Answer.php
1 <?php
2 
3 /**
4  * Gentics Portal.Node PHP
5  * Author & Copyright (c) by Gentics Software GmbH
6  * sales@gentics.com
7  * http://www.gentics.com
8  * Licenses can be found in the LICENSE.txt file in the root-folder of this installation
9  * You must not use this software without a valid license agreement.
10  *
11  * Represents single answer
12  *
13  **/
14 class Answer extends CActiveRecord
15 {
16 
17  /**
18  * Returns the static model of the specified AR class.
19  *
20  * @param string $className active record class name
21  *
22  * @return array|CActiveRecord
23  */
24  public static function model($className = __CLASS__)
25  {
26  return parent::model($className);
27  }
28 
29  /**
30  * Returns the name of the associated database table.
31  * By default this method returns the class name as the table name.
32  * You may override this method if the table is not named after this convention.
33  *
34  * @return string the table name
35  */
36  public function tableName()
37  {
38  return '{{answer}}';
39  }
40 
41  /**
42  * Returns the validation rules for attributes.
43  *
44  * @return array
45  */
46  public function rules()
47  {
48  return array(
49  array('active', 'default', 'value' => 1),
50  array('created', 'default', 'value' => AppHelper::mysqlDate()),
51  array('question_id, answer_key, text, active','required'),
52  array('order, active', 'numerical', 'integerOnly' => true),
53  array('text', 'safe'),
54  array('created', 'type', 'type'=>'datetime', 'datetimeFormat' => 'yyyy-MM-dd HH:mm:ss'),
55  array('id, question_id, text, order, created','safe', 'on'=>'search'),
56  );
57  }
58 
59 
60  public function relations()
61  {
62  return array(
63  'question' => array(CActiveRecord::BELONGS_TO, 'Question', 'question_id'),
64  'userAnswers' => array(CActiveRecord::HAS_MANY, 'UserAnswer', 'answer_id'),
65  'userAnswersCount' => array(CActiveRecord::STAT, 'UserAnswer', 'answer_id')
66  );
67  }
68  public function getAttributeLabel($name)
69  {
70  return VoteModule::t(parent::getAttributeLabel($name));
71  }
72 }
73