ILIAS  Release_5_0_x_branch Revision 61816
 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  $this->setShowRowsSelector(true);
53 
54  if($this->roleAssignmentEditable)
55  {
56  $this->setSelectAllCheckbox("user_id[]");
57  $this->addMultiCommand("deassignUser", $lng->txt("remove"));
58  }
59 
60  $this->getItems();
61 
62  // mjansen: Used for mail referer link (@see fillRow). I don't want to create a new instance in each fillRow call.
63  include_once './Services/Administration/classes/class.ilAdministrationGUI.php';
64  #$this->topGuiObj = new ilAdministrationGUI();
65  }
66 
71  public function getRoleId()
72  {
73  return $this->role_id;
74  }
75 
80  public function isRoleAssignmentEditable()
81  {
83  }
84 
88  function getItems()
89  {
90  global $lng,$rbacreview;
91 
92  $this->determineOffsetAndOrder();
93 
94  include_once("./Services/User/classes/class.ilUserQuery.php");
95 
96  $usr_data = ilUserQuery::getUserListData(
100  ilUtil::stripSlashes($this->getLimit()),
101  '',
102  '',
103  null,
104  false,
105  false,
106  0,
107  $this->getRoleId()
108  );
109 
110  /*
111  if($rbacreview->isAssigned(SYSTEM_USER_ID, $this->getRoleId()))
112  {
113  $this->setMaxCount($usr_data["cnt"] - 1);
114  }
115  else
116  {
117  */
118  $this->setMaxCount($usr_data["cnt"]);
119  // }
120  $this->setData($usr_data["set"]);
121  }
122 
123 
124 
128  protected function fillRow($user)
129  {
130  global $ilCtrl, $lng;
131 
132  $this->tpl->setVariable("VAL_FIRSTNAME", $user["firstname"]);
133  $this->tpl->setVariable("VAL_LASTNAME", $user["lastname"]);
134 
135  if(
136  $user['usr_id'] != SYSTEM_USER_ID and
137  ($user['usr_id'] != ANONYMOUS_USER_ID or $this->getRoleId() != ANONYMOUS_ROLE_ID) and
138  $this->isRoleAssignmentEditable())
139  {
140  $this->tpl->setVariable("ID", $user["usr_id"]);
141  }
142 
143  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
144  $actions = new ilAdvancedSelectionListGUI();
145  $actions->setSelectionHeaderClass("small");
146  $actions->setItemLinkClass("small");
147 
148  $actions->setListTitle($lng->txt('actions'));
149  $actions->setId($user['usr_id']);
150 
151  $link_contact = ilMailFormCall::getLinkTarget(
152  $this->getParentObject(), $this->getParentCmd(),
153  array('fr' => rawurlencode(base64_encode($ilCtrl->getLinkTarget($this->getParentObject(), 'userassignment', '', false, false)))),
154  array('type' => 'new', 'rcp_to' => urlencode($user['login']))
155  );
156  $actions->addItem(
157  $lng->txt('message'),
158  '',
159  $link_contact
160  );
161 
162  if(strtolower($_GET["baseClass"]) == 'iladministrationgui' && $_GET["admin_mode"] == "settings")
163  {
164  $ilCtrl->setParameterByClass("ilobjusergui", "ref_id", 7);
165  $ilCtrl->setParameterByClass("ilobjusergui", "obj_id", $user["usr_id"]);
166 
167  $link_change = $ilCtrl->getLinkTargetByClass(array("iladministrationgui", "ilobjusergui"), "view");
168 
169  $this->tpl->setVariable('VAL_LOGIN',$user['login']);
170  $this->tpl->setVariable('HREF_LOGIN',$link_change);
171  $actions->addItem(
172  $this->lng->txt("edit"),
173  '',
174  $link_change
175  );
176  }
177  else
178  {
179  $this->tpl->setVariable('VAL_PLAIN_LOGIN',$user['login']);
180  }
181 
182  if(
183  ($this->getRoleId() != SYSTEM_ROLE_ID or $user['usr_id'] != SYSTEM_USER_ID) and
184  ($this->getRoleId() != ANONYMOUS_ROLE_ID or $user['usr_id'] != ANONYMOUS_USER_ID) and
185  $this->isRoleAssignmentEditable())
186  {
187  $ilCtrl->setParameter($this->getParentObject(), "user_id", $user["usr_id"]);
188  $link_leave = $ilCtrl->getLinkTarget($this->getParentObject(),"deassignUser");
189 
190  $actions->addItem(
191  $this->lng->txt('remove'),
192  '',
193  $link_leave
194  );
195  }
196 
197  $this->tpl->setVariable('VAL_ACTIONS',$actions->getHTML());
198  }
199 
200 }
201 ?>