ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilCourseGroupingAssignmentTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once('./Services/Table/classes/class.ilTable2GUI.php');
5 
14 {
15  public function __construct($a_parent_obj, $a_parent_cmd, $a_content_obj, $a_group_obj)
16  {
17  global $DIC;
18 
19  $lng = $DIC['lng'];
20  $ilCtrl = $DIC['ilCtrl'];
21 
22  $this->lng = $lng;
23  $this->ctrl = $ilCtrl;
24 
25  parent::__construct($a_parent_obj, $a_parent_cmd);
26 
27  $this->type = ilObject::_lookupType($a_content_obj->getId());
28  $this->lng->loadLanguageModule($this->type);
29 
30  // #9017
31  $this->setLimit(9999);
32 
33  $this->addColumn('', '', 1);
34  $this->addColumn($this->lng->txt('title'), 'title');
35  $this->addColumn($this->lng->txt('path'), 'path');
36 
37  $this->setDefaultOrderField('title');
38  $this->setDefaultOrderDirection('asc');
39 
40  $this->setTitle($this->lng->txt('crs_grp_assign_crs') . ' (' . $a_group_obj->getTitle() . ')');
41 
42  $this->setRowTemplate("tpl.crs_grp_select_crs.html", "Modules/Course");
43  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
44 
45  $this->addMultiCommand('assignCourse', $this->lng->txt('grouping_change_assignment'));
46  $this->addCommandButton('edit', $this->lng->txt('cancel'));
47 
48  $this->getItems($a_content_obj, $a_group_obj);
49  }
50 
51  protected function getItems($a_content_obj, $a_group_obj)
52  {
53  global $DIC;
54 
55  $ilUser = $DIC['ilUser'];
56  $tree = $DIC['tree'];
57 
58  $counter = 0;
60  $this->type,
61  'write',
62  $ilUser->getId(),
63  -1
64  );
65  $items_obj_id = array();
66  $items_ids = array();
67  foreach ($items as $ref_id) {
68  $obj_id = ilObject::_lookupObjId($ref_id);
69  $items_ids[$obj_id] = $ref_id;
70  $items_obj_id[] = $obj_id;
71  }
72  $items_obj_id = ilUtil::_sortIds($items_obj_id, 'object_data', 'title', 'obj_id');
73 
74  $assigned_ids = array();
75  $assigned = $a_group_obj->getAssignedItems();
76  if ($assigned) {
77  foreach ($assigned as $item) {
78  $assigned_ids[] = $item['target_ref_id'];
79  }
80  }
81 
82  $data = array();
83  foreach ($items_obj_id as $obj_id) {
84  $item_id = $items_ids[$obj_id];
85  if ($tree->checkForParentType($item_id, 'adm')) {
86  continue;
87  }
88 
89  $obj_id = ilObject::_lookupObjId($item_id);
90 
91  $data[] = array('id' => $item_id,
92  'title' => ilObject::_lookupTitle($obj_id),
93  'description' => ilObject::_lookupDescription($obj_id),
94  'path' => $this->__formatPath($tree->getPathFull($item_id)),
95  'assigned' => in_array($item_id, $assigned_ids));
96  }
97 
98  $this->setData($data);
99  }
100 
101  public function __formatPath($a_path_arr)
102  {
103  $counter = 0;
104  foreach ($a_path_arr as $data) {
105  if (!$counter++) {
106  continue;
107  }
108  if ($counter++ > 2) {
109  $path .= " -> ";
110  }
111  $path .= $data['title'];
112  }
113 
114  return $path;
115  }
116 
117  public function fillRow($a_set)
118  {
119  $this->tpl->setVariable("ID", $a_set["id"]);
120  $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
121  $this->tpl->setVariable("TXT_PATH", $a_set["path"]);
122 
123  if ($a_set["assigned"]) {
124  $this->tpl->setVariable("STATUS_CHECKED", " checked=\"checked\"");
125  }
126  }
127 }
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
$path
Definition: aliased.php:25
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
global $DIC
Definition: saml.php:7
static _getObjectsByOperations($a_obj_type, $a_operation, $a_usr_id=0, $limit=0)
Get all objects of a specific type and check access This function is not recursive, instead it parses the serialized rbac_pa entries.
static _lookupTitle($a_id)
lookup object title
__construct($a_parent_obj, $a_parent_cmd, $a_content_obj, $a_group_obj)
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
Class ilTable2GUI.
static _sortIds($a_ids, $a_table, $a_field, $a_id_name)
Function that sorts ids by a given table field using WHERE IN E.g: __sort(array(6,7),&#39;usr_data&#39;,&#39;lastname&#39;,&#39;usr_id&#39;) => sorts by lastname.
static _lookupDescription($a_id)
lookup object description
static _lookupObjId($a_id)
addMultiCommand($a_cmd, $a_text)
Add Command button.
$ilUser
Definition: imgupload.php:18
setRowTemplate($a_template, $a_template_dir="")
Set row template.
static _lookupType($a_id, $a_reference=false)
lookup object type
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setLimit($a_limit=0, $a_default_limit=0)