ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 
24 require_once "./Services/Container/classes/class.ilContainer.php";
25 include_once './Modules/Course/classes/class.ilCourseConstants.php';
26 include_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;
46  const CAL_ACTIVATION_END = 4;
47  const CAL_COURSE_START = 5;
48  const CAL_COURSE_END = 6;
51 
52 
55 
56  private $member_obj = null;
57  private $members_obj = null;
58  public $archives_obj;
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 
78  protected $course_start_time_indication = false;
79 
83  protected $crs_start; // [ilDate]
84 
88  protected $crs_end; // [ilDate]
89 
90 
91  protected $leave_end; // [ilDate]
92  protected $min_members; // [int]
93  protected $auto_fill_from_waiting; // [bool]
94 
98  protected $member_export = false;
99 
104 
110  private $auto_notification = true;
111 
112 
116  private $target_group = '';
117 
118 
125  public function __construct($a_id = 0, $a_call_by_reference = true)
126  {
127 
128  #define("ILIAS_MODULE","course");
129  #define("KEEP_IMAGE_PATH",1);
130 
131  $this->SUBSCRIPTION_DEACTIVATED = 1;
132  $this->SUBSCRIPTION_CONFIRMATION = 2;
133  $this->SUBSCRIPTION_DIRECT = 3;
134  $this->SUBSCRIPTION_PASSWORD = 4;
135  $this->SUBSCRIPTION_AUTOSUBSCRIPTION = 5;
136  $this->ARCHIVE_DISABLED = 1;
137  $this->ARCHIVE_READ = 2;
138  $this->ARCHIVE_DOWNLOAD = 3;
139  $this->ABO_ENABLED = 1;
140  $this->ABO_DISABLED = 0;
141  $this->SHOW_MEMBERS_ENABLED = 1;
142  $this->SHOW_MEMBERS_DISABLED = 0;
143  $this->setStatusDetermination(self::STATUS_DETERMINATION_LP);
144 
145  $this->type = "crs";
146 
147  $this->course_logger = $GLOBALS['DIC']->logger()->crs();
148 
149  parent::__construct($a_id, $a_call_by_reference);
150  }
151 
157  public static function lookupShowMembersEnabled($a_obj_id)
158  {
159  $query = 'SELECT show_members FROM crs_settings ' .
160  'WHERE obj_id = ' . $GLOBALS['DIC']['ilDB']->quote($a_obj_id, 'integer');
161  $res = $GLOBALS['DIC']['ilDB']->query($query);
162  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
163  return (bool) $row->show_members;
164  }
165  return false;
166  }
167 
168  public function getShowMembersExport()
169  {
170  return $this->member_export;
171  }
172 
173  public function setShowMembersExport($a_mem_export)
174  {
175  $this->member_export = $a_mem_export;
176  }
177 
182  public function getRegistrationAccessCode()
183  {
184  return $this->reg_access_code;
185  }
186 
192  public function setRegistrationAccessCode($a_code)
193  {
194  $this->reg_access_code = $a_code;
195  }
196 
202  {
203  return (bool) $this->reg_access_code_enabled;
204  }
205 
211  public function enableRegistrationAccessCode($a_status)
212  {
213  $this->reg_access_code_enabled = $a_status;
214  }
215 
216  public function getImportantInformation()
217  {
218  return $this->important;
219  }
220  public function setImportantInformation($a_info)
221  {
222  $this->important = $a_info;
223  }
224  public function getSyllabus()
225  {
226  return $this->syllabus;
227  }
228  public function setSyllabus($a_syllabus)
229  {
230  $this->syllabus = $a_syllabus;
231  }
232 
236  public function getTargetGroup() : ?string
237  {
238  return $this->target_group;
239  }
240 
244  public function setTargetGroup(?string $a_tg)
245  {
246  $this->target_group = $a_tg;
247  }
248 
249  public function getContactName()
250  {
251  return $this->contact_name;
252  }
253  public function setContactName($a_cn)
254  {
255  $this->contact_name = $a_cn;
256  }
257  public function getContactConsultation()
258  {
259  return $this->contact_consultation;
260  }
261  public function setContactConsultation($a_value)
262  {
263  $this->contact_consultation = $a_value;
264  }
265  public function getContactPhone()
266  {
267  return $this->contact_phone;
268  }
269  public function setContactPhone($a_value)
270  {
271  $this->contact_phone = $a_value;
272  }
273  public function getContactEmail()
274  {
275  return $this->contact_email;
276  }
277  public function setContactEmail($a_value)
278  {
279  $this->contact_email = $a_value;
280  }
281  public function getContactResponsibility()
282  {
283  return $this->contact_responsibility;
284  }
285  public function setContactResponsibility($a_value)
286  {
287  $this->contact_responsibility = $a_value;
288  }
295  {
296  return !$this->getActivationStart() || !$this->getActivationEnd();
297  }
298  public function getActivationStart()
299  {
300  return $this->activation_start;
301  }
302  public function setActivationStart($a_value)
303  {
304  $this->activation_start = $a_value;
305  }
306  public function getActivationEnd()
307  {
308  return $this->activation_end;
309  }
310  public function setActivationEnd($a_value)
311  {
312  $this->activation_end = $a_value;
313  }
314  public function setActivationVisibility($a_value)
315  {
316  $this->activation_visibility = (bool) $a_value;
317  }
318  public function getActivationVisibility()
319  {
320  return $this->activation_visibility;
321  }
322 
324  {
325  return $this->subscription_limitation_type;
326  }
328  {
329  $this->subscription_limitation_type = $a_type;
330  }
332  {
333  return $this->subscription_limitation_type == IL_CRS_SUBSCRIPTION_UNLIMITED;
334  }
335  public function getSubscriptionStart()
336  {
337  return $this->subscription_start;
338  }
339  public function setSubscriptionStart($a_value)
340  {
341  $this->subscription_start = $a_value;
342  }
343  public function getSubscriptionEnd()
344  {
345  return $this->subscription_end;
346  }
347  public function setSubscriptionEnd($a_value)
348  {
349  $this->subscription_end = $a_value;
350  }
351  public function getSubscriptionType()
352  {
353  return $this->subscription_type ? $this->subscription_type : IL_CRS_SUBSCRIPTION_DIRECT;
354  #return $this->subscription_type ? $this->subscription_type : $this->SUBSCRIPTION_DEACTIVATED;
355  }
356  public function setSubscriptionType($a_value)
357  {
358  $this->subscription_type = $a_value;
359  }
360  public function getSubscriptionPassword()
361  {
362  return $this->subscription_password;
363  }
364  public function setSubscriptionPassword($a_value)
365  {
366  $this->subscription_password = $a_value;
367  }
368  public function enabledObjectiveView()
369  {
370  return $this->view_mode == IL_CRS_VIEW_OBJECTIVE;
371  }
372 
373  public function enabledWaitingList()
374  {
375  return (bool) $this->waiting_list;
376  }
377 
378  public function enableWaitingList($a_status)
379  {
380  $this->waiting_list = (bool) $a_status;
381  }
382 
383  public function inSubscriptionTime()
384  {
385  if ($this->getSubscriptionUnlimitedStatus()) {
386  return true;
387  }
388  if (time() > $this->getSubscriptionStart() and time() < $this->getSubscriptionEnd()) {
389  return true;
390  }
391  return false;
392  }
393 
399  public function enableSessionLimit($a_status)
400  {
401  $this->session_limit = $a_status;
402  }
403 
404  public function isSessionLimitEnabled()
405  {
406  return (bool) $this->session_limit;
407  }
408 
416  public function enableSubscriptionMembershipLimitation($a_status)
417  {
418  $this->subscription_membership_limitation = $a_status;
419  }
420 
426  public function setNumberOfPreviousSessions($a_num)
427  {
428  $this->session_prev = $a_num;
429  }
430 
435  public function getNumberOfPreviousSessions()
436  {
437  return $this->session_prev;
438  }
439 
445  public function setNumberOfNextSessions($a_num)
446  {
447  $this->session_next = $a_num;
448  }
449 
454  public function getNumberOfNextSessions()
455  {
456  return $this->session_next;
457  }
466  {
467  return (bool) $this->subscription_membership_limitation;
468  }
469 
470  public function getSubscriptionMaxMembers()
471  {
472  return $this->subscription_max_members;
473  }
474  public function setSubscriptionMaxMembers($a_value)
475  {
476  $this->subscription_max_members = $a_value;
477  }
478 
487  public static function _isSubscriptionNotificationEnabled($a_course_id)
488  {
489  global $DIC;
490 
491  $ilDB = $DIC['ilDB'];
492 
493  $query = "SELECT * FROM crs_settings " .
494  "WHERE obj_id = " . $ilDB->quote($a_course_id, 'integer') . " " .
495  "AND sub_notify = 1";
496  $res = $ilDB->query($query);
497  return $res->numRows() ? true : false;
498  }
499 
506  public function getSubItems(
507  $a_admin_panel_enabled = false,
508  $a_include_side_block = false,
509  $a_get_single = 0,
510  \ilContainerUserFilter $container_user_filter = null
511  ) {
512  global $DIC;
513 
514  $ilUser = $DIC['ilUser'];
515  $access = $DIC->access();
516 
517  // Caching
518  if (is_array($this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block])) {
519  return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
520  }
521 
522  // Results are stored in $this->items
523  parent::getSubItems($a_admin_panel_enabled, $a_include_side_block, $a_get_single);
524 
525  $limit_sess = false;
526  if (!$a_admin_panel_enabled &&
527  !$a_include_side_block &&
528  $this->items['sess'] &&
529  is_array($this->items['sess']) &&
530  $this->isSessionLimitEnabled() &&
531  $this->getViewMode() == ilContainer::VIEW_SESSIONS) { // #16686
532  $limit_sess = true;
533  }
534 
535  if (!$limit_sess) {
536  return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
537  }
538 
539 
540  // do session limit
541 
542  // @todo move to gui class
543  if (isset($_GET['crs_prev_sess'])) {
544  $ilUser->writePref('crs_sess_show_prev_' . $this->getId(), (string) (int) $_GET['crs_prev_sess']);
545  }
546  if (isset($_GET['crs_next_sess'])) {
547  $ilUser->writePref('crs_sess_show_next_' . $this->getId(), (string) (int) $_GET['crs_next_sess']);
548  }
549 
550  $session_rbac_checked = [];
551  foreach ($this->items['sess'] as $session_tree_info) {
552  if ($access->checkAccess('visible', '', $session_tree_info['ref_id'])) {
553  $session_rbac_checked[] = $session_tree_info;
554  }
555  }
556  $sessions = ilUtil::sortArray($session_rbac_checked, 'start', 'ASC', true, false);
557  //$sessions = ilUtil::sortArray($this->items['sess'],'start','ASC',true,false);
558  $today = new ilDate(date('Ymd', time()), IL_CAL_DATE);
559  $previous = $current = $next = array();
560  foreach ($sessions as $key => $item) {
561  $start = new ilDateTime($item['start'], IL_CAL_UNIX);
562  $end = new ilDateTime($item['end'], IL_CAL_UNIX);
563 
564  if (ilDateTime::_within($today, $start, $end, IL_CAL_DAY)) {
565  $current[] = $item;
566  } elseif (ilDateTime::_before($start, $today, IL_CAL_DAY)) {
567  $previous[] = $item;
568  } elseif (ilDateTime::_after($start, $today, IL_CAL_DAY)) {
569  $next[] = $item;
570  }
571  }
572  $num_previous_remove = max(
573  count($previous) - $this->getNumberOfPreviousSessions(),
574  0
575  );
576  while ($num_previous_remove--) {
577  if (!$ilUser->getPref('crs_sess_show_prev_' . $this->getId())) {
578  array_shift($previous);
579  }
580  $this->items['sess_link']['prev']['value'] = 1;
581  }
582 
583  $num_next_remove = max(
584  count($next) - $this->getNumberOfNextSessions(),
585  0
586  );
587  while ($num_next_remove--) {
588  if (!$ilUser->getPref('crs_sess_show_next_' . $this->getId())) {
589  array_pop($next);
590  }
591  // @fixme
592  $this->items['sess_link']['next']['value'] = 1;
593  }
594 
595  $sessions = array_merge($previous, $current, $next);
596  $this->items['sess'] = $sessions;
597 
598  // #15389 - see ilContainer::getSubItems()
599  include_once('Services/Container/classes/class.ilContainerSorting.php');
600  $sort = ilContainerSorting::_getInstance($this->getId());
601  $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block] = $sort->sortItems($this->items);
602 
603  return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
604  }
605 
606  public function getSubscriptionNotify()
607  {
608  return true;
609  return $this->subscription_notify ? true : false;
610  }
611  public function setSubscriptionNotify($a_value)
612  {
613  $this->subscription_notify = $a_value ? true : false;
614  }
615 
616  public function setViewMode($a_mode)
617  {
618  $this->view_mode = $a_mode;
619  }
620  public function getViewMode()
621  {
622  return $this->view_mode;
623  }
624 
629  public static function lookupTimingMode($a_obj_id)
630  {
631  global $DIC;
632 
633  $ilDB = $DIC['ilDB'];
634 
635  $query = 'SELECT timing_mode FROM crs_settings ' .
636  'WHERE obj_id = ' . $ilDB->quote($a_obj_id, 'integer');
637  $res = $ilDB->query($query);
638 
639  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
640  return (int) $row->timing_mode;
641  }
643  }
644 
648  public function setTimingMode($a_mode)
649  {
650  $this->timing_mode = $a_mode;
651  }
652 
656  public function getTimingMode()
657  {
658  return $this->timing_mode;
659  }
660 
661 
667  public static function _lookupViewMode($a_id)
668  {
669  global $DIC;
670 
671  $ilDB = $DIC['ilDB'];
672 
673  $query = "SELECT view_mode FROM crs_settings WHERE obj_id = " . $ilDB->quote($a_id, 'integer') . " ";
674  $res = $ilDB->query($query);
675  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
676  return $row->view_mode;
677  }
678  return false;
679  }
680 
681  public static function _lookupAboStatus($a_id)
682  {
683  global $DIC;
684 
685  $ilDB = $DIC['ilDB'];
686 
687  $query = "SELECT abo FROM crs_settings WHERE obj_id = " . $ilDB->quote($a_id, 'integer') . " ";
688  $res = $ilDB->query($query);
689  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
690  return $row->abo;
691  }
692  return false;
693  }
694 
695  public function getArchiveStart()
696  {
697  return $this->archive_start ? $this->archive_start : time();
698  }
699  public function setArchiveStart($a_value)
700  {
701  $this->archive_start = $a_value;
702  }
703  public function getArchiveEnd()
704  {
705  return $this->archive_end ? $this->archive_end : mktime(0, 0, 0, 12, 12, date("Y", time()) + 2);
706  }
707  public function setArchiveEnd($a_value)
708  {
709  $this->archive_end = $a_value;
710  }
711  public function getArchiveType()
712  {
713  return $this->archive_type ? IL_CRS_ARCHIVE_DOWNLOAD : IL_CRS_ARCHIVE_NONE;
714  }
715  public function setArchiveType($a_value)
716  {
717  $this->archive_type = $a_value;
718  }
719  public function setAboStatus($a_status)
720  {
721  $this->abo = $a_status;
722  }
723  public function getAboStatus()
724  {
725  return $this->abo;
726  }
727  public function setShowMembers($a_status)
728  {
729  $this->show_members = $a_status;
730  }
731  public function getShowMembers()
732  {
733  return $this->show_members;
734  }
735 
741  public function setMailToMembersType($a_type)
742  {
743  $this->mail_members = $a_type;
744  }
745 
750  public function getMailToMembersType()
751  {
752  return $this->mail_members;
753  }
754 
755  public function getMessage()
756  {
757  return $this->message;
758  }
759  public function setMessage($a_message)
760  {
761  $this->message = $a_message;
762  }
763  public function appendMessage($a_message)
764  {
765  if ($this->getMessage()) {
766  $this->message .= "<br /> ";
767  }
768  $this->message .= $a_message;
769  }
770 
775  public function isActivated()
776  {
777  if ($this->getOfflineStatus()) {
778  return false;
779  }
780  if ($this->getActivationUnlimitedStatus()) {
781  return true;
782  }
783  if (time() < $this->getActivationStart() or
784  time() > $this->getActivationEnd()) {
785  return false;
786  }
787  return true;
788  }
789 
796  public static function _isActivated($a_obj_id)
797  {
798  include_once("./Modules/Course/classes/class.ilObjCourseAccess.php");
799  return ilObjCourseAccess::_isActivated($a_obj_id);
800  }
801 
808  public static function _registrationEnabled($a_obj_id)
809  {
810  include_once("./Modules/Course/classes/class.ilObjCourseAccess.php");
811  return ilObjCourseAccess::_registrationEnabled($a_obj_id);
812  }
813 
814 
815  public function allowAbo()
816  {
817  return $this->ABO == $this->ABO_ENABLED;
818  }
819 
823  public function read()
824  {
825  parent::read();
826 
827  include_once('./Services/Container/classes/class.ilContainerSortingSettings.php');
829 
830  $this->__readSettings();
831  }
832  public function create($a_upload = false)
833  {
834  global $DIC;
835 
836  $ilAppEventHandler = $DIC['ilAppEventHandler'];
837 
838  parent::create($a_upload);
839 
840  if (!$a_upload) {
841  $this->createMetaData();
842  }
843  $this->__createDefaultSettings();
844 
845  $ilAppEventHandler->raise(
846  'Modules/Course',
847  'create',
848  array('object' => $this,
849  'obj_id' => $this->getId(),
850  'appointments' => $this->prepareAppointments('create'))
851  );
852  }
853 
859  public function setLatitude($a_latitude)
860  {
861  $this->latitude = $a_latitude;
862  }
863 
869  public function getLatitude()
870  {
871  return $this->latitude;
872  }
873 
879  public function setLongitude($a_longitude)
880  {
881  $this->longitude = $a_longitude;
882  }
883 
889  public function getLongitude()
890  {
891  return $this->longitude;
892  }
893 
899  public function setLocationZoom($a_locationzoom)
900  {
901  $this->locationzoom = $a_locationzoom;
902  }
903 
909  public function getLocationZoom()
910  {
911  return $this->locationzoom;
912  }
913 
919  public function setEnableCourseMap($a_enablemap)
920  {
921  $this->enablemap = $a_enablemap;
922  }
923 
928  public function getEnableMap()
929  {
930  return $this->getEnableCourseMap();
931  }
932 
938  public function getEnableCourseMap()
939  {
940  return $this->enablemap;
941  }
942 
948  public function setCoursePeriod(\ilDateTime $start = null, \ilDateTime $end = null)
949  {
950  if (
951  ($start instanceof \ilDate && !$end instanceof ilDate) ||
952  ($end instanceof \ilDate && !$start instanceof ilDate)
953  ) {
954  throw new InvalidArgumentException('Different date types not supported.');
955  }
956 
957  if ($start instanceof \ilDate) {
958  $this->toggleCourseStartTimeIndication(false);
959  } else {
960  $this->toggleCourseStartTimeIndication(true);
961  }
962  $this->setCourseStart($start);
963  $this->setCourseEnd($end);
964  }
965 
969  protected function toggleCourseStartTimeIndication(bool $time_indication)
970  {
971  $this->course_start_time_indication = $time_indication;
972  }
973 
977  public function getCourseStartTimeIndication() : bool
978  {
980  }
981 
982 
986  protected function setCourseStart(ilDateTime $a_value = null)
987  {
988  $this->crs_start = $a_value;
989  }
990 
994  public function getCourseStart() : ?\ilDateTime
995  {
996  return $this->crs_start;
997  }
998 
1002  protected function setCourseEnd(ilDateTime $a_value = null)
1003  {
1004  $this->crs_end = $a_value;
1005  }
1006 
1010  public function getCourseEnd() : ?\ilDateTime
1011  {
1012  return $this->crs_end;
1013  }
1014 
1015  public function setCancellationEnd(ilDate $a_value = null)
1016  {
1017  $this->leave_end = $a_value;
1018  }
1019 
1020  public function getCancellationEnd()
1021  {
1022  return $this->leave_end;
1023  }
1024 
1025  public function setSubscriptionMinMembers($a_value)
1026  {
1027  if ($a_value !== null) {
1028  $a_value = (int) $a_value;
1029  }
1030  $this->min_members = $a_value;
1031  }
1032 
1033  public function getSubscriptionMinMembers()
1034  {
1035  return $this->min_members;
1036  }
1037 
1038  public function setWaitingListAutoFill($a_value)
1039  {
1040  $this->auto_fill_from_waiting = (bool) $a_value;
1041  }
1042 
1043  public function hasWaitingListAutoFill()
1044  {
1045  return (bool) $this->auto_fill_from_waiting;
1046  }
1047 
1056  public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = false)
1057  {
1058  global $DIC;
1059 
1060  $ilDB = $DIC['ilDB'];
1061  $ilUser = $DIC['ilUser'];
1062  $certificateLogger = $DIC->logger()->cert();
1063 
1064 
1065  $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
1066 
1067  $this->cloneAutoGeneratedRoles($new_obj);
1068  $this->cloneMetaData($new_obj);
1069 
1070  // Assign admin
1071  $new_obj->getMemberObject()->add($ilUser->getId(), IL_CRS_ADMIN);
1072  // cognos-blu-patch: begin
1073  $new_obj->getMemberObject()->updateContact($ilUser->getId(), 1);
1074  // cognos-blu-patch: end
1075 
1076 
1077  // #14596
1078  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
1079  if ($cwo->isRootNode($this->getRefId())) {
1080  $this->setOfflineStatus(true);
1081  }
1082 
1083  // Copy settings
1084  $this->cloneSettings($new_obj);
1085 
1086  // Course Defined Fields
1087  include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
1088  ilCourseDefinedFieldDefinition::_clone($this->getId(), $new_obj->getId());
1089 
1090  // Clone course files
1091  include_once('Modules/Course/classes/class.ilCourseFile.php');
1092  ilCourseFile::_cloneFiles($this->getId(), $new_obj->getId());
1093 
1094  // Copy learning progress settings
1095  include_once('Services/Tracking/classes/class.ilLPObjSettings.php');
1096  $obj_settings = new ilLPObjSettings($this->getId());
1097  $obj_settings->cloneSettings($new_obj->getId());
1098  unset($obj_settings);
1099 
1100  // clone certificate (#11085)
1101  $pathFactory = new ilCertificatePathFactory();
1102  $templateRepository = new ilCertificateTemplateRepository($ilDB);
1103 
1104  $cloneAction = new ilCertificateCloneAction(
1105  $ilDB,
1106  $pathFactory,
1107  $templateRepository,
1108  $DIC->filesystem()->web(),
1109  $certificateLogger,
1111  );
1112 
1113  $cloneAction->cloneCertificate($this, $new_obj);
1114 
1115  $book_service = new ilBookingService();
1116  $book_service->cloneSettings($this->getId(), $new_obj->getId());
1117 
1118 
1119  return $new_obj;
1120  }
1121 
1130  public function cloneDependencies($a_target_id, $a_copy_id)
1131  {
1132  parent::cloneDependencies($a_target_id, $a_copy_id);
1133 
1134  // Clone course start objects
1135  include_once('Services/Container/classes/class.ilContainerStartObjects.php');
1136  $start = new ilContainerStartObjects($this->getRefId(), $this->getId());
1137  $start->cloneDependencies($a_target_id, $a_copy_id);
1138 
1139  // Clone course item settings
1140  include_once('Services/Object/classes/class.ilObjectActivation.php');
1141  ilObjectActivation::cloneDependencies($this->getRefId(), $a_target_id, $a_copy_id);
1142 
1143  // clone objective settings
1144  include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
1145  ilLOSettings::cloneSettings($a_copy_id, $this->getId(), ilObject::_lookupObjId($a_target_id));
1146 
1147  // Clone course learning objectives
1148  include_once('Modules/Course/classes/class.ilCourseObjective.php');
1149  $crs_objective = new ilCourseObjective($this);
1150  $crs_objective->ilClone($a_target_id, $a_copy_id);
1151 
1152  // clone membership limitation
1153  foreach (\ilObjCourseGrouping::_getGroupings($this->getId()) as $grouping_id) {
1154  \ilLoggerFactory::getLogger('crs')->info('Handling grouping id: ' . $grouping_id);
1155  $grouping = new \ilObjCourseGrouping($grouping_id);
1156  $grouping->cloneGrouping($a_target_id, $a_copy_id);
1157  }
1158 
1159  return true;
1160  }
1161 
1169  public function cloneAutoGeneratedRoles($new_obj)
1170  {
1171  global $DIC;
1172 
1173  $ilLog = $DIC['ilLog'];
1174  $rbacadmin = $DIC['rbacadmin'];
1175  $rbacreview = $DIC['rbacreview'];
1176 
1177  $admin = $this->getDefaultAdminRole();
1178  $new_admin = $new_obj->getDefaultAdminRole();
1179 
1180  if (!$admin || !$new_admin || !$this->getRefId() || !$new_obj->getRefId()) {
1181  $ilLog->write(__METHOD__ . ' : Error cloning auto generated role: il_crs_admin');
1182  }
1183  $rbacadmin->copyRolePermissions($admin, $this->getRefId(), $new_obj->getRefId(), $new_admin, true);
1184  $ilLog->write(__METHOD__ . ' : Finished copying of role crs_admin.');
1185 
1186  $tutor = $this->getDefaultTutorRole();
1187  $new_tutor = $new_obj->getDefaultTutorRole();
1188  if (!$tutor || !$new_tutor) {
1189  $ilLog->write(__METHOD__ . ' : Error cloning auto generated role: il_crs_tutor');
1190  }
1191  $rbacadmin->copyRolePermissions($tutor, $this->getRefId(), $new_obj->getRefId(), $new_tutor, true);
1192  $ilLog->write(__METHOD__ . ' : Finished copying of role crs_tutor.');
1193 
1194  $member = $this->getDefaultMemberRole();
1195  $new_member = $new_obj->getDefaultMemberRole();
1196  if (!$member || !$new_member) {
1197  $ilLog->write(__METHOD__ . ' : Error cloning auto generated role: il_crs_member');
1198  }
1199  $rbacadmin->copyRolePermissions($member, $this->getRefId(), $new_obj->getRefId(), $new_member, true);
1200  $ilLog->write(__METHOD__ . ' : Finished copying of role crs_member.');
1201 
1202  return true;
1203  }
1204 
1205 
1206  public function validate()
1207  {
1208  $this->setMessage('');
1209 
1211  $this->getSubscriptionStart() > $this->getSubscriptionEnd()) {
1212  $this->appendMessage($this->lng->txt("subscription_times_not_valid"));
1213  }
1215  $this->appendMessage($this->lng->txt("crs_password_required"));
1216  }
1217  if ($this->isSubscriptionMembershipLimited()) {
1218  if ($this->getSubscriptionMinMembers() <= 0 && $this->getSubscriptionMaxMembers() <= 0) {
1219  $this->appendMessage($this->lng->txt("crs_max_and_min_members_needed"));
1220  }
1221  if ($this->getSubscriptionMaxMembers() <= 0 && $this->enabledWaitingList()) {
1222  $this->appendMessage($this->lng->txt("crs_max_members_needed"));
1223  }
1224  if ($this->getSubscriptionMaxMembers() > 0 && $this->getSubscriptionMinMembers() > $this->getSubscriptionMaxMembers()) {
1225  $this->appendMessage($this->lng->txt("crs_max_and_min_members_invalid"));
1226  }
1227  }
1228  if (!$this->getTitle() || !$this->getStatusDetermination()) {
1229  $this->appendMessage($this->lng->txt('err_check_input'));
1230  }
1231 
1232  // :TODO: checkInput() is not used properly
1233  if (($this->getCourseStart() && !$this->getCourseEnd()) ||
1234  (!$this->getCourseStart() && $this->getCourseEnd()) ||
1235  ($this->getCourseStart() && $this->getCourseEnd() && $this->getCourseStart()->get(IL_CAL_UNIX) > $this->getCourseEnd()->get(IL_CAL_UNIX))) {
1236  $this->appendMessage($this->lng->txt("crs_course_period_not_valid"));
1237  }
1238 
1239  return $this->getMessage() ? false : true;
1240  }
1241 
1242  public function validateInfoSettings()
1243  {
1244  global $DIC;
1245 
1246  $ilErr = $DIC['ilErr'];
1247  $error = false;
1248  if ($this->getContactEmail()) {
1249  $emails = explode(",", $this->getContactEmail());
1250 
1251  foreach ($emails as $email) {
1252  $email = trim($email);
1253  if (!(ilUtil::is_email($email) or ilObjUser::getUserIdByLogin($email))) {
1254  $ilErr->appendMessage($this->lng->txt('contact_email_not_valid') . " '" . $email . "'");
1255  $error = true;
1256  }
1257  }
1258  }
1259  return !$error;
1260  }
1261 
1262  public function hasContactData()
1263  {
1264  return strlen($this->getContactName()) or
1265  strlen($this->getContactResponsibility()) or
1266  strlen($this->getContactEmail()) or
1267  strlen($this->getContactPhone()) or
1268  strlen($this->getContactConsultation());
1269  }
1270 
1271 
1278  public function delete()
1279  {
1280  global $DIC;
1281 
1282  $ilAppEventHandler = $DIC['ilAppEventHandler'];
1283 
1284  // always call parent delete function first!!
1285  if (!parent::delete()) {
1286  return false;
1287  }
1288 
1289  // delete meta data
1290  $this->deleteMetaData();
1291 
1292  // put here course specific stuff
1293 
1294  $this->__deleteSettings();
1295 
1296  include_once('Modules/Course/classes/class.ilCourseParticipants.php');
1298 
1299  include_once './Modules/Course/classes/class.ilCourseObjective.php';
1301 
1302  include_once './Modules/Course/classes/class.ilObjCourseGrouping.php';
1304 
1305  include_once './Modules/Course/classes/class.ilCourseFile.php';
1307 
1308  include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
1310 
1311  $ilAppEventHandler->raise(
1312  'Modules/Course',
1313  'delete',
1314  array('object' => $this,
1315  'obj_id' => $this->getId(),
1316  'appointments' => $this->prepareAppointments('delete'))
1317  );
1318 
1319 
1320  return true;
1321  }
1322 
1323 
1327  public function update()
1328  {
1329  global $DIC;
1330 
1331  $ilAppEventHandler = $DIC['ilAppEventHandler'];
1332  $ilLog = $DIC->logger()->crs();
1333 
1334  include_once('./Services/Container/classes/class.ilContainerSortingSettings.php');
1335  $sorting = new ilContainerSortingSettings($this->getId());
1336  $sorting->setSortMode($this->getOrderType());
1337  $sorting->update();
1338 
1339  $this->updateMetaData();
1340  $this->updateSettings();
1341  parent::update();
1342 
1343  $ilAppEventHandler->raise(
1344  'Modules/Course',
1345  'update',
1346  array('object' => $this,
1347  'obj_id' => $this->getId(),
1348  'appointments' => $this->prepareAppointments('update'))
1349  );
1350  }
1351 
1355  public function updateSettings()
1356  {
1357  global $DIC;
1358 
1359  $ilDB = $DIC['ilDB'];
1360 
1361  // Due to a bug 3.5.alpha maybe no settings exist. => create default settings
1362 
1363  $query = "SELECT * FROM crs_settings WHERE obj_id = " . $ilDB->quote($this->getId(), 'integer') . " ";
1364  $res = $ilDB->query($query);
1365 
1366  if (!$res->numRows()) {
1367  $this->__createDefaultSettings();
1368  }
1369 
1370 
1371  $query = "UPDATE crs_settings SET " .
1372  "syllabus = " . $ilDB->quote($this->getSyllabus(), 'text') . ", " .
1373  "contact_name = " . $ilDB->quote($this->getContactName(), 'text') . ", " .
1374  "contact_responsibility = " . $ilDB->quote($this->getContactResponsibility(), 'text') . ", " .
1375  "contact_phone = " . $ilDB->quote($this->getContactPhone(), 'text') . ", " .
1376  "contact_email = " . $ilDB->quote($this->getContactEmail(), 'text') . ", " .
1377  "contact_consultation = " . $ilDB->quote($this->getContactConsultation(), 'text') . ", " .
1378  "activation_type = " . $ilDB->quote(!$this->getOfflineStatus(), 'integer') . ", " .
1379  "sub_limitation_type = " . $ilDB->quote($this->getSubscriptionLimitationType(), 'integer') . ", " .
1380  "sub_start = " . $ilDB->quote($this->getSubscriptionStart(), 'integer') . ", " .
1381  "sub_end = " . $ilDB->quote($this->getSubscriptionEnd(), 'integer') . ", " .
1382  "sub_type = " . $ilDB->quote($this->getSubscriptionType(), 'integer') . ", " .
1383  "sub_password = " . $ilDB->quote($this->getSubscriptionPassword(), 'text') . ", " .
1384  "sub_mem_limit = " . $ilDB->quote((int) $this->isSubscriptionMembershipLimited(), 'integer') . ", " .
1385  "sub_max_members = " . $ilDB->quote($this->getSubscriptionMaxMembers(), 'integer') . ", " .
1386  "sub_notify = " . $ilDB->quote($this->getSubscriptionNotify(), 'integer') . ", " .
1387  "view_mode = " . $ilDB->quote($this->getViewMode(), 'integer') . ", " .
1388  'timing_mode = ' . $ilDB->quote($this->getTimingMode(), 'integer') . ', ' .
1389  "abo = " . $ilDB->quote($this->getAboStatus(), 'integer') . ", " .
1390  "waiting_list = " . $ilDB->quote($this->enabledWaitingList(), 'integer') . ", " .
1391  "important = " . $ilDB->quote($this->getImportantInformation(), 'text') . ", " .
1392  'target_group = ' . $ilDB->quote($this->getTargetGroup(), \ilDBConstants::T_TEXT) . ', ' .
1393  "show_members = " . $ilDB->quote($this->getShowMembers(), 'integer') . ", " .
1394  "show_members_export = " . $ilDB->quote($this->getShowMembersExport(), 'integer') . ", " .
1395  "latitude = " . $ilDB->quote($this->getLatitude(), 'text') . ", " .
1396  "longitude = " . $ilDB->quote($this->getLongitude(), 'text') . ", " .
1397  "location_zoom = " . $ilDB->quote($this->getLocationZoom(), 'integer') . ", " .
1398  "enable_course_map = " . $ilDB->quote((int) $this->getEnableCourseMap(), 'integer') . ", " .
1399  'session_limit = ' . $ilDB->quote($this->isSessionLimitEnabled(), 'integer') . ', ' .
1400  'session_prev = ' . $ilDB->quote($this->getNumberOfPreviousSessions(), 'integer') . ', ' .
1401  'session_next = ' . $ilDB->quote($this->getNumberOfNextSessions(), 'integer') . ', ' .
1402  'reg_ac_enabled = ' . $ilDB->quote($this->isRegistrationAccessCodeEnabled(), 'integer') . ', ' .
1403  'reg_ac = ' . $ilDB->quote($this->getRegistrationAccessCode(), 'text') . ', ' .
1404  'auto_notification = ' . $ilDB->quote((int) $this->getAutoNotification(), 'integer') . ', ' .
1405  'status_dt = ' . $ilDB->quote((int) $this->getStatusDetermination()) . ', ' .
1406  'mail_members_type = ' . $ilDB->quote((int) $this->getMailToMembersType(), 'integer') . ', ' .
1407  'period_start = ' . $ilDB->quote(\ilCalendarUtil::convertDateToUtcDBTimestamp($this->getCourseStart()), \ilDBConstants::T_TIMESTAMP) . ', ' .
1408  'period_end = ' . $ilDB->quote(\ilCalendarUtil::convertDateToUtcDBTimestamp($this->getCourseEnd()), \ilDBConstants::T_TIMESTAMP) . ', ' .
1409  'period_time_indication = ' . $ilDB->quote($this->getCourseStartTimeIndication() ? 1 : 0, \ilDBConstants::T_INTEGER) . ', ' .
1410  'auto_wait = ' . $ilDB->quote((int) $this->hasWaitingListAutoFill(), 'integer') . ', ' .
1411  'leave_end = ' . $ilDB->quote(($this->getCancellationEnd() && !$this->getCancellationEnd()->isNull()) ? $this->getCancellationEnd()->get(IL_CAL_UNIX) : null, 'integer') . ', ' .
1412  'min_members = ' . $ilDB->quote((int) $this->getSubscriptionMinMembers(), 'integer') . ' ' .
1413  "WHERE obj_id = " . $ilDB->quote($this->getId(), 'integer') . "";
1414 
1415  $res = $ilDB->manipulate($query);
1416 
1417  // moved activation to ilObjectActivation
1418  if ($this->ref_id) {
1419  include_once "./Services/Object/classes/class.ilObjectActivation.php";
1420  ilObjectActivation::getItem($this->ref_id);
1421 
1422  $item = new ilObjectActivation;
1423  if (!$this->getActivationStart() || !$this->getActivationEnd()) {
1425  } else {
1426  $item->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
1427  $item->setTimingStart($this->getActivationStart());
1428  $item->setTimingEnd($this->getActivationEnd());
1429  $item->toggleVisible($this->getActivationVisibility());
1430  }
1431 
1432  $item->update($this->ref_id);
1433  }
1434  }
1435 
1443  public function cloneSettings(\ilObjCourse $new_obj)
1444  {
1445  $new_obj->setSyllabus($this->getSyllabus());
1446  $new_obj->setContactName($this->getContactName());
1448  $new_obj->setContactPhone($this->getContactPhone());
1449  $new_obj->setContactEmail($this->getContactEmail());
1450  $new_obj->setContactConsultation($this->getContactConsultation());
1451  $new_obj->setOfflineStatus($this->getOfflineStatus()); // #9914
1452  $new_obj->setActivationStart($this->getActivationStart());
1453  $new_obj->setActivationEnd($this->getActivationEnd());
1456  $new_obj->setSubscriptionStart($this->getSubscriptionStart());
1457  $new_obj->setSubscriptionEnd($this->getSubscriptionEnd());
1458  $new_obj->setSubscriptionType($this->getSubscriptionType());
1462  $new_obj->setSubscriptionNotify($this->getSubscriptionNotify());
1463  $new_obj->setViewMode($this->getViewMode());
1464  $new_obj->setTimingMode($this->getTimingMode());
1465  $new_obj->setOrderType($this->getOrderType());
1466  $new_obj->setAboStatus($this->getAboStatus());
1467  $new_obj->enableWaitingList($this->enabledWaitingList());
1469  $new_obj->setTargetGroup($this->getTargetGroup());
1470  $new_obj->setShowMembers($this->getShowMembers());
1471  // patch mem_exp
1472  $new_obj->setShowMembersExport($this->getShowMembersExport());
1473  // patch mem_exp
1474  $new_obj->enableSessionLimit($this->isSessionLimitEnabled());
1477  $new_obj->setAutoNotification($this->getAutoNotification());
1479  include_once './Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
1481  $new_obj->setStatusDetermination($this->getStatusDetermination());
1482  $new_obj->setMailToMembersType($this->getMailToMembersType());
1483  $new_obj->setCoursePeriod(
1484  $this->getCourseStart(),
1485  $this->getCourseEnd()
1486  );
1487  $new_obj->setCancellationEnd($this->getCancellationEnd());
1488  $new_obj->setWaitingListAutoFill($this->hasWaitingListAutoFill());
1490 
1491  // #10271
1492  $new_obj->setEnableCourseMap($this->getEnableCourseMap());
1493  $new_obj->setLatitude($this->getLatitude());
1494  $new_obj->setLongitude($this->getLongitude());
1495  $new_obj->setLocationZoom($this->getLocationZoom());
1496 
1497  $new_obj->update();
1498  }
1499 
1500  public function __createDefaultSettings()
1501  {
1502  global $DIC;
1503 
1504  $ilDB = $DIC['ilDB'];
1505 
1506  include_once './Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
1508 
1509  $query = "INSERT INTO crs_settings (obj_id,syllabus,contact_name,contact_responsibility," .
1510  "contact_phone,contact_email,contact_consultation," .
1511  "sub_limitation_type,sub_start,sub_end,sub_type,sub_password,sub_mem_limit," .
1512  "sub_max_members,sub_notify,view_mode,timing_mode,abo," .
1513  "latitude,longitude,location_zoom,enable_course_map,waiting_list,show_members,show_members_export, " .
1514  "session_limit,session_prev,session_next, reg_ac_enabled, reg_ac, auto_notification, status_dt,mail_members_type) " .
1515  "VALUES( " .
1516  $ilDB->quote($this->getId(), 'integer') . ", " .
1517  $ilDB->quote($this->getSyllabus(), 'text') . ", " .
1518  $ilDB->quote($this->getContactName(), 'text') . ", " .
1519  $ilDB->quote($this->getContactResponsibility(), 'text') . ", " .
1520  $ilDB->quote($this->getContactPhone(), 'text') . ", " .
1521  $ilDB->quote($this->getContactEmail(), 'text') . ", " .
1522  $ilDB->quote($this->getContactConsultation(), 'text') . ", " .
1523  $ilDB->quote(IL_CRS_SUBSCRIPTION_DEACTIVATED, 'integer') . ", " .
1524  $ilDB->quote($this->getSubscriptionStart(), 'integer') . ", " .
1525  $ilDB->quote($this->getSubscriptionEnd(), 'integer') . ", " .
1526  $ilDB->quote(IL_CRS_SUBSCRIPTION_DIRECT, 'integer') . ", " .
1527  $ilDB->quote($this->getSubscriptionPassword(), 'text') . ", " .
1528  "0, " .
1529  $ilDB->quote($this->getSubscriptionMaxMembers(), 'integer') . ", " .
1530  "1, " .
1531  "0, " .
1532  $ilDB->quote(IL_CRS_VIEW_TIMING_ABSOLUTE, 'integer') . ', ' .
1533  $ilDB->quote($this->ABO_ENABLED, 'integer') . ", " .
1534  $ilDB->quote($this->getLatitude(), 'text') . ", " .
1535  $ilDB->quote($this->getLongitude(), 'text') . ", " .
1536  $ilDB->quote($this->getLocationZoom(), 'integer') . ", " .
1537  $ilDB->quote($this->getEnableCourseMap(), 'integer') . ", " .
1538  #"objective_view = '0', ".
1539  "1, " .
1540  "1," .
1541  '0,' .
1542  $ilDB->quote($this->isSessionLimitEnabled(), 'integer') . ', ' .
1543  $ilDB->quote($this->getNumberOfPreviousSessions(), 'integer') . ', ' .
1544  $ilDB->quote($this->getNumberOfPreviousSessions(), 'integer') . ', ' .
1545  $ilDB->quote($this->isRegistrationAccessCodeEnabled(), 'integer') . ', ' .
1546  $ilDB->quote($this->getRegistrationAccessCode(), 'text') . ', ' .
1547  $ilDB->quote((int) $this->getAutoNotification(), 'integer') . ', ' .
1548  $ilDB->quote((int) $this->getStatusDetermination(), 'integer') . ', ' .
1549  $ilDB->quote((int) $this->getMailToMembersType(), 'integer') . ' ' .
1550  ")";
1551 
1552  $res = $ilDB->manipulate($query);
1553  $this->__readSettings();
1554 
1555  include_once('./Services/Container/classes/class.ilContainerSortingSettings.php');
1556  $sorting = new ilContainerSortingSettings($this->getId());
1557  $sorting->setSortMode(ilContainer::SORT_MANUAL);
1558  $sorting->update();
1559  }
1560 
1561 
1562  public function __readSettings()
1563  {
1564  global $DIC;
1565 
1566  $ilDB = $DIC['ilDB'];
1567 
1568  $query = "SELECT * FROM crs_settings WHERE obj_id = " . $ilDB->quote($this->getId(), 'integer') . "";
1569 
1570  $res = $ilDB->query($query);
1571  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1572  $this->setSyllabus($row->syllabus);
1573  $this->setTargetGroup($row->target_group);
1574  $this->setContactName($row->contact_name);
1575  $this->setContactResponsibility($row->contact_responsibility);
1576  $this->setContactPhone($row->contact_phone);
1577  $this->setContactEmail($row->contact_email);
1578  $this->setContactConsultation($row->contact_consultation);
1579  $this->setOfflineStatus(!(bool) $row->activation_type); // see below
1580  $this->setSubscriptionLimitationType($row->sub_limitation_type);
1581  $this->setSubscriptionStart($row->sub_start);
1582  $this->setSubscriptionEnd($row->sub_end);
1583  $this->setSubscriptionType($row->sub_type);
1584  $this->setSubscriptionPassword($row->sub_password);
1585  $this->enableSubscriptionMembershipLimitation($row->sub_mem_limit);
1586  $this->setSubscriptionMaxMembers($row->sub_max_members);
1587  $this->setSubscriptionNotify($row->sub_notify);
1588  $this->setViewMode($row->view_mode);
1589  $this->setTimingMode((int) $row->timing_mode);
1590  $this->setAboStatus($row->abo);
1591  $this->enableWaitingList($row->waiting_list);
1592  $this->setImportantInformation($row->important);
1593  $this->setShowMembers($row->show_members);
1594 
1595  if (\ilPrivacySettings::_getInstance()->participantsListInCoursesEnabled()) {
1596  $this->setShowMembersExport($row->show_members_export);
1597  } else {
1598  $this->setShowMembersExport(false);
1599  }
1600  $this->setLatitude($row->latitude);
1601  $this->setLongitude($row->longitude);
1602  $this->setLocationZoom($row->location_zoom);
1603  $this->setEnableCourseMap($row->enable_course_map);
1604  $this->enableSessionLimit($row->session_limit);
1605  $this->setNumberOfPreviousSessions($row->session_prev);
1606  $this->setNumberOfNextSessions($row->session_next);
1607  $this->enableRegistrationAccessCode($row->reg_ac_enabled);
1608  $this->setRegistrationAccessCode($row->reg_ac);
1609  $this->setAutoNotification($row->auto_notification == 1 ? true : false);
1610  $this->setStatusDetermination((int) $row->status_dt);
1611  $this->setMailToMembersType($row->mail_members_type);
1612 
1613  if ($row->period_time_indication) {
1614  $this->setCoursePeriod(
1615  new \ilDateTime($row->period_start, IL_CAL_DATETIME, \ilTimeZone::UTC),
1616  new \ilDateTime($row->period_end, IL_CAL_DATETIME, \ilTimeZone::UTC)
1617  );
1618  } elseif (!is_null($row->period_start) && !is_null($row->period_end)) {
1619  $this->setCoursePeriod(
1620  new \ilDate($row->period_start, IL_CAL_DATE),
1621  new \ilDate($row->period_end, IL_CAL_DATE)
1622  );
1623  }
1624  $this->toggleCourseStartTimeIndication((bool) $row->period_time_indication);
1625  $this->setCancellationEnd($row->leave_end ? new ilDate($row->leave_end, IL_CAL_UNIX) : null);
1626  $this->setWaitingListAutoFill($row->auto_wait);
1627  $this->setSubscriptionMinMembers($row->min_members ? $row->min_members : null);
1628  }
1629 
1630  // moved activation to ilObjectActivation
1631  if ($this->ref_id) {
1632  include_once "./Services/Object/classes/class.ilObjectActivation.php";
1633  $activation = ilObjectActivation::getItem($this->ref_id);
1634  switch ($activation["timing_type"]) {
1636  $this->setActivationStart($activation["timing_start"]);
1637  $this->setActivationEnd($activation["timing_end"]);
1638  $this->setActivationVisibility($activation["visible"]);
1639  break;
1640  }
1641  }
1642  return true;
1643  }
1644 
1645  public function initWaitingList()
1646  {
1647  include_once "./Modules/Course/classes/class.ilCourseWaitingList.php";
1648 
1649  if (!is_object($this->waiting_list_obj)) {
1650  $this->waiting_list_obj = new ilCourseWaitingList($this->getId());
1651  }
1652  return true;
1653  }
1654 
1655 
1661  protected function initCourseMemberObject()
1662  {
1663  global $DIC;
1664 
1665  $ilUser = $DIC['ilUser'];
1666 
1667  include_once "./Modules/Course/classes/class.ilCourseParticipant.php";
1668  $this->member_obj = ilCourseParticipant::_getInstanceByObjId($this->getId(), $ilUser->getId());
1669  return true;
1670  }
1671 
1677  protected function initCourseMembersObject()
1678  {
1679  global $DIC;
1680 
1681  $ilUser = $DIC['ilUser'];
1682 
1683  include_once "./Modules/Course/classes/class.ilCourseParticipants.php";
1684  $this->members_obj = ilCourseParticipants::_getInstanceByObjId($this->getId());
1685  return true;
1686  }
1687 
1692  public function getMemberObject()
1693  {
1694  if (!$this->member_obj instanceof ilCourseParticipant) {
1695  $this->initCourseMemberObject();
1696  }
1697  return $this->member_obj;
1698  }
1699 
1703  public function getMembersObject()
1704  {
1705  if (!$this->members_obj instanceof ilCourseParticipants) {
1706  $this->initCourseMembersObject();
1707  }
1708  return $this->members_obj;
1709  }
1710 
1711 
1712 
1713  // RBAC METHODS
1714  public function initDefaultRoles()
1715  {
1716  global $DIC;
1717 
1718  $rbacadmin = $DIC['rbacadmin'];
1719  $rbacreview = $DIC['rbacreview'];
1720  $ilDB = $DIC['ilDB'];
1721 
1722  include_once './Services/AccessControl/classes/class.ilObjRole.php';
1724  'il_crs_admin_' . $this->getRefId(),
1725  "Admin of crs obj_no." . $this->getId(),
1726  'il_crs_admin',
1727  $this->getRefId()
1728  );
1730  'il_crs_tutor_' . $this->getRefId(),
1731  "Tutor of crs obj_no." . $this->getId(),
1732  'il_crs_tutor',
1733  $this->getRefId()
1734  );
1736  'il_crs_member_' . $this->getRefId(),
1737  "Member of crs obj_no." . $this->getId(),
1738  'il_crs_member',
1739  $this->getRefId()
1740  );
1741 
1742  return array();
1743  }
1744 
1754  public function setParentRolePermissions($a_parent_ref)
1755  {
1756  global $DIC;
1757 
1758  $rbacadmin = $DIC['rbacadmin'];
1759  $rbacreview = $DIC['rbacreview'];
1760 
1761  $parent_roles = $rbacreview->getParentRoleIds($a_parent_ref);
1762  foreach ((array) $parent_roles as $parent_role) {
1763  $rbacadmin->initIntersectionPermissions(
1764  $this->getRefId(),
1765  $parent_role['obj_id'],
1766  $parent_role['parent'],
1767  $this->__getCrsNonMemberTemplateId(),
1768  ROLE_FOLDER_ID
1769  );
1770  }
1771  }
1772 
1780  {
1781  global $DIC;
1782 
1783  $ilDB = $DIC['ilDB'];
1784 
1785  $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_crs_non_member'";
1786  $res = $this->ilias->db->query($q);
1787  $row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
1788 
1789  return $row["obj_id"];
1790  }
1791 
1796  public static function lookupCourseNonMemberTemplatesId()
1797  {
1798  global $DIC;
1799 
1800  $ilDB = $DIC['ilDB'];
1801 
1802  $query = 'SELECT obj_id FROM object_data WHERE type = ' . $ilDB->quote('rolt', 'text') . ' AND title = ' . $ilDB->quote('il_crs_non_member', 'text');
1803  $res = $ilDB->query($query);
1804  $row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
1805 
1806  return isset($row['obj_id']) ? $row['obj_id'] : 0;
1807  }
1808 
1815  public function getLocalCourseRoles($a_translate = false)
1816  {
1817  global $DIC;
1818 
1819  $rbacadmin = $DIC['rbacadmin'];
1820  $rbacreview = $DIC['rbacreview'];
1821 
1822  if (empty($this->local_roles)) {
1823  $this->local_roles = array();
1824  $role_arr = $rbacreview->getRolesOfRoleFolder($this->getRefId());
1825 
1826  foreach ($role_arr as $role_id) {
1827  if ($rbacreview->isAssignable($role_id, $this->getRefId()) == true) {
1828  $role_Obj = $this->ilias->obj_factory->getInstanceByObjId($role_id);
1829 
1830  if ($a_translate) {
1831  $role_name = ilObjRole::_getTranslation($role_Obj->getTitle());
1832  } else {
1833  $role_name = $role_Obj->getTitle();
1834  }
1835  $this->local_roles[$role_name] = $role_Obj->getId();
1836  }
1837  }
1838  }
1839 
1840  return $this->local_roles;
1841  }
1842 
1843 
1844 
1854  public function getDefaultCourseRoles($a_crs_id = "")
1855  {
1856  global $DIC;
1857 
1858  $rbacadmin = $DIC['rbacadmin'];
1859  $rbacreview = $DIC['rbacreview'];
1860 
1861  if (strlen($a_crs_id) > 0) {
1862  $crs_id = $a_crs_id;
1863  } else {
1864  $crs_id = $this->getRefId();
1865  }
1866 
1867  $role_arr = $rbacreview->getRolesOfRoleFolder($crs_id);
1868 
1869  foreach ($role_arr as $role_id) {
1870  $role_Obj = &$this->ilias->obj_factory->getInstanceByObjId($role_id);
1871 
1872  $crs_Member = "il_crs_member_" . $crs_id;
1873  $crs_Admin = "il_crs_admin_" . $crs_id;
1874  $crs_Tutor = "il_crs_tutor_" . $crs_id;
1875 
1876  if (strcmp($role_Obj->getTitle(), $crs_Member) == 0) {
1877  $arr_crsDefaultRoles["crs_member_role"] = $role_Obj->getId();
1878  }
1879 
1880  if (strcmp($role_Obj->getTitle(), $crs_Admin) == 0) {
1881  $arr_crsDefaultRoles["crs_admin_role"] = $role_Obj->getId();
1882  }
1883 
1884  if (strcmp($role_Obj->getTitle(), $crs_Tutor) == 0) {
1885  $arr_crsDefaultRoles["crs_tutor_role"] = $role_Obj->getId();
1886  }
1887  }
1888 
1889  return $arr_crsDefaultRoles;
1890  }
1891 
1892  public function __getLocalRoles()
1893  {
1894  global $DIC;
1895 
1896  $rbacreview = $DIC['rbacreview'];
1897 
1898  // GET role_objects of predefined roles
1899 
1900  return $rbacreview->getRolesOfRoleFolder($this->getRefId(), false);
1901  }
1902 
1903  public function __deleteSettings()
1904  {
1905  global $DIC;
1906 
1907  $ilDB = $DIC['ilDB'];
1908 
1909  $query = "DELETE FROM crs_settings " .
1910  "WHERE obj_id = " . $ilDB->quote($this->getId(), 'integer') . " ";
1911  $res = $ilDB->manipulate($query);
1912 
1913  return true;
1914  }
1915 
1916 
1917  public function getDefaultMemberRole()
1918  {
1919  $local_roles = $this->__getLocalRoles();
1920 
1921  foreach ($local_roles as $role_id) {
1922  $title = ilObject::_lookupTitle($role_id);
1923  if (substr($title, 0, 8) == 'il_crs_m') {
1924  return $role_id;
1925  }
1926  }
1927  return 0;
1928  }
1929  public function getDefaultTutorRole()
1930  {
1931  $local_roles = $this->__getLocalRoles();
1932 
1933  foreach ($local_roles as $role_id) {
1934  if ($tmp_role = &ilObjectFactory::getInstanceByObjId($role_id, false)) {
1935  if (!strcmp($tmp_role->getTitle(), "il_crs_tutor_" . $this->getRefId())) {
1936  return $role_id;
1937  }
1938  }
1939  }
1940  return false;
1941  }
1942  public function getDefaultAdminRole()
1943  {
1944  $local_roles = $this->__getLocalRoles();
1945 
1946  foreach ($local_roles as $role_id) {
1947  if ($tmp_role = &ilObjectFactory::getInstanceByObjId($role_id, false)) {
1948  if (!strcmp($tmp_role->getTitle(), "il_crs_admin_" . $this->getRefId())) {
1949  return $role_id;
1950  }
1951  }
1952  }
1953  return false;
1954  }
1955 
1956  public static function _deleteUser($a_usr_id)
1957  {
1958  // Delete all user related data
1959  // delete lm_history
1960  include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
1961  ilCourseLMHistory::_deleteUser($a_usr_id);
1962 
1963  include_once './Modules/Course/classes/class.ilCourseParticipants.php';
1965 
1966  // Course objectives
1967  include_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php";
1969  }
1970 
1977  public function MDUpdateListener($a_element)
1978  {
1979  global $DIC;
1980 
1981  $ilLog = $DIC['ilLog'];
1982 
1983  parent::MDUpdateListener($a_element);
1984 
1985  switch ($a_element) {
1986  case 'General':
1987  // Update ecs content
1988  include_once 'Modules/Course/classes/class.ilECSCourseSettings.php';
1989  $ecs = new ilECSCourseSettings($this);
1990  $ecs->handleContentUpdate();
1991  break;
1992 
1993  default:
1994  return true;
1995  }
1996  }
1997 
2002  public function addAdditionalSubItemInformation(&$a_item_data)
2003  {
2004  include_once './Services/Object/classes/class.ilObjectActivation.php';
2006  }
2007 
2015  protected function prepareAppointments($a_mode = 'create')
2016  {
2017  include_once('./Services/Calendar/classes/class.ilCalendarAppointmentTemplate.php');
2018  include_once('./Services/Calendar/classes/class.ilDateTime.php');
2019 
2020  switch ($a_mode) {
2021  case 'create':
2022  case 'update':
2023  if (!$this->getActivationUnlimitedStatus() and !$this->getOfflineStatus()) {
2024  $app = new ilCalendarAppointmentTemplate(self::CAL_ACTIVATION_START);
2025  $app->setTitle($this->getTitle());
2026  $app->setSubtitle('crs_cal_activation_start');
2027  $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
2028  $app->setDescription($this->getLongDescription());
2029  $app->setStart(new ilDateTime($this->getActivationStart(), IL_CAL_UNIX));
2030  $apps[] = $app;
2031 
2032  $app = new ilCalendarAppointmentTemplate(self::CAL_ACTIVATION_END);
2033  $app->setTitle($this->getTitle());
2034  $app->setSubtitle('crs_cal_activation_end');
2035  $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
2036  $app->setDescription($this->getLongDescription());
2037  $app->setStart(new ilDateTime($this->getActivationEnd(), IL_CAL_UNIX));
2038  $apps[] = $app;
2039  }
2041  $app = new ilCalendarAppointmentTemplate(self::CAL_REG_START);
2042  $app->setTitle($this->getTitle());
2043  $app->setSubtitle('crs_cal_reg_start');
2044  $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
2045  $app->setDescription($this->getLongDescription());
2046  $app->setStart(new ilDateTime($this->getSubscriptionStart(), IL_CAL_UNIX));
2047  $apps[] = $app;
2048 
2049  $app = new ilCalendarAppointmentTemplate(self::CAL_REG_END);
2050  $app->setTitle($this->getTitle());
2051  $app->setSubtitle('crs_cal_reg_end');
2052  $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
2053  $app->setDescription($this->getLongDescription());
2054  $app->setStart(new ilDateTime($this->getSubscriptionEnd(), IL_CAL_UNIX));
2055  $apps[] = $app;
2056  }
2057  if ($this->getCourseStart() && $this->getCourseEnd()) {
2058  $app = new ilCalendarAppointmentTemplate(self::CAL_COURSE_START);
2059  $app->setTitle($this->getTitle());
2060  $app->setSubtitle('crs_cal_start');
2061  $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
2062  $app->setDescription($this->getLongDescription());
2063  $app->setStart($this->getCourseStart());
2064  $app->setFullday(!$this->getCourseStartTimeIndication());
2065  $apps[] = $app;
2066 
2067  $app = new ilCalendarAppointmentTemplate(self::CAL_COURSE_END);
2068  $app->setTitle($this->getTitle());
2069  $app->setSubtitle('crs_cal_end');
2070  $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
2071  $app->setDescription($this->getLongDescription());
2072  $app->setStart($this->getCourseEnd());
2073  $app->setFullday(!$this->getCourseStartTimeIndication());
2074  $apps[] = $app;
2075  }
2076  if (
2078  ) {
2079  $active = ilObjectActivation::getTimingsItems($this->getRefId());
2080  foreach ($active as $null => $item) {
2081  if ($item['timing_type'] == ilObjectActivation::TIMINGS_PRESETTING) {
2082  // create calendar entry for fixed types
2083  $app = new ilCalendarAppointmentTemplate(self::CAL_COURSE_TIMING_START);
2084  $app->setContextInfo($item['ref_id']);
2085  $app->setTitle($item['title']);
2086  $app->setSubtitle('cal_crs_timing_start');
2087  $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
2088  $app->setStart(new ilDate($item['suggestion_start'], IL_CAL_UNIX));
2089  $app->setFullday(true);
2090  $apps[] = $app;
2091 
2092  $app = new ilCalendarAppointmentTemplate(self::CAL_COURSE_TIMING_END);
2093  $app->setContextInfo($item['ref_id']);
2094  $app->setTitle($item['title']);
2095  $app->setSubtitle('cal_crs_timing_end');
2096  $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
2097  $app->setStart(new ilDate($item['suggestion_end'], IL_CAL_UNIX));
2098  $app->setFullday(true);
2099  $apps[] = $app;
2100  }
2101  }
2102  }
2103  return $apps ? $apps : array();
2104 
2105  case 'delete':
2106  // Nothing to do: The category and all assigned appointments will be deleted.
2107  return array();
2108  }
2109  }
2110 
2111  ###### Interface ilMembershipRegistrationCodes
2112 
2116  public static function lookupObjectsByCode($a_code)
2117  {
2118  global $DIC;
2119 
2120  $ilDB = $DIC['ilDB'];
2121 
2122  $query = "SELECT obj_id FROM crs_settings " .
2123  "WHERE reg_ac_enabled = " . $ilDB->quote(1, 'integer') . " " .
2124  "AND reg_ac = " . $ilDB->quote($a_code, 'text');
2125  $res = $ilDB->query($query);
2126 
2127  $obj_ids = array();
2128  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
2129  $obj_ids[] = $row->obj_id;
2130  }
2131  return $obj_ids;
2132  }
2133 
2141  public function register($a_user_id, $a_role = ilCourseConstants::CRS_MEMBER, $a_force_registration = false)
2142  {
2143  global $DIC;
2144 
2145  $ilCtrl = $DIC['ilCtrl'];
2146  $tree = $DIC['tree'];
2147  include_once './Services/Membership/exceptions/class.ilMembershipRegistrationException.php';
2148  include_once "./Modules/Course/classes/class.ilCourseParticipants.php";
2150 
2151  if ($part->isAssigned($a_user_id)) {
2152  return true;
2153  }
2154 
2155  if (!$a_force_registration) {
2156  // offline
2157  if (ilObjCourseAccess::_isOffline($this->getId())) {
2159  "Can't register to course, course is offline.",
2161  );
2162  }
2163  // activation
2164  if (!ilObjCourseAccess::_isActivated($this->getId())) {
2166  "Can't register to course, course is not activated.",
2168  );
2169  }
2170 
2173  throw new ilMembershipRegistrationException('Cant registrate to course ' . $this->getId() .
2174  ', course subscription is deactivated.', ilMembershipRegistrationException::REGISTRATION_CODE_DISABLED);
2175  }
2176  }
2177 
2178  // Time Limitation
2180  if (!$this->inSubscriptionTime()) {
2181  throw new ilMembershipRegistrationException('Cant registrate to course ' . $this->getId() .
2182  ', course is out of registration time.', ilMembershipRegistrationException::OUT_OF_REGISTRATION_PERIOD);
2183  }
2184  }
2185 
2186  // Max members
2187  if ($this->isSubscriptionMembershipLimited()) {
2188  $free = max(0, $this->getSubscriptionMaxMembers() - $part->getCountMembers());
2189  include_once('./Modules/Course/classes/class.ilCourseWaitingList.php');
2190  $waiting_list = new ilCourseWaitingList($this->getId());
2191  if ($this->enabledWaitingList() and (!$free or $waiting_list->getCountUsers())) {
2192  $waiting_list->addToList($a_user_id);
2193  $this->lng->loadLanguageModule("crs");
2194  $info = sprintf(
2195  $this->lng->txt('crs_added_to_list'),
2196  $waiting_list->getPosition($a_user_id)
2197  );
2198  include_once('./Modules/Course/classes/class.ilCourseParticipants.php');
2199  $participants = ilCourseParticipants::_getInstanceByObjId($this->getId());
2200  $participants->sendNotification($participants->NOTIFY_WAITING_LIST, $a_user_id);
2201 
2203  }
2204 
2205  if (!$this->enabledWaitingList() && !$free) {
2206  throw new ilMembershipRegistrationException('Cant registrate to course ' . $this->getId() .
2207  ', membership is limited.', ilMembershipRegistrationException::OBJECT_IS_FULL);
2208  }
2209  }
2210  }
2211 
2212  $part->add($a_user_id, $a_role);
2213  $part->sendNotification($part->NOTIFY_ACCEPT_USER, $a_user_id);
2214  $part->sendNotification($part->NOTIFY_ADMINS, $a_user_id);
2215 
2216 
2217  include_once './Modules/Forum/classes/class.ilForumNotification.php';
2219 
2220  return true;
2221  }
2222 
2229  public function getAutoNotification()
2230  {
2231  return $this->auto_notification;
2232  }
2233 
2234 
2241  public function setAutoNotification($value)
2242  {
2243  $this->auto_notification = $value;
2244  }
2245 
2251  public function setStatusDetermination($a_value)
2252  {
2253  $a_value = (int) $a_value;
2254 
2255  // #13905
2256  if ($a_value == self::STATUS_DETERMINATION_LP) {
2257  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
2259  $a_value = self::STATUS_DETERMINATION_MANUAL;
2260  }
2261  }
2262 
2263  $this->status_dt = $a_value;
2264  }
2265 
2271  public function getStatusDetermination()
2272  {
2273  return $this->status_dt;
2274  }
2275 
2279  public function syncMembersStatusWithLP()
2280  {
2281  include_once "Services/Tracking/classes/class.ilLPStatusWrapper.php";
2282  foreach ($this->getMembersObject()->getParticipants() as $user_id) {
2283  // #15529 - force raise on sync
2284  ilLPStatusWrapper::_updateStatus($this->getId(), $user_id, null, false, true);
2285  }
2286  }
2287 
2295  public function checkLPStatusSync($a_member_id)
2296  {
2297  // #11113
2298  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
2301  include_once("Services/Tracking/classes/class.ilLPStatus.php");
2302  // #13811 - we need to suppress creation if status entry
2303  $has_completed = (ilLPStatus::_lookupStatus($this->getId(), $a_member_id, false) == ilLPStatus::LP_STATUS_COMPLETED_NUM);
2304  $this->getMembersObject()->updatePassed($a_member_id, $has_completed, false, true);
2305  }
2306  }
2307 
2308  public function getOrderType()
2309  {
2310  if ($this->enabledObjectiveView()) {
2311  return ilContainer::SORT_MANUAL;
2312  }
2313  return parent::getOrderType();
2314  }
2315 
2319  public function handleAutoFill()
2320  {
2321  if (
2322  !$this->enabledWaitingList() or
2323  !$this->hasWaitingListAutoFill()
2324  ) {
2325  $this->course_logger->debug('Waiting list or auto fill disabled.');
2326  return;
2327  }
2328 
2329  $max = $this->getSubscriptionMaxMembers();
2331 
2332  $this->course_logger->debug('Max members: ' . $max);
2333  $this->course_logger->debug('Current members: ' . $now);
2334 
2335  if ($max <= $now) {
2336  return;
2337  }
2338 
2339  // see assignFromWaitingListObject()
2340  include_once('./Modules/Course/classes/class.ilCourseWaitingList.php');
2341  $waiting_list = new ilCourseWaitingList($this->getId());
2342 
2343  foreach ($waiting_list->getUserIds() as $user_id) {
2344  if (!$tmp_obj = ilObjectFactory::getInstanceByObjId($user_id, false)) {
2345  $this->course_logger->warning('Cannot create user instance for id: ' . $user_id);
2346  continue;
2347  }
2348  if ($this->getMembersObject()->isAssigned($user_id)) {
2349  $this->course_logger->warning('User is already assigned to course. uid: ' . $user_id . ' course_id: ' . $this->getRefId());
2350  continue;
2351  }
2352  $this->getMembersObject()->add($user_id, IL_CRS_MEMBER);
2353  $this->getMembersObject()->sendNotification($this->getMembersObject()->NOTIFY_ACCEPT_USER, $user_id, true);
2354  $waiting_list->removeFromList($user_id);
2355  $this->checkLPStatusSync($user_id);
2356 
2357  $this->course_logger->info('Assigned user from waiting list to course: ' . $this->getTitle());
2358  $now++;
2359  if ($now >= $max) {
2360  break;
2361  }
2362  }
2363  }
2364 
2365  public static function mayLeave($a_course_id, $a_user_id = null, &$a_date = null)
2366  {
2367  global $DIC;
2368 
2369  $ilUser = $DIC['ilUser'];
2370  $ilDB = $DIC['ilDB'];
2371 
2372  if (!$a_user_id) {
2373  $a_user_id = $ilUser->getId();
2374  }
2375 
2376  $set = $ilDB->query("SELECT leave_end" .
2377  " FROM crs_settings" .
2378  " WHERE obj_id = " . $ilDB->quote($a_course_id, "integer"));
2379  $row = $ilDB->fetchAssoc($set);
2380  if ($row && $row["leave_end"]) {
2381  // timestamp to date
2382  $limit = date("Ymd", $row["leave_end"]);
2383  if ($limit < date("Ymd")) {
2384  $a_date = new ilDate(date("Y-m-d", $row["leave_end"]), IL_CAL_DATE);
2385  return false;
2386  }
2387  }
2388  return true;
2389  }
2390 
2396  public static function findCoursesWithNotEnoughMembers()
2397  {
2398  $ilDB = $GLOBALS['DIC']->database();
2399  $tree = $GLOBALS['DIC']->repositoryTree();
2400 
2401  $res = array();
2402 
2403  $before = new ilDateTime(time(), IL_CAL_UNIX);
2404  $before->increment(IL_CAL_DAY, -1);
2405  $now = $before->get(IL_CAL_UNIX);
2406 
2407  include_once "Modules/Course/classes/class.ilCourseParticipants.php";
2408 
2409  $set = $ilDB->query("SELECT obj_id, min_members" .
2410  " FROM crs_settings" .
2411  " WHERE min_members > " . $ilDB->quote(0, "integer") .
2412  " AND sub_mem_limit = " . $ilDB->quote(1, "integer") . // #17206
2413  " AND ((leave_end IS NOT NULL" .
2414  " AND leave_end < " . $ilDB->quote($now, "text") . ")" .
2415  " OR (leave_end IS NULL" .
2416  " AND sub_end IS NOT NULL" .
2417  " AND sub_end < " . $ilDB->quote($now, "text") . "))" .
2418  " AND (period_start IS NULL OR period_start > " . $ilDB->quote($now, "integer") . ")");
2419  while ($row = $ilDB->fetchAssoc($set)) {
2420  $refs = ilObject::_getAllReferences($row['obj_id']);
2421  $ref = end($refs);
2422 
2423  if ($tree->isDeleted($ref)) {
2424  continue;
2425  }
2426 
2427  $part = new ilCourseParticipants($row["obj_id"]);
2428  $reci = $part->getNotificationRecipients();
2429  if (sizeof($reci)) {
2430  $missing = (int) $row["min_members"] - $part->getCountMembers();
2431  if ($missing > 0) {
2432  $res[$row["obj_id"]] = array($missing, $reci);
2433  }
2434  }
2435  }
2436 
2437  return $res;
2438  }
2439 } //END class.ilObjCourse
const LP_STATUS_COMPLETED_NUM
$app
Definition: cli.php:38
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
setActivationEnd($a_value)
static getUserIdByLogin($a_login)
setArchiveType($a_value)
setSubscriptionNotify($a_value)
getEnableMap()
Type independent wrapper.
setContactResponsibility($a_value)
getMailToMembersType()
Get mail to members type.
setSubscriptionStart($a_value)
setSubscriptionEnd($a_value)
static _deleteAllEntries($a_obj_id)
Delete all entries Normally called for course deletion.
const IL_CRS_SUBSCRIPTION_LIMITED
setCoursePeriod(\ilDateTime $start=null, \ilDateTime $end=null)
static lookupNumberOfMembers($a_ref_id)
Lookup number of members ilRbacReview $rbacreview <type> $ilObjDataCache.
setShowMembersExport($a_mem_export)
const IL_CRS_VIEW_OBJECTIVE
const IL_CAL_DATETIME
setNumberOfPreviousSessions($a_num)
Set number of previous sessions.
getLongitude()
Get Longitude.
setAutoNotification($value)
Sets automatic notification status in $this->auto_notification, using given $status.
static convertDateToUtcDBTimestamp(\ilDateTime $date=null)
static cloneSettings($a_copy_id, $a_container_id, $a_new_container_id)
Clone settings.
static lookupObjectsByCode($a_code)
static _deleteUser($a_usr_id)
Delete user type $ilDB.
setParentRolePermissions($a_parent_ref)
This method is called before "initDefaultRoles".
static is_email($a_email, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
getDefaultCourseRoles($a_crs_id="")
get default course roles, returns the defaultlike create roles il_crs_tutor, il_crs_admin and il_crs_...
const IL_CAL_TRANSLATION_SYSTEM
$_GET["client_id"]
static lookupCourseNonMemberTemplatesId()
Lookup course non member id.
static _registrationEnabled($a_obj_id)
Registration enabled? Method is in Access class, since it is needed by Access/ListGUI.
setImportantInformation($a_info)
static _registrationEnabled($a_obj_id)
updateMetaData()
update meta data entry
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.
setMailToMembersType($a_type)
Set mail to members type.
static getTimingsItems($a_container_ref_id)
Get (sub) item data for timings view (no session material, no side blocks)
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
getSubItems( $a_admin_panel_enabled=false, $a_include_side_block=false, $a_get_single=0, \ilContainerUserFilter $container_user_filter=null)
Get subitems of container.
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.
static getItem($a_ref_id)
Get item data.
getOfflineStatus()
Get offline status.
static _isSubscriptionNotificationEnabled($a_course_id)
Check if subscription notification is enabled.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
setContactEmail($a_value)
enableSubscriptionMembershipLimitation($a_status)
enable max members
cloneObject($a_target_id, $a_copy_id=0, $a_omit_tree=false)
Clone course (no member data)
createMetaData()
create meta data entry
enableSessionLimit($a_status)
en/disable limited number of sessions
const IL_CRS_VIEW_TIMING_ABSOLUTE
setTimingMode($a_mode)
static _lookupTitle($a_id)
lookup object title
Apointment templates are used for automatic generated apointments.
isRegistrationAccessCodeEnabled()
Check if access code is enabled.
getStatusDetermination()
Get status determination mode.
static lookupTimingMode($a_obj_id)
static _lookupViewMode($a_id)
lookup view mode of container
const IL_CAL_UNIX
setSubscriptionPassword($a_value)
static _deleteByContainer($a_container_id)
Delete all fields of a container.
const STATUS_DETERMINATION_LP
addAdditionalSubItemInformation(&$a_item_data)
Add additional information to sub item, e.g.
setRegistrationAccessCode($a_code)
Set refistration access code.
static _clone($a_source_id, $a_target_id)
Clone fields.
static deleteResultsForUser($a_user_id)
Delete all result entries for user.
setSyllabus($a_syllabus)
static _usingRegistrationCode()
Using Registration code.
static _getAllReferences($a_id)
get all reference ids of object
const IL_CRS_ARCHIVE_NONE
update()
update complete object
handleAutoFill()
Handle course auto fill.
$ilErr
Definition: raiseError.php:18
static createDefaultRole($a_title, $a_description, $a_tpl_name, $a_ref_id)
setLatitude($a_latitude)
Set Latitude.
cloneSettings(\ilObjCourse $new_obj)
Clone entries in settings table.
setViewMode($a_mode)
global $ilCtrl
Definition: ilias.php:18
setEnableCourseMap($a_enablemap)
Set Enable Course Map.
const IL_CRS_MEMBER
setActivationVisibility($a_value)
static lookupShowMembersEnabled($a_obj_id)
Check if show member is enabled.
setAboStatus($a_status)
static _deleteAll($a_course_id)
$a_type
Definition: workflow.php:92
setLocationZoom($a_locationzoom)
Set LocationZoom.
const IL_CAL_DAY
const CAL_ACTIVATION_END
static _enabledLearningProgress()
check wether learing progress is enabled or not
const IL_CRS_SUBSCRIPTION_PASSWORD
static addAdditionalSubItemInformation(array &$a_item)
Parse item data for list entries.
const CAL_ACTIVATION_START
static _getInstance($a_copy_id)
Get instance of copy wizard options.
getLocationZoom()
Get LocationZoom.
setActivationStart($a_value)
isActivated()
Check if course is active and not offline.
getMemberObject()
Get course member object.
Class for single dates.
foreach($_POST as $key=> $value) $res
setLongitude($a_longitude)
Set Longitude.
getId()
get object id public
Interface for all objects that offer registration with access codes.
getNumberOfNextSessions()
Set number of previous sessions.
setSubscriptionType($a_value)
static _isOffline($a_obj_id)
Type-specific implementation of general status.
class ilcourseobjective
syncMembersStatusWithLP()
Set course status for all members by lp status.
__getCrsNonMemberTemplateId()
get course non-member template private
static _lookupObjId($a_id)
prepareAppointments($a_mode='create')
Prepare calendar appointments.
cloneDependencies($a_target_id, $a_copy_id)
Clone object dependencies (start objects, preconditions)
setSubscriptionMinMembers($a_value)
Low level api for booking service.
setNumberOfNextSessions($a_num)
Set number of previous sessions.
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
const IL_CRS_SUBSCRIPTION_UNLIMITED
setArchiveEnd($a_value)
const CAL_COURSE_TIMING_END
getTitle()
get object title public
setContactConsultation($a_value)
MDUpdateListener($a_element)
Overwriten Metadata update listener for ECS functionalities.
$ilUser
Definition: imgupload.php:18
redirection script todo: (a better solution should control the processing via a xml file) ...
cloneMetaData($target_obj)
Copy meta data.
Class ilContainer.
const IL_CRS_ADMIN
Base class for course and group participants.
$query
const STATUS_DETERMINATION_MANUAL
static _getInstanceByObjId($a_obj_id, $a_usr_id)
Get singleton instance.
getRegistrationAccessCode()
get access code
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
enableRegistrationAccessCode($a_status)
En/disable registration access code.
static _getTranslation($a_role_title)
if($orgName !==null) if($spconfig->hasValue('contacts')) $email
Definition: metadata.php:285
setTimingType($a_type)
Set timing type.
getLocalCourseRoles($a_translate=false)
get ALL local roles of course, also those created and defined afterwards only fetch data once from da...
static mayLeave($a_course_id, $a_user_id=null, &$a_date=null)
getAutoNotification()
Returns automatic notification status from $this->auto_notification.
checkLPStatusSync($a_member_id)
sync course status from lp
getLatitude()
Get Latitude.
cloneAutoGeneratedRoles($new_obj)
Clone automatic genrated roles (permissions and template permissions)
setMessage($a_message)
isSubscriptionMembershipLimited()
is membership limited
static _isActivated($a_obj_id)
Is activated.
setTargetGroup(?string $a_tg)
const IL_CAL_DATE
static generateCode()
Generate new registration key.
setContactPhone($a_value)
const CAL_COURSE_TIMING_START
static _lookupAboStatus($a_id)
getActivationUnlimitedStatus()
get activation unlimited no start or no end
setCancellationEnd(ilDate $a_value=null)
setOrderType($a_value)
static findCoursesWithNotEnoughMembers()
Minimum members check type $ilDB.
static _deleteByCourse($a_course_id)
initCourseMembersObject()
Init course member object ilObjUser $ilUser.
setOfflineStatus($a_status)
Set offline status.
static cloneDependencies($a_ref_id, $a_target_id, $a_copy_id)
Clone dependencies.
__construct(Container $dic, ilPlugin $plugin)
create($a_upload=false)
global $ilDB
const IL_CRS_ARCHIVE_DOWNLOAD
static _deleteUser($a_usr_id)
Delete user data.
getNumberOfPreviousSessions()
Set number of previous sessions.
$DIC
Definition: xapitoken.php:46
getLongDescription()
get object long description (stored in object_description)
setSubscriptionMaxMembers($a_value)
static _deleteAll($course_id)
getRefId()
get reference id public
enableWaitingList($a_status)
static _deleteUser($a_usr_id)
deleteMetaData()
delete meta data entry
$message
Definition: xapiexit.php:14
toggleCourseStartTimeIndication(bool $time_indication)
initCourseMemberObject()
Init course member object ilObjUser $ilUser.
const IL_CRS_SUBSCRIPTION_DIRECT
static getLogger($a_component_id)
Get component logger.
setWaitingListAutoFill($a_value)
static _lookupSortMode($a_obj_id)
lookup sort mode
static _getInstance()
Get instance of ilPrivacySettings.
static _getInstance($a_obj_id)
get instance by obj_id
__construct($a_id=0, $a_call_by_reference=true)
Constructor public.
static _getGroupings($a_course_id)
getEnableCourseMap()
Get Enable Course Map.
static checkForumsExistsInsert($ref_id, $user_id=0)
static _isActivated($a_obj_id, &$a_visible_flag=null, $a_mind_member_view=true)
Is activated?
setCourseEnd(ilDateTime $a_value=null)
setCourseStart(ilDateTime $a_value=null)
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.
Class ilObjectActivation.
static _cloneFiles($a_source_id, $a_target_id)
Clone course files.
appendMessage($a_message)
static _lookupStatus($a_obj_id, $a_user_id, $a_create=true)
Lookup status.
setShowMembers($a_status)
Class ilECSCourseSettings.
const IL_CRS_SUBSCRIPTION_DEACTIVATED
updateSettings()
Update settings.
setStatusDetermination($a_value)
Set status determination mode.
setArchiveStart($a_value)
setSubscriptionLimitationType($a_type)