ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjSessionListGUI.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/Object/classes/class.ilObjectListGUI.php');
25 
26 
35 {
36  protected $app_info = array();
37 
38 
45  public function __construct()
46  {
47  global $lng;
48 
49  $lng->loadLanguageModule('crs');
50  $lng->loadLanguageModule('sess');
51 
52  parent::__construct();
53  }
54 
61  public function init()
62  {
63  $this->delete_enabled = true;
64  $this->cut_enabled = true;
65  $this->copy_enabled = true;
66  $this->subscribe_enabled = true;
67  $this->link_enabled = true;
68  $this->info_screen_enabled = true;
69  $this->subitems_enabled = true;
70  $this->type = "sess";
71  $this->gui_class_name = "ilobjsessiongui";
72 
73  $this->substitutions = ilAdvancedMDSubstitution::_getInstanceByObjectType($this->type);
74  $this->enableSubstitutions($this->substitutions->isActive());
75 
76  // general commands array
77  include_once('./Modules/Session/classes/class.ilObjSessionAccess.php');
78  $this->commands = ilObjSessionAccess::_getCommands();
79  }
80 
90  public function getTitle()
91  {
92  $app_info = $this->getAppointmentInfo();
93  $title = strlen($this->title) ? (': ' . $this->title) : '';
94  return ilSessionAppointment::_appointmentToString($app_info['start'], $app_info['end'], $app_info['fullday']) . $title;
95  }
96 
97 
98 
106  public function getCommandLink($a_cmd)
107  {
108  global $ilCtrl;
109 
110  // separate method for this line
111  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->ref_id);
112  $cmd_link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", $a_cmd);
113  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
114  return $cmd_link;
115  }
116 
126  public function checkCommandAccess($a_permission, $a_cmd, $a_ref_id, $a_type, $a_obj_id="")
127  {
128  if ($a_cmd != 'register' and $a_cmd != 'unregister') {
129  $a_cmd = '';
130  }
131  return parent::checkCommandAccess($a_permission, $a_cmd, $a_ref_id, $a_type, $a_obj_id);
132  }
133 
134 
142  public function getProperties()
143  {
144  $app_info = $this->getAppointmentInfo();
145 
146  /*
147  $props[] = array(
148  'alert' => false,
149  'property' => $this->lng->txt('event_date'),
150  'value' => ilSessionAppointment::_appointmentToString($app_info['start'],$app_info['end'],$app_info['fullday']));
151  */
152  include_once './Modules/Session/classes/class.ilObjSession.php';
153  $session_data = new ilObjSession($this->obj_id, false);
154  include_once './Modules/Session/classes/class.ilSessionParticipants.php';
155  $part = ilSessionParticipants::getInstance($this->ref_id);
156 
157  if ($session_data->isRegistrationUserLimitEnabled()) {
158  if ($part->getCountMembers() <= $session_data->getRegistrationMaxUsers()) {
159  $props[] = array(
160  'alert' => false,
161  'property' => $this->lng->txt('sess_list_reg_limit_places'),
162  'value' => max(
163  0,
164  $session_data->getRegistrationMaxUsers() - $part->getCountMembers()
165  )
166  );
167  }
168  }
169 
171  if ($items = self::lookupAssignedMaterials($this->obj_id)) {
172  $props[] = array(
173  'alert' => false,
174  'property' => $this->lng->txt('event_ass_materials_prop'),
175  'value' => count($items)
176  );
177  }
178  }
180  include_once './Modules/Session/classes/class.ilObjSession.php';
181  $session_data = ilObjSession::lookupSession($this->obj_id);
182 
183  if (strlen($session_data['location'])) {
184  $props[] = array(
185  'alert' => false,
186  'property' => $this->lng->txt('event_location'),
187  'value' => $session_data['location']
188  );
189  }
190  if (strlen($session_data['details'])) {
191  $props[] = array(
192  'alert' => false,
193  'property' => $this->lng->txt('event_details_workflow'),
194  'value' => nl2br($session_data['details']),
195  'newline' => true
196  );
197  }
198  $has_new_line = false;
199  if (strlen($session_data['name'])) {
200  $props[] = array(
201  'alert' => false,
202  'property' => $this->lng->txt('event_lecturer'),
203  'value' => $session_data['name'],
204  'newline' => true
205  );
206  $has_new_line = true;
207  }
208  if (strlen($session_data['email'])) {
209  $props[] = array(
210  'alert' => false,
211  'property' => $this->lng->txt('tutor_email'),
212  'value' => $session_data['email'],
213  'newline' => $has_new_line ? false : true
214  );
215  $has_new_line = true;
216  }
217  if (strlen($session_data['phone'])) {
218  $props[] = array(
219  'alert' => false,
220  'property' => $this->lng->txt('tutor_phone'),
221  'value' => $session_data['phone'],
222  'newline' => $has_new_line ? false : true
223  );
224  $has_new_line = true;
225  }
226  }
227 
228  return $props;
229  }
230 
231 
232 
239  protected function getAppointmentInfo()
240  {
241  if (isset($this->app_info[$this->obj_id])) {
242  return $this->app_info[$this->obj_id];
243  }
244  include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
245  return $this->app_info[$this->obj_id] = ilSessionAppointment::_lookupAppointment($this->obj_id);
246  }
247 
253  protected static function lookupAssignedMaterials($a_sess_id)
254  {
255  global $ilDB;
256 
257  $query = 'SELECT * FROM event_items ei ' .
258  'JOIN tree ON item_id = child ' .
259  'WHERE event_id = ' . $ilDB->quote($a_sess_id, 'integer') . ' ' .
260  'AND tree > 0';
261  $res = $ilDB->query($query);
262  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
263  $items[] = $row->item_id;
264  }
265  return $items ? $items : array();
266  }
267 }
getAppointmentInfo()
get appointment info
$_GET["client_id"]
getCommandLink($a_cmd)
Get command link url.
enableSubstitutions($a_status)
Enable substitutions.
static _getInstanceByObjectType($a_type)
Singleton: use this method to get an instance.
checkCommandAccess($a_permission, $a_cmd, $a_ref_id, $a_type, $a_obj_id="")
Only check cmd access for cmd &#39;register&#39; and &#39;unregister&#39;.
static lookupSession($a_obj_id)
Get session data.
global $ilCtrl
Definition: ilias.php:18
$a_type
Definition: workflow.php:92
foreach($_POST as $key=> $value) $res
getTitle()
get title Overwritten since sessions prepend the date of the session to the title ...
Class ilObjectListGUI.
static _appointmentToString($start, $end, $fulltime)
getDetailsLevel()
Get current details level.
static _getCommands()
get list of command/permission combinations
$query
Create styles array
The data for the language used.
static getInstance($a_ref_id)
Get instance.
static lookupAssignedMaterials($a_sess_id)
Get assigned items of event.
static _lookupAppointment($a_obj_id)
lookup appointment
global $ilDB