HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
AccountTypes.php
Go to the documentation of this file.
1 <?php
2 
11 class AccountTypes extends CActiveRecord
12 {
16  public function tableName()
17  {
18  return 'account_types';
19  }
20 
24  public function rules()
25  {
26  // NOTE: you should only define rules for those attributes that
27  // will receive user inputs.
28  return array(
29  array('Type', 'required'),
30  array('Type', 'length', 'max' => 150),
31  // The following rule is used by search().
32  // @todo Please remove those attributes that should not be searched.
33  array('Id, Type', 'safe', 'on' => 'search'),
34  );
35  }
36 
40  public function relations()
41  {
42  // NOTE: you may need to adjust the relation name and the related
43  // class name for the relations automatically generated below.
44  return array(
45  );
46  }
47 
51  public function attributeLabels()
52  {
53  return array(
54  'Id' => 'ID',
55  'Type' => 'Type',
56  );
57  }
58 
71  public function search()
72  {
73  // @todo Please modify the following code to remove attributes that should not be searched.
74 
75  $criteria = new CDbCriteria();
76 
77  $criteria->compare('Id', $this->Id, true);
78  $criteria->compare('Type', $this->Type, true);
79 
80  return new CActiveDataProvider($this, array(
81  'criteria' => $criteria,
82  ));
83  }
84 
93  public static function model($className = __CLASS__)
94  {
95  return parent::model($className);
96  }
97 
98  protected function beforeDelete()
99  {
100  $primaryKey = $this->primaryKey;
101  if (!empty($primaryKey)) {
102  AccountUsers::model()->setAllUsersDefaultAccountTypeByAccountTypeId($primaryKey);
103  }
104  return parent::beforeDelete();
105  }
106 
107  /*
108  * Returns available types
109  * @return object AccountTypes
110  */
111  /*public function getAvailableTypes() {
112  $accountTypeIds = array();
113  $accountTypesLimits = AccountTypesLimits::model()->findAll();
114  foreach ($accountTypesLimits as $accountTypeLimit) {
115  $accountTypeIds[] = $accountTypeLimit->AccountTypeId;
116  }
117 
118  $criteria = new CDbCriteria();
119  $criteria->addNotInCondition('Id', $accountTypeIds);
120  return AccountTypes::model()->findAll($criteria);
121  }*/
122 }