ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjCourse.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 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 
33 require_once "./Services/Container/classes/class.ilContainer.php";
34 
35 define('IL_CRS_ACTIVATION_OFFLINE',0);
36 define('IL_CRS_ACTIVATION_UNLIMITED',1);
37 define('IL_CRS_ACTIVATION_LIMITED',2);
38 
39 define('IL_CRS_SUBSCRIPTION_DEACTIVATED',0);
40 define('IL_CRS_SUBSCRIPTION_UNLIMITED',1);
41 define('IL_CRS_SUBSCRIPTION_LIMITED',2);
42 
43 define('IL_CRS_SUBSCRIPTION_CONFIRMATION',2);
44 define('IL_CRS_SUBSCRIPTION_DIRECT',3);
45 define('IL_CRS_SUBSCRIPTION_PASSWORD',4);
46 
47 define('IL_CRS_VIEW_SESSIONS', 0);
48 define('IL_CRS_VIEW_OBJECTIVE', 1);
49 define('IL_CRS_VIEW_TIMING', 2);
50 define('IL_CRS_VIEW_ARCHIVE', 3);
51 define('IL_CRS_VIEW_SIMPLE', 4);
52 define('IL_CRS_VIEW_BY_TYPE', 5);
53 
54 define('IL_CRS_ARCHIVE_DOWNLOAD',3);
55 define('IL_CRS_ARCHIVE_NONE',0);
56 
57 class ilObjCourse extends ilContainer
58 {
59  const CAL_REG_START = 1;
60  const CAL_REG_END = 2;
62  const CAL_ACTIVATION_END = 4;
63 
67 
74  function ilObjCourse($a_id = 0,$a_call_by_reference = true)
75  {
76 
77  #define("ILIAS_MODULE","course");
78  #define("KEEP_IMAGE_PATH",1);
79 
80  $this->SUBSCRIPTION_DEACTIVATED = 1;
81  $this->SUBSCRIPTION_CONFIRMATION = 2;
82  $this->SUBSCRIPTION_DIRECT = 3;
83  $this->SUBSCRIPTION_PASSWORD = 4;
84  $this->SUBSCRIPTION_AUTOSUBSCRIPTION = 5;
85  $this->ARCHIVE_DISABLED = 1;
86  $this->ARCHIVE_READ = 2;
87  $this->ARCHIVE_DOWNLOAD = 3;
88  $this->ABO_ENABLED = 1;
89  $this->ABO_DISABLED = 0;
90  $this->SHOW_MEMBERS_ENABLED = 1;
91  $this->SHOW_MEMBERS_DISABLED = 0;
92 
93  $this->type = "crs";
94 
95  parent::__construct($a_id,$a_call_by_reference);
96 
97  if($a_id)
98  {
99  #$this->__initMetaObject();
100  $this->initCourseMemberObject();
101  }
102  else
103  {
104 
105  }
106  }
107 
109  {
110  return $this->important;
111  }
112  function setImportantInformation($a_info)
113  {
114  $this->important = $a_info;
115  }
116  function getSyllabus()
117  {
118  return $this->syllabus;
119  }
120  function setSyllabus($a_syllabus)
121  {
122  $this->syllabus = $a_syllabus;
123  }
124  function getContactName()
125  {
126  return $this->contact_name;
127  }
128  function setContactName($a_cn)
129  {
130  $this->contact_name = $a_cn;
131  }
133  {
134  return $this->contact_consultation;
135  }
136  function setContactConsultation($a_value)
137  {
138  $this->contact_consultation = $a_value;
139  }
140  function getContactPhone()
141  {
142  return $this->contact_phone;
143  }
144  function setContactPhone($a_value)
145  {
146  $this->contact_phone = $a_value;
147  }
148  function getContactEmail()
149  {
150  return $this->contact_email;
151  }
152  function setContactEmail($a_value)
153  {
154  $this->contact_email = $a_value;
155  }
157  {
158  return $this->contact_responsibility;
159  }
160  function setContactResponsibility($a_value)
161  {
162  $this->contact_responsibility = $a_value;
163  }
164 
165  function getActivationType()
166  {
167  return (int) $this->activation_type;
168  }
169  function setActivationType($a_type)
170  {
171  $this->activation_type = $a_type;
172  }
174  {
175  return $this->activation_type == IL_CRS_ACTIVATION_UNLIMITED;
176 
177  }
178 
180  {
181  return $this->activation_start ? $this->activation_start : time();
182  }
183  function setActivationStart($a_value)
184  {
185  $this->activation_start = $a_value;
186  }
187  function getActivationEnd()
188  {
189  return $this->activation_end ? $this->activation_end : mktime(0,0,0,12,12,date("Y",time())+2);
190  }
191  function setActivationEnd($a_value)
192  {
193  $this->activation_end = $a_value;
194  }
195  function getOfflineStatus()
196  {
197  return $this->activation_type == IL_CRS_ACTIVATION_OFFLINE;
198  }
199 
200 
202  {
203  return $this->subscription_limitation_type;
204  }
206  {
207  $this->subscription_limitation_type = $a_type;
208  }
210  {
211  return $this->subscription_limitation_type == IL_CRS_SUBSCRIPTION_UNLIMITED;
212  }
214  {
215  return $this->subscription_start ? $this->subscription_start : time();
216  }
217  function setSubscriptionStart($a_value)
218  {
219  $this->subscription_start = $a_value;
220  }
222  {
223  return $this->subscription_end ? $this->subscription_end : mktime(0,0,0,12,12,date("Y",time())+2);
224  }
225  function setSubscriptionEnd($a_value)
226  {
227  $this->subscription_end = $a_value;
228  }
230  {
231  return $this->subscription_type ? $this->subscription_type : IL_CRS_SUBSCRIPTION_DIRECT;
232  #return $this->subscription_type ? $this->subscription_type : $this->SUBSCRIPTION_DEACTIVATED;
233  }
234  function setSubscriptionType($a_value)
235  {
236  $this->subscription_type = $a_value;
237  }
239  {
240  return $this->subscription_password;
241  }
242  function setSubscriptionPassword($a_value)
243  {
244  $this->subscription_password = $a_value;
245  }
247  {
248  return $this->view_mode == IL_CRS_VIEW_OBJECTIVE;
249  }
250 
252  {
253  return (bool) $this->waiting_list;
254  }
255 
256  function enableWaitingList($a_status)
257  {
258  $this->waiting_list = (bool) $a_status;
259  }
260 
262  {
263  if($this->getSubscriptionUnlimitedStatus())
264  {
265  return true;
266  }
267  if(time() > $this->getSubscriptionStart() and time() < $this->getSubscriptionEnd())
268  {
269  return true;
270  }
271  return false;
272  }
273 
281  public function enableSubscriptionMembershipLimitation($a_status)
282  {
283  $this->subscription_membership_limitation = $a_status;
284  }
285 
294  {
295  return (bool) $this->subscription_membership_limitation;
296  }
297 
299  {
300  return $this->subscription_max_members;
301  }
302  function setSubscriptionMaxMembers($a_value)
303  {
304  $this->subscription_max_members = $a_value;
305  }
306 
315  public static function _isSubscriptionNotificationEnabled($a_course_id)
316  {
317  global $ilDB;
318 
319  $query = "SELECT * FROM crs_settings ".
320  "WHERE obj_id = ".$ilDB->quote($a_course_id)." ".
321  "AND subscription_notify = 1";
322  $res = $ilDB->query($query);
323  return $res->numRows() ? true : false;
324  }
325 
327  {
328  return true;
329  return $this->subscription_notify ? true : false;
330  }
331  function setSubscriptionNotify($a_value)
332  {
333  $this->subscription_notify = $a_value ? true : false;
334  }
335 
336  function setViewMode($a_mode)
337  {
338  $this->view_mode = $a_mode;
339  }
340  function getViewMode()
341  {
342  return $this->view_mode;
343  }
344 
345  function _lookupViewMode($a_id)
346  {
347  global $ilDB;
348 
349  $query = "SELECT view_mode FROM crs_settings WHERE obj_id = ".$ilDB->quote($a_id)." ";
350  $res = $ilDB->query($query);
351  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
352  {
353  return $row->view_mode;
354  }
355  return false;
356  }
357 
358  function _lookupAboStatus($a_id)
359  {
360  global $ilDB;
361 
362  $query = "SELECT abo FROM crs_settings WHERE obj_id = ".$ilDB->quote($a_id)." ";
363  $res = $ilDB->query($query);
364  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
365  {
366  return $row->abo;
367  }
368  return false;
369  }
370 
371  function getArchiveStart()
372  {
373  return $this->archive_start ? $this->archive_start : time();
374  }
375  function setArchiveStart($a_value)
376  {
377  $this->archive_start = $a_value;
378  }
379  function getArchiveEnd()
380  {
381  return $this->archive_end ? $this->archive_end : mktime(0,0,0,12,12,date("Y",time())+2);
382  }
383  function setArchiveEnd($a_value)
384  {
385  $this->archive_end = $a_value;
386  }
387  function getArchiveType()
388  {
389  return $this->archive_type ? IL_CRS_ARCHIVE_DOWNLOAD : IL_CRS_ARCHIVE_NONE;
390  }
391  function setArchiveType($a_value)
392  {
393  $this->archive_type = $a_value;
394  }
395  function setAboStatus($a_status)
396  {
397  $this->abo = $a_status;
398  }
399  function getAboStatus()
400  {
401  return $this->abo;
402  }
403  function setShowMembers($a_status)
404  {
405  $this->show_members = $a_status;
406  }
407  function getShowMembers()
408  {
409  return $this->show_members;
410  }
411 
412  function getMessage()
413  {
414  return $this->message;
415  }
416  function setMessage($a_message)
417  {
418  $this->message = $a_message;
419  }
420  function appendMessage($a_message)
421  {
422  if($this->getMessage())
423  {
424  $this->message .= "<br /> ";
425  }
426  $this->message .= $a_message;
427  }
428 
429  function getMembers()
430  {
431  return $this->members_obj->getMembers();
432  }
433 
434 
435  function isActivated($a_check_archive = false)
436  {
437  if($a_check_archive)
438  {
439  if($this->isArchived())
440  {
441  return true;
442  }
443  }
444  if($this->getOfflineStatus())
445  {
446  return false;
447  }
448  if($this->getActivationUnlimitedStatus())
449  {
450  return true;
451  }
452  if(time() < $this->getActivationStart() or
453  time() > $this->getActivationEnd())
454  {
455  return false;
456  }
457  return true;
458  }
459 
466  function _isActivated($a_obj_id)
467  {
468  global $ilDB;
469 
470  $query = "SELECT * FROM crs_settings ".
471  "WHERE obj_id = ".$ilDB->quote($a_obj_id)." ";
472 
473  $res = $ilDB->query($query);
474  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
475  {
476  $type = $row->activation_type;
477  $start = $row->activation_start;
478  $end = $row->activation_end;
479  }
480  switch($type)
481  {
483  return false;
484 
486  return true;
487 
489  if(time() < $start or
490  time() > $end)
491  {
492  return false;
493  }
494  return true;
495 
496  default:
497  return false;
498  }
499  }
500 
501  function _registrationEnabled($a_obj_id)
502  {
503  global $ilDB;
504 
505  $query = "SELECT * FROM crs_settings ".
506  "WHERE obj_id = ".$ilDB->quote($a_obj_id)." ";
507 
508  $res = $ilDB->query($query);
509  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
510  {
511  $type = $row->subscription_limitation_type;
512  $reg_start = $row->subscription_start;
513  $reg_end = $row->subscription_end;
514  }
515 
516  switch($type)
517  {
519  return true;
520 
522  return false;
523 
525  if(time() > $reg_start and
526  time() < $reg_end)
527  {
528  return true;
529  }
530  default:
531  return false;
532  }
533  return false;
534  }
535 
536  function isArchived()
537  {
538  if($this->getViewMode() != IL_CRS_VIEW_ARCHIVE)
539  {
540  return false;
541  }
542  if(time() < $this->getArchiveStart() or time() > $this->getArchiveEnd())
543  {
544  return false;
545  }
546  return true;
547  }
548 
549  function allowAbo()
550  {
551  return $this->ABO == $this->ABO_ENABLED;
552  }
553 
554  function read($a_force_db = false)
555  {
556  parent::read($a_force_db);
557 
558  $this->__readSettings();
559  }
560  function create($a_upload = false)
561  {
562  global $ilAppEventHandler;
563 
564  parent::create($a_upload);
565 
566  if(!$a_upload)
567  {
568  $this->createMetaData();
569  }
570  $this->__createDefaultSettings();
571 
572  $ilAppEventHandler->raise('Modules/Course',
573  'create',
574  array('object' => $this,
575  'obj_id' => $this->getId(),
576  'appointments' => $this->prepareAppointments('create')));
577 
578  }
579 
585  function setLatitude($a_latitude)
586  {
587  $this->latitude = $a_latitude;
588  }
589 
595  function getLatitude()
596  {
597  return $this->latitude;
598  }
599 
605  function setLongitude($a_longitude)
606  {
607  $this->longitude = $a_longitude;
608  }
609 
615  function getLongitude()
616  {
617  return $this->longitude;
618  }
619 
625  function setLocationZoom($a_locationzoom)
626  {
627  $this->locationzoom = $a_locationzoom;
628  }
629 
635  function getLocationZoom()
636  {
637  return $this->locationzoom;
638  }
639 
645  function setEnableCourseMap($a_enablemap)
646  {
647  $this->enablemap = $a_enablemap;
648  }
649 
656  {
657  return $this->enablemap;
658  }
659 
668  public function cloneObject($a_target_id,$a_copy_id = 0)
669  {
670  global $ilDB,$ilUser;
671 
672  $new_obj = parent::cloneObject($a_target_id,$a_copy_id);
673 
674  $this->cloneAutoGeneratedRoles($new_obj);
675  $this->cloneMetaData($new_obj);
676 
677  // Assign admin
678  $new_obj->initCourseMemberObject();
679  $new_obj->members_obj->add($ilUser->getId(),IL_CRS_ADMIN);
680 
681  // Copy settings
682  $this->cloneSettings($new_obj);
683 
684  // Course Defined Fields
685  include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
686  ilCourseDefinedFieldDefinition::_clone($this->getId(),$new_obj->getId());
687 
688  // Clone course files
689  include_once('Modules/Course/classes/class.ilCourseFile.php');
690  ilCourseFile::_cloneFiles($this->getId(),$new_obj->getId());
691 
692  // Copy learning progress settings
693  include_once('Services/Tracking/classes/class.ilLPObjSettings.php');
694  $obj_settings = new ilLPObjSettings($this->getId());
695  $obj_settings->cloneSettings($new_obj->getId());
696  unset($obj_settings);
697 
698  // clone icons
699  global $ilLog;
700  $ilLog->write(__METHOD__.': '.$this->getBigIconPath().' '.$this->getSmallIconPath());
701  $new_obj->saveIcons($this->getBigIconPath(),
702  $this->getSmallIconPath(),
703  $this->getTinyIconPath());
704 
705  return $new_obj;
706  }
707 
716  public function cloneDependencies($a_target_id,$a_copy_id)
717  {
718  global $ilObjDataCache;
719 
720  parent::cloneDependencies($a_target_id,$a_copy_id);
721 
722  // Clone course start objects
723  include_once('Modules/Course/classes/class.ilCourseStart.php');
724  $start = new ilCourseStart($this->getRefId(),$this->getId());
725  $start->cloneDependencies($a_target_id,$a_copy_id);
726 
727  // Clone course item settings
728  $this->initCourseItemObject();
729  $this->items_obj->cloneDependencies($a_target_id,$a_copy_id);
730 
731  // Clone course learning objectives
732  include_once('Modules/Course/classes/class.ilCourseObjective.php');
733  $crs_objective = new ilCourseObjective($this);
734  $crs_objective->ilClone($a_target_id,$a_copy_id);
735 
736  include_once('Services/Tracking/classes/class.ilLPCollections.php');
737  $lp_collection = new ilLPCollections($this->getId());
738  $lp_collection->cloneCollections($a_target_id,$a_copy_id);
739 
740  return true;
741  }
742 
750  public function cloneAutoGeneratedRoles($new_obj)
751  {
752  global $ilLog,$rbacadmin,$rbacreview;
753 
754  $admin = $this->getDefaultAdminRole();
755  $new_admin = $new_obj->getDefaultAdminRole();
756  $source_rolf = $rbacreview->getRoleFolderIdOfObject($this->getRefId());
757  $target_rolf = $rbacreview->getRoleFolderIdOfObject($new_obj->getRefId());
758 
759  if(!$admin || !$new_admin || !$source_rolf || !$target_rolf)
760  {
761  $ilLog->write(__METHOD__.' : Error cloning auto generated role: il_crs_admin');
762  }
763  $rbacadmin->copyRolePermissions($admin,$source_rolf,$target_rolf,$new_admin,true);
764  $ilLog->write(__METHOD__.' : Finished copying of role crs_admin.');
765 
766  $tutor = $this->getDefaultTutorRole();
767  $new_tutor = $new_obj->getDefaultTutorRole();
768  if(!$tutor || !$new_tutor)
769  {
770  $ilLog->write(__METHOD__.' : Error cloning auto generated role: il_crs_tutor');
771  }
772  $rbacadmin->copyRolePermissions($tutor,$source_rolf,$target_rolf,$new_tutor,true);
773  $ilLog->write(__METHOD__.' : Finished copying of role crs_tutor.');
774 
775  $member = $this->getDefaultMemberRole();
776  $new_member = $new_obj->getDefaultMemberRole();
777  if(!$member || !$new_member)
778  {
779  $ilLog->write(__METHOD__.' : Error cloning auto generated role: il_crs_member');
780  }
781  $rbacadmin->copyRolePermissions($member,$source_rolf,$target_rolf,$new_member,true);
782  $ilLog->write(__METHOD__.' : Finished copying of role crs_member.');
783 
784  return true;
785  }
786 
787 
788  function validate()
789  {
790  $this->initCourseMemberObject();
791 
792  $this->setMessage('');
793 
794  #if(($this->getSubscriptionLimitationType() != IL_CRS_SUBSCRIPTION_DEACTIVATED) and
795  # $this->getSubscriptionType() == )
796  #{
797  # $this->appendMessage($this->lng->txt('crs_select_registration_type'));
798  #}
799 
800  if(($this->getActivationType() == IL_CRS_ACTIVATION_LIMITED) and
801  $this->getActivationEnd() < $this->getActivationStart())
802  {
803  $this->appendMessage($this->lng->txt("activation_times_not_valid"));
804  }
806  $this->getSubscriptionStart() > $this->getSubscriptionEnd())
807  {
808  $this->appendMessage($this->lng->txt("subscription_times_not_valid"));
809  }
810  #if((!$this->getActivationUnlimitedStatus() and
811  # !$this->getSubscriptionUnlimitedStatus()) and
812  # ($this->getSubscriptionStart() > $this->getActivationEnd() or
813  # $this->getSubscriptionStart() < $this->getActivationStart() or
814  # $this->getSubscriptionEnd() > $this->getActivationEnd() or
815  # $this->getSubscriptionEnd() < $this->getActivationStart()))
816  #
817  #{
818  # $this->appendMessage($this->lng->txt("subscription_time_not_within_activation"));
819  #}
821  {
822  $this->appendMessage($this->lng->txt("crs_password_required"));
823  }
824  if($this->isSubscriptionMembershipLimited() and ($this->getSubscriptionMaxMembers() <= 0 or !is_numeric($this->getSubscriptionMaxMembers())))
825  {
826  $this->appendMessage($this->lng->txt("max_members_not_numeric"));
827  }
828  if(($this->getViewMode() == IL_CRS_VIEW_ARCHIVE) and
829  $this->getArchiveStart() > $this->getArchiveEnd())
830  {
831  $this->appendMessage($this->lng->txt("archive_times_not_valid"));
832  }
833  return $this->getMessage() ? false : true;
834  }
835 
837  {
838  global $ilErr;
839  $error = false;
840  if($this->getContactEmail()) {
841  $emails = split(",",$this->getContactEmail());
842 
843  foreach ($emails as $email) {
844  $email = trim($email);
845  if (!(ilUtil::is_email($email) or ilObjUser::getUserIdByLogin($email)))
846  {
847  $ilErr->appendMessage($this->lng->txt('contact_email_not_valid')." '".$email."'");
848  $error = true;
849  }
850  }
851  }
852  return !$error;
853  }
854 
855  function hasContactData()
856  {
857  return strlen($this->getContactName()) or
858  strlen($this->getContactResponsibility()) or
859  strlen($this->getContactEmail()) or
860  strlen($this->getContactPhone()) or
861  strlen($this->getContactConsultation());
862  }
863 
864 
871  function delete()
872  {
873  global $ilAppEventHandler;
874 
875  // always call parent delete function first!!
876  if (!parent::delete())
877  {
878  return false;
879  }
880 
881  // delete meta data
882  $this->deleteMetaData();
883 
884  // put here course specific stuff
885 
886  $this->__deleteSettings();
887 
888  $this->initCourseItemObject();
889  $this->items_obj->deleteAllEntries();
890 
891  include_once('Modules/Course/classes/class.ilCourseParticipants.php');
893 
894  $this->initCourseArchiveObject();
895  $this->archives_obj->deleteAll();
896 
897  include_once './Modules/Course/classes/class.ilCourseObjective.php';
899 
900  include_once './Modules/Course/classes/class.ilObjCourseGrouping.php';
902 
903  include_once './Modules/Course/classes/class.ilCourseFile.php';
905 
906  include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
908 
909  $ilAppEventHandler->raise('Modules/Course',
910  'delete',
911  array('object' => $this,
912  'obj_id' => $this->getId(),
913  'appointments' => $this->prepareAppointments('delete')));
914 
915 
916  return true;
917  }
918 
919 
920 
924  function update()
925  {
926  global $ilAppEventHandler;
927 
928  include_once('./Services/Container/classes/class.ilContainerSortingSettings.php');
929  $sorting = new ilContainerSortingSettings($this->getId());
930  $sorting->setSortMode($this->getOrderType());
931  $sorting->update();
932 
933  $this->updateMetaData();
934  $this->updateSettings();
935  parent::update();
936 
937  $ilAppEventHandler->raise('Modules/Course',
938  'update',
939  array('object' => $this,
940  'obj_id' => $this->getId(),
941  'appointments' => $this->prepareAppointments('update')));
942 
943  }
944 
945  function updateSettings()
946  {
947  global $ilDB;
948 
949  // Due to a bug 3.5.alpha maybe no settings exist. => create default settings
950 
951  $query = "SELECT * FROM crs_settings WHERE obj_id = ".$ilDB->quote($this->getId())." ";
952  $res = $ilDB->query($query);
953 
954  if(!$res->numRows())
955  {
956  $this->__createDefaultSettings();
957  }
958 
959  $query = "UPDATE crs_settings SET ".
960  "syllabus = ".$ilDB->quote($this->getSyllabus()).", ".
961  "contact_name = ".$ilDB->quote($this->getContactName()).", ".
962  "contact_responsibility = ".$ilDB->quote($this->getContactResponsibility()).", ".
963  "contact_phone = ".$ilDB->quote($this->getContactPhone()).", ".
964  "contact_email = ".$ilDB->quote($this->getContactEmail()).", ".
965  "contact_consultation = ".$ilDB->quote($this->getContactConsultation()).", ".
966  "activation_type = ".$ilDB->quote($this->getActivationType()).", ".
967  #"activation_unlimited = '".(int) $this->getActivationUnlimitedStatus()."', ".
968  "activation_start = ".$ilDB->quote($this->getActivationStart()).", ".
969  "activation_end = ".$ilDB->quote($this->getActivationEnd()).", ".
970  #"activation_offline = '".(int) $this->getOfflineStatus()."', ".
971  "subscription_limitation_type = ".$ilDB->quote($this->getSubscriptionLimitationType()).", ".
972  #"subscription_unlimited = '".(int) $this->getSubscriptionUnlimitedStatus()."', ".
973  "subscription_start = ".$ilDB->quote($this->getSubscriptionStart()).", ".
974  "subscription_end = ".$ilDB->quote($this->getSubscriptionEnd()).", ".
975  "subscription_type = ".$ilDB->quote($this->getSubscriptionType()).", ".
976  "subscription_password = ".$ilDB->quote($this->getSubscriptionPassword()).", ".
977  "subscription_membership_limitation = ".$ilDB->quote((int) $this->isSubscriptionMembershipLimited()).", ".
978  "subscription_max_members = ".$ilDB->quote($this->getSubscriptionMaxMembers()).", ".
979  "subscription_notify = ".$ilDB->quote($this->getSubscriptionNotify()).", ".
980  "view_mode = ".$ilDB->quote($this->getViewMode()).", ".
981  "archive_start = ".$ilDB->quote($this->getArchiveStart()).", ".
982  "archive_end = ".$ilDB->quote($this->getArchiveEnd()).", ".
983  "archive_type = ".$ilDB->quote($this->getArchiveType()).", ".
984  "abo = ".$ilDB->quote($this->getAboStatus()).", ".
985  #"objective_view = '".(int) $this->enabledObjectiveView()."', ".
986  "waiting_list = ".$ilDB->quote($this->enabledWaitingList()).", ".
987  "important = ".$ilDB->quote($this->getImportantInformation()).", ".
988  "show_members = ".$ilDB->quote($this->getShowMembers()).", ".
989  "latitude = ".$ilDB->quote($this->getLatitude()).", ".
990  "longitude = ".$ilDB->quote($this->getLongitude()).", ".
991  "location_zoom = ".$ilDB->quote($this->getLocationZoom()).", ".
992  "enable_course_map = ".$ilDB->quote($this->getEnableCourseMap())." ".
993  "WHERE obj_id = ".$ilDB->quote($this->getId())."";
994 
995  $res = $ilDB->query($query);
996  }
997 
1005  public function cloneSettings($new_obj)
1006  {
1007  $new_obj->setSyllabus($this->getSyllabus());
1008  $new_obj->setContactName($this->getContactName());
1009  $new_obj->setContactResponsibility($this->getContactResponsibility());
1010  $new_obj->setContactPhone($this->getContactPhone());
1011  $new_obj->setContactEmail($this->getContactEmail());
1012  $new_obj->setContactConsultation($this->getContactConsultation());
1013  $new_obj->setActivationType($this->getActivationType());
1014  $new_obj->setActivationStart($this->getActivationStart());
1015  $new_obj->setActivationEnd($this->getActivationEnd());
1016  $new_obj->setSubscriptionLimitationType($this->getSubscriptionLimitationType());
1017  $new_obj->setSubscriptionStart($this->getSubscriptionStart());
1018  $new_obj->setSubscriptionEnd($this->getSubscriptionEnd());
1019  $new_obj->setSubscriptionType($this->getSubscriptionType());
1020  $new_obj->setSubscriptionPassword($this->getSubscriptionPassword());
1021  $new_obj->enableSubscriptionMembershipLimitation($this->isSubscriptionMembershipLimited());
1022  $new_obj->setSubscriptionMaxMembers($this->getSubscriptionMaxMembers());
1023  $new_obj->setSubscriptionNotify($this->getSubscriptionNotify());
1024  $new_obj->setViewMode($this->getViewMode());
1025  $new_obj->setOrderType($this->getOrderType());
1026  $new_obj->setArchiveStart($this->getArchiveStart());
1027  $new_obj->setArchiveEnd($this->getArchiveEnd());
1028  $new_obj->setArchiveType($this->getArchiveType());
1029  $new_obj->setAboStatus($this->getAboStatus());
1030  $new_obj->enableWaitingList($this->enabledWaitingList());
1031  $new_obj->setImportantInformation($this->getImportantInformation());
1032  $new_obj->setShowMembers($this->getShowMembers());
1033  $new_obj->update();
1034  }
1035 
1037  {
1038  global $ilDB;
1039 
1040  $query = "INSERT INTO crs_settings SET ".
1041  "obj_id = ".$ilDB->quote($this->getId()).", ".
1042  "syllabus = ".$ilDB->quote($this->getSyllabus()).", ".
1043  "contact_name = ".$ilDB->quote($this->getContactName()).", ".
1044  "contact_responsibility = ".$ilDB->quote($this->getContactResponsibility()).", ".
1045  "contact_phone = ".$ilDB->quote($this->getContactPhone()).", ".
1046  "contact_email = ".$ilDB->quote($this->getContactEmail()).", ".
1047  "contact_consultation = ".$ilDB->quote($this->getContactConsultation()).", ".
1048  "activation_type = ".$ilDB->quote(IL_CRS_ACTIVATION_OFFLINE).", ".
1049  #"activation_unlimited = '1', ".
1050  "activation_start = ".$ilDB->quote($this->getActivationStart()).", ".
1051  "activation_end = ".$ilDB->quote($this->getActivationEnd()).", ".
1052  #"activation_offline = '1', ".
1053  "subscription_limitation_type = ".$ilDB->quote(IL_CRS_SUBSCRIPTION_DEACTIVATED).", ".
1054  #"subscription_unlimited = '1', ".
1055  "subscription_start = ".$ilDB->quote($this->getSubscriptionStart()).", ".
1056  "subscription_end = ".$ilDB->quote($this->getSubscriptionEnd()).", ".
1057  "subscription_type = ".$ilDB->quote(IL_CRS_SUBSCRIPTION_DIRECT).", ".
1058  "subscription_password = ".$ilDB->quote($this->getSubscriptionPassword()).", ".
1059  "subscription_membership_limitation = ".$ilDB->quote(0).", ".
1060  "subscription_max_members = ".$ilDB->quote($this->getSubscriptionMaxMembers()).", ".
1061  "subscription_notify = '1', ".
1062  "view_mode = '0', ".
1063  "archive_start = ".$ilDB->quote($this->getArchiveStart()).", ".
1064  "archive_end = ".$ilDB->quote($this->getArchiveEnd()).", ".
1065  "archive_type = ".$ilDB->quote(IL_CRS_ARCHIVE_NONE).", ".
1066  "abo = ".$ilDB->quote($this->ABO_ENABLED).", ".
1067  "latitude = ".$ilDB->quote($this->getLatitude()).", ".
1068  "longitude = ".$ilDB->quote($this->getLongitude()).", ".
1069  "location_zoom = ".$ilDB->quote($this->getLocationZoom()).", ".
1070  "enable_course_map = ".$ilDB->quote($this->getEnableCourseMap()).", ".
1071  #"objective_view = '0', ".
1072  "waiting_list = '1', ".
1073  "show_members = '1'";
1074 
1075 
1076  $res = $ilDB->query($query);
1077  $this->__readSettings();
1078 
1079  include_once('./Services/Container/classes/class.ilContainerSortingSettings.php');
1080  $sorting = new ilContainerSortingSettings($this->getId());
1081  $sorting->setSortMode(ilContainer::SORT_MANUAL);
1082  $sorting->update();
1083  }
1084 
1085 
1086  function __readSettings()
1087  {
1088  global $ilDB;
1089 
1090  $query = "SELECT * FROM crs_settings WHERE obj_id = ".$ilDB->quote($this->getId())."";
1091 
1092  $res = $ilDB->query($query);
1093  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
1094  {
1095  $this->setSyllabus($row->syllabus);
1096  $this->setContactName($row->contact_name);
1097  $this->setContactResponsibility($row->contact_responsibility);
1098  $this->setContactPhone($row->contact_phone);
1099  $this->setContactEmail($row->contact_email);
1100  $this->setContactConsultation($row->contact_consultation);
1101  $this->setActivationType($row->activation_type);
1102  #$this->setActivationUnlimitedStatus($row->activation_unlimited);
1103  $this->setActivationStart($row->activation_start);
1104  $this->setActivationEnd($row->activation_end);
1105  #$this->setOfflineStatus($row->activation_offline);
1106  $this->setSubscriptionLimitationType($row->subscription_limitation_type);
1107  #$this->setSubscriptionUnlimitedStatus($row->subscription_unlimited);
1108  $this->setSubscriptionStart($row->subscription_start);
1109  $this->setSubscriptionEnd($row->subscription_end);
1110  $this->setSubscriptionType($row->subscription_type);
1111  $this->setSubscriptionPassword($row->subscription_password);
1112  $this->enableSubscriptionMembershipLimitation($row->subscription_membership_limitation);
1113  $this->setSubscriptionMaxMembers($row->subscription_max_members);
1114  $this->setSubscriptionNotify($row->subscription_notify);
1115  $this->setViewMode($row->view_mode);
1116  $this->setArchiveStart($row->archive_start);
1117  $this->setArchiveEnd($row->archive_end);
1118  $this->setArchiveType($row->archive_type);
1119  $this->setAboStatus($row->abo);
1120  $this->enableWaitingList($row->waiting_list);
1121  $this->setImportantInformation($row->important);
1122  $this->setShowMembers($row->show_members);
1123  $this->setLatitude($row->latitude);
1124  $this->setLongitude($row->longitude);
1125  $this->setLocationZoom($row->location_zoom);
1126  $this->setEnableCourseMap($row->enable_course_map);
1127  }
1128  return true;
1129  }
1130 
1131  function initWaitingList()
1132  {
1133  include_once "./Modules/Course/classes/class.ilCourseWaitingList.php";
1134 
1135  if(!is_object($this->waiting_list_obj))
1136  {
1137  $this->waiting_list_obj = new ilCourseWaitingList($this->getId());
1138  }
1139  return true;
1140  }
1141 
1142 
1144  {
1145  include_once "./Modules/Course/classes/class.ilCourseParticipants.php";
1146  $this->members_obj = ilCourseParticipants::_getInstanceByObjId($this->getId());
1147  return true;
1148  }
1149 
1150  function initCourseItemObject($a_child_id = 0)
1151  {
1152  include_once "./Modules/Course/classes/class.ilCourseItems.php";
1153 
1154  if(!is_object($this->items_obj))
1155  {
1156  $this->items_obj = new ilCourseItems($this,$a_child_id);
1157  }
1158  return true;
1159  }
1160 
1168  public function getCourseItemObject()
1169  {
1170  if(is_object($this->items_obj))
1171  {
1172  return $this->items_obj;
1173  }
1174  $this->initCourseItemObject();
1175  return $this->items_obj;
1176  }
1177 
1178 
1180  {
1181  include_once "./Modules/Course/classes/class.ilCourseArchives.php";
1182 
1183  if(!is_object($this->archives_obj))
1184  {
1185  $this->archives_obj =& new ilCourseArchives($this);
1186  }
1187  return true;
1188  }
1189 
1190 
1191 
1192  // RBAC METHODS
1193  function initDefaultRoles()
1194  {
1195  global $rbacadmin,$rbacreview,$ilDB;
1196 
1197  $rolf_obj = $this->createRoleFolder();
1198 
1199  // CREATE ADMIN ROLE
1200  $role_obj = $rolf_obj->createRole("il_crs_admin_".$this->getRefId(),"Admin of course obj_no.".$this->getId());
1201  $admin_id = $role_obj->getId();
1202 
1203  // SET PERMISSION TEMPLATE OF NEW LOCAL ADMIN ROLE
1204  $query = "SELECT obj_id FROM object_data ".
1205  " WHERE type='rolt' AND title='il_crs_admin'";
1206 
1207  $res = $this->ilias->db->getRow($query, DB_FETCHMODE_OBJECT);
1208  $rbacadmin->copyRoleTemplatePermissions($res->obj_id,ROLE_FOLDER_ID,$rolf_obj->getRefId(),$role_obj->getId());
1209 
1210  // SET OBJECT PERMISSIONS OF COURSE OBJECT
1211  $ops = $rbacreview->getOperationsOfRole($role_obj->getId(),"crs",$rolf_obj->getRefId());
1212  $rbacadmin->grantPermission($role_obj->getId(),$ops,$this->getRefId());
1213 
1214  // SET OBJECT PERMISSIONS OF ROLE FOLDER OBJECT
1215  //$ops = $rbacreview->getOperationsOfRole($role_obj->getId(),"rolf",$rolf_obj->getRefId());
1216  //$rbacadmin->grantPermission($role_obj->getId(),$ops,$rolf_obj->getRefId());
1217 
1218  // CREATE TUTOR ROLE
1219  // CREATE ROLE AND ASSIGN ROLE TO ROLEFOLDER...
1220  $role_obj = $rolf_obj->createRole("il_crs_tutor_".$this->getRefId(),"Tutors of course obj_no.".$this->getId());
1221  $member_id = $role_obj->getId();
1222 
1223  // SET PERMISSION TEMPLATE OF NEW LOCAL ROLE
1224  $query = "SELECT obj_id FROM object_data ".
1225  " WHERE type='rolt' AND title='il_crs_tutor'";
1226  $res = $this->ilias->db->getRow($query, DB_FETCHMODE_OBJECT);
1227  $rbacadmin->copyRoleTemplatePermissions($res->obj_id,ROLE_FOLDER_ID,$rolf_obj->getRefId(),$role_obj->getId());
1228 
1229  // SET OBJECT PERMISSIONS OF COURSE OBJECT
1230  $ops = $rbacreview->getOperationsOfRole($role_obj->getId(),"crs",$rolf_obj->getRefId());
1231  $rbacadmin->grantPermission($role_obj->getId(),$ops,$this->getRefId());
1232 
1233  // SET OBJECT PERMISSIONS OF ROLE FOLDER OBJECT
1234  //$ops = $rbacreview->getOperationsOfRole($role_obj->getId(),"rolf",$rolf_obj->getRefId());
1235  //$rbacadmin->grantPermission($role_obj->getId(),$ops,$rolf_obj->getRefId());
1236 
1237  // CREATE MEMBER ROLE
1238  // CREATE ROLE AND ASSIGN ROLE TO ROLEFOLDER...
1239  $role_obj = $rolf_obj->createRole("il_crs_member_".$this->getRefId(),"Member of course obj_no.".$this->getId());
1240  $member_id = $role_obj->getId();
1241 
1242  // SET PERMISSION TEMPLATE OF NEW LOCAL ROLE
1243  $query = "SELECT obj_id FROM object_data ".
1244  " WHERE type='rolt' AND title='il_crs_member'";
1245  $res = $this->ilias->db->getRow($query, DB_FETCHMODE_OBJECT);
1246  $rbacadmin->copyRoleTemplatePermissions($res->obj_id,ROLE_FOLDER_ID,$rolf_obj->getRefId(),$role_obj->getId());
1247 
1248  // SET OBJECT PERMISSIONS OF COURSE OBJECT
1249  $ops = $rbacreview->getOperationsOfRole($role_obj->getId(),"crs",$rolf_obj->getRefId());
1250  $rbacadmin->grantPermission($role_obj->getId(),$ops,$this->getRefId());
1251 
1252  // SET OBJECT PERMISSIONS OF ROLE FOLDER OBJECT
1253  //$ops = $rbacreview->getOperationsOfRole($role_obj->getId(),"rolf",$rolf_obj->getRefId());
1254  //$rbacadmin->grantPermission($role_obj->getId(),$ops,$rolf_obj->getRefId());
1255 
1256  unset($role_obj);
1257  unset($rolf_obj);
1258 
1259  // Break inheritance, create local roles and initialize permission
1260  // settings depending on course status.
1261  $this->__setCourseStatus();
1262 
1263  return true;
1264  }
1265 
1283  {
1284  global $rbacadmin, $rbacreview, $rbacsystem;
1285 
1286  //get Rolefolder of course
1287  $rolf_data = $rbacreview->getRoleFolderOfObject($this->getRefId());
1288 
1289  //define all relevant roles for which rights are needed to be changed
1290  $arr_parentRoles = $rbacreview->getParentRoleIds($this->getRefId());
1291  $arr_relevantParentRoleIds = array_diff(array_keys($arr_parentRoles),$this->getDefaultCourseRoles());
1292 
1293  $template_id = $this->__getCrsNonMemberTemplateId();
1294 
1295  //get defined operations from template
1296  if (is_null($template_id))
1297  {
1298  $template_ops = array();
1299  } else {
1300  $template_ops = $rbacreview->getOperationsOfRole($template_id, 'crs', ROLE_FOLDER_ID);
1301  }
1302 
1303  foreach ($arr_relevantParentRoleIds as $parentRole)
1304  {
1305  if ($rbacreview->isProtected($arr_parentRoles[$parentRole]['parent'],$parentRole))
1306  {
1307  continue;
1308  }
1309 
1310  $granted_permissions = array();
1311 
1312  // Delete the linked role for the parent role
1313  // (just in case if it already exists).
1314  $rbacadmin->deleteLocalRole($parentRole,$rolf_data["child"]);
1315 
1316  // Grant permissions on the course object for
1317  // the parent role. In the foreach loop we
1318  // compute the intersection of the role
1319  // template il_crs_non_member and the
1320  // permission template of the parent role.
1321  $current_ops = $rbacreview->getRoleOperationsOnObject($parentRole, $this->getRefId());
1322  $rbacadmin->revokePermission($this->getRefId(), $parentRole);
1323  foreach ($template_ops as $template_op)
1324  {
1325  if (in_array($template_op,$current_ops))
1326  {
1327  array_push($granted_permissions,$template_op);
1328  }
1329  }
1330  if (!empty($granted_permissions))
1331  {
1332  $rbacadmin->grantPermission($parentRole, $granted_permissions, $this->getRefId());
1333  }
1334 
1335  // Create a linked role for the parent role and
1336  // initialize it with the intersection of
1337  // il_crs_non_member and the permission
1338  // template of the parent role
1339  if (! is_null($template_id))
1340  {
1341  $rbacadmin->copyRolePermissionIntersection(
1342  $template_id, ROLE_FOLDER_ID,
1343  $parentRole, $arr_parentRoles[$parentRole]['parent'],
1344  $rolf_data["child"], $parentRole
1345  );
1346  }
1347  $rbacadmin->assignRoleToFolder($parentRole,$rolf_data["child"],"false");
1348  }//END foreach
1349  }
1350 
1358  {
1359  global $ilDB;
1360 
1361  $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_crs_non_member'";
1362  $res = $this->ilias->db->query($q);
1363  $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
1364 
1365  return $row["obj_id"];
1366  }
1367 
1374  public function getLocalCourseRoles($a_translate = false)
1375  {
1376  global $rbacadmin,$rbacreview;
1377 
1378  if (empty($this->local_roles))
1379  {
1380  $this->local_roles = array();
1381  $rolf = $rbacreview->getRoleFolderOfObject($this->getRefId());
1382  $role_arr = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"]);
1383 
1384  foreach ($role_arr as $role_id)
1385  {
1386  if ($rbacreview->isAssignable($role_id,$rolf["ref_id"]) == true)
1387  {
1388  $role_Obj = $this->ilias->obj_factory->getInstanceByObjId($role_id);
1389 
1390  if ($a_translate)
1391  {
1392  $role_name = ilObjRole::_getTranslation($role_Obj->getTitle());
1393  }
1394  else
1395  {
1396  $role_name = $role_Obj->getTitle();
1397  }
1398  $this->local_roles[$role_name] = $role_Obj->getId();
1399  }
1400  }
1401  }
1402 
1403  return $this->local_roles;
1404  }
1405 
1406 
1407 
1417  public function getDefaultCourseRoles($a_crs_id = "")
1418  {
1419  global $rbacadmin, $rbacreview;
1420 
1421  if (strlen($a_crs_id) > 0)
1422  {
1423  $crs_id = $a_crs_id;
1424  }
1425  else
1426  {
1427  $crs_id = $this->getRefId();
1428  }
1429 
1430  $rolf = $rbacreview->getRoleFolderOfObject($crs_id);
1431  $role_arr = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"]);
1432 
1433  foreach ($role_arr as $role_id)
1434  {
1435  $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1436 
1437  $crs_Member ="il_crs_member_".$crs_id;
1438  $crs_Admin ="il_crs_admin_".$crs_id;
1439  $crs_Tutor ="il_crs_tutor_".$crs_id;
1440 
1441  if (strcmp($role_Obj->getTitle(), $crs_Member) == 0 )
1442  {
1443  $arr_crsDefaultRoles["crs_member_role"] = $role_Obj->getId();
1444  }
1445 
1446  if (strcmp($role_Obj->getTitle(), $crs_Admin) == 0)
1447  {
1448  $arr_crsDefaultRoles["crs_admin_role"] = $role_Obj->getId();
1449  }
1450 
1451  if (strcmp($role_Obj->getTitle(), $crs_Tutor) == 0)
1452  {
1453  $arr_crsDefaultRoles["crs_tutor_role"] = $role_Obj->getId();
1454  }
1455  }
1456 
1457  return $arr_crsDefaultRoles;
1458  }
1459 
1460  function __getLocalRoles()
1461  {
1462  global $rbacreview;
1463 
1464  // GET role_objects of predefined roles
1465 
1466  $rolf = $rbacreview->getRoleFolderOfObject($this->getRefId());
1467 
1468  return $rbacreview->getRolesOfRoleFolder($rolf["ref_id"],false);
1469  }
1470 
1471  function __deleteSettings()
1472  {
1473  global $ilDB;
1474 
1475  $query = "DELETE FROM crs_settings ".
1476  "WHERE obj_id = ".$ilDB->quote($this->getId())." ";
1477 
1478  $this->ilias->db->query($query);
1479 
1480  return true;
1481  }
1482 
1484  {
1485  $local_roles = $this->__getLocalRoles();
1486 
1487  foreach($local_roles as $role_id)
1488  {
1489  if($tmp_role =& ilObjectFactory::getInstanceByObjId($role_id,false))
1490  {
1491  if(!strcmp($tmp_role->getTitle(),"il_crs_member_".$this->getRefId()))
1492  {
1493  return $role_id;
1494  }
1495  }
1496  }
1497  return false;
1498  }
1500  {
1501  $local_roles = $this->__getLocalRoles();
1502 
1503  foreach($local_roles as $role_id)
1504  {
1505  if($tmp_role =& ilObjectFactory::getInstanceByObjId($role_id,false))
1506  {
1507  if(!strcmp($tmp_role->getTitle(),"il_crs_tutor_".$this->getRefId()))
1508  {
1509  return $role_id;
1510  }
1511  }
1512  }
1513  return false;
1514  }
1516  {
1517  $local_roles = $this->__getLocalRoles();
1518 
1519  foreach($local_roles as $role_id)
1520  {
1521  if($tmp_role =& ilObjectFactory::getInstanceByObjId($role_id,false))
1522  {
1523  if(!strcmp($tmp_role->getTitle(),"il_crs_admin_".$this->getRefId()))
1524  {
1525  return $role_id;
1526  }
1527  }
1528  }
1529  return false;
1530  }
1531 
1532  // static method for condition handler
1533  function _checkCondition($a_obj_id,$a_operator,$a_value,$a_usr_id = 0)
1534  {
1535  global $ilUser;
1536 
1537  $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
1538 
1539  include_once "./Modules/Course/classes/class.ilCourseParticipants.php";
1540 
1541  switch($a_operator)
1542  {
1543  case 'passed':
1544  return ilCourseParticipants::_hasPassed($a_obj_id,$a_usr_id);
1545 
1546  default:
1547  return true;
1548  }
1549  }
1550 
1551  function _deleteUser($a_usr_id)
1552  {
1553  // Delete all user related data
1554  // delete lm_history
1555  include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
1556  ilCourseLMHistory::_deleteUser($a_usr_id);
1557 
1558  include_once './Modules/Course/classes/class.ilCourseParticipants.php';
1560 
1561  // Course objectives
1562  include_once './Modules/Course/classes/class.ilCourseObjectiveResult.php';
1564  }
1565 
1575  public function handleECSSettings($a_export,$a_owner,$a_mids)
1576  {
1577  try
1578  {
1579  include_once('./Services/WebServices/ECS/classes/class.ilECSContentWriter.php');
1580 
1581  $writer = new ilECSContentWriter($this);
1582  $writer->setExportable($a_export);
1583  $writer->setOwnerId($a_owner);
1584  $writer->setParticipantIds((array) $a_mids);
1585  $writer->refresh();
1586  }
1587  catch(ilECSConnectorException $exc)
1588  {
1589  throw $exc;
1590  }
1591  catch(ilECSContentWriterException $exc)
1592  {
1593  throw $exc;
1594  }
1595  }
1596 
1603  public function MDUpdateListener($a_element)
1604  {
1605  global $ilLog;
1606 
1607  parent::MDUpdateListener($a_element);
1608 
1609  switch($a_element)
1610  {
1611  case 'General':
1612  $this->updateECSContent();
1613  break;
1614  default:
1615  return true;
1616  }
1617  }
1618 
1626  public function updateECSContent()
1627  {
1628  global $ilLog;
1629 
1630  include_once('./Services/WebServices/ECS/classes/class.ilECSSettings.php');
1631  $settings = ilECSSettings::_getInstance();
1632  if(!$settings->isEnabled())
1633  {
1634  return true;
1635  }
1636  try
1637  {
1638  // Update ECS EContent
1639  include_once('./Services/WebServices/ECS/classes/class.ilECSContentWriter.php');
1640  $writer = new ilECSContentWriter($this);
1641  $writer->refreshSettings();
1642  }
1643  catch(ilException $exc)
1644  {
1645  $ilLog->write(__METHOD__.': Cannot save ECS settings. '.$exc->getMessage());
1646  return false;
1647  }
1648  return true;
1649  }
1650 
1655  function addAdditionalSubItemInformation(&$a_item_data)
1656  {
1657  global $ilBench;
1658 
1659  $ilBench->start("Course", "initCourseItemObject");
1660  $this->initCourseItemObject();
1661  $ilBench->stop("Course", "initCourseItemObject");
1662 
1663  $ilBench->start("Course", "addAdditionalSubItemInformation");
1664  $this->items_obj->addAdditionalSubItemInformation($a_item_data);
1665  $ilBench->stop("Course", "addAdditionalSubItemInformation");
1666  }
1667 
1675  protected function prepareAppointments($a_mode = 'create')
1676  {
1677  include_once('./Services/Calendar/classes/class.ilCalendarAppointmentTemplate.php');
1678  include_once('./Services/Calendar/classes/class.ilDateTime.php');
1679 
1680  switch($a_mode)
1681  {
1682  case 'create':
1683  case 'update':
1684  if(!$this->getActivationUnlimitedStatus() and !$this->getOfflineStatus())
1685  {
1686  $app = new ilCalendarAppointmentTemplate(self::CAL_ACTIVATION_START);
1687  $app->setTitle($this->getTitle());
1688  $app->setSubtitle('crs_cal_activation_start');
1689  $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
1690  $app->setDescription($this->getLongDescription());
1691  $app->setStart(new ilDateTime($this->getActivationStart(),IL_CAL_UNIX));
1692  $apps[] = $app;
1693 
1694  $app = new ilCalendarAppointmentTemplate(self::CAL_ACTIVATION_END);
1695  $app->setTitle($this->getTitle());
1696  $app->setSubtitle('crs_cal_activation_end');
1697  $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
1698  $app->setDescription($this->getLongDescription());
1699  $app->setStart(new ilDateTime($this->getActivationEnd(),IL_CAL_UNIX));
1700  $apps[] = $app;
1701  }
1703  {
1704  $app = new ilCalendarAppointmentTemplate(self::CAL_REG_START);
1705  $app->setTitle($this->getTitle());
1706  $app->setSubtitle('crs_cal_reg_start');
1707  $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
1708  $app->setDescription($this->getLongDescription());
1709  $app->setStart(new ilDateTime($this->getSubscriptionStart(),IL_CAL_UNIX));
1710  $apps[] = $app;
1711 
1712  $app = new ilCalendarAppointmentTemplate(self::CAL_REG_END);
1713  $app->setTitle($this->getTitle());
1714  $app->setSubtitle('crs_cal_reg_end');
1715  $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
1716  $app->setDescription($this->getLongDescription());
1717  $app->setStart(new ilDateTime($this->getSubscriptionEnd(),IL_CAL_UNIX));
1718  $apps[] = $app;
1719  }
1720 
1721  return $apps ? $apps : array();
1722 
1723  case 'delete':
1724  // Nothing to do: The category and all assigned appointments will be deleted.
1725  return array();
1726  }
1727  }
1728 
1729 } //END class.ilObjCourse
1730 ?>