ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilCalendarManageTableGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once('./Services/Table/classes/class.ilTable2GUI.php');
25 
36 {
44  public function __construct($a_parent_obj)
45  {
46  global $lng, $ilCtrl, $ilUser;
47 
48  $this->setId("calmng");
49 
50  $this->lng = $lng;
51  $this->lng->loadLanguageModule('dateplaner');
52  $this->ctrl = $ilCtrl;
53 
54  parent::__construct($a_parent_obj, 'manage');
55  $this->setFormName('categories');
56  $this->addColumn('','','1px', true);
57  $this->addColumn($this->lng->txt('type'), 'type_sortable', '1%');
58  $this->addColumn($this->lng->txt('title'),'title', '79%');
59  $this->addColumn('','','20%');
60 
61  $this->setRowTemplate("tpl.manage_row.html","Services/Calendar");
62  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, "manage"));
63 
64  $this->enable('select_all');
65  $this->enable('sort');
66  $this->enable('header');
67  $this->enable('num_info');
68 
69  $this->setSelectAllCheckbox('selected_cat_ids');
70  $this->setShowRowsSelector(true);
71  // $this->setDisplayAsBlock(true);
72 
73 
74  /*
75  $title = $this->lng->txt('cal_table_categories');
76  $title .= $this->appendCalendarSelection();
77  $table_gui->setTitle($title);
78  */
79 
80  $this->addMultiCommand('confirmDelete',$this->lng->txt('delete'));
81  // $this->addCommandButton('add',$this->lng->txt('add'));
82 
83  $this->setDefaultOrderDirection('asc');
84  $this->setDefaultOrderField('type_sortable');
85  }
86 
90  public function resetToDefaults()
91  {
92  $this->resetOffset();
93  $this->setOrderField('type_sortable');
94  $this->setOrderDirection('asc');
95  }
96 
104  protected function fillRow($a_set)
105  {
106  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
107  $current_selection_list = new ilAdvancedSelectionListGUI();
108  $current_selection_list->setListTitle($this->lng->txt("actions"));
109  $current_selection_list->setId("act_".$a_set['id']);
110 
111  $this->ctrl->setParameter($this->getParentObject(),'category_id',$a_set['id']);
112 
113  // repository calendars cannot be edited
114  if($a_set['editable'] &&
115  !in_array($a_set['type'], array(
119  {
120  $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'edit');
121  $current_selection_list->addItem($this->lng->txt('edit'), '', $url);
122 
123  $this->tpl->setCurrentBlock("checkbox");
124  $this->tpl->setVariable('VAL_ID',$a_set['id']);
125  $this->tpl->parseCurrentBlock();
126  }
127 
128  // import (ics appointments)
129  if($a_set['editable'] &&
130  !in_array($a_set['type'], array(
133  {
134  $url = $this->ctrl->getLinkTarget($this->getParentObject(),'importAppointments');
135  $current_selection_list->addItem($this->lng->txt('cal_import_appointments'),'', $url);
136  }
137 
138  if($a_set['accepted'])
139  {
140  $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'unshare');
141  $current_selection_list->addItem($this->lng->txt('cal_unshare'), '', $url);
142  }
143  else if($a_set['type'] == ilCalendarCategory::TYPE_USR)
144  {
145  $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'shareSearch');
146  $current_selection_list->addItem($this->lng->txt('cal_share'), '', $url);
147  }
148 
149  if($a_set['remote'])
150  {
151  $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'synchroniseCalendar');
152  $current_selection_list->addItem($this->lng->txt('cal_cal_synchronize'),'',$url);
153  }
154 
155  $this->ctrl->setParameter($this->getParentObject(),'category_id','');
156 
157  switch($a_set['type'])
158  {
160  $this->tpl->setVariable('IMG_SRC',ilUtil::getImagePath('icon_calg.svg'));
161  $this->tpl->setVariable('IMG_ALT', $this->lng->txt('cal_type_system'));
162  break;
163 
165  $this->tpl->setVariable('IMG_SRC',ilUtil::getImagePath('icon_usr.svg'));
166  $this->tpl->setVariable('IMG_ALT',$this->lng->txt('cal_type_personal'));
167  break;
168 
170  $type = ilObject::_lookupType($a_set['obj_id']);
171  $this->tpl->setVariable('IMG_SRC',ilUtil::getImagePath('icon_'.$type.'.svg'));
172  $this->tpl->setVariable('IMG_ALT',$this->lng->txt('cal_type_'.$type));
173  break;
174 
176  $this->tpl->setVariable('IMG_SRC',ilUtil::getImagePath('icon_book.svg'));
177  $this->tpl->setVariable('IMG_ALT',$this->lng->txt('cal_type_'.$type));
178  break;
179 
181  $this->tpl->setVariable('IMG_SRC',ilUtil::getImagePath('icon_calch.svg'));
182  $this->tpl->setVariable('IMG_ALT',$this->lng->txt('cal_ch_ch'));
183  break;
184 
185  }
186 
187  $this->tpl->setVariable('VAL_TITLE',$a_set['title']);
188  $this->ctrl->setParameter(
189  $this->getParentObject(),
190  'category_id',
191  $a_set['id']
192  );
193  $this->tpl->setVariable(
194  'EDIT_LINK',
195  $this->ctrl->getLinkTarget(
196  $this->getParentObject(),
197  'details'
198  )
199  );
200 
201  $this->tpl->setVariable('BGCOLOR',$a_set['color']);
202  $this->tpl->setVariable("ACTIONS", $current_selection_list->getHTML());
203 
204 /* if(strlen($a_set['path']))
205  {
206  $this->tpl->setCurrentBlock('calendar_path');
207  $this->tpl->setVariable('ADD_PATH_INFO',$a_set['path']);
208  $this->tpl->parseCurrentBlock();
209  }*/
210  }
211 
218  public function parse()
219  {
220  global $ilUser, $tree;
221 
222  include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
223  $cats = ilCalendarCategories::_getInstance($ilUser->getId());
224  $cats->initialize(ilCalendarCategories::MODE_MANAGE);
225 
226  $tmp_title_counter = array();
227  $categories = array();
228  foreach($cats->getCategoriesInfo() as $category)
229  {
230  $tmp_arr['obj_id'] = $category['obj_id'];
231  $tmp_arr['id'] = $category['cat_id'];
232  $tmp_arr['title'] = $category['title'];
233  $tmp_arr['type'] = $category['type'];
234 
235  // Append object type to make type sortable
236  $tmp_arr['type_sortable'] = ilCalendarCategory::lookupCategorySortIndex($category['type']);
237  if($category['type'] == ilCalendarCategory::TYPE_OBJ)
238  {
239  $tmp_arr['type_sortable'] .= ('_'.ilObject::_lookupType($category['obj_id']));
240  }
241 
242  $tmp_arr['color'] = $category['color'];
243  $tmp_arr['editable'] = $category['editable'];
244  $tmp_arr['accepted'] = $category['accepted'];
245  $tmp_arr['remote'] = $category['remote'];
246 
247  $categories[] = $tmp_arr;
248 
249  // count title for appending the parent container if there is more than one entry.
250  $tmp_title_counter[$category['type'].'_'.$category['title']]++;
251  }
252 
253  $path_categories = array();
254  foreach($categories as $cat)
255  {
256  if($cat['type'] == ilCalendarCategory::TYPE_OBJ)
257  {
258  if($tmp_title_counter[$cat['type'].'_'.$cat['title']] > 1)
259  {
260  foreach(ilObject::_getAllReferences($cat['obj_id']) as $ref_id)
261  {
262  include_once './Services/Tree/classes/class.ilPathGUI.php';
263  $path = new ilPathGUI();
264  $path->setUseImages(false);
265  $path->enableTextOnly(false);
266  $cat['path'] = $path->getPath(ROOT_FOLDER_ID, $ref_id);
267  break;
268  }
269  }
270  }
271  $path_categories[] = $cat;
272  }
273  $this->setData($path_categories);
274  }
275 }
276 ?>
static lookupCategorySortIndex($a_type_id)
Lookup sort index of calendar type.
Creates a path for a start and endnode.
$path
Definition: aliased.php:25
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
resetOffset($a_in_determination=false)
Reset offset.
resetToDefaults()
reset table to defaults
show list of alle calendars to manage
$url
Definition: shib_logout.php:72
__construct($a_parent_obj)
Constructor.
getParentObject()
Get parent object.
setId($a_val)
Set id.
static _getAllReferences($a_id)
get all reference ids of object
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setOrderDirection($a_order_direction)
set order direction public
setOrderField($a_order_field)
set order column
Class ilTable2GUI.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
addMultiCommand($a_cmd, $a_text)
Add Command button.
enable($a_module_name)
enables particular modules of table
$ilUser
Definition: imgupload.php:18
static _getInstance($a_usr_id=0)
get singleton instance
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
User interface class for advanced drop-down selection lists.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
$ref_id
Definition: sahs_server.php:39
setFormName($a_formname="")
Set Form name.
global $lng
Definition: privfeed.php:17
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
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.