ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilConsultationHoursTableGUI.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 include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
6 
17 {
18  private $user_id = 0;
19  private $has_groups = false;
20 
28  public function __construct($a_gui,$a_cmd,$a_user_id)
29  {
30  global $lng,$ilCtrl;
31 
32  $this->user_id = $a_user_id;
33 
34  include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourGroups.php';
35  $this->has_groups = ilConsultationHourGroups::getCountGroupsOfUser($a_user_id);
36 
37  $this->setId('chtg_'.$this->getUserId());
38  parent::__construct($a_gui,$a_cmd);
39 
40  $this->addColumn('','f',1);
41  $this->addColumn($this->lng->txt('appointment'),'start');
42 
43  if($this->hasGroups())
44  {
45  $this->addColumn($this->lng->txt('cal_ch_grp_header'),'group');
46  }
47 
48  $this->addColumn($this->lng->txt('title'),'title');
49  $this->addColumn($this->lng->txt('cal_ch_num_bookings'),'num_bookings');
50  $this->addColumn($this->lng->txt('cal_ch_bookings'),'participants');
51  $this->addColumn($this->lng->txt('cal_ch_target_object'),'target');
52  $this->addColumn('');
53 
54  $this->setRowTemplate('tpl.ch_upcoming_row.html','Services/Calendar');
55  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject(),$this->getParentCmd()));
56  $this->setTitle($this->lng->txt('cal_ch_ch'));
57 
58  $this->enable('sort');
59  $this->enable('header');
60  $this->enable('numinfo');
61 
62  $this->setDefaultOrderField('start');
63  $this->setSelectAllCheckbox('apps');
64  $this->setShowRowsSelector(true);
65  $this->addMultiCommand('edit', $this->lng->txt('edit'));
66  $this->addMultiCommand('searchUsersForAppointments', $this->lng->txt('cal_ch_assign_participants'));
67  $this->addMultiCommand('confirmDelete', $this->lng->txt('delete'));
68  }
69 
74  public function getUserId()
75  {
76  return $this->user_id;
77  }
78 
82  public function hasGroups()
83  {
84  return $this->has_groups;
85  }
86 
91  public function fillRow($row)
92  {
93  global $ilCtrl;
94 
95  $this->tpl->setVariable('VAL_ID',$row['id']);
96  $this->tpl->setVariable('START',$row['start_p']);
97  $this->tpl->setVariable('TITLE',$row['title']);
98 
99  if($this->hasGroups())
100  {
101  $this->tpl->setVariable('TITLE_GROUP',$row['group']);
102  }
103 
104  $this->tpl->setVariable('NUM_BOOKINGS',$row['num_bookings']);
105 
106  foreach((array) $row['target_links'] as $link)
107  {
108  $this->tpl->setCurrentBlock('links');
109  $this->tpl->setVariable('TARGET', $link['title']);
110  $this->tpl->setVariable('URL_TARGET',$link['link']);
111  $this->tpl->parseCurrentBlock();
112  }
113  if($row['bookings'])
114  {
115  foreach($row['bookings'] as $user_id => $name)
116  {
117  $user_profile_prefs = ilObjUser::_getPreferences($user_id);
118  if($user_profile_prefs["public_profile"] == "y")
119  {
120  $this->tpl->setCurrentBlock('booking_with_link');
121  $ilCtrl->setParameter($this->getParentObject(), 'user', $user_id);
122  $this->tpl->setVariable('URL_BOOKING', $ilCtrl->getLinkTarget($this->getParentObject(), 'showprofile'));
123  }
124  else
125  {
126  $this->tpl->setCurrentBlock('booking_without_link');
127  }
128  $ilCtrl->setParameter($this->getParentObject(), 'user', '');
129  $this->tpl->setVariable('TXT_BOOKING', $name);
130  $this->tpl->parseCurrentBlock();
131  }
132  }
133 
134  $this->tpl->setVariable('BOOKINGS',implode(', ', $row['bookings']));
135 
136  include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
137  $list = new ilAdvancedSelectionListGUI();
138  $list->setId('act_cht_'.$row['id']);
139  $list->setListTitle($this->lng->txt('actions'));
140 
141  $ilCtrl->setParameter($this->getParentObject(),'apps',$row['id']);
142  $list->addItem(
143  $this->lng->txt('edit'),
144  '',
145  $ilCtrl->getLinkTarget($this->getParentObject(),'edit')
146  );
147  $list->addItem(
148  $this->lng->txt('cal_ch_assign_participants'),
149  '',
150  $ilCtrl->getLinkTargetByClass('ilRepositorySearchGUI','')
151  );
152  $list->addItem(
153  $this->lng->txt('delete'),
154  '',
155  $ilCtrl->getLinkTarget($this->getParentObject(),'confirmDelete')
156  );
157  $this->tpl->setVariable('ACTIONS',$list->getHTML());
158 
159  }
160 
165  public function parse()
166  {
167  global $ilDB, $ilObjDataCache;
168 
169  include_once 'Services/Booking/classes/class.ilBookingEntry.php';
170 
171  $data = array();
172  $counter = 0;
174  {
175  $data[$counter]['id'] = $app->getEntryId();
176  $data[$counter]['title'] = $app->getTitle();
177  $data[$counter]['description'] = $app->getDescription();
178  $data[$counter]['start'] = $app->getStart()->get(IL_CAL_UNIX);
179  $data[$counter]['start_p'] = ilDatePresentation::formatPeriod($app->getStart(),$app->getEnd());
180 
181  $booking = new ilBookingEntry($app->getContextId());
182 
183  $booked_user_ids = $booking->getCurrentBookings($app->getEntryId());
184  $booked_user_ids = ilUtil::_sortIds($booked_user_ids, 'usr_data', 'lastname', 'usr_id');
185  $users = array();
186  $data[$counter]['participants'] = '';
187  $user_counter = 0;
188  foreach($booked_user_ids as $user_id)
189  {
190  if(!$user_counter)
191  {
192  $name = ilObjUser::_lookupName($user_id);
193  $data[$counter]['participants'] = $name['lastname'];
194  }
195  $users[$user_id] = ilObjUser::_lookupFullname($user_id);
196  $user_counter++;
197  }
198  $data[$counter]['bookings'] = $users;
199  $data[$counter]['num_bookings'] = $booking->getNumberOfBookings();
200 
201  $data[$counter]['group'] = '';
202  $group_id = $booking->getBookingGroup();
203  if($this->hasGroups() && $group_id)
204  {
206  }
207 
208  // obj assignments
209  $refs_counter = 0;
210  $obj_ids = ilUtil::_sortIds($booking->getTargetObjIds(), 'object_data', 'title', 'obj_id');
211  foreach($obj_ids as $obj_id)
212  {
213  if($refs_counter)
214  {
215  $data[$counter]['target'] = ilObject::_lookupTitle($obj_id);
216  }
217 
218  $refs = ilObject::_getAllReferences($obj_id);
219  include_once './Services/Link/classes/class.ilLink.php';
220  $data[$counter]['target_links'][$refs_counter]['title'] = ilObject::_lookupTitle($obj_id);
221  $data[$counter]['target_links'][$refs_counter]['link'] = ilLink::_getLink(end($refs));
222  ++$refs_counter;
223  }
224  $counter++;
225  }
226  $this->setData($data);
227  }
228 }
229 ?>
static _lookupName($a_user_id)
lookup user name
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
static lookupTitle($a_group_id)
Lookup group title.
static _lookupFullname($a_user_id)
Lookup Full Name.
static formatPeriod(ilDateTime $start, ilDateTime $end)
Format a period of two date Shows: 14.
Booking definition.
static _lookupTitle($a_id)
lookup object title
const IL_CAL_UNIX
getParentCmd()
Get parent command.
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
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
$counter
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 getAppointments($a_user_id)
Get all appointments.
addMultiCommand($a_cmd, $a_text)
Add Command button.
enable($a_module_name)
enables particular modules of table
Consultation hours administration.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
User interface class for advanced drop-down selection lists.
__construct($a_gui, $a_cmd, $a_user_id)
Constructor.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
getCurrentBookings($a_entry_id)
get current bookings
global $lng
Definition: privfeed.php:17
global $ilDB
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
hasGroups()
Check if user has created groups.
static getCountGroupsOfUser($a_user_id)
Get number of consultation hour groups type $ilDB.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
static _getPreferences($user_id)
get preferences for user
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.