HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
UsersRights.php
Go to the documentation of this file.
1 <?php
2 abstract class UsersRights extends CActiveRecord
3 {
9  public static function model($className = __CLASS__)
10  {
11  return parent::model($className);
12  }
13 
19  public function behaviors()
20  {
21  return array(
22  'StatesBinaryField' => array(
23  'class' => 'StatesBinaryFieldBehavior',
24  'attribute' => 'Rights',
25  'data' => $this->getRightsList(),
26  ),
27  );
28  }
29 
35  public function getRightsList()
36  {
37  $key = $this->_getRightsKey();
38 
39  return UsersRightsDefaults::model()->getRightsList($key);
40  }
41 
49  public function setRightsList($rights)
50  {
51  $key = $this->_getRightsKey();
52  UsersRightsDefaults::model()->setRightsList($key, $rights);
53  }
54 
62  abstract public function search($params);
63 
72  abstract public function setRightsAllRecords($records, $rights = array());
73 
82  abstract public function setRightsSingleRecord($params, $autoSet = false);
83 
92  abstract public function buildRightsSingleRecordParams($record, $rights = array());
93 
99  abstract protected function _getRightsKey();
100 
109  protected function _getValueFromRecord($record, $fields)
110  {
111  $value = '';
112  if (empty($record) || empty($fields)) {
113  return $value;
114  }
115  foreach ($fields as $field) {
116  if (is_array($record)) {
117  if (isset($record[$field])) {
118  $value = $record[$field];
119  break;
120  }
121  } elseif ($record instanceof CActiveRecord) {
122  if (isset($record->$field)) {
123  $value = $record->$field;
124  break;
125  }
126  }
127  }
128 
129  return $value;
130  }
131 }