ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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->payment_enabled = false;
69  $this->info_screen_enabled = true;
70  $this->subitems_enabled = true;
71  $this->type = "sess";
72  $this->gui_class_name = "ilobjsessiongui";
73 
74  // general commands array
75  include_once('./Modules/Session/classes/class.ilObjSessionAccess.php');
76  $this->commands = ilObjSessionAccess::_getCommands();
77  }
78 
88  public function getTitle()
89  {
90  $app_info = $this->getAppointmentInfo();
91  $title = strlen($this->title) ? (': '.$this->title) : '';
92  return ilSessionAppointment::_appointmentToString($app_info['start'], $app_info['end'],$app_info['fullday']) . $title;
93  }
94 
95 
96 
104  public function getCommandLink($a_cmd)
105  {
106  global $ilCtrl;
107 
108  // separate method for this line
109  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->ref_id);
110  $cmd_link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", $a_cmd);
111  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
112  return $cmd_link;
113  }
114 
124  public function checkCommandAccess($a_permission,$a_cmd,$a_ref_id,$a_type,$a_obj_id="")
125  {
126  if($a_cmd != 'register' and $a_cmd != 'unregister')
127  {
128  $a_cmd = '';
129  }
130  return parent::checkCommandAccess($a_permission,$a_cmd,$a_ref_id,$a_type,$a_obj_id);
131  }
132 
133 
141  public function getProperties()
142  {
143  $app_info = $this->getAppointmentInfo();
144 
145  /*
146  $props[] = array(
147  'alert' => false,
148  'property' => $this->lng->txt('event_date'),
149  'value' => ilSessionAppointment::_appointmentToString($app_info['start'],$app_info['end'],$app_info['fullday']));
150  */
151  include_once './Modules/Session/classes/class.ilObjSession.php';
152  $session_data = new ilObjSession($this->obj_id, false);
153  include_once './Modules/Session/classes/class.ilSessionParticipants.php';
154  $part = ilSessionParticipants::_getInstanceByObjId($this->obj_id);
155 
156  if($session_data->isRegistrationUserLimitEnabled()) {
157  if ($part->getCountMembers() <= $session_data->getRegistrationMaxUsers()) {
158  $props[] = array(
159  'alert' => false,
160  'property' => $this->lng->txt('sess_list_reg_limit_places'),
161  'value' => max(
162  0,
163  $session_data->getRegistrationMaxUsers() - $part->getCountMembers()
164  )
165  );
166  }
167  }
168 
170  {
171  if($items = self::lookupAssignedMaterials($this->obj_id))
172  {
173  $props[] = array(
174  'alert' => false,
175  'property' => $this->lng->txt('event_ass_materials_prop'),
176  'value' => count($items)
177  );
178 
179  }
180  }
182  {
183  include_once './Modules/Session/classes/class.ilObjSession.php';
184  $session_data = ilObjSession::lookupSession($this->obj_id);
185 
186  if(strlen($session_data['location']))
187  {
188  $props[] = array(
189  'alert' => false,
190  'property' => $this->lng->txt('event_location'),
191  'value' => $session_data['location']
192  );
193  }
194  if(strlen($session_data['details']))
195  {
196  $props[] = array(
197  'alert' => false,
198  'property' => $this->lng->txt('event_details_workflow'),
199  'value' => nl2br($session_data['details']),
200  'newline' => true
201  );
202  }
203  $has_new_line = false;
204  if(strlen($session_data['name']))
205  {
206  $props[] = array(
207  'alert' => false,
208  'property' => $this->lng->txt('event_lecturer'),
209  'value' => $session_data['name'],
210  'newline' => true
211  );
212  $has_new_line = true;
213  }
214  if(strlen($session_data['email']))
215  {
216  $props[] = array(
217  'alert' => false,
218  'property' => $this->lng->txt('tutor_email'),
219  'value' => $session_data['email'],
220  'newline' => $has_new_line ? false : true
221  );
222  $has_new_line = true;
223  }
224  if(strlen($session_data['phone']))
225  {
226  $props[] = array(
227  'alert' => false,
228  'property' => $this->lng->txt('tutor_phone'),
229  'value' => $session_data['phone'],
230  'newline' => $has_new_line ? false : true
231  );
232  $has_new_line = true;
233  }
234  }
235 
236  return $props;
237  }
238 
239 
240 
247  protected function getAppointmentInfo()
248  {
249  if(isset($this->app_info[$this->obj_id]))
250  {
251  return $this->app_info[$this->obj_id];
252  }
253  include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
254  return $this->app_info[$this->obj_id] = ilSessionAppointment::_lookupAppointment($this->obj_id);
255  }
256 
262  protected static function lookupAssignedMaterials($a_sess_id)
263  {
264  global $ilDB;
265 
266  $query = 'SELECT * FROM event_items ei '.
267  'JOIN tree ON item_id = child '.
268  'WHERE event_id = '.$ilDB->quote($a_sess_id,'integer').' '.
269  'AND tree > 0';
270  $res = $ilDB->query($query);
271  while($row = $res->fetchRow(FETCHMODE_OBJECT))
272  {
273  $items[] = $row->item_id;
274  }
275  return $items ? $items : array();
276  }
277 
278 }
279 ?>
getAppointmentInfo()
get appointment info
$_GET["client_id"]
getCommandLink($a_cmd)
Get command link url.
_getCommands()
get list of command/permission combinations
static _getInstanceByObjId($a_obj_id)
Get singleton 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
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 lookupAssignedMaterials($a_sess_id)
Get assigned items of event.
global $lng
Definition: privfeed.php:40
static _lookupAppointment($a_obj_id)
lookup appointment
global $ilDB