ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilECSEContent.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 
34 {
35  private $obj_id;
36 
37  // ECS JSON variables
38  // All exportable fields have to be public
39  public $url = '';
40  public $title = '';
41  public $eligibleMembers = array();
42  public $etype = 'application/ecs-course';
43  public $status = 'offline';
44  public $lang = 'en_EN';
45  public $abstract = '';
46  public $study_courses = array();
47  public $owner = 0;
48  public $credits = '';
49  public $semesterHours = '';
50  public $lecturer = array();
51  public $courseType = '';
52  public $courseID = '';
53  public $eid = 0;
54  public $term = '';
55  public $timePlace = null;
56 
57 
65  public function __construct($a_eid = 0)
66  {
67  include_once('./Services/WebServices/ECS/classes/class.ilECSTimePlace.php');
68 
69  if($a_eid)
70  {
71  $this->eid = $a_eid;
72  }
73  $this->timePlace = new ilECSTimePlace();
74  }
75 
82  public function getEContentId()
83  {
84  return $this->eid;
85  }
86 
94  public function setObjId($a_id)
95  {
96  $this->obj_id = $a_id;
97  }
98 
106  public function getObjId()
107  {
108  return $this->obj_id;
109  }
110 
117  public function getOrganization()
118  {
119  return $this->organization;
120  }
121 
129  public function getTimePlace()
130  {
131  return $this->timePlace;
132  }
133 
141  public function setTitle($a_title)
142  {
143  $this->title = $a_title;
144  }
145 
152  public function getTitle()
153  {
154  return $this->title;
155  }
156 
164  public function setInfo($a_info)
165  {
166  $this->abstract = $a_info;
167  }
168 
175  public function getInfo()
176  {
177  return $this->abstract;
178  }
179 
187  public function setURL($a_url)
188  {
189  $this->url = $a_url;
190  }
191 
198  public function getURL()
199  {
200  return $this->url;
201  }
202 
210  public function setLanguage($a_key)
211  {
212  if(strlen($a_key))
213  {
214  $this->lang = ($a_key.'_'.strtoupper($a_key));
215  }
216  }
217 
224  public function getLanguage()
225  {
226  if(strlen($this->lang))
227  {
228  return substr($this->lang,0,2);
229  }
230  }
231 
238  public function setEligibleMembers($a_members)
239  {
240  $this->eligibleMembers = array();
241  foreach($a_members as $member)
242  {
243  $this->eligibleMembers[] = (int) $member;
244  }
245  }
246 
253  public function getEligibleMembers()
254  {
255  return $this->eligibleMembers ? $this->eligibleMembers : array();
256  }
257 
263  public function getOwner()
264  {
265  return $this->owner ? $this->owner : 0;
266  }
267 
275  public function setOwner($a_owner)
276  {
277  $this->owner = (int) $a_owner;
278  }
279 
286  public function getParticipants()
287  {
288  return $this->getEligibleMembers();
289  }
290 
298  public function setStatus($a_status)
299  {
300  switch($a_status)
301  {
302  case 'online':
303  $this->status = 'online';
304  break;
305 
306  default:
307  $this->status = 'offline';
308  break;
309  }
310  }
311 
319  public function getStatus()
320  {
321  return $this->status == 'online' ? $this->status : 'offline';
322  }
323 
330  public function isOnline()
331  {
332  return $this->status == 'online' ? true : false;
333  }
334 
342  public function setCredits($a_credits)
343  {
344  $this->credits = $a_credits;
345  }
346 
353  public function getCredits()
354  {
355  return $this->credits;
356  }
357 
365  public function setSemesterHours($a_semester_hours)
366  {
367  $this->semesterHours = $a_semester_hours;
368  }
369 
376  public function getSemesterHours()
377  {
378  return $this->semesterHours;
379  }
380 
390  public function setLecturers($a_lecturer)
391  {
392  $lecturer_arr = explode(',',$a_lecturer);
393  $this->lecturer = array();
394  foreach($lecturer_arr as $lecturer)
395  {
396  $this->lecturer[] = trim($lecturer);
397  }
398  return true;
399  }
400 
407  public function getLecturers()
408  {
409  return implode(', ',$this->lecturer);
410  }
411 
421  public function setStudyCourses($a_courses)
422  {
423  $courses_arr = explode(',',$a_courses);
424  $this->study_courses = array();
425  foreach($courses_arr as $course)
426  {
427  $this->study_courses[] = trim($course);
428  }
429  return true;
430  }
431 
438  public function getStudyCourses()
439  {
440  return implode(', ',$this->study_courses);
441  }
442 
450  public function setCourseType($a_type)
451  {
452  $this->courseType = $a_type;
453  }
454 
461  public function getCourseType()
462  {
463  return $this->courseType;
464  }
465 
473  public function setCourseID($a_id)
474  {
475  $this->courseID = $a_id;
476  }
477 
484  public function getCourseID()
485  {
486  return $this->courseID;
487  }
488 
496  public function setTerm($a_term)
497  {
498  $this->term = $a_term;
499  }
500 
507  public function getTerm()
508  {
509  return $this->term;
510  }
511 
519  public function loadFromJSON($a_json)
520  {
521  global $ilLog;
522 
523  if(!is_object($a_json))
524  {
525  include_once('./Services/WebServices/ECS/classes/class.ilECSReaderException.php');
526  $ilLog->write(__METHOD__.': Cannot load from JSON. No object given.');
527  throw new ilECSReaderException('Cannot parse ECSContent.');
528  }
529  $this->organization = $a_json->organization;
530  $this->study_courses = $a_json->study_courses ? $a_json->study_courses : array();
531  $this->owner = $a_json->owner;
532  $this->title = $a_json->title;
533  $this->abstract = $a_json->abstract;
534  $this->credits = $a_json->credits;
535  $this->semesterHours = $a_json->semesterHours;
536  $this->lecturer = $a_json->lecturer ? $a_json->lecturer : array();
537  $this->etype = $a_json->etype;
538  $this->status = $a_json->status;
539 
540  $this->courseID = $a_json->courseID;
541  $this->courseType = $a_json->courseType;
542  $this->eid = $a_json->eid;
543  $this->term = $a_json->term;
544  $this->url = $a_json->url;
545  $this->lang = $a_json->lang;
546 
547  if(is_object($a_json->timePlace))
548  {
549  $this->timePlace = new ilECSTimePlace();
550  $this->timePlace->loadFromJSON($a_json->timePlace);
551  }
552  else
553  {
554  $this->timePlace = new ilECSTimePlace();
555  }
556  $this->eligibleMembers = $a_json->eligibleMembers ? $a_json->eligibleMembers : array();
557  }
558 }
559 
560 ?>