1 <?php
2 3 4 5 6 7 8
9 class RUserBehavior extends CModelBehavior
10 {
11 12 13
14 public $idColumn;
15 16 17
18 public $nameColumn;
19
20 private $_assignments;
21
22 23 24 25 26
27 public function getId()
28 {
29 if( $this->idColumn===null )
30 $this->idColumn = Rights::module()->userIdColumn;
31
32 return $this->owner->{$this->idColumn};
33 }
34
35 36 37 38 39
40 public function getName()
41 {
42 if( $this->nameColumn===null )
43 $this->nameColumn = Rights::module()->userNameColumn;
44
45 return $this->owner->{$this->nameColumn};
46 }
47
48 49 50 51
52 public function getAssignmentNameLink()
53 {
54 return CHtml::link($this->getName(), array('assignment/user', 'id'=>$this->getId()));
55 }
56
57 58 59 60 61 62
63 public function getAssignmentsText($type)
64 {
65 $assignedItems = $this->getAssignments();
66
67 if( isset($assignedItems[ $type ])===true )
68 {
69 $items = $assignedItems[ $type ];
70 $names = array();
71 foreach( $items as $itemname=>$item )
72 $names[] = $item->getNameText();
73
74 return implode('<br />', $names);
75 }
76 }
77
78 79 80 81
82 public function getAssignments()
83 {
84 if( $this->_assignments!==null )
85 {
86 return $this->_assignments;
87 }
88 else
89 {
90 $authorizer = Rights::getAuthorizer();
91 $authAssignments = $authorizer->authManager->getAuthAssignments($this->getId());
92 $nestedItems = $authorizer->authManager->getAuthItemsByNames(array_keys($authAssignments), true);
93
94 $assignments = array();
95 foreach( $nestedItems as $type=>$items )
96 {
97 $items = $authorizer->attachAuthItemBehavior($items);
98 $assignments[ $type ] = array();
99 foreach( $items as $itemName=>$item )
100 $assignments[ $type ][ $itemName ] = $item;
101 }
102
103 return $this->_assignments = $assignments;
104 }
105 }
106 }