ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ceven 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
24require_once "./Services/Container/classes/class.ilContainer.php";
25include_once './Modules/Course/classes/class.ilCourseConstants.php';
26include_once './Services/Membership/interfaces/interface.ilMembershipRegistrationCodes.php';
27
36{
40 protected $course_logger = null;
41
42
43 const CAL_REG_START = 1;
44 const CAL_REG_END = 2;
48 const CAL_COURSE_END = 6;
51
52
55
56 private $member_obj = null;
57 private $members_obj = null;
59
60 private $latitude = '';
61 private $longitude = '';
62 private $locationzoom = 0;
63 private $enablemap = 0;
64
65 private $session_limit = 0;
66 private $session_prev = -1;
67 private $session_next = -1;
68
69 private $reg_access_code = '';
70 private $reg_access_code_enabled = false;
71 private $status_dt = null;
72
74
75 protected $crs_start; // [ilDate]
76 protected $crs_end; // [ilDate]
77 protected $leave_end; // [ilDate]
78 protected $min_members; // [int]
79 protected $auto_fill_from_waiting; // [bool]
80
84 protected $member_export = false;
85
90
96 private $auto_notification = true;
97
98
105 public function __construct($a_id = 0, $a_call_by_reference = true)
106 {
107
108 #define("ILIAS_MODULE","course");
109 #define("KEEP_IMAGE_PATH",1);
110
111 $this->SUBSCRIPTION_DEACTIVATED = 1;
112 $this->SUBSCRIPTION_CONFIRMATION = 2;
113 $this->SUBSCRIPTION_DIRECT = 3;
114 $this->SUBSCRIPTION_PASSWORD = 4;
115 $this->SUBSCRIPTION_AUTOSUBSCRIPTION = 5;
116 $this->ARCHIVE_DISABLED = 1;
117 $this->ARCHIVE_READ = 2;
118 $this->ARCHIVE_DOWNLOAD = 3;
119 $this->ABO_ENABLED = 1;
120 $this->ABO_DISABLED = 0;
121 $this->SHOW_MEMBERS_ENABLED = 1;
122 $this->SHOW_MEMBERS_DISABLED = 0;
123 $this->setStatusDetermination(self::STATUS_DETERMINATION_LP);
124
125 $this->type = "crs";
126
127 $this->course_logger = $GLOBALS['DIC']->logger()->crs();
128
129 parent::__construct($a_id, $a_call_by_reference);
130 }
131
137 public static function lookupShowMembersEnabled($a_obj_id)
138 {
139 $query = 'SELECT show_members FROM crs_settings ' .
140 'WHERE obj_id = ' . $GLOBALS['DIC']['ilDB']->quote($a_obj_id, 'integer');
141 $res = $GLOBALS['DIC']['ilDB']->query($query);
142 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
143 return (bool) $row->show_members;
144 }
145 return false;
146 }
147
148 public function getShowMembersExport()
149 {
151 }
152
153 public function setShowMembersExport($a_mem_export)
154 {
155 $this->member_export = $a_mem_export;
156 }
157
163 {
165 }
166
172 public function setRegistrationAccessCode($a_code)
173 {
174 $this->reg_access_code = $a_code;
175 }
176
182 {
183 return (bool) $this->reg_access_code_enabled;
184 }
185
191 public function enableRegistrationAccessCode($a_status)
192 {
193 $this->reg_access_code_enabled = $a_status;
194 }
195
196 public function getImportantInformation()
197 {
198 return $this->important;
199 }
200 public function setImportantInformation($a_info)
201 {
202 $this->important = $a_info;
203 }
204 public function getSyllabus()
205 {
206 return $this->syllabus;
207 }
208 public function setSyllabus($a_syllabus)
209 {
210 $this->syllabus = $a_syllabus;
211 }
212 public function getContactName()
213 {
214 return $this->contact_name;
215 }
216 public function setContactName($a_cn)
217 {
218 $this->contact_name = $a_cn;
219 }
220 public function getContactConsultation()
221 {
222 return $this->contact_consultation;
223 }
224 public function setContactConsultation($a_value)
225 {
226 $this->contact_consultation = $a_value;
227 }
228 public function getContactPhone()
229 {
230 return $this->contact_phone;
231 }
232 public function setContactPhone($a_value)
233 {
234 $this->contact_phone = $a_value;
235 }
236 public function getContactEmail()
237 {
238 return $this->contact_email;
239 }
240 public function setContactEmail($a_value)
241 {
242 $this->contact_email = $a_value;
243 }
244 public function getContactResponsibility()
245 {
246 return $this->contact_responsibility;
247 }
248 public function setContactResponsibility($a_value)
249 {
250 $this->contact_responsibility = $a_value;
251 }
258 {
259 return !$this->getActivationStart() || !$this->getActivationEnd();
260 }
261 public function getActivationStart()
262 {
263 return $this->activation_start;
264 }
265 public function setActivationStart($a_value)
266 {
267 $this->activation_start = $a_value;
268 }
269 public function getActivationEnd()
270 {
271 return $this->activation_end;
272 }
273 public function setActivationEnd($a_value)
274 {
275 $this->activation_end = $a_value;
276 }
277 public function setActivationVisibility($a_value)
278 {
279 $this->activation_visibility = (bool) $a_value;
280 }
281 public function getActivationVisibility()
282 {
283 return $this->activation_visibility;
284 }
285
287 {
288 return $this->subscription_limitation_type;
289 }
291 {
292 $this->subscription_limitation_type = $a_type;
293 }
295 {
296 return $this->subscription_limitation_type == IL_CRS_SUBSCRIPTION_UNLIMITED;
297 }
298 public function getSubscriptionStart()
299 {
300 return $this->subscription_start;
301 }
302 public function setSubscriptionStart($a_value)
303 {
304 $this->subscription_start = $a_value;
305 }
306 public function getSubscriptionEnd()
307 {
308 return $this->subscription_end;
309 }
310 public function setSubscriptionEnd($a_value)
311 {
312 $this->subscription_end = $a_value;
313 }
314 public function getSubscriptionType()
315 {
316 return $this->subscription_type ? $this->subscription_type : IL_CRS_SUBSCRIPTION_DIRECT;
317 #return $this->subscription_type ? $this->subscription_type : $this->SUBSCRIPTION_DEACTIVATED;
318 }
319 public function setSubscriptionType($a_value)
320 {
321 $this->subscription_type = $a_value;
322 }
323 public function getSubscriptionPassword()
324 {
325 return $this->subscription_password;
326 }
327 public function setSubscriptionPassword($a_value)
328 {
329 $this->subscription_password = $a_value;
330 }
331 public function enabledObjectiveView()
332 {
333 return $this->view_mode == IL_CRS_VIEW_OBJECTIVE;
334 }
335
336 public function enabledWaitingList()
337 {
338 return (bool) $this->waiting_list;
339 }
340
341 public function enableWaitingList($a_status)
342 {
343 $this->waiting_list = (bool) $a_status;
344 }
345
346 public function inSubscriptionTime()
347 {
348 if ($this->getSubscriptionUnlimitedStatus()) {
349 return true;
350 }
351 if (time() > $this->getSubscriptionStart() and time() < $this->getSubscriptionEnd()) {
352 return true;
353 }
354 return false;
355 }
356
362 public function enableSessionLimit($a_status)
363 {
364 $this->session_limit = $a_status;
365 }
366
367 public function isSessionLimitEnabled()
368 {
369 return (bool) $this->session_limit;
370 }
371
379 public function enableSubscriptionMembershipLimitation($a_status)
380 {
381 $this->subscription_membership_limitation = $a_status;
382 }
383
389 public function setNumberOfPreviousSessions($a_num)
390 {
391 $this->session_prev = $a_num;
392 }
393
399 {
400 return $this->session_prev;
401 }
402
408 public function setNumberOfNextSessions($a_num)
409 {
410 $this->session_next = $a_num;
411 }
412
417 public function getNumberOfNextSessions()
418 {
419 return $this->session_next;
420 }
429 {
430 return (bool) $this->subscription_membership_limitation;
431 }
432
434 {
435 return $this->subscription_max_members;
436 }
437 public function setSubscriptionMaxMembers($a_value)
438 {
439 $this->subscription_max_members = $a_value;
440 }
441
450 public static function _isSubscriptionNotificationEnabled($a_course_id)
451 {
452 global $DIC;
453
454 $ilDB = $DIC['ilDB'];
455
456 $query = "SELECT * FROM crs_settings " .
457 "WHERE obj_id = " . $ilDB->quote($a_course_id, 'integer') . " " .
458 "AND sub_notify = 1";
459 $res = $ilDB->query($query);
460 return $res->numRows() ? true : false;
461 }
462
469 public function getSubItems($a_admin_panel_enabled = false, $a_include_side_block = false, $a_get_single = 0)
470 {
471 global $DIC;
472
473 $ilUser = $DIC['ilUser'];
474 $access = $DIC->access();
475
476 // Caching
477 if (is_array($this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block])) {
478 return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
479 }
480
481 // Results are stored in $this->items
482 parent::getSubItems($a_admin_panel_enabled, $a_include_side_block, $a_get_single);
483
484 $limit_sess = false;
485 if (!$a_admin_panel_enabled &&
486 !$a_include_side_block &&
487 $this->items['sess'] &&
488 is_array($this->items['sess']) &&
489 $this->isSessionLimitEnabled() &&
490 $this->getViewMode() == ilContainer::VIEW_SESSIONS) { // #16686
491 $limit_sess = true;
492 }
493
494 if (!$limit_sess) {
495 return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
496 }
497
498
499 // do session limit
500
501 // @todo move to gui class
502 if (isset($_GET['crs_prev_sess'])) {
503 $ilUser->writePref('crs_sess_show_prev_' . $this->getId(), (string) (int) $_GET['crs_prev_sess']);
504 }
505 if (isset($_GET['crs_next_sess'])) {
506 $ilUser->writePref('crs_sess_show_next_' . $this->getId(), (string) (int) $_GET['crs_next_sess']);
507 }
508
509 $session_rbac_checked = [];
510 foreach ($this->items['sess'] as $session_tree_info) {
511 if ($access->checkAccess('visible', '', $session_tree_info['ref_id'])) {
512 $session_rbac_checked[] = $session_tree_info;
513 }
514 }
515 $sessions = ilUtil::sortArray($session_rbac_checked, 'start', 'ASC', true, false);
516 //$sessions = ilUtil::sortArray($this->items['sess'],'start','ASC',true,false);
517 $today = new ilDate(date('Ymd', time()), IL_CAL_DATE);
518 $previous = $current = $next = array();
519 foreach ($sessions as $key => $item) {
520 $start = new ilDateTime($item['start'], IL_CAL_UNIX);
521 $end = new ilDateTime($item['end'], IL_CAL_UNIX);
522
523 if (ilDateTime::_within($today, $start, $end, IL_CAL_DAY)) {
524 $current[] = $item;
525 } elseif (ilDateTime::_before($start, $today, IL_CAL_DAY)) {
526 $previous[] = $item;
527 } elseif (ilDateTime::_after($start, $today, IL_CAL_DAY)) {
528 $next[] = $item;
529 }
530 }
531 $num_previous_remove = max(
532 count($previous) - $this->getNumberOfPreviousSessions(),
533 0
534 );
535 while ($num_previous_remove--) {
536 if (!$ilUser->getPref('crs_sess_show_prev_' . $this->getId())) {
537 array_shift($previous);
538 }
539 $this->items['sess_link']['prev']['value'] = 1;
540 }
541
542 $num_next_remove = max(
543 count($next) - $this->getNumberOfNextSessions(),
544 0
545 );
546 while ($num_next_remove--) {
547 if (!$ilUser->getPref('crs_sess_show_next_' . $this->getId())) {
548 array_pop($next);
549 }
550 // @fixme
551 $this->items['sess_link']['next']['value'] = 1;
552 }
553
554 $sessions = array_merge($previous, $current, $next);
555 $this->items['sess'] = $sessions;
556
557 // #15389 - see ilContainer::getSubItems()
558 include_once('Services/Container/classes/class.ilContainerSorting.php');
559 $sort = ilContainerSorting::_getInstance($this->getId());
560 $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block] = $sort->sortItems($this->items);
561
562 return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
563 }
564
565 public function getSubscriptionNotify()
566 {
567 return true;
568 return $this->subscription_notify ? true : false;
569 }
570 public function setSubscriptionNotify($a_value)
571 {
572 $this->subscription_notify = $a_value ? true : false;
573 }
574
575 public function setViewMode($a_mode)
576 {
577 $this->view_mode = $a_mode;
578 }
579 public function getViewMode()
580 {
581 return $this->view_mode;
582 }
583
588 public static function lookupTimingMode($a_obj_id)
589 {
590 global $DIC;
591
592 $ilDB = $DIC['ilDB'];
593
594 $query = 'SELECT timing_mode FROM crs_settings ' .
595 'WHERE obj_id = ' . $ilDB->quote($a_obj_id, 'integer');
596 $res = $ilDB->query($query);
597
598 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
599 return (int) $row->timing_mode;
600 }
602 }
603
607 public function setTimingMode($a_mode)
608 {
609 $this->timing_mode = $a_mode;
610 }
611
615 public function getTimingMode()
616 {
617 return $this->timing_mode;
618 }
619
620
626 public static function _lookupViewMode($a_id)
627 {
628 global $DIC;
629
630 $ilDB = $DIC['ilDB'];
631
632 $query = "SELECT view_mode FROM crs_settings WHERE obj_id = " . $ilDB->quote($a_id, 'integer') . " ";
633 $res = $ilDB->query($query);
634 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
635 return $row->view_mode;
636 }
637 return false;
638 }
639
640 public static function _lookupAboStatus($a_id)
641 {
642 global $DIC;
643
644 $ilDB = $DIC['ilDB'];
645
646 $query = "SELECT abo FROM crs_settings WHERE obj_id = " . $ilDB->quote($a_id, 'integer') . " ";
647 $res = $ilDB->query($query);
648 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
649 return $row->abo;
650 }
651 return false;
652 }
653
654 public function getArchiveStart()
655 {
656 return $this->archive_start ? $this->archive_start : time();
657 }
658 public function setArchiveStart($a_value)
659 {
660 $this->archive_start = $a_value;
661 }
662 public function getArchiveEnd()
663 {
664 return $this->archive_end ? $this->archive_end : mktime(0, 0, 0, 12, 12, date("Y", time()) + 2);
665 }
666 public function setArchiveEnd($a_value)
667 {
668 $this->archive_end = $a_value;
669 }
670 public function getArchiveType()
671 {
672 return $this->archive_type ? IL_CRS_ARCHIVE_DOWNLOAD : IL_CRS_ARCHIVE_NONE;
673 }
674 public function setArchiveType($a_value)
675 {
676 $this->archive_type = $a_value;
677 }
678 public function setAboStatus($a_status)
679 {
680 $this->abo = $a_status;
681 }
682 public function getAboStatus()
683 {
684 return $this->abo;
685 }
686 public function setShowMembers($a_status)
687 {
688 $this->show_members = $a_status;
689 }
690 public function getShowMembers()
691 {
692 return $this->show_members;
693 }
694
701 {
702 $this->mail_members = $a_type;
703 }
704
709 public function getMailToMembersType()
710 {
711 return $this->mail_members;
712 }
713
714 public function getMessage()
715 {
716 return $this->message;
717 }
718 public function setMessage($a_message)
719 {
720 $this->message = $a_message;
721 }
722 public function appendMessage($a_message)
723 {
724 if ($this->getMessage()) {
725 $this->message .= "<br /> ";
726 }
727 $this->message .= $a_message;
728 }
729
734 public function isActivated()
735 {
736 if ($this->getOfflineStatus()) {
737 return false;
738 }
739 if ($this->getActivationUnlimitedStatus()) {
740 return true;
741 }
742 if (time() < $this->getActivationStart() or
743 time() > $this->getActivationEnd()) {
744 return false;
745 }
746 return true;
747 }
748
755 public static function _isActivated($a_obj_id)
756 {
757 include_once("./Modules/Course/classes/class.ilObjCourseAccess.php");
758 return ilObjCourseAccess::_isActivated($a_obj_id);
759 }
760
767 public static function _registrationEnabled($a_obj_id)
768 {
769 include_once("./Modules/Course/classes/class.ilObjCourseAccess.php");
771 }
772
773
774 public function allowAbo()
775 {
776 return $this->ABO == $this->ABO_ENABLED;
777 }
778
782 public function read()
783 {
784 parent::read();
785
786 include_once('./Services/Container/classes/class.ilContainerSortingSettings.php');
788
789 $this->__readSettings();
790 }
791 public function create($a_upload = false)
792 {
793 global $DIC;
794
795 $ilAppEventHandler = $DIC['ilAppEventHandler'];
796
797 parent::create($a_upload);
798
799 if (!$a_upload) {
800 $this->createMetaData();
801 }
803
804 $ilAppEventHandler->raise(
805 'Modules/Course',
806 'create',
807 array('object' => $this,
808 'obj_id' => $this->getId(),
809 'appointments' => $this->prepareAppointments('create'))
810 );
811 }
812
818 public function setLatitude($a_latitude)
819 {
820 $this->latitude = $a_latitude;
821 }
822
828 public function getLatitude()
829 {
830 return $this->latitude;
831 }
832
838 public function setLongitude($a_longitude)
839 {
840 $this->longitude = $a_longitude;
841 }
842
848 public function getLongitude()
849 {
850 return $this->longitude;
851 }
852
858 public function setLocationZoom($a_locationzoom)
859 {
860 $this->locationzoom = $a_locationzoom;
861 }
862
868 public function getLocationZoom()
869 {
870 return $this->locationzoom;
871 }
872
878 public function setEnableCourseMap($a_enablemap)
879 {
880 $this->enablemap = $a_enablemap;
881 }
882
887 public function getEnableMap()
888 {
889 return $this->getEnableCourseMap();
890 }
891
897 public function getEnableCourseMap()
898 {
899 return $this->enablemap;
900 }
901
902 public function setCourseStart(ilDate $a_value = null)
903 {
904 $this->crs_start = $a_value;
905 }
906
907 public function getCourseStart()
908 {
909 return $this->crs_start;
910 }
911
912 public function setCourseEnd(ilDate $a_value = null)
913 {
914 $this->crs_end = $a_value;
915 }
916
917 public function getCourseEnd()
918 {
919 return $this->crs_end;
920 }
921
922 public function setCancellationEnd(ilDate $a_value = null)
923 {
924 $this->leave_end = $a_value;
925 }
926
927 public function getCancellationEnd()
928 {
929 return $this->leave_end;
930 }
931
932 public function setSubscriptionMinMembers($a_value)
933 {
934 if ($a_value !== null) {
935 $a_value = (int) $a_value;
936 }
937 $this->min_members = $a_value;
938 }
939
941 {
942 return $this->min_members;
943 }
944
945 public function setWaitingListAutoFill($a_value)
946 {
947 $this->auto_fill_from_waiting = (bool) $a_value;
948 }
949
950 public function hasWaitingListAutoFill()
951 {
952 return (bool) $this->auto_fill_from_waiting;
953 }
954
963 public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = false)
964 {
965 global $DIC;
966
967 $ilDB = $DIC['ilDB'];
968 $ilUser = $DIC['ilUser'];
969 $certificateLogger = $DIC->logger()->cert();
970
971
972 $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
973
974 $this->cloneAutoGeneratedRoles($new_obj);
975 $this->cloneMetaData($new_obj);
976
977 // Assign admin
978 $new_obj->getMemberObject()->add($ilUser->getId(), IL_CRS_ADMIN);
979 // cognos-blu-patch: begin
980 $new_obj->getMemberObject()->updateContact($ilUser->getId(), 1);
981 // cognos-blu-patch: end
982
983
984 // #14596
985 $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
986 if ($cwo->isRootNode($this->getRefId())) {
987 $this->setOfflineStatus(true);
988 }
989
990 // Copy settings
991 $this->cloneSettings($new_obj);
992
993 // Course Defined Fields
994 include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
995 ilCourseDefinedFieldDefinition::_clone($this->getId(), $new_obj->getId());
996
997 // Clone course files
998 include_once('Modules/Course/classes/class.ilCourseFile.php');
999 ilCourseFile::_cloneFiles($this->getId(), $new_obj->getId());
1000
1001 // Copy learning progress settings
1002 include_once('Services/Tracking/classes/class.ilLPObjSettings.php');
1003 $obj_settings = new ilLPObjSettings($this->getId());
1004 $obj_settings->cloneSettings($new_obj->getId());
1005 unset($obj_settings);
1006
1007 // clone certificate (#11085)
1009 $templateRepository = new ilCertificateTemplateRepository($ilDB);
1010
1011 $cloneAction = new ilCertificateCloneAction(
1012 $ilDB,
1013 $factory,
1014 $templateRepository,
1015 $DIC->filesystem()->web(),
1016 $certificateLogger,
1018 );
1019
1020 $cloneAction->cloneCertificate($this, $new_obj);
1021
1022 return $new_obj;
1023 }
1024
1033 public function cloneDependencies($a_target_id, $a_copy_id)
1034 {
1035 parent::cloneDependencies($a_target_id, $a_copy_id);
1036
1037 // Clone course start objects
1038 include_once('Services/Container/classes/class.ilContainerStartObjects.php');
1039 $start = new ilContainerStartObjects($this->getRefId(), $this->getId());
1040 $start->cloneDependencies($a_target_id, $a_copy_id);
1041
1042 // Clone course item settings
1043 include_once('Services/Object/classes/class.ilObjectActivation.php');
1044 ilObjectActivation::cloneDependencies($this->getRefId(), $a_target_id, $a_copy_id);
1045
1046 // clone objective settings
1047 include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
1048 ilLOSettings::cloneSettings($a_copy_id, $this->getId(), ilObject::_lookupObjId($a_target_id));
1049
1050 // Clone course learning objectives
1051 include_once('Modules/Course/classes/class.ilCourseObjective.php');
1052 $crs_objective = new ilCourseObjective($this);
1053 $crs_objective->ilClone($a_target_id, $a_copy_id);
1054
1055 // clone membership limitation
1056 foreach (\ilObjCourseGrouping::_getGroupings($this->getId()) as $grouping_id) {
1057 \ilLoggerFactory::getLogger('crs')->info('Handling grouping id: ' . $grouping_id);
1058 $grouping = new \ilObjCourseGrouping($grouping_id);
1059 $grouping->cloneGrouping($a_target_id, $a_copy_id);
1060 }
1061
1062 return true;
1063 }
1064
1072 public function cloneAutoGeneratedRoles($new_obj)
1073 {
1074 global $DIC;
1075
1076 $ilLog = $DIC['ilLog'];
1077 $rbacadmin = $DIC['rbacadmin'];
1078 $rbacreview = $DIC['rbacreview'];
1079
1080 $admin = $this->getDefaultAdminRole();
1081 $new_admin = $new_obj->getDefaultAdminRole();
1082
1083 if (!$admin || !$new_admin || !$this->getRefId() || !$new_obj->getRefId()) {
1084 $ilLog->write(__METHOD__ . ' : Error cloning auto generated role: il_crs_admin');
1085 }
1086 $rbacadmin->copyRolePermissions($admin, $this->getRefId(), $new_obj->getRefId(), $new_admin, true);
1087 $ilLog->write(__METHOD__ . ' : Finished copying of role crs_admin.');
1088
1089 $tutor = $this->getDefaultTutorRole();
1090 $new_tutor = $new_obj->getDefaultTutorRole();
1091 if (!$tutor || !$new_tutor) {
1092 $ilLog->write(__METHOD__ . ' : Error cloning auto generated role: il_crs_tutor');
1093 }
1094 $rbacadmin->copyRolePermissions($tutor, $this->getRefId(), $new_obj->getRefId(), $new_tutor, true);
1095 $ilLog->write(__METHOD__ . ' : Finished copying of role crs_tutor.');
1096
1097 $member = $this->getDefaultMemberRole();
1098 $new_member = $new_obj->getDefaultMemberRole();
1099 if (!$member || !$new_member) {
1100 $ilLog->write(__METHOD__ . ' : Error cloning auto generated role: il_crs_member');
1101 }
1102 $rbacadmin->copyRolePermissions($member, $this->getRefId(), $new_obj->getRefId(), $new_member, true);
1103 $ilLog->write(__METHOD__ . ' : Finished copying of role crs_member.');
1104
1105 return true;
1106 }
1107
1108
1109 public function validate()
1110 {
1111 $this->setMessage('');
1112
1114 $this->getSubscriptionStart() > $this->getSubscriptionEnd()) {
1115 $this->appendMessage($this->lng->txt("subscription_times_not_valid"));
1116 }
1118 $this->appendMessage($this->lng->txt("crs_password_required"));
1119 }
1120 if ($this->isSubscriptionMembershipLimited()) {
1121 if ($this->getSubscriptionMinMembers() <= 0 && $this->getSubscriptionMaxMembers() <= 0) {
1122 $this->appendMessage($this->lng->txt("crs_max_and_min_members_needed"));
1123 }
1124 if ($this->getSubscriptionMaxMembers() <= 0 && $this->enabledWaitingList()) {
1125 $this->appendMessage($this->lng->txt("crs_max_members_needed"));
1126 }
1127 if ($this->getSubscriptionMaxMembers() > 0 && $this->getSubscriptionMinMembers() > $this->getSubscriptionMaxMembers()) {
1128 $this->appendMessage($this->lng->txt("crs_max_and_min_members_invalid"));
1129 }
1130 }
1131 if (!$this->getTitle() || !$this->getStatusDetermination()) {
1132 $this->appendMessage($this->lng->txt('err_check_input'));
1133 }
1134
1135 // :TODO: checkInput() is not used properly
1136 if (($this->getCourseStart() && !$this->getCourseEnd()) ||
1137 (!$this->getCourseStart() && $this->getCourseEnd()) ||
1138 ($this->getCourseStart() && $this->getCourseEnd() && $this->getCourseStart()->get(IL_CAL_UNIX) > $this->getCourseEnd()->get(IL_CAL_UNIX))) {
1139 $this->appendMessage($this->lng->txt("crs_course_period_not_valid"));
1140 }
1141
1142 return $this->getMessage() ? false : true;
1143 }
1144
1145 public function validateInfoSettings()
1146 {
1147 global $DIC;
1148
1149 $ilErr = $DIC['ilErr'];
1150 $error = false;
1151 if ($this->getContactEmail()) {
1152 $emails = explode(",", $this->getContactEmail());
1153
1154 foreach ($emails as $email) {
1155 $email = trim($email);
1157 $ilErr->appendMessage($this->lng->txt('contact_email_not_valid') . " '" . $email . "'");
1158 $error = true;
1159 }
1160 }
1161 }
1162 return !$error;
1163 }
1164
1165 public function hasContactData()
1166 {
1167 return strlen($this->getContactName()) or
1168 strlen($this->getContactResponsibility()) or
1169 strlen($this->getContactEmail()) or
1170 strlen($this->getContactPhone()) or
1171 strlen($this->getContactConsultation());
1172 }
1173
1174
1181 public function delete()
1182 {
1183 global $DIC;
1184
1185 $ilAppEventHandler = $DIC['ilAppEventHandler'];
1186
1187 // always call parent delete function first!!
1188 if (!parent::delete()) {
1189 return false;
1190 }
1191
1192 // delete meta data
1193 $this->deleteMetaData();
1194
1195 // put here course specific stuff
1196
1197 $this->__deleteSettings();
1198
1199 include_once('Modules/Course/classes/class.ilCourseParticipants.php');
1201
1202 include_once './Modules/Course/classes/class.ilCourseObjective.php';
1204
1205 include_once './Modules/Course/classes/class.ilObjCourseGrouping.php';
1207
1208 include_once './Modules/Course/classes/class.ilCourseFile.php';
1210
1211 include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
1213
1214 $ilAppEventHandler->raise(
1215 'Modules/Course',
1216 'delete',
1217 array('object' => $this,
1218 'obj_id' => $this->getId(),
1219 'appointments' => $this->prepareAppointments('delete'))
1220 );
1221
1222
1223 return true;
1224 }
1225
1226
1230 public function update()
1231 {
1232 global $DIC;
1233
1234 $ilAppEventHandler = $DIC['ilAppEventHandler'];
1235 $ilLog = $DIC->logger()->crs();
1236
1237 include_once('./Services/Container/classes/class.ilContainerSortingSettings.php');
1238 $sorting = new ilContainerSortingSettings($this->getId());
1239 $sorting->setSortMode($this->getOrderType());
1240 $sorting->update();
1241
1242 $this->updateMetaData();
1243 $this->updateSettings();
1245
1246 $ilAppEventHandler->raise(
1247 'Modules/Course',
1248 'update',
1249 array('object' => $this,
1250 'obj_id' => $this->getId(),
1251 'appointments' => $this->prepareAppointments('update'))
1252 );
1253 }
1254
1255 public function updateSettings()
1256 {
1257 global $DIC;
1258
1259 $ilDB = $DIC['ilDB'];
1260
1261 // Due to a bug 3.5.alpha maybe no settings exist. => create default settings
1262
1263 $query = "SELECT * FROM crs_settings WHERE obj_id = " . $ilDB->quote($this->getId(), 'integer') . " ";
1264 $res = $ilDB->query($query);
1265
1266 if (!$res->numRows()) {
1267 $this->__createDefaultSettings();
1268 }
1269
1270 $query = "UPDATE crs_settings SET " .
1271 "syllabus = " . $ilDB->quote($this->getSyllabus(), 'text') . ", " .
1272 "contact_name = " . $ilDB->quote($this->getContactName(), 'text') . ", " .
1273 "contact_responsibility = " . $ilDB->quote($this->getContactResponsibility(), 'text') . ", " .
1274 "contact_phone = " . $ilDB->quote($this->getContactPhone(), 'text') . ", " .
1275 "contact_email = " . $ilDB->quote($this->getContactEmail(), 'text') . ", " .
1276 "contact_consultation = " . $ilDB->quote($this->getContactConsultation(), 'text') . ", " .
1277 "activation_type = " . $ilDB->quote(!$this->getOfflineStatus(), 'integer') . ", " .
1278 "sub_limitation_type = " . $ilDB->quote($this->getSubscriptionLimitationType(), 'integer') . ", " .
1279 "sub_start = " . $ilDB->quote($this->getSubscriptionStart(), 'integer') . ", " .
1280 "sub_end = " . $ilDB->quote($this->getSubscriptionEnd(), 'integer') . ", " .
1281 "sub_type = " . $ilDB->quote($this->getSubscriptionType(), 'integer') . ", " .
1282 "sub_password = " . $ilDB->quote($this->getSubscriptionPassword(), 'text') . ", " .
1283 "sub_mem_limit = " . $ilDB->quote((int) $this->isSubscriptionMembershipLimited(), 'integer') . ", " .
1284 "sub_max_members = " . $ilDB->quote($this->getSubscriptionMaxMembers(), 'integer') . ", " .
1285 "sub_notify = " . $ilDB->quote($this->getSubscriptionNotify(), 'integer') . ", " .
1286 "view_mode = " . $ilDB->quote($this->getViewMode(), 'integer') . ", " .
1287 'timing_mode = ' . $ilDB->quote($this->getTimingMode(), 'integer') . ', ' .
1288 "abo = " . $ilDB->quote($this->getAboStatus(), 'integer') . ", " .
1289 "waiting_list = " . $ilDB->quote($this->enabledWaitingList(), 'integer') . ", " .
1290 "important = " . $ilDB->quote($this->getImportantInformation(), 'text') . ", " .
1291 "show_members = " . $ilDB->quote($this->getShowMembers(), 'integer') . ", " .
1292 "show_members_export = " . $ilDB->quote($this->getShowMembersExport(), 'integer') . ", " .
1293 "latitude = " . $ilDB->quote($this->getLatitude(), 'text') . ", " .
1294 "longitude = " . $ilDB->quote($this->getLongitude(), 'text') . ", " .
1295 "location_zoom = " . $ilDB->quote($this->getLocationZoom(), 'integer') . ", " .
1296 "enable_course_map = " . $ilDB->quote((int) $this->getEnableCourseMap(), 'integer') . ", " .
1297 'session_limit = ' . $ilDB->quote($this->isSessionLimitEnabled(), 'integer') . ', ' .
1298 'session_prev = ' . $ilDB->quote($this->getNumberOfPreviousSessions(), 'integer') . ', ' .
1299 'session_next = ' . $ilDB->quote($this->getNumberOfNextSessions(), 'integer') . ', ' .
1300 'reg_ac_enabled = ' . $ilDB->quote($this->isRegistrationAccessCodeEnabled(), 'integer') . ', ' .
1301 'reg_ac = ' . $ilDB->quote($this->getRegistrationAccessCode(), 'text') . ', ' .
1302 'auto_notification = ' . $ilDB->quote((int) $this->getAutoNotification(), 'integer') . ', ' .
1303 'status_dt = ' . $ilDB->quote((int) $this->getStatusDetermination()) . ', ' .
1304 'mail_members_type = ' . $ilDB->quote((int) $this->getMailToMembersType(), 'integer') . ', ' .
1305 'crs_start = ' . $ilDB->quote(($this->getCourseStart() && !$this->getCourseStart()->isNull()) ? $this->getCourseStart()->get(IL_CAL_UNIX) : null, 'integer') . ', ' .
1306 'crs_end = ' . $ilDB->quote(($this->getCourseEnd() && !$this->getCourseEnd()->isNull()) ? $this->getCourseEnd()->get(IL_CAL_UNIX) : null, 'integer') . ', ' .
1307 'auto_wait = ' . $ilDB->quote((int) $this->hasWaitingListAutoFill(), 'integer') . ', ' .
1308 'leave_end = ' . $ilDB->quote(($this->getCancellationEnd() && !$this->getCancellationEnd()->isNull()) ? $this->getCancellationEnd()->get(IL_CAL_UNIX) : null, 'integer') . ', ' .
1309 'min_members = ' . $ilDB->quote((int) $this->getSubscriptionMinMembers(), 'integer') . ' ' .
1310 "WHERE obj_id = " . $ilDB->quote($this->getId(), 'integer') . "";
1311
1312 $res = $ilDB->manipulate($query);
1313
1314 // moved activation to ilObjectActivation
1315 if ($this->ref_id) {
1316 include_once "./Services/Object/classes/class.ilObjectActivation.php";
1317 ilObjectActivation::getItem($this->ref_id);
1318
1319 $item = new ilObjectActivation;
1320 if (!$this->getActivationStart() || !$this->getActivationEnd()) {
1322 } else {
1323 $item->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
1324 $item->setTimingStart($this->getActivationStart());
1325 $item->setTimingEnd($this->getActivationEnd());
1326 $item->toggleVisible($this->getActivationVisibility());
1327 }
1328
1329 $item->update($this->ref_id);
1330 }
1331 }
1332
1340 public function cloneSettings($new_obj)
1341 {
1342 $new_obj->setSyllabus($this->getSyllabus());
1343 $new_obj->setContactName($this->getContactName());
1344 $new_obj->setContactResponsibility($this->getContactResponsibility());
1345 $new_obj->setContactPhone($this->getContactPhone());
1346 $new_obj->setContactEmail($this->getContactEmail());
1347 $new_obj->setContactConsultation($this->getContactConsultation());
1348 $new_obj->setOfflineStatus($this->getOfflineStatus()); // #9914
1349 $new_obj->setActivationStart($this->getActivationStart());
1350 $new_obj->setActivationEnd($this->getActivationEnd());
1351 $new_obj->setActivationVisibility($this->getActivationVisibility());
1352 $new_obj->setSubscriptionLimitationType($this->getSubscriptionLimitationType());
1353 $new_obj->setSubscriptionStart($this->getSubscriptionStart());
1354 $new_obj->setSubscriptionEnd($this->getSubscriptionEnd());
1355 $new_obj->setSubscriptionType($this->getSubscriptionType());
1356 $new_obj->setSubscriptionPassword($this->getSubscriptionPassword());
1357 $new_obj->enableSubscriptionMembershipLimitation($this->isSubscriptionMembershipLimited());
1358 $new_obj->setSubscriptionMaxMembers($this->getSubscriptionMaxMembers());
1359 $new_obj->setSubscriptionNotify($this->getSubscriptionNotify());
1360 $new_obj->setViewMode($this->getViewMode());
1361 $new_obj->setTimingMode($this->getTimingMode());
1362 $new_obj->setOrderType($this->getOrderType());
1363 $new_obj->setAboStatus($this->getAboStatus());
1364 $new_obj->enableWaitingList($this->enabledWaitingList());
1365 $new_obj->setImportantInformation($this->getImportantInformation());
1366 $new_obj->setShowMembers($this->getShowMembers());
1367 // patch mem_exp
1368 $new_obj->setShowMembersExport($this->getShowMembersExport());
1369 // patch mem_exp
1370 $new_obj->enableSessionLimit($this->isSessionLimitEnabled());
1371 $new_obj->setNumberOfPreviousSessions($this->getNumberOfPreviousSessions());
1372 $new_obj->setNumberOfNextSessions($this->getNumberOfNextSessions());
1373 $new_obj->setAutoNotification($this->getAutoNotification());
1374 $new_obj->enableRegistrationAccessCode($this->isRegistrationAccessCodeEnabled());
1375 include_once './Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
1376 $new_obj->setRegistrationAccessCode(ilMembershipRegistrationCodeUtils::generateCode());
1377 $new_obj->setStatusDetermination($this->getStatusDetermination());
1378 $new_obj->setMailToMembersType($this->getMailToMembersType());
1379 $new_obj->setCourseStart($this->getCourseStart());
1380 $new_obj->setCourseEnd($this->getCourseEnd());
1381 $new_obj->setCancellationEnd($this->getCancellationEnd());
1382 $new_obj->setWaitingListAutoFill($this->hasWaitingListAutoFill());
1383 $new_obj->setSubscriptionMinMembers($this->getSubscriptionMinMembers());
1384
1385 // #10271
1386 $new_obj->setEnableCourseMap($this->getEnableCourseMap());
1387 $new_obj->setLatitude($this->getLatitude());
1388 $new_obj->setLongitude($this->getLongitude());
1389 $new_obj->setLocationZoom($this->getLocationZoom());
1390
1391 $new_obj->update();
1392 }
1393
1394 public function __createDefaultSettings()
1395 {
1396 global $DIC;
1397
1398 $ilDB = $DIC['ilDB'];
1399
1400 include_once './Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
1402
1403 $query = "INSERT INTO crs_settings (obj_id,syllabus,contact_name,contact_responsibility," .
1404 "contact_phone,contact_email,contact_consultation," .
1405 "sub_limitation_type,sub_start,sub_end,sub_type,sub_password,sub_mem_limit," .
1406 "sub_max_members,sub_notify,view_mode,timing_mode,abo," .
1407 "latitude,longitude,location_zoom,enable_course_map,waiting_list,show_members,show_members_export, " .
1408 "session_limit,session_prev,session_next, reg_ac_enabled, reg_ac, auto_notification, status_dt,mail_members_type) " .
1409 "VALUES( " .
1410 $ilDB->quote($this->getId(), 'integer') . ", " .
1411 $ilDB->quote($this->getSyllabus(), 'text') . ", " .
1412 $ilDB->quote($this->getContactName(), 'text') . ", " .
1413 $ilDB->quote($this->getContactResponsibility(), 'text') . ", " .
1414 $ilDB->quote($this->getContactPhone(), 'text') . ", " .
1415 $ilDB->quote($this->getContactEmail(), 'text') . ", " .
1416 $ilDB->quote($this->getContactConsultation(), 'text') . ", " .
1417 $ilDB->quote(IL_CRS_SUBSCRIPTION_DEACTIVATED, 'integer') . ", " .
1418 $ilDB->quote($this->getSubscriptionStart(), 'integer') . ", " .
1419 $ilDB->quote($this->getSubscriptionEnd(), 'integer') . ", " .
1420 $ilDB->quote(IL_CRS_SUBSCRIPTION_DIRECT, 'integer') . ", " .
1421 $ilDB->quote($this->getSubscriptionPassword(), 'text') . ", " .
1422 "0, " .
1423 $ilDB->quote($this->getSubscriptionMaxMembers(), 'integer') . ", " .
1424 "1, " .
1425 "0, " .
1426 $ilDB->quote(IL_CRS_VIEW_TIMING_ABSOLUTE, 'integer') . ', ' .
1427 $ilDB->quote($this->ABO_ENABLED, 'integer') . ", " .
1428 $ilDB->quote($this->getLatitude(), 'text') . ", " .
1429 $ilDB->quote($this->getLongitude(), 'text') . ", " .
1430 $ilDB->quote($this->getLocationZoom(), 'integer') . ", " .
1431 $ilDB->quote($this->getEnableCourseMap(), 'integer') . ", " .
1432 #"objective_view = '0', ".
1433 "1, " .
1434 "1," .
1435 '0,' .
1436 $ilDB->quote($this->isSessionLimitEnabled(), 'integer') . ', ' .
1437 $ilDB->quote($this->getNumberOfPreviousSessions(), 'integer') . ', ' .
1438 $ilDB->quote($this->getNumberOfPreviousSessions(), 'integer') . ', ' .
1439 $ilDB->quote($this->isRegistrationAccessCodeEnabled(), 'integer') . ', ' .
1440 $ilDB->quote($this->getRegistrationAccessCode(), 'text') . ', ' .
1441 $ilDB->quote((int) $this->getAutoNotification(), 'integer') . ', ' .
1442 $ilDB->quote((int) $this->getStatusDetermination(), 'integer') . ', ' .
1443 $ilDB->quote((int) $this->getMailToMembersType(), 'integer') . ' ' .
1444 ")";
1445
1446 $res = $ilDB->manipulate($query);
1447 $this->__readSettings();
1448
1449 include_once('./Services/Container/classes/class.ilContainerSortingSettings.php');
1450 $sorting = new ilContainerSortingSettings($this->getId());
1451 $sorting->setSortMode(ilContainer::SORT_MANUAL);
1452 $sorting->update();
1453 }
1454
1455
1456 public function __readSettings()
1457 {
1458 global $DIC;
1459
1460 $ilDB = $DIC['ilDB'];
1461
1462 $query = "SELECT * FROM crs_settings WHERE obj_id = " . $ilDB->quote($this->getId(), 'integer') . "";
1463
1464 $res = $ilDB->query($query);
1465 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1466 $this->setSyllabus($row->syllabus);
1467 $this->setContactName($row->contact_name);
1468 $this->setContactResponsibility($row->contact_responsibility);
1469 $this->setContactPhone($row->contact_phone);
1470 $this->setContactEmail($row->contact_email);
1471 $this->setContactConsultation($row->contact_consultation);
1472 $this->setOfflineStatus(!(bool) $row->activation_type); // see below
1473 $this->setSubscriptionLimitationType($row->sub_limitation_type);
1474 $this->setSubscriptionStart($row->sub_start);
1475 $this->setSubscriptionEnd($row->sub_end);
1476 $this->setSubscriptionType($row->sub_type);
1477 $this->setSubscriptionPassword($row->sub_password);
1478 $this->enableSubscriptionMembershipLimitation($row->sub_mem_limit);
1479 $this->setSubscriptionMaxMembers($row->sub_max_members);
1480 $this->setSubscriptionNotify($row->sub_notify);
1481 $this->setViewMode($row->view_mode);
1482 $this->setTimingMode((int) $row->timing_mode);
1483 $this->setAboStatus($row->abo);
1484 $this->enableWaitingList($row->waiting_list);
1485 $this->setImportantInformation($row->important);
1486 $this->setShowMembers($row->show_members);
1487
1488 if (\ilPrivacySettings::_getInstance()->participantsListInCoursesEnabled()) {
1489 $this->setShowMembersExport($row->show_members_export);
1490 } else {
1491 $this->setShowMembersExport(false);
1492 }
1493 $this->setLatitude($row->latitude);
1494 $this->setLongitude($row->longitude);
1495 $this->setLocationZoom($row->location_zoom);
1496 $this->setEnableCourseMap($row->enable_course_map);
1497 $this->enableSessionLimit($row->session_limit);
1498 $this->setNumberOfPreviousSessions($row->session_prev);
1499 $this->setNumberOfNextSessions($row->session_next);
1500 $this->enableRegistrationAccessCode($row->reg_ac_enabled);
1501 $this->setRegistrationAccessCode($row->reg_ac);
1502 $this->setAutoNotification($row->auto_notification == 1 ? true : false);
1503 $this->setStatusDetermination((int) $row->status_dt);
1504 $this->setMailToMembersType($row->mail_members_type);
1505 $this->setCourseStart($row->crs_start ? new ilDate($row->crs_start, IL_CAL_UNIX) : null);
1506 $this->setCourseEnd($row->crs_end ? new ilDate($row->crs_end, IL_CAL_UNIX) : null);
1507 $this->setCancellationEnd($row->leave_end ? new ilDate($row->leave_end, IL_CAL_UNIX) : null);
1508 $this->setWaitingListAutoFill($row->auto_wait);
1509 $this->setSubscriptionMinMembers($row->min_members ? $row->min_members : null);
1510 }
1511
1512 // moved activation to ilObjectActivation
1513 if ($this->ref_id) {
1514 include_once "./Services/Object/classes/class.ilObjectActivation.php";
1515 $activation = ilObjectActivation::getItem($this->ref_id);
1516 switch ($activation["timing_type"]) {
1518 $this->setActivationStart($activation["timing_start"]);
1519 $this->setActivationEnd($activation["timing_end"]);
1520 $this->setActivationVisibility($activation["visible"]);
1521 break;
1522 }
1523 }
1524 return true;
1525 }
1526
1527 public function initWaitingList()
1528 {
1529 include_once "./Modules/Course/classes/class.ilCourseWaitingList.php";
1530
1531 if (!is_object($this->waiting_list_obj)) {
1532 $this->waiting_list_obj = new ilCourseWaitingList($this->getId());
1533 }
1534 return true;
1535 }
1536
1537
1543 protected function initCourseMemberObject()
1544 {
1545 global $DIC;
1546
1547 $ilUser = $DIC['ilUser'];
1548
1549 include_once "./Modules/Course/classes/class.ilCourseParticipant.php";
1550 $this->member_obj = ilCourseParticipant::_getInstanceByObjId($this->getId(), $ilUser->getId());
1551 return true;
1552 }
1553
1559 protected function initCourseMembersObject()
1560 {
1561 global $DIC;
1562
1563 $ilUser = $DIC['ilUser'];
1564
1565 include_once "./Modules/Course/classes/class.ilCourseParticipants.php";
1566 $this->members_obj = ilCourseParticipants::_getInstanceByObjId($this->getId());
1567 return true;
1568 }
1569
1574 public function getMemberObject()
1575 {
1576 if (!$this->member_obj instanceof ilCourseParticipant) {
1577 $this->initCourseMemberObject();
1578 }
1579 return $this->member_obj;
1580 }
1581
1585 public function getMembersObject()
1586 {
1587 if (!$this->members_obj instanceof ilCourseParticipants) {
1588 $this->initCourseMembersObject();
1589 }
1590 return $this->members_obj;
1591 }
1592
1593
1594
1595 // RBAC METHODS
1596 public function initDefaultRoles()
1597 {
1598 global $DIC;
1599
1600 $rbacadmin = $DIC['rbacadmin'];
1601 $rbacreview = $DIC['rbacreview'];
1602 $ilDB = $DIC['ilDB'];
1603
1604 include_once './Services/AccessControl/classes/class.ilObjRole.php';
1606 'il_crs_admin_' . $this->getRefId(),
1607 "Admin of crs obj_no." . $this->getId(),
1608 'il_crs_admin',
1609 $this->getRefId()
1610 );
1612 'il_crs_tutor_' . $this->getRefId(),
1613 "Tutor of crs obj_no." . $this->getId(),
1614 'il_crs_tutor',
1615 $this->getRefId()
1616 );
1618 'il_crs_member_' . $this->getRefId(),
1619 "Member of crs obj_no." . $this->getId(),
1620 'il_crs_member',
1621 $this->getRefId()
1622 );
1623
1624 return array();
1625 }
1626
1636 public function setParentRolePermissions($a_parent_ref)
1637 {
1638 global $DIC;
1639
1640 $rbacadmin = $DIC['rbacadmin'];
1641 $rbacreview = $DIC['rbacreview'];
1642
1643 $parent_roles = $rbacreview->getParentRoleIds($a_parent_ref);
1644 foreach ((array) $parent_roles as $parent_role) {
1645 $rbacadmin->initIntersectionPermissions(
1646 $this->getRefId(),
1647 $parent_role['obj_id'],
1648 $parent_role['parent'],
1650 ROLE_FOLDER_ID
1651 );
1652 }
1653 }
1654
1662 {
1663 global $DIC;
1664
1665 $ilDB = $DIC['ilDB'];
1666
1667 $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_crs_non_member'";
1668 $res = $this->ilias->db->query($q);
1670
1671 return $row["obj_id"];
1672 }
1673
1678 public static function lookupCourseNonMemberTemplatesId()
1679 {
1680 global $DIC;
1681
1682 $ilDB = $DIC['ilDB'];
1683
1684 $query = 'SELECT obj_id FROM object_data WHERE type = ' . $ilDB->quote('rolt', 'text') . ' AND title = ' . $ilDB->quote('il_crs_non_member', 'text');
1685 $res = $ilDB->query($query);
1687
1688 return isset($row['obj_id']) ? $row['obj_id'] : 0;
1689 }
1690
1697 public function getLocalCourseRoles($a_translate = false)
1698 {
1699 global $DIC;
1700
1701 $rbacadmin = $DIC['rbacadmin'];
1702 $rbacreview = $DIC['rbacreview'];
1703
1704 if (empty($this->local_roles)) {
1705 $this->local_roles = array();
1706 $role_arr = $rbacreview->getRolesOfRoleFolder($this->getRefId());
1707
1708 foreach ($role_arr as $role_id) {
1709 if ($rbacreview->isAssignable($role_id, $this->getRefId()) == true) {
1710 $role_Obj = $this->ilias->obj_factory->getInstanceByObjId($role_id);
1711
1712 if ($a_translate) {
1713 $role_name = ilObjRole::_getTranslation($role_Obj->getTitle());
1714 } else {
1715 $role_name = $role_Obj->getTitle();
1716 }
1717 $this->local_roles[$role_name] = $role_Obj->getId();
1718 }
1719 }
1720 }
1721
1722 return $this->local_roles;
1723 }
1724
1725
1726
1736 public function getDefaultCourseRoles($a_crs_id = "")
1737 {
1738 global $DIC;
1739
1740 $rbacadmin = $DIC['rbacadmin'];
1741 $rbacreview = $DIC['rbacreview'];
1742
1743 if (strlen($a_crs_id) > 0) {
1744 $crs_id = $a_crs_id;
1745 } else {
1746 $crs_id = $this->getRefId();
1747 }
1748
1749 $role_arr = $rbacreview->getRolesOfRoleFolder($crs_id);
1750
1751 foreach ($role_arr as $role_id) {
1752 $role_Obj = &$this->ilias->obj_factory->getInstanceByObjId($role_id);
1753
1754 $crs_Member = "il_crs_member_" . $crs_id;
1755 $crs_Admin = "il_crs_admin_" . $crs_id;
1756 $crs_Tutor = "il_crs_tutor_" . $crs_id;
1757
1758 if (strcmp($role_Obj->getTitle(), $crs_Member) == 0) {
1759 $arr_crsDefaultRoles["crs_member_role"] = $role_Obj->getId();
1760 }
1761
1762 if (strcmp($role_Obj->getTitle(), $crs_Admin) == 0) {
1763 $arr_crsDefaultRoles["crs_admin_role"] = $role_Obj->getId();
1764 }
1765
1766 if (strcmp($role_Obj->getTitle(), $crs_Tutor) == 0) {
1767 $arr_crsDefaultRoles["crs_tutor_role"] = $role_Obj->getId();
1768 }
1769 }
1770
1771 return $arr_crsDefaultRoles;
1772 }
1773
1774 public function __getLocalRoles()
1775 {
1776 global $DIC;
1777
1778 $rbacreview = $DIC['rbacreview'];
1779
1780 // GET role_objects of predefined roles
1781
1782 return $rbacreview->getRolesOfRoleFolder($this->getRefId(), false);
1783 }
1784
1785 public function __deleteSettings()
1786 {
1787 global $DIC;
1788
1789 $ilDB = $DIC['ilDB'];
1790
1791 $query = "DELETE FROM crs_settings " .
1792 "WHERE obj_id = " . $ilDB->quote($this->getId(), 'integer') . " ";
1793 $res = $ilDB->manipulate($query);
1794
1795 return true;
1796 }
1797
1798
1799 public function getDefaultMemberRole()
1800 {
1801 $local_roles = $this->__getLocalRoles();
1802
1803 foreach ($local_roles as $role_id) {
1804 $title = ilObject::_lookupTitle($role_id);
1805 if (substr($title, 0, 8) == 'il_crs_m') {
1806 return $role_id;
1807 }
1808 }
1809 return 0;
1810 }
1811 public function getDefaultTutorRole()
1812 {
1813 $local_roles = $this->__getLocalRoles();
1814
1815 foreach ($local_roles as $role_id) {
1816 if ($tmp_role = &ilObjectFactory::getInstanceByObjId($role_id, false)) {
1817 if (!strcmp($tmp_role->getTitle(), "il_crs_tutor_" . $this->getRefId())) {
1818 return $role_id;
1819 }
1820 }
1821 }
1822 return false;
1823 }
1824 public function getDefaultAdminRole()
1825 {
1826 $local_roles = $this->__getLocalRoles();
1827
1828 foreach ($local_roles as $role_id) {
1829 if ($tmp_role = &ilObjectFactory::getInstanceByObjId($role_id, false)) {
1830 if (!strcmp($tmp_role->getTitle(), "il_crs_admin_" . $this->getRefId())) {
1831 return $role_id;
1832 }
1833 }
1834 }
1835 return false;
1836 }
1837
1838 public static function _deleteUser($a_usr_id)
1839 {
1840 // Delete all user related data
1841 // delete lm_history
1842 include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
1844
1845 include_once './Modules/Course/classes/class.ilCourseParticipants.php';
1847
1848 // Course objectives
1849 include_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php";
1851 }
1852
1859 public function MDUpdateListener($a_element)
1860 {
1861 global $DIC;
1862
1863 $ilLog = $DIC['ilLog'];
1864
1865 parent::MDUpdateListener($a_element);
1866
1867 switch ($a_element) {
1868 case 'General':
1869 // Update ecs content
1870 include_once 'Modules/Course/classes/class.ilECSCourseSettings.php';
1871 $ecs = new ilECSCourseSettings($this);
1872 $ecs->handleContentUpdate();
1873 break;
1874
1875 default:
1876 return true;
1877 }
1878 }
1879
1884 public function addAdditionalSubItemInformation(&$a_item_data)
1885 {
1886 include_once './Services/Object/classes/class.ilObjectActivation.php';
1888 }
1889
1897 protected function prepareAppointments($a_mode = 'create')
1898 {
1899 include_once('./Services/Calendar/classes/class.ilCalendarAppointmentTemplate.php');
1900 include_once('./Services/Calendar/classes/class.ilDateTime.php');
1901
1902 switch ($a_mode) {
1903 case 'create':
1904 case 'update':
1905 if (!$this->getActivationUnlimitedStatus() and !$this->getOfflineStatus()) {
1906 $app = new ilCalendarAppointmentTemplate(self::CAL_ACTIVATION_START);
1907 $app->setTitle($this->getTitle());
1908 $app->setSubtitle('crs_cal_activation_start');
1909 $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
1910 $app->setDescription($this->getLongDescription());
1911 $app->setStart(new ilDateTime($this->getActivationStart(), IL_CAL_UNIX));
1912 $apps[] = $app;
1913
1914 $app = new ilCalendarAppointmentTemplate(self::CAL_ACTIVATION_END);
1915 $app->setTitle($this->getTitle());
1916 $app->setSubtitle('crs_cal_activation_end');
1917 $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
1918 $app->setDescription($this->getLongDescription());
1919 $app->setStart(new ilDateTime($this->getActivationEnd(), IL_CAL_UNIX));
1920 $apps[] = $app;
1921 }
1923 $app = new ilCalendarAppointmentTemplate(self::CAL_REG_START);
1924 $app->setTitle($this->getTitle());
1925 $app->setSubtitle('crs_cal_reg_start');
1926 $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
1927 $app->setDescription($this->getLongDescription());
1928 $app->setStart(new ilDateTime($this->getSubscriptionStart(), IL_CAL_UNIX));
1929 $apps[] = $app;
1930
1931 $app = new ilCalendarAppointmentTemplate(self::CAL_REG_END);
1932 $app->setTitle($this->getTitle());
1933 $app->setSubtitle('crs_cal_reg_end');
1934 $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
1935 $app->setDescription($this->getLongDescription());
1936 $app->setStart(new ilDateTime($this->getSubscriptionEnd(), IL_CAL_UNIX));
1937 $apps[] = $app;
1938 }
1939 if ($this->getCourseStart() && $this->getCourseEnd()) {
1940 $app = new ilCalendarAppointmentTemplate(self::CAL_COURSE_START);
1941 $app->setTitle($this->getTitle());
1942 $app->setSubtitle('crs_cal_start');
1943 $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
1944 $app->setDescription($this->getLongDescription());
1945 $app->setStart($this->getCourseStart());
1946 $app->setFullday(true);
1947 $apps[] = $app;
1948
1949 $app = new ilCalendarAppointmentTemplate(self::CAL_COURSE_END);
1950 $app->setTitle($this->getTitle());
1951 $app->setSubtitle('crs_cal_end');
1952 $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
1953 $app->setDescription($this->getLongDescription());
1954 $app->setStart($this->getCourseEnd());
1955 $app->setFullday(true);
1956 $apps[] = $app;
1957 }
1958 if (
1960 ) {
1962 foreach ($active as $null => $item) {
1963 if ($item['timing_type'] == ilObjectActivation::TIMINGS_PRESETTING) {
1964 // create calendar entry for fixed types
1965 $app = new ilCalendarAppointmentTemplate(self::CAL_COURSE_TIMING_START);
1966 $app->setContextInfo($item['ref_id']);
1967 $app->setTitle($item['title']);
1968 $app->setSubtitle('cal_crs_timing_start');
1969 $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
1970 $app->setStart(new ilDate($item['suggestion_start'], IL_CAL_UNIX));
1971 $app->setFullday(true);
1972 $apps[] = $app;
1973
1974 $app = new ilCalendarAppointmentTemplate(self::CAL_COURSE_TIMING_END);
1975 $app->setContextInfo($item['ref_id']);
1976 $app->setTitle($item['title']);
1977 $app->setSubtitle('cal_crs_timing_end');
1978 $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
1979 $app->setStart(new ilDate($item['suggestion_end'], IL_CAL_UNIX));
1980 $app->setFullday(true);
1981 $apps[] = $app;
1982 }
1983 }
1984 }
1985 return $apps ? $apps : array();
1986
1987 case 'delete':
1988 // Nothing to do: The category and all assigned appointments will be deleted.
1989 return array();
1990 }
1991 }
1992
1993 ###### Interface ilMembershipRegistrationCodes
1998 public static function lookupObjectsByCode($a_code)
1999 {
2000 global $DIC;
2001
2002 $ilDB = $DIC['ilDB'];
2003
2004 $query = "SELECT obj_id FROM crs_settings " .
2005 "WHERE reg_ac_enabled = " . $ilDB->quote(1, 'integer') . " " .
2006 "AND reg_ac = " . $ilDB->quote($a_code, 'text');
2007 $res = $ilDB->query($query);
2008
2009 $obj_ids = array();
2010 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
2011 $obj_ids[] = $row->obj_id;
2012 }
2013 return $obj_ids;
2014 }
2015
2023 public function register($a_user_id, $a_role = ilCourseConstants::CRS_MEMBER, $a_force_registration = false)
2024 {
2025 global $DIC;
2026
2027 $ilCtrl = $DIC['ilCtrl'];
2028 $tree = $DIC['tree'];
2029 include_once './Services/Membership/exceptions/class.ilMembershipRegistrationException.php';
2030 include_once "./Modules/Course/classes/class.ilCourseParticipants.php";
2032
2033 if ($part->isAssigned($a_user_id)) {
2034 return true;
2035 }
2036
2037 if (!$a_force_registration) {
2038 // offline
2039 if (ilObjCourseAccess::_isOffline($this->getId())) {
2041 "Can't register to course, course is offline.",
2043 );
2044 }
2045 // activation
2046 if (!ilObjCourseAccess::_isActivated($this->getId())) {
2048 "Can't register to course, course is not activated.",
2050 );
2051 }
2052
2055 throw new ilMembershipRegistrationException('Cant registrate to course ' . $this->getId() .
2056 ', course subscription is deactivated.', ilMembershipRegistrationException::REGISTRATION_CODE_DISABLED);
2057 }
2058 }
2059
2060 // Time Limitation
2062 if (!$this->inSubscriptionTime()) {
2063 throw new ilMembershipRegistrationException('Cant registrate to course ' . $this->getId() .
2064 ', course is out of registration time.', ilMembershipRegistrationException::OUT_OF_REGISTRATION_PERIOD);
2065 }
2066 }
2067
2068 // Max members
2069 if ($this->isSubscriptionMembershipLimited()) {
2070 $free = max(0, $this->getSubscriptionMaxMembers() - $part->getCountMembers());
2071 include_once('./Modules/Course/classes/class.ilCourseWaitingList.php');
2072 $waiting_list = new ilCourseWaitingList($this->getId());
2073 if ($this->enabledWaitingList() and (!$free or $waiting_list->getCountUsers())) {
2074 $waiting_list->addToList($a_user_id);
2075 $this->lng->loadLanguageModule("crs");
2076 $info = sprintf(
2077 $this->lng->txt('crs_added_to_list'),
2078 $waiting_list->getPosition($a_user_id)
2079 );
2080 include_once('./Modules/Course/classes/class.ilCourseParticipants.php');
2081 $participants = ilCourseParticipants::_getInstanceByObjId($this->getId());
2082 $participants->sendNotification($participants->NOTIFY_WAITING_LIST, $a_user_id);
2083
2085 }
2086
2087 if (!$this->enabledWaitingList() && !$free) {
2088 throw new ilMembershipRegistrationException('Cant registrate to course ' . $this->getId() .
2089 ', membership is limited.', ilMembershipRegistrationException::OBJECT_IS_FULL);
2090 }
2091 }
2092 }
2093
2094 $part->add($a_user_id, $a_role);
2095 $part->sendNotification($part->NOTIFY_ACCEPT_USER, $a_user_id);
2096 $part->sendNotification($part->NOTIFY_ADMINS, $a_user_id);
2097
2098
2099 include_once './Modules/Forum/classes/class.ilForumNotification.php';
2101
2102 return true;
2103 }
2104
2111 public function getAutoNotification()
2112 {
2114 }
2115
2116
2123 public function setAutoNotification($value)
2124 {
2125 $this->auto_notification = $value;
2126 }
2127
2133 public function setStatusDetermination($a_value)
2134 {
2135 $a_value = (int) $a_value;
2136
2137 // #13905
2138 if ($a_value == self::STATUS_DETERMINATION_LP) {
2139 include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
2142 }
2143 }
2144
2145 $this->status_dt = $a_value;
2146 }
2147
2153 public function getStatusDetermination()
2154 {
2155 return $this->status_dt;
2156 }
2157
2161 public function syncMembersStatusWithLP()
2162 {
2163 include_once "Services/Tracking/classes/class.ilLPStatusWrapper.php";
2164 foreach ($this->getMembersObject()->getParticipants() as $user_id) {
2165 // #15529 - force raise on sync
2166 ilLPStatusWrapper::_updateStatus($this->getId(), $user_id, null, false, true);
2167 }
2168 }
2169
2177 public function checkLPStatusSync($a_member_id)
2178 {
2179 // #11113
2180 include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
2183 include_once("Services/Tracking/classes/class.ilLPStatus.php");
2184 // #13811 - we need to suppress creation if status entry
2185 $has_completed = (ilLPStatus::_lookupStatus($this->getId(), $a_member_id, false) == ilLPStatus::LP_STATUS_COMPLETED_NUM);
2186 $this->getMembersObject()->updatePassed($a_member_id, $has_completed, false, true);
2187 }
2188 }
2189
2190 public function getOrderType()
2191 {
2192 if ($this->enabledObjectiveView()) {
2194 }
2195 return parent::getOrderType();
2196 }
2197
2201 public function handleAutoFill()
2202 {
2203 if (
2204 !$this->enabledWaitingList() or
2205 !$this->hasWaitingListAutoFill()
2206 ) {
2207 $this->course_logger->debug('Waiting list or auto fill disabled.');
2208 return;
2209 }
2210
2211 $max = $this->getSubscriptionMaxMembers();
2213
2214 $this->course_logger->debug('Max members: ' . $max);
2215 $this->course_logger->debug('Current members: ' . $now);
2216
2217 if ($max <= $now) {
2218 return;
2219 }
2220
2221 // see assignFromWaitingListObject()
2222 include_once('./Modules/Course/classes/class.ilCourseWaitingList.php');
2223 $waiting_list = new ilCourseWaitingList($this->getId());
2224
2225 foreach ($waiting_list->getUserIds() as $user_id) {
2226 if (!$tmp_obj = ilObjectFactory::getInstanceByObjId($user_id, false)) {
2227 $this->course_logger->warning('Cannot create user instance for id: ' . $user_id);
2228 continue;
2229 }
2230 if ($this->getMembersObject()->isAssigned($user_id)) {
2231 $this->course_logger->warning('User is already assigned to course. uid: ' . $user_id . ' course_id: ' . $this->getRefId());
2232 continue;
2233 }
2234 $this->getMembersObject()->add($user_id, IL_CRS_MEMBER);
2235 $this->getMembersObject()->sendNotification($this->getMembersObject()->NOTIFY_ACCEPT_USER, $user_id, true);
2236 $waiting_list->removeFromList($user_id);
2237 $this->checkLPStatusSync($user_id);
2238
2239 $this->course_logger->info('Assigned user from waiting list to course: ' . $this->getTitle());
2240 $now++;
2241 if ($now >= $max) {
2242 break;
2243 }
2244 }
2245 }
2246
2247 public static function mayLeave($a_course_id, $a_user_id = null, &$a_date = null)
2248 {
2249 global $DIC;
2250
2251 $ilUser = $DIC['ilUser'];
2252 $ilDB = $DIC['ilDB'];
2253
2254 if (!$a_user_id) {
2255 $a_user_id = $ilUser->getId();
2256 }
2257
2258 $set = $ilDB->query("SELECT leave_end" .
2259 " FROM crs_settings" .
2260 " WHERE obj_id = " . $ilDB->quote($a_course_id, "integer"));
2261 $row = $ilDB->fetchAssoc($set);
2262 if ($row && $row["leave_end"]) {
2263 // timestamp to date
2264 $limit = date("Ymd", $row["leave_end"]);
2265 if ($limit < date("Ymd")) {
2266 $a_date = new ilDate(date("Y-m-d", $row["leave_end"]), IL_CAL_DATE);
2267 return false;
2268 }
2269 }
2270 return true;
2271 }
2272
2278 public static function findCoursesWithNotEnoughMembers()
2279 {
2280 $ilDB = $GLOBALS['DIC']->database();
2281 $tree = $GLOBALS['DIC']->repositoryTree();
2282
2283 $res = array();
2284
2285 $before = new ilDateTime(time(), IL_CAL_UNIX);
2286 $before->increment(IL_CAL_DAY, -1);
2287 $now = $before->get(IL_CAL_UNIX);
2288
2289 include_once "Modules/Course/classes/class.ilCourseParticipants.php";
2290
2291 $set = $ilDB->query("SELECT obj_id, min_members" .
2292 " FROM crs_settings" .
2293 " WHERE min_members > " . $ilDB->quote(0, "integer") .
2294 " AND sub_mem_limit = " . $ilDB->quote(1, "integer") . // #17206
2295 " AND ((leave_end IS NOT NULL" .
2296 " AND leave_end < " . $ilDB->quote($now, "text") . ")" .
2297 " OR (leave_end IS NULL" .
2298 " AND sub_end IS NOT NULL" .
2299 " AND sub_end < " . $ilDB->quote($now, "text") . "))" .
2300 " AND (crs_start IS NULL OR crs_start > " . $ilDB->quote($now, "integer") . ")");
2301 while ($row = $ilDB->fetchAssoc($set)) {
2302 $refs = ilObject::_getAllReferences($row['obj_id']);
2303 $ref = end($refs);
2304
2305 if ($tree->isDeleted($ref)) {
2306 continue;
2307 }
2308
2309 $part = new ilCourseParticipants($row["obj_id"]);
2310 $reci = $part->getNotificationRecipients();
2311 if (sizeof($reci)) {
2312 $missing = (int) $row["min_members"] - $part->getCountMembers();
2313 if ($missing > 0) {
2314 $res[$row["obj_id"]] = array($missing, $reci);
2315 }
2316 }
2317 }
2318
2319 return $res;
2320 }
2321} //END class.ilObjCourse
$factory
Definition: metadata.php:43
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_TRANSLATION_SYSTEM
const IL_CRS_SUBSCRIPTION_LIMITED
const IL_CRS_VIEW_TIMING_ABSOLUTE
const IL_CRS_VIEW_OBJECTIVE
const IL_CRS_SUBSCRIPTION_PASSWORD
const IL_CRS_ARCHIVE_NONE
const IL_CRS_ARCHIVE_DOWNLOAD
const IL_CRS_SUBSCRIPTION_UNLIMITED
const IL_CRS_SUBSCRIPTION_DEACTIVATED
const IL_CRS_SUBSCRIPTION_DIRECT
const IL_CAL_DATE
const IL_CAL_UNIX
const IL_CAL_DAY
const IL_CRS_ADMIN
Base class for course and group participants.
const IL_CRS_MEMBER
Apointment templates are used for automatic generated apointments.
static _lookupSortMode($a_obj_id)
lookup sort mode
static _getInstance($a_obj_id)
get instance by obj_id
Class ilContainer.
setOrderType($a_value)
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static _deleteByContainer($a_container_id)
Delete all fields of a container.
static _clone($a_source_id, $a_target_id)
Clone fields.
static _cloneFiles($a_source_id, $a_target_id)
Clone course files.
static _deleteByCourse($a_course_id)
static _deleteUser($a_usr_id)
Delete user @global type $ilDB.
class ilcourseobjective
static _deleteAll($course_id)
static _getInstanceByObjId($a_obj_id, $a_usr_id)
Get singleton instance.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
@classDescription Date and time handling
static _after(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
static _within(ilDateTime $dt, ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
Check whether an date is within a date duration given by start and end.
static _before(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
Class for single dates.
Class ilECSCourseSettings.
static checkForumsExistsInsert($ref_id, $user_id=0)
static cloneSettings($a_copy_id, $a_container_id, $a_new_container_id)
Clone settings.
static deleteResultsForUser($a_user_id)
Delete all result entries for user.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
const LP_STATUS_COMPLETED_NUM
static _lookupStatus($a_obj_id, $a_user_id, $a_create=true)
Lookup status.
static getLogger($a_component_id)
Get component logger.
static generateCode()
Generate new registration key.
static _registrationEnabled($a_obj_id)
static _usingRegistrationCode()
Using Registration code.
static _isActivated($a_obj_id, &$a_visible_flag=null, $a_mind_member_view=true)
Is activated?
static _isOffline($a_obj_id)
Type-specific implementation of general status.
static _deleteAll($a_course_id)
static _getGroupings($a_course_id)
Class ilObjCourse.
static lookupCourseNonMemberTemplatesId()
Lookup course non member id.
getDefaultCourseRoles($a_crs_id="")
get default course roles, returns the defaultlike create roles il_crs_tutor, il_crs_admin and il_crs_...
static _lookupViewMode($a_id)
lookup view mode of container
cloneObject($a_target_id, $a_copy_id=0, $a_omit_tree=false)
Clone course (no member data)
getNumberOfNextSessions()
Set number of previous sessions.
getMailToMembersType()
Get mail to members type.
setParentRolePermissions($a_parent_ref)
This method is called before "initDefaultRoles".
const STATUS_DETERMINATION_MANUAL
setLongitude($a_longitude)
Set Longitude.
static _registrationEnabled($a_obj_id)
Registration enabled? Method is in Access class, since it is needed by Access/ListGUI.
setMessage($a_message)
const STATUS_DETERMINATION_LP
isActivated()
Check if course is active and not offline.
setActivationStart($a_value)
setStatusDetermination($a_value)
Set status determination mode.
setSubscriptionNotify($a_value)
setTimingMode($a_mode)
enableWaitingList($a_status)
setShowMembersExport($a_mem_export)
static _isSubscriptionNotificationEnabled($a_course_id)
Check if subscription notification is enabled.
handleAutoFill()
Handle course auto fill.
update()
update complete object
isSubscriptionMembershipLimited()
is membership limited
enableSubscriptionMembershipLimitation($a_status)
enable max members
enableSessionLimit($a_status)
en/disable limited number of sessions
initDefaultRoles()
init default roles settings Purpose of this function is to create a local role folder and local roles...
getLatitude()
Get Latitude.
cloneDependencies($a_target_id, $a_copy_id)
Clone object dependencies (start objects, preconditions)
getLocalCourseRoles($a_translate=false)
get ALL local roles of course, also those created and defined afterwards only fetch data once from da...
getViewMode()
Get container view mode.
static _lookupAboStatus($a_id)
setNumberOfNextSessions($a_num)
Set number of previous sessions.
setWaitingListAutoFill($a_value)
setCourseEnd(ilDate $a_value=null)
setSubscriptionType($a_value)
MDUpdateListener($a_element)
Overwriten Metadata update listener for ECS functionalities.
__getCrsNonMemberTemplateId()
get course non-member template @access private
static lookupObjectsByCode($a_code)
getSubItems($a_admin_panel_enabled=false, $a_include_side_block=false, $a_get_single=0)
Get subitems of container.
static mayLeave($a_course_id, $a_user_id=null, &$a_date=null)
setCourseStart(ilDate $a_value=null)
static _isActivated($a_obj_id)
Is activated.
setContactEmail($a_value)
initCourseMemberObject()
Init course member object @global ilObjUser $ilUser.
setActivationEnd($a_value)
setRegistrationAccessCode($a_code)
Set refistration access code.
prepareAppointments($a_mode='create')
Prepare calendar appointments.
setContactPhone($a_value)
getLocationZoom()
Get LocationZoom.
initCourseMembersObject()
Init course member object @global ilObjUser $ilUser.
static findCoursesWithNotEnoughMembers()
Minimum members check @global type $ilDB.
setArchiveType($a_value)
getEnableCourseMap()
Get Enable Course Map.
setSubscriptionEnd($a_value)
setLatitude($a_latitude)
Set Latitude.
enableRegistrationAccessCode($a_status)
En/disable registration access code.
setSubscriptionMaxMembers($a_value)
static lookupShowMembersEnabled($a_obj_id)
Check if show member is enabled.
create($a_upload=false)
getRegistrationAccessCode()
get access code
getMemberObject()
Get course member object.
checkLPStatusSync($a_member_id)
sync course status from lp
syncMembersStatusWithLP()
Set course status for all members by lp status.
setArchiveEnd($a_value)
setShowMembers($a_status)
setMailToMembersType($a_type)
Set mail to members type.
setSubscriptionPassword($a_value)
setSubscriptionStart($a_value)
setImportantInformation($a_info)
const CAL_ACTIVATION_START
getOrderType()
Get order type default implementation.
const CAL_COURSE_TIMING_START
setNumberOfPreviousSessions($a_num)
Set number of previous sessions.
cloneAutoGeneratedRoles($new_obj)
Clone automatic genrated roles (permissions and template permissions)
appendMessage($a_message)
getActivationUnlimitedStatus()
get activation unlimited no start or no end
setContactConsultation($a_value)
__construct($a_id=0, $a_call_by_reference=true)
Constructor @access public.
setSyllabus($a_syllabus)
setSubscriptionMinMembers($a_value)
setContactResponsibility($a_value)
setAboStatus($a_status)
getStatusDetermination()
Get status determination mode.
addAdditionalSubItemInformation(&$a_item_data)
Add additional information to sub item, e.g.
static lookupTimingMode($a_obj_id)
setViewMode($a_mode)
const CAL_COURSE_TIMING_END
cloneSettings($new_obj)
Clone entries in settings table.
setArchiveStart($a_value)
setEnableCourseMap($a_enablemap)
Set Enable Course Map.
const CAL_ACTIVATION_END
setSubscriptionLimitationType($a_type)
static _deleteUser($a_usr_id)
isRegistrationAccessCodeEnabled()
Check if access code is enabled.
getEnableMap()
Type independent wrapper.
setCancellationEnd(ilDate $a_value=null)
setLocationZoom($a_locationzoom)
Set LocationZoom.
getAutoNotification()
Returns automatic notification status from $this->auto_notification.
getNumberOfPreviousSessions()
Set number of previous sessions.
setAutoNotification($value)
Sets automatic notification status in $this->auto_notification, using given $status.
setActivationVisibility($a_value)
getLongitude()
Get Longitude.
static _getTranslation($a_role_title)
static createDefaultRole($a_title, $a_description, $a_tpl_name, $a_ref_id)
static _enabledLearningProgress()
check wether learing progress is enabled or not
static getUserIdByLogin($a_login)
Class ilObjectActivation.
setTimingType($a_type)
Set timing type.
static cloneDependencies($a_ref_id, $a_target_id, $a_copy_id)
Clone dependencies.
static addAdditionalSubItemInformation(array &$a_item)
Parse item data for list entries.
static getTimingsItems($a_container_ref_id)
Get (sub) item data for timings view (no session material, no side blocks)
static getItem($a_ref_id)
Get item data.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupObjId($a_id)
setOfflineStatus($a_status)
Set offline status.
static _lookupTitle($a_id)
lookup object title
deleteMetaData()
delete meta data entry
updateMetaData()
update meta data entry
getOfflineStatus()
Get offline status.
createMetaData()
create meta data entry
getRefId()
get reference id @access public
getLongDescription()
get object long description (stored in object_description)
static _getAllReferences($a_id)
get all reference ids of object
cloneMetaData($target_obj)
Copy meta data.
getId()
get object id @access public
getTitle()
get object title @access public
static lookupNumberOfMembers($a_ref_id)
Lookup number of members @global ilRbacReview $rbacreview @global <type> $ilObjDataCache.
static _deleteUser($a_usr_id)
Delete user data.
static _deleteAllEntries($a_obj_id)
Delete all entries Normally called for course deletion.
static _getInstance()
Get instance of ilPrivacySettings.
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static is_email($a_email, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
$key
Definition: croninfo.php:18
global $ilCtrl
Definition: ilias.php:18
Interface for all objects that offer registration with access codes.
if( $orgName !==null) if($spconfig->hasValue('contacts')) $email
Definition: metadata.php:201
catch(Exception $e) $message
$info
Definition: index.php:5
$row
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
update($pash, $contents, Config $config)
redirection script todo: (a better solution should control the processing via a xml file)
$query
$ilErr
Definition: raiseError.php:18
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
global $ilDB
$ilUser
Definition: imgupload.php:18
$start
Definition: bench.php:8
$a_type
Definition: workflow.php:92