Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Question.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 question
12  *
13  **/
14 class Question 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 '{{question}}';
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('created', 'default', 'value' => AppHelper::mysqlDate()),
50  array('id, author_id, text','required'),
51  array('id', 'length', 'max'=>255),
52  array('author_id', 'numerical', 'integerOnly' => true),
53  array('text', 'safe'),
54  array('created', 'type', 'type'=>'datetime', 'datetimeFormat' => 'yyyy-MM-dd HH:mm:ss'),
55  array('id, author_id, text, created','safe', 'on'=>'search'),
56  );
57  }
58 
59 
60  public function getAttributeLabel($name)
61  {
62  return VoteModule::t(parent::getAttributeLabel($name));
63  }
64 
65  public function relations()
66  {
67  return array(
68  'answers' => array(CActiveRecord::HAS_MANY, 'Answer', 'question_id')
69  );
70  }
71 }