HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
AssignmentForm.php
Go to the documentation of this file.
1 <?php
10 class AssignmentForm extends CFormModel
11 {
12  public $itemname;
13 
19  const DEFAULT_ROLE_TYPE = 'default';
20 
26  const DEFAULT_TEMP_ROLE_TYPE = 'default_temp';
27 
31  public function rules()
32  {
33  return array(
34  array('itemname', 'safe'),
35  );
36  }
37 
41  public function attributeLabels()
42  {
43  return array(
44  'itemname' => Rights::t('core', 'Authorization item'),
45  );
46  }
47 
55  public static function setDefaultAuthAssignments($userId, $defaultType = self::DEFAULT_ROLE_TYPE)
56  {
57  if (empty($userId)) {
58  return false;
59  }
60  $defaultUser = User::model()->findByAttributes(array('username' => $defaultType));
61  $assignedItems = Rights::getAuthorizer()->getAuthItems(null, $defaultUser->id);
62  foreach ($assignedItems as $assignedItem) {
63  Rights::getAuthorizer()->authManager->assign(
64  $assignedItem->name, $userId
65  );
66  }
67 
68  return true;
69  }
70 }