HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
RUserBehavior.php
Go to the documentation of this file.
1 <?php
10 class RUserBehavior extends CModelBehavior
11 {
15  public $idColumn;
19  public $nameColumn;
20 
21  private $_assignments;
22 
29  public function getId()
30  {
31  if ($this->idColumn === null) {
32  $this->idColumn = Rights::module()->userIdColumn;
33  }
34 
35  return $this->owner->{$this->idColumn};
36  }
37 
44  public function getName()
45  {
46  if ($this->nameColumn === null) {
47  $this->nameColumn = Rights::module()->userNameColumn;
48  }
49 
50  return $this->owner->{$this->nameColumn};
51  }
52 
58  public function getAssignmentNameLink()
59  {
60  return CHtml::link($this->getName(), array('assignment/user', 'id' => $this->getId()));
61  }
62 
71  public function getAssignmentsText($type)
72  {
73  $assignedItems = $this->getAssignments();
74 
75  if (isset($assignedItems[ $type ]) === true) {
76  $items = $assignedItems[ $type ];
77  $names = array();
78  foreach ($items as $itemname => $item) {
79  $names[] = $item->getNameText();
80  }
81 
82  return implode('<br />', $names);
83  }
84  }
85 
91  public function getAssignments()
92  {
93  if ($this->_assignments !== null) {
94  return $this->_assignments;
95  } else {
96  $authorizer = Rights::getAuthorizer();
97  $authAssignments = $authorizer->authManager->getAuthAssignments($this->getId());
98  $nestedItems = $authorizer->authManager->getAuthItemsByNames(array_keys($authAssignments), true);
99 
100  $assignments = array();
101  foreach ($nestedItems as $type => $items) {
102  $items = $authorizer->attachAuthItemBehavior($items);
103  $assignments[ $type ] = array();
104  foreach ($items as $itemName => $item) {
105  $assignments[ $type ][ $itemName ] = $item;
106  }
107  }
108 
109  return $this->_assignments = $assignments;
110  }
111  }
112 }