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';
84 #define("ILIAS_MODULE","course");
85 #define("KEEP_IMAGE_PATH",1);
87 $this->SUBSCRIPTION_DEACTIVATED = 1;
88 $this->SUBSCRIPTION_CONFIRMATION = 2;
89 $this->SUBSCRIPTION_DIRECT = 3;
90 $this->SUBSCRIPTION_PASSWORD = 4;
91 $this->SUBSCRIPTION_AUTOSUBSCRIPTION = 5;
92 $this->ARCHIVE_DISABLED = 1;
93 $this->ARCHIVE_READ = 2;
94 $this->ARCHIVE_DOWNLOAD = 3;
95 $this->ABO_ENABLED = 1;
96 $this->ABO_DISABLED = 0;
97 $this->SHOW_MEMBERS_ENABLED = 1;
98 $this->SHOW_MEMBERS_DISABLED = 0;
103 parent::__construct($a_id,$a_call_by_reference);
114 $query =
'SELECT show_members FROM crs_settings '.
115 'WHERE obj_id = '.$GLOBALS[
'ilDB']->quote($a_obj_id,
'integer');
119 return (
bool)
$row->show_members;
140 $this->reg_access_code = $a_code;
159 $this->reg_access_code_enabled = $a_status;
164 return $this->important;
168 $this->important = $a_info;
172 return $this->syllabus;
176 $this->syllabus = $a_syllabus;
180 return $this->contact_name;
184 $this->contact_name = $a_cn;
188 return $this->contact_consultation;
192 $this->contact_consultation = $a_value;
196 return $this->contact_phone;
200 $this->contact_phone = $a_value;
204 return $this->contact_email;
208 $this->contact_email = $a_value;
212 return $this->contact_responsibility;
216 $this->contact_responsibility = $a_value;
220 return (
int) $this->activation_type;
231 $this->activation_type = $a_type;
239 return $this->activation_start ? $this->activation_start : time();
243 $this->activation_start = $a_value;
247 return $this->activation_end ? $this->activation_end : mktime(0,0,0,12,12,date(
"Y",time())+2);
251 $this->activation_end = $a_value;
255 return (
bool)$this->activation_offline;
259 $this->activation_offline = (bool) $a_value;
263 $this->activation_visibility = (bool) $a_value;
267 return $this->activation_visibility;
272 return $this->subscription_limitation_type;
276 $this->subscription_limitation_type = $a_type;
284 return $this->subscription_start ? $this->subscription_start : time();
288 $this->subscription_start = $a_value;
292 return $this->subscription_end ? $this->subscription_end : mktime(0,0,0,12,12,date(
"Y",time())+2);
296 $this->subscription_end = $a_value;
301 #return $this->subscription_type ? $this->subscription_type : $this->SUBSCRIPTION_DEACTIVATED;
305 $this->subscription_type = $a_value;
309 return $this->subscription_password;
313 $this->subscription_password = $a_value;
322 return (
bool) $this->waiting_list;
327 $this->waiting_list = (bool) $a_status;
350 $this->session_limit = $a_status;
367 $this->subscription_membership_limitation = $a_status;
377 $this->session_prev = $a_num;
396 $this->session_next = $a_num;
416 return (
bool) $this->subscription_membership_limitation;
421 return $this->subscription_max_members;
425 $this->subscription_max_members = $a_value;
440 $query =
"SELECT * FROM crs_settings ".
441 "WHERE obj_id = ".$ilDB->quote($a_course_id ,
'integer').
" ".
442 "AND sub_notify = 1";
444 return $res->numRows() ?
true :
false;
453 public function getSubItems($a_admin_panel_enabled =
false, $a_include_side_block =
false)
458 if (is_array($this->items[(
int) $a_admin_panel_enabled][(
int) $a_include_side_block]))
460 return $this->items[(int) $a_admin_panel_enabled][(
int) $a_include_side_block];
467 if(!$a_admin_panel_enabled &&
468 !$a_include_side_block &&
469 $this->items[
'sess'] &&
470 is_array($this->items[
'sess']) &&
479 return $this->items[(int) $a_admin_panel_enabled][(
int) $a_include_side_block];
486 if(isset(
$_GET[
'crs_prev_sess']))
488 $ilUser->writePref(
'crs_sess_show_prev_'.$this->
getId(), (
string) (
int)
$_GET[
'crs_prev_sess']);
490 if(isset(
$_GET[
'crs_next_sess']))
492 $ilUser->writePref(
'crs_sess_show_next_'.$this->
getId(), (
string) (
int)
$_GET[
'crs_next_sess']);
497 $previous = $current = $next = array();
498 foreach($sessions as $key => $item)
516 $num_previous_remove = max(
520 while($num_previous_remove--)
522 if(!$ilUser->getPref(
'crs_sess_show_prev_'.$this->getId()))
524 array_shift($previous);
526 $this->items[
'sess_link'][
'prev'][
'value'] = 1;
529 $num_next_remove = max(
533 while($num_next_remove--)
535 if(!$ilUser->getPref(
'crs_sess_show_next_'.$this->getId()))
540 $this->items[
'sess_link'][
'next'][
'value'] = 1;
543 $sessions = array_merge($previous,$current,$next);
544 $this->items[
'sess'] = $sessions;
547 include_once(
'Services/Container/classes/class.ilContainerSorting.php');
549 $this->items[(int) $a_admin_panel_enabled][(
int) $a_include_side_block] = $sort->sortItems($this->items);
551 return $this->items[(int) $a_admin_panel_enabled][(
int) $a_include_side_block];
557 return $this->subscription_notify ?
true :
false;
561 $this->subscription_notify = $a_value ?
true :
false;
566 $this->view_mode = $a_mode;
570 return $this->view_mode;
577 $query =
"SELECT view_mode FROM crs_settings WHERE obj_id = ".$ilDB->quote($a_id ,
'integer').
" ";
581 return $row->view_mode;
590 $query =
"SELECT abo FROM crs_settings WHERE obj_id = ".$ilDB->quote($a_id ,
'integer').
" ";
601 return $this->archive_start ? $this->archive_start : time();
605 $this->archive_start = $a_value;
609 return $this->archive_end ? $this->archive_end : mktime(0,0,0,12,12,date(
"Y",time())+2);
613 $this->archive_end = $a_value;
621 $this->archive_type = $a_value;
625 $this->abo = $a_status;
633 $this->show_members = $a_status;
637 return $this->show_members;
647 $this->mail_members = $a_type;
661 return $this->message;
665 $this->message = $a_message;
671 $this->message .=
"<br /> ";
673 $this->message .= $a_message;
709 include_once(
"./Modules/Course/classes/class.ilObjCourseAccess.php");
721 include_once(
"./Modules/Course/classes/class.ilObjCourseAccess.php");
740 return $this->ABO == $this->ABO_ENABLED;
743 function read($a_force_db =
false)
747 include_once(
'./Services/Container/classes/class.ilContainerSortingSettings.php');
754 global $ilAppEventHandler;
764 $ilAppEventHandler->raise(
'Modules/Course',
766 array(
'object' => $this,
767 'obj_id' => $this->
getId(),
779 $this->latitude = $a_latitude;
799 $this->longitude = $a_longitude;
819 $this->locationzoom = $a_locationzoom;
839 $this->enablemap = $a_enablemap;
870 $new_obj->getMemberObject()->add($ilUser->getId(),
IL_CRS_ADMIN);
874 if($cwo->isRootNode($this->getRefId()))
883 include_once(
'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
887 include_once(
'Modules/Course/classes/class.ilCourseFile.php');
891 include_once(
'Services/Tracking/classes/class.ilLPObjSettings.php');
893 $obj_settings->cloneSettings($new_obj->getId());
894 unset($obj_settings);
898 $ilLog->write(__METHOD__.
': '.$this->getBigIconPath().
' '.$this->
getSmallIconPath());
904 include_once
"./Services/Certificate/classes/class.ilCertificate.php";
905 include_once
"./Modules/Course/classes/class.ilCourseCertificateAdapter.php";
908 $cert->cloneCertificate($newcert);
926 include_once(
'Services/Container/classes/class.ilContainerStartObjects.php');
928 $start->cloneDependencies($a_target_id,$a_copy_id);
931 include_once(
'Services/Object/classes/class.ilObjectActivation.php');
934 include_once
'./Modules/Course/classes/Objectives/class.ilLOSettings.php';
938 include_once(
'Modules/Course/classes/class.ilCourseObjective.php');
940 $crs_objective->ilClone($a_target_id,$a_copy_id);
954 global
$ilLog,$rbacadmin,$rbacreview;
957 $new_admin = $new_obj->getDefaultAdminRole();
959 if(!$admin || !$new_admin || !$this->
getRefId() || !$new_obj->getRefId())
961 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_crs_admin');
963 $rbacadmin->copyRolePermissions($admin,$this->
getRefId(),$new_obj->getRefId(),$new_admin,
true);
964 $ilLog->write(__METHOD__.
' : Finished copying of role crs_admin.');
967 $new_tutor = $new_obj->getDefaultTutorRole();
968 if(!$tutor || !$new_tutor)
970 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_crs_tutor');
972 $rbacadmin->copyRolePermissions($tutor,$this->
getRefId(),$new_obj->getRefId(),$new_tutor,
true);
973 $ilLog->write(__METHOD__.
' : Finished copying of role crs_tutor.');
976 $new_member = $new_obj->getDefaultMemberRole();
977 if(!$member || !$new_member)
979 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_crs_member');
981 $rbacadmin->copyRolePermissions($member,$this->
getRefId(),$new_obj->getRefId(),$new_member,
true);
982 $ilLog->write(__METHOD__.
' : Finished copying of role crs_member.');
992 #if(($this->getSubscriptionLimitationType() != IL_CRS_SUBSCRIPTION_DEACTIVATED) and
993 # $this->getSubscriptionType() == )
995 # $this->appendMessage($this->lng->txt('crs_select_registration_type'));
1001 $this->
appendMessage($this->lng->txt(
"activation_times_not_valid"));
1006 $this->
appendMessage($this->lng->txt(
"subscription_times_not_valid"));
1008 #if((!$this->getActivationUnlimitedStatus() and
1009 # !$this->getSubscriptionUnlimitedStatus()) and
1010 # ($this->getSubscriptionStart() > $this->getActivationEnd() or
1011 # $this->getSubscriptionStart() < $this->getActivationStart() or
1012 # $this->getSubscriptionEnd() > $this->getActivationEnd() or
1013 # $this->getSubscriptionEnd() < $this->getActivationStart()))
1016 # $this->appendMessage($this->lng->txt("subscription_time_not_within_activation"));
1020 $this->
appendMessage($this->lng->txt(
"crs_password_required"));
1024 $this->
appendMessage($this->lng->txt(
"max_members_not_numeric"));
1029 $this->
appendMessage($this->lng->txt(
"archive_times_not_valid"));
1047 foreach ($emails as $email) {
1048 $email = trim($email);
1051 $ilErr->appendMessage($this->lng->txt(
'contact_email_not_valid').
" '".$email.
"'");
1077 global $ilAppEventHandler;
1080 if (!parent::delete())
1092 include_once(
'Modules/Course/classes/class.ilCourseParticipants.php');
1096 $this->archives_obj->deleteAll();
1098 include_once
'./Modules/Course/classes/class.ilCourseObjective.php';
1101 include_once
'./Modules/Course/classes/class.ilObjCourseGrouping.php';
1104 include_once
'./Modules/Course/classes/class.ilCourseFile.php';
1107 include_once(
'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
1110 $ilAppEventHandler->raise(
'Modules/Course',
1112 array(
'object' => $this,
1113 'obj_id' => $this->
getId(),
1127 global $ilAppEventHandler,
$ilLog;
1129 include_once(
'./Services/Container/classes/class.ilContainerSortingSettings.php');
1138 $ilAppEventHandler->raise(
'Modules/Course',
1140 array(
'object' => $this,
1141 'obj_id' => $this->
getId(),
1152 $query =
"SELECT * FROM crs_settings WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer').
" ";
1155 if(!
$res->numRows())
1160 $query =
"UPDATE crs_settings SET ".
1161 "syllabus = ".$ilDB->quote($this->
getSyllabus() ,
'text').
", ".
1162 "contact_name = ".$ilDB->quote($this->
getContactName() ,
'text').
", ".
1164 "contact_phone = ".$ilDB->quote($this->
getContactPhone() ,
'text').
", ".
1165 "contact_email = ".$ilDB->quote($this->
getContactEmail() ,
'text').
", ".
1167 "activation_type = ".$ilDB->quote(!$this->
getOfflineStatus() ,
'integer').
", ".
1176 "view_mode = ".$ilDB->quote($this->
getViewMode() ,
'integer').
", ".
1177 "archive_start = ".$ilDB->quote($this->
getArchiveStart() ,
'integer').
", ".
1178 "archive_end = ".$ilDB->quote($this->
getArchiveEnd() ,
'integer').
", ".
1179 "archive_type = ".$ilDB->quote($this->
getArchiveType() ,
'integer').
", ".
1180 "abo = ".$ilDB->quote($this->
getAboStatus() ,
'integer').
", ".
1183 "show_members = ".$ilDB->quote($this->
getShowMembers() ,
'integer').
", ".
1184 "latitude = ".$ilDB->quote($this->
getLatitude() ,
'text').
", ".
1185 "longitude = ".$ilDB->quote($this->
getLongitude() ,
'text').
", ".
1186 "location_zoom = ".$ilDB->quote($this->
getLocationZoom() ,
'integer').
", ".
1187 "enable_course_map = ".$ilDB->quote((
int) $this->
getEnableCourseMap() ,
'integer').
", ".
1196 "WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer').
"";
1204 include_once
"./Services/Object/classes/class.ilObjectActivation.php";
1220 $item->update($this->ref_id);
1266 include_once
'./Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
1284 include_once
'./Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
1287 $query =
"INSERT INTO crs_settings (obj_id,syllabus,contact_name,contact_responsibility,".
1288 "contact_phone,contact_email,contact_consultation,activation_type,activation_start,".
1289 "activation_end,sub_limitation_type,sub_start,sub_end,sub_type,sub_password,sub_mem_limit,".
1290 "sub_max_members,sub_notify,view_mode,archive_start,archive_end,archive_type,abo," .
1291 "latitude,longitude,location_zoom,enable_course_map,waiting_list,show_members, ".
1292 "session_limit,session_prev,session_next, reg_ac_enabled, reg_ac, auto_notification, status_dt,mail_members_type) ".
1294 $ilDB->quote($this->
getId() ,
'integer').
", ".
1301 $ilDB->quote(0 ,
'integer').
", ".
1316 $ilDB->quote($this->ABO_ENABLED ,
'integer').
", ".
1321 #"objective_view = '0', ".
1337 include_once(
'./Services/Container/classes/class.ilContainerSortingSettings.php');
1348 $query =
"SELECT * FROM crs_settings WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer').
"";
1393 include_once
"./Services/Object/classes/class.ilObjectActivation.php";
1395 switch($activation[
"timing_type"])
1420 include_once
"./Modules/Course/classes/class.ilCourseWaitingList.php";
1422 if(!is_object($this->waiting_list_obj))
1439 include_once
"./Modules/Course/classes/class.ilCourseParticipant.php";
1453 include_once
"./Modules/Course/classes/class.ilCourseParticipants.php";
1486 include_once
"./Modules/Course/classes/class.ilCourseArchives.php";
1488 if(!is_object($this->archives_obj))
1500 global $rbacadmin,$rbacreview,
$ilDB;
1502 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
1505 "Admin of crs obj_no.".$this->
getId(),
1511 "Tutor of crs obj_no.".$this->
getId(),
1516 'il_crs_member_'.$this->
getRefId(),
1517 "Member of crs obj_no.".$this->
getId(),
1536 global $rbacadmin, $rbacreview;
1538 $parent_roles = $rbacreview->getParentRoleIds($a_parent_ref);
1539 foreach((array) $parent_roles as $parent_role)
1541 $rbacadmin->initIntersectionPermissions(
1543 $parent_role[
'obj_id'],
1544 $parent_role[
'parent'],
1561 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_crs_non_member'";
1562 $res = $this->ilias->db->query($q);
1565 return $row[
"obj_id"];
1576 $query =
'SELECT obj_id FROM object_data WHERE type = '.$ilDB->quote(
'rolt',
'text').
' AND title = '.$ilDB->quote(
'il_crs_non_member',
'text');
1580 return isset(
$row[
'obj_id']) ?
$row[
'obj_id'] : 0;
1591 global $rbacadmin,$rbacreview;
1593 if (empty($this->local_roles))
1595 $this->local_roles = array();
1596 $role_arr = $rbacreview->getRolesOfRoleFolder($this->
getRefId());
1598 foreach ($role_arr as $role_id)
1600 if ($rbacreview->isAssignable($role_id,$this->getRefId()) ==
true)
1602 $role_Obj = $this->ilias->obj_factory->getInstanceByObjId($role_id);
1610 $role_name = $role_Obj->getTitle();
1612 $this->local_roles[$role_name] = $role_Obj->getId();
1617 return $this->local_roles;
1633 global $rbacadmin, $rbacreview;
1635 if (strlen($a_crs_id) > 0)
1637 $crs_id = $a_crs_id;
1644 $role_arr = $rbacreview->getRolesOfRoleFolder($crs_id);
1646 foreach ($role_arr as $role_id)
1648 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1650 $crs_Member =
"il_crs_member_".$crs_id;
1651 $crs_Admin =
"il_crs_admin_".$crs_id;
1652 $crs_Tutor =
"il_crs_tutor_".$crs_id;
1654 if (strcmp($role_Obj->getTitle(), $crs_Member) == 0 )
1656 $arr_crsDefaultRoles[
"crs_member_role"] = $role_Obj->getId();
1659 if (strcmp($role_Obj->getTitle(), $crs_Admin) == 0)
1661 $arr_crsDefaultRoles[
"crs_admin_role"] = $role_Obj->getId();
1664 if (strcmp($role_Obj->getTitle(), $crs_Tutor) == 0)
1666 $arr_crsDefaultRoles[
"crs_tutor_role"] = $role_Obj->getId();
1670 return $arr_crsDefaultRoles;
1679 return $rbacreview->getRolesOfRoleFolder($this->
getRefId(),
false);
1686 $query =
"DELETE FROM crs_settings ".
1687 "WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer').
" ";
1698 foreach($local_roles as $role_id)
1701 if(substr(
$title,0,8) ==
'il_crs_m')
1712 foreach($local_roles as $role_id)
1716 if(!strcmp($tmp_role->getTitle(),
"il_crs_tutor_".$this->getRefId()))
1728 foreach($local_roles as $role_id)
1732 if(!strcmp($tmp_role->getTitle(),
"il_crs_admin_".$this->getRefId()))
1745 include_once
'./Modules/Course/classes/class.ilCourseLMHistory.php';
1748 include_once
'./Modules/Course/classes/class.ilCourseParticipants.php';
1752 include_once
"Modules/Course/classes/Objectives/class.ilLOUserResults.php";
1772 include_once
'Modules/Course/classes/class.ilECSCourseSettings.php';
1774 $ecs->handleContentUpdate();
1788 include_once
'./Services/Object/classes/class.ilObjectActivation.php';
1801 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentTemplate.php');
1802 include_once(
'./Services/Calendar/classes/class.ilDateTime.php');
1812 $app->setSubtitle(
'crs_cal_activation_start');
1820 $app->setSubtitle(
'crs_cal_activation_end');
1830 $app->setSubtitle(
'crs_cal_reg_start');
1838 $app->setSubtitle(
'crs_cal_reg_end');
1845 return $apps ? $apps : array();
1853 ###### Interface ilMembershipRegistrationCodes
1862 $query =
"SELECT obj_id FROM crs_settings ".
1863 "WHERE reg_ac_enabled = ".$ilDB->quote(1,
'integer').
" ".
1864 "AND reg_ac = ".$ilDB->quote($a_code,
'text');
1870 $obj_ids[] =
$row->obj_id;
1884 include_once
'./Services/Membership/exceptions/class.ilMembershipRegistrationException.php';
1885 include_once
"./Modules/Course/classes/class.ilCourseParticipants.php";
1888 if($part->isAssigned($a_user_id))
1893 if(!$a_force_registration)
1898 include_once
'./Modules/Group/classes/class.ilObjGroupAccess.php';
1903 ', course subscription is deactivated.',
'456');
1913 ', course is out of registration time.',
'789');
1921 include_once(
'./Modules/Course/classes/class.ilCourseWaitingList.php');
1925 $waiting_list->addToList($a_user_id);
1926 $this->lng->loadLanguageModule(
"crs");
1927 $info = sprintf($this->lng->txt(
'crs_added_to_list'),
1928 $waiting_list->getPosition($a_user_id));
1929 include_once(
'./Modules/Course/classes/class.ilCourseParticipants.php');
1931 $participants->sendNotification($participants->NOTIFY_WAITING_LIST,$a_user_id);
1939 ', membership is limited.',
'123');
1944 $part->add($a_user_id,$a_role);
1945 $part->sendNotification($part->NOTIFY_ACCEPT_USER, $a_user_id);
1946 $part->sendNotification($part->NOTIFY_ADMINS,$a_user_id);
1949 include_once
'./Modules/Forum/classes/class.ilForumNotification.php';
1975 $this->auto_notification = $value;
1985 $a_value = (int)$a_value;
1988 if($a_value == self::STATUS_DETERMINATION_LP)
1990 include_once(
"Services/Tracking/classes/class.ilObjUserTracking.php");
1997 $this->status_dt = $a_value;
2015 include_once
"Services/Tracking/classes/class.ilLPStatusWrapper.php";
2033 include_once(
"Services/Tracking/classes/class.ilObjUserTracking.php");
2037 include_once(
"Services/Tracking/classes/class.ilLPStatus.php");
2040 $this->
getMembersObject()->updatePassed($a_member_id, $has_completed,
false,
true);