ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilMStListCoursesGUI.php
Go to the documentation of this file.
1 <?php
2 
12 {
13  const CMD_APPLY_FILTER = 'applyFilter';
14  const CMD_INDEX = 'index';
15  const CMD_GET_ACTIONS = "getActions";
16  const CMD_RESET_FILTER = 'resetFilter';
20  protected $table;
24  protected $access;
25 
26 
30  public function __construct()
31  {
32  $this->access = ilMyStaffAccess::getInstance();
33  }
34 
35 
39  protected function checkAccessOrFail()
40  {
41  global $DIC;
42 
43  if ($this->access->hasCurrentUserAccessToMyStaff()) {
44  return;
45  } else {
46  ilUtil::sendFailure($DIC->language()->txt("permission_denied"), true);
47  $DIC->ctrl()->redirectByClass(ilPersonalDesktopGUI::class, "");
48  }
49  }
50 
51 
55  public function executeCommand()
56  {
57  global $DIC;
58 
59  $cmd = $DIC->ctrl()->getCmd();
60  $next_class = $DIC->ctrl()->getNextClass();
61 
62  switch ($next_class) {
63  case strtolower(ilFormPropertyDispatchGUI::class):
64  $this->checkAccessOrFail();
65 
66  $DIC->ctrl()->setReturn($this, self::CMD_INDEX);
67  $this->table = new ilMStListCoursesTableGUI($this, self::CMD_INDEX);
68  $this->table->executeCommand();
69  break;
70  default:
71  switch ($cmd) {
72 
73  case self::CMD_RESET_FILTER:
74  case self::CMD_APPLY_FILTER:
75  case self::CMD_INDEX:
76  case self::CMD_GET_ACTIONS:
77  $this->$cmd();
78  break;
79  default:
80  $this->index();
81  break;
82  }
83  break;
84  }
85  }
86 
87 
91  public function index()
92  {
93  $this->listUsers();
94  }
95 
96 
100  public function listUsers()
101  {
102  global $DIC;
103 
104  $this->checkAccessOrFail();
105 
106  $this->table = new ilMStListCoursesTableGUI($this, self::CMD_INDEX);
107  $this->table->setTitle($DIC->language()->txt('mst_list_courses'));
108  $DIC->ui()->mainTemplate()->setContent($this->table->getHTML());
109  }
110 
111 
115  public function applyFilter()
116  {
117  $this->table = new ilMStListCoursesTableGUI($this, self::CMD_APPLY_FILTER);
118  $this->table->writeFilterToSession();
119  $this->table->resetOffset();
120  $this->index();
121  }
122 
123 
127  public function resetFilter()
128  {
129  $this->table = new ilMStListCoursesTableGUI($this, self::CMD_RESET_FILTER);
130  $this->table->resetOffset();
131  $this->table->resetFilter();
132  $this->index();
133  }
134 
135 
139  public function getId()
140  {
141  $this->table = new ilMStListCoursesTableGUI($this, self::CMD_INDEX);
142 
143  return $this->table->getId();
144  }
145 
146 
150  public function cancel()
151  {
152  global $DIC;
153 
154  $DIC->ctrl()->redirect($this);
155  }
156 
157 
161  public function getActions()
162  {
163  global $DIC;
164 
165  $mst_co_usr_id = $DIC->http()->request()->getQueryParams()['mst_lco_usr_id'];
166  $mst_lco_crs_ref_id = $DIC->http()->request()->getQueryParams()['mst_lco_crs_ref_id'];
167 
168  if ($mst_co_usr_id > 0 && $mst_lco_crs_ref_id > 0) {
169  $selection = new ilAdvancedSelectionListGUI();
170 
171  if ($DIC->access()->checkAccess("visible", "", $mst_lco_crs_ref_id)) {
172  $link = ilLink::_getStaticLink($mst_lco_crs_ref_id, ilMyStaffAccess::DEFAULT_CONTEXT);
173  $selection->addItem(ilObject2::_lookupTitle(ilObject2::_lookupObjectId($mst_lco_crs_ref_id)), '', $link);
174  };
175 
177  foreach (ilOrgUnitUserAssignment::innerjoin('object_reference', 'orgu_id', 'ref_id')->where(array(
178  'user_id' => $mst_co_usr_id,
179  'object_reference.deleted' => null
180  ), array( 'user_id' => '=', 'object_reference.deleted' => '!=' ))->get() as $org_unit_assignment) {
181  if ($DIC->access()->checkAccess("read", "", $org_unit_assignment->getOrguId())) {
182  $link = ilLink::_getStaticLink($org_unit_assignment->getOrguId(), 'orgu');
183  $selection->addItem($org_units[$org_unit_assignment->getOrguId()], '', $link);
184  }
185  }
186 
187  $selection = ilMyStaffGUI::extendActionMenuWithUserActions($selection, $mst_co_usr_id, rawurlencode($DIC->ctrl()
188  ->getLinkTarget($this, self::CMD_INDEX)));
189 
190  echo $selection->getHTML(true);
191  }
192  exit;
193  }
194 }
static _lookupTitle($a_id)
static innerjoin($tablename, $on_this, $on_external, $fields=array(' *'), $operator='=', $both_external=false)
global $DIC
Definition: saml.php:7
static _lookupObjectId($a_ref_id)
Class ilMStListCoursesTableGUI.
static getTextRepresentationOfOrgUnits($sort_by_title=true)
Get ref id path array.
Class ilMStListCoursesGUI.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
User interface class for advanced drop-down selection lists.
exit
Definition: backend.php:16