ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilAssignedUsersTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Table/classes/class.ilTable2GUI.php");
5 require_once 'Services/Mail/classes/class.ilMailFormCall.php';
6 
16 {
17  protected $role_id;
18  protected $roleAssignmentEditable = true;
19 
25  function __construct($a_parent_obj, $a_parent_cmd, $a_role_id, $a_editable = true)
26  {
27  global $ilCtrl, $lng, $ilAccess, $lng, $rbacsystem;
28 
29  $this->setId("rbac_ua_".$a_role_id);
30  $this->role_id = $a_role_id;
31  $this->roleAssignmentEditable = $a_editable;
32 
33  parent::__construct($a_parent_obj, $a_parent_cmd);
34 // $this->setTitle($this->lng->txt("users"));
35 
36  $this->addColumn("", "", "1", true);
37  $this->addColumn($this->lng->txt("login"), "login", "29%");
38  $this->addColumn($this->lng->txt("firstname"), "firstname", "29%");
39  $this->addColumn($this->lng->txt("lastname"), "lastname", "29%");
40  $this->addColumn($this->lng->txt('actions'),'','13%');
41 
42  $this->setExternalSorting(true);
43  $this->setExternalSegmentation(true);
44  $this->setEnableHeader(true);
45  $this->setFormAction($ilCtrl->getFormAction($this->parent_obj, $a_parent_cmd));
46  $this->setRowTemplate("tpl.user_assignment_row.html", "Services/AccessControl");
47 
48  $this->setEnableTitle(true);
49  $this->setDefaultOrderField("login");
50  $this->setDefaultOrderDirection("asc");
51 
52  if($this->roleAssignmentEditable)
53  {
54  $this->setSelectAllCheckbox("user_id[]");
55  $this->addMultiCommand("deassignUser", $lng->txt("remove"));
56  }
57 
58  $this->getItems();
59 
60  // mjansen: Used for mail referer link (@see fillRow). I don't want to create a new instance in each fillRow call.
61  include_once './Services/Administration/classes/class.ilAdministrationGUI.php';
62  #$this->topGuiObj = new ilAdministrationGUI();
63  }
64 
69  public function getRoleId()
70  {
71  return $this->role_id;
72  }
73 
78  public function isRoleAssignmentEditable()
79  {
81  }
82 
86  function getItems()
87  {
88  global $lng,$rbacreview;
89 
90  $this->determineOffsetAndOrder();
91 
92  include_once("./Services/User/classes/class.ilUserQuery.php");
93 
94  $usr_data = ilUserQuery::getUserListData(
99  '',
100  '',
101  null,
102  false,
103  false,
104  0,
105  $this->getRoleId()
106  );
107 
108  if($rbacreview->isAssigned(SYSTEM_USER_ID, $this->getRoleId()))
109  {
110  $this->setMaxCount($usr_data["cnt"] - 1);
111  }
112  else
113  {
114  $this->setMaxCount($usr_data["cnt"]);
115  }
116  $this->setData($usr_data["set"]);
117  }
118 
119 
120 
124  protected function fillRow($user)
125  {
126  global $ilCtrl, $lng;
127 
128  $this->tpl->setVariable("VAL_FIRSTNAME", $user["firstname"]);
129  $this->tpl->setVariable("VAL_LASTNAME", $user["lastname"]);
130 
131  if(
132  $user['usr_id'] != SYSTEM_USER_ID and
133  ($user['usr_id'] != ANONYMOUS_USER_ID or $this->getRoleId() != ANONYMOUS_ROLE_ID) and
134  $this->isRoleAssignmentEditable())
135  {
136  $this->tpl->setVariable("ID", $user["usr_id"]);
137  }
138 
139  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
140  $actions = new ilAdvancedSelectionListGUI();
141  $actions->setSelectionHeaderClass("small");
142  $actions->setItemLinkClass("small");
143 
144  $actions->setListTitle($lng->txt('actions'));
145  $actions->setId($user['usr_id']);
146 
147  #$link_contact = ilMailFormCall::getLinkTarget(
148  # $this->topGuiObj, 'frameset',
149  # array('fr' => rawurlencode(base64_encode($ilCtrl->getLinkTarget($this->getParentObject(), 'userassignment', '', false, false)))),
150  # array('type' => 'new', 'rcp_to' => urlencode($user['login']))
151  #);
152  $actions->addItem(
153  $lng->txt('message'),
154  '',
155  $link_contact
156  );
157 
158  if(strtolower($_GET["baseClass"]) == 'iladministrationgui' && $_GET["admin_mode"] == "settings")
159  {
160  $ilCtrl->setParameterByClass("ilobjusergui", "ref_id", 7);
161  $ilCtrl->setParameterByClass("ilobjusergui", "obj_id", $user["usr_id"]);
162 
163  $link_change = $ilCtrl->getLinkTargetByClass(array("iladministrationgui", "ilobjusergui"), "view");
164 
165  $this->tpl->setVariable('VAL_LOGIN',$user['login']);
166  $this->tpl->setVariable('HREF_LOGIN',$link_change);
167  $actions->addItem(
168  $this->lng->txt("edit"),
169  '',
170  $link_change
171  );
172  }
173  else
174  {
175  $this->tpl->setVariable('VAL_PLAIN_LOGIN',$user['login']);
176  }
177 
178  if(
179  ($this->getRoleId() != SYSTEM_ROLE_ID or $user['usr_id'] != SYSTEM_USER_ID) and
180  ($this->getRoleId() != ANONYMOUS_ROLE_ID or $user['usr_id'] != ANONYMOUS_USER_ID) and
181  $this->isRoleAssignmentEditable())
182  {
183  $ilCtrl->setParameter($this->getParentObject(), "user_id", $user["usr_id"]);
184  $link_leave = $ilCtrl->getLinkTarget($this->getParentObject(),"deassignUser");
185 
186  $actions->addItem(
187  $this->lng->txt('remove'),
188  '',
189  $link_leave
190  );
191  }
192 
193  $this->tpl->setVariable('VAL_ACTIONS',$actions->getHTML());
194  }
195 
196 }
197 ?>