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';
69 #define("ILIAS_MODULE","course");
70 #define("KEEP_IMAGE_PATH",1);
72 $this->SUBSCRIPTION_DEACTIVATED = 1;
73 $this->SUBSCRIPTION_CONFIRMATION = 2;
74 $this->SUBSCRIPTION_DIRECT = 3;
75 $this->SUBSCRIPTION_PASSWORD = 4;
76 $this->SUBSCRIPTION_AUTOSUBSCRIPTION = 5;
77 $this->ARCHIVE_DISABLED = 1;
78 $this->ARCHIVE_READ = 2;
79 $this->ARCHIVE_DOWNLOAD = 3;
80 $this->ABO_ENABLED = 1;
81 $this->ABO_DISABLED = 0;
82 $this->SHOW_MEMBERS_ENABLED = 1;
83 $this->SHOW_MEMBERS_DISABLED = 0;
87 parent::__construct($a_id,$a_call_by_reference);
91 #$this->__initMetaObject();
116 $this->reg_access_code = $a_code;
135 $this->reg_access_code_enabled = $a_status;
140 return $this->important;
144 $this->important = $a_info;
148 return $this->syllabus;
152 $this->syllabus = $a_syllabus;
156 return $this->contact_name;
160 $this->contact_name = $a_cn;
164 return $this->contact_consultation;
168 $this->contact_consultation = $a_value;
172 return $this->contact_phone;
176 $this->contact_phone = $a_value;
180 return $this->contact_email;
184 $this->contact_email = $a_value;
188 return $this->contact_responsibility;
192 $this->contact_responsibility = $a_value;
197 return (
int) $this->activation_type;
201 $this->activation_type = $a_type;
211 return $this->activation_start ? $this->activation_start : time();
215 $this->activation_start = $a_value;
219 return $this->activation_end ? $this->activation_end : mktime(0,0,0,12,12,date(
"Y",time())+2);
223 $this->activation_end = $a_value;
233 return $this->subscription_limitation_type;
237 $this->subscription_limitation_type = $a_type;
245 return $this->subscription_start ? $this->subscription_start : time();
249 $this->subscription_start = $a_value;
253 return $this->subscription_end ? $this->subscription_end : mktime(0,0,0,12,12,date(
"Y",time())+2);
257 $this->subscription_end = $a_value;
262 #return $this->subscription_type ? $this->subscription_type : $this->SUBSCRIPTION_DEACTIVATED;
266 $this->subscription_type = $a_value;
270 return $this->subscription_password;
274 $this->subscription_password = $a_value;
283 return (
bool) $this->waiting_list;
288 $this->waiting_list = (bool) $a_status;
311 $this->session_limit = $a_status;
328 $this->subscription_membership_limitation = $a_status;
338 $this->session_prev = $a_num;
357 $this->session_next = $a_num;
377 return (
bool) $this->subscription_membership_limitation;
382 return $this->subscription_max_members;
386 $this->subscription_max_members = $a_value;
401 $query =
"SELECT * FROM crs_settings ".
402 "WHERE obj_id = ".$ilDB->quote($a_course_id ,
'integer').
" ".
403 "AND sub_notify = 1";
405 return $res->numRows() ?
true :
false;
414 public function getSubItems($a_admin_panel_enabled =
false, $a_include_side_block =
false)
417 if (is_array($this->items[(
int) $a_admin_panel_enabled][(
int) $a_include_side_block]))
419 return $this->items[(int) $a_admin_panel_enabled][(
int) $a_include_side_block];
426 if(!is_array($this->items[
'sess']) or !$this->items[
'sess'])
428 return $this->items[(int) $a_admin_panel_enabled][(
int) $a_include_side_block];
433 return $this->items[(int) $a_admin_panel_enabled][(
int) $a_include_side_block];
442 foreach($sessions as $key => $item)
444 if($item[
'start'] >= $today)
451 $previous = $sessions;
455 $previous = array_slice($previous, 0, $num);
461 array_splice($previous, 0, $to_remove);
465 $next = array_slice($next, $num);
471 $sessions = array_merge($previous,$next);
472 $this->items[
'sess'] = $sessions;
473 $this->items[(int) $a_admin_panel_enabled][(
int) $a_include_side_block] = $this->items;
474 return $this->items[(int) $a_admin_panel_enabled][(
int) $a_include_side_block];
480 return $this->subscription_notify ?
true :
false;
484 $this->subscription_notify = $a_value ?
true :
false;
489 $this->view_mode = $a_mode;
493 return $this->view_mode;
500 $query =
"SELECT view_mode FROM crs_settings WHERE obj_id = ".$ilDB->quote($a_id ,
'integer').
" ";
504 return $row->view_mode;
513 $query =
"SELECT abo FROM crs_settings WHERE obj_id = ".$ilDB->quote($a_id ,
'integer').
" ";
524 return $this->archive_start ? $this->archive_start : time();
528 $this->archive_start = $a_value;
532 return $this->archive_end ? $this->archive_end : mktime(0,0,0,12,12,date(
"Y",time())+2);
536 $this->archive_end = $a_value;
544 $this->archive_type = $a_value;
548 $this->abo = $a_status;
556 $this->show_members = $a_status;
560 return $this->show_members;
565 return $this->message;
569 $this->message = $a_message;
575 $this->message .=
"<br /> ";
577 $this->message .= $a_message;
582 return $this->members_obj->getMembers();
619 include_once(
"./Modules/Course/classes/class.ilObjCourseAccess.php");
631 include_once(
"./Modules/Course/classes/class.ilObjCourseAccess.php");
650 return $this->ABO == $this->ABO_ENABLED;
653 function read($a_force_db =
false)
661 global $ilAppEventHandler;
671 $ilAppEventHandler->raise(
'Modules/Course',
673 array(
'object' => $this,
674 'obj_id' => $this->
getId(),
686 $this->latitude = $a_latitude;
706 $this->longitude = $a_longitude;
726 $this->locationzoom = $a_locationzoom;
746 $this->enablemap = $a_enablemap;
769 global
$ilDB,$ilUser;
777 $new_obj->initCourseMemberObject();
778 $new_obj->members_obj->add($ilUser->getId(),
IL_CRS_ADMIN);
784 include_once(
'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
788 include_once(
'Modules/Course/classes/class.ilCourseFile.php');
792 include_once(
'Services/Tracking/classes/class.ilLPObjSettings.php');
794 $obj_settings->cloneSettings($new_obj->getId());
795 unset($obj_settings);
799 $ilLog->write(__METHOD__.
': '.$this->getBigIconPath().
' '.$this->
getSmallIconPath());
817 global $ilObjDataCache;
822 include_once(
'Modules/Course/classes/class.ilCourseStart.php');
824 $start->cloneDependencies($a_target_id,$a_copy_id);
828 $this->items_obj->cloneDependencies($a_target_id,$a_copy_id);
831 include_once(
'Modules/Course/classes/class.ilCourseObjective.php');
833 $crs_objective->ilClone($a_target_id,$a_copy_id);
835 include_once(
'Services/Tracking/classes/class.ilLPCollections.php');
837 $lp_collection->cloneCollections($a_target_id,$a_copy_id);
851 global
$ilLog,$rbacadmin,$rbacreview;
854 $new_admin = $new_obj->getDefaultAdminRole();
855 $source_rolf = $rbacreview->getRoleFolderIdOfObject($this->
getRefId());
856 $target_rolf = $rbacreview->getRoleFolderIdOfObject($new_obj->getRefId());
858 if(!$admin || !$new_admin || !$source_rolf || !$target_rolf)
860 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_crs_admin');
862 $rbacadmin->copyRolePermissions($admin,$source_rolf,$target_rolf,$new_admin,
true);
863 $ilLog->write(__METHOD__.
' : Finished copying of role crs_admin.');
866 $new_tutor = $new_obj->getDefaultTutorRole();
867 if(!$tutor || !$new_tutor)
869 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_crs_tutor');
871 $rbacadmin->copyRolePermissions($tutor,$source_rolf,$target_rolf,$new_tutor,
true);
872 $ilLog->write(__METHOD__.
' : Finished copying of role crs_tutor.');
875 $new_member = $new_obj->getDefaultMemberRole();
876 if(!$member || !$new_member)
878 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_crs_member');
880 $rbacadmin->copyRolePermissions($member,$source_rolf,$target_rolf,$new_member,
true);
881 $ilLog->write(__METHOD__.
' : Finished copying of role crs_member.');
893 #if(($this->getSubscriptionLimitationType() != IL_CRS_SUBSCRIPTION_DEACTIVATED) and
894 # $this->getSubscriptionType() == )
896 # $this->appendMessage($this->lng->txt('crs_select_registration_type'));
902 $this->
appendMessage($this->lng->txt(
"activation_times_not_valid"));
907 $this->
appendMessage($this->lng->txt(
"subscription_times_not_valid"));
909 #if((!$this->getActivationUnlimitedStatus() and
910 # !$this->getSubscriptionUnlimitedStatus()) and
911 # ($this->getSubscriptionStart() > $this->getActivationEnd() or
912 # $this->getSubscriptionStart() < $this->getActivationStart() or
913 # $this->getSubscriptionEnd() > $this->getActivationEnd() or
914 # $this->getSubscriptionEnd() < $this->getActivationStart()))
917 # $this->appendMessage($this->lng->txt("subscription_time_not_within_activation"));
921 $this->
appendMessage($this->lng->txt(
"crs_password_required"));
925 $this->
appendMessage($this->lng->txt(
"max_members_not_numeric"));
930 $this->
appendMessage($this->lng->txt(
"archive_times_not_valid"));
948 foreach ($emails as $email) {
949 $email = trim($email);
952 $ilErr->appendMessage($this->lng->txt(
'contact_email_not_valid').
" '".$email.
"'");
978 global $ilAppEventHandler;
981 if (!parent::delete())
994 $this->items_obj->deleteAllEntries();
996 include_once(
'Modules/Course/classes/class.ilCourseParticipants.php');
1000 $this->archives_obj->deleteAll();
1002 include_once
'./Modules/Course/classes/class.ilCourseObjective.php';
1005 include_once
'./Modules/Course/classes/class.ilObjCourseGrouping.php';
1008 include_once
'./Modules/Course/classes/class.ilCourseFile.php';
1011 include_once(
'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
1014 $ilAppEventHandler->raise(
'Modules/Course',
1016 array(
'object' => $this,
1017 'obj_id' => $this->
getId(),
1031 global $ilAppEventHandler,
$ilLog;
1033 include_once(
'./Services/Container/classes/class.ilContainerSortingSettings.php');
1042 $ilAppEventHandler->raise(
'Modules/Course',
1044 array(
'object' => $this,
1045 'obj_id' => $this->
getId(),
1056 $query =
"SELECT * FROM crs_settings WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer').
" ";
1059 if(!
$res->numRows())
1064 $query =
"UPDATE crs_settings SET ".
1065 "syllabus = ".$ilDB->quote($this->
getSyllabus() ,
'text').
", ".
1066 "contact_name = ".$ilDB->quote($this->
getContactName() ,
'text').
", ".
1068 "contact_phone = ".$ilDB->quote($this->
getContactPhone() ,
'text').
", ".
1069 "contact_email = ".$ilDB->quote($this->
getContactEmail() ,
'text').
", ".
1073 "activation_end = ".$ilDB->quote($this->
getActivationEnd() ,
'integer').
", ".
1082 "view_mode = ".$ilDB->quote($this->
getViewMode() ,
'integer').
", ".
1083 "archive_start = ".$ilDB->quote($this->
getArchiveStart() ,
'integer').
", ".
1084 "archive_end = ".$ilDB->quote($this->
getArchiveEnd() ,
'integer').
", ".
1085 "archive_type = ".$ilDB->quote($this->
getArchiveType() ,
'integer').
", ".
1086 "abo = ".$ilDB->quote($this->
getAboStatus() ,
'integer').
", ".
1089 "show_members = ".$ilDB->quote($this->
getShowMembers() ,
'integer').
", ".
1090 "latitude = ".$ilDB->quote($this->
getLatitude() ,
'text').
", ".
1091 "longitude = ".$ilDB->quote($this->
getLongitude() ,
'text').
", ".
1092 "location_zoom = ".$ilDB->quote($this->
getLocationZoom() ,
'integer').
", ".
1093 "enable_course_map = ".$ilDB->quote((
int) $this->
getEnableCourseMap() ,
'integer').
", ".
1099 "WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer').
"";
1144 include_once
'./Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
1154 include_once
'./Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
1157 $query =
"INSERT INTO crs_settings (obj_id,syllabus,contact_name,contact_responsibility,".
1158 "contact_phone,contact_email,contact_consultation,activation_type,activation_start,".
1159 "activation_end,sub_limitation_type,sub_start,sub_end,sub_type,sub_password,sub_mem_limit,".
1160 "sub_max_members,sub_notify,view_mode,archive_start,archive_end,archive_type,abo," .
1161 "latitude,longitude,location_zoom,enable_course_map,waiting_list,show_members, ".
1162 "session_limit,session_prev,session_next, reg_ac_enabled, reg_ac) ".
1164 $ilDB->quote($this->
getId() ,
'integer').
", ".
1186 $ilDB->quote($this->ABO_ENABLED ,
'integer').
", ".
1191 #"objective_view = '0', ".
1204 include_once(
'./Services/Container/classes/class.ilContainerSortingSettings.php');
1215 $query =
"SELECT * FROM crs_settings WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer').
"";
1261 include_once
"./Modules/Course/classes/class.ilCourseWaitingList.php";
1263 if(!is_object($this->waiting_list_obj))
1273 include_once
"./Modules/Course/classes/class.ilCourseParticipants.php";
1280 include_once
"./Modules/Course/classes/class.ilCourseItems.php";
1282 if(!is_object($this->items_obj))
1298 if(is_object($this->items_obj))
1309 include_once
"./Modules/Course/classes/class.ilCourseArchives.php";
1311 if(!is_object($this->archives_obj))
1323 global $rbacadmin,$rbacreview,
$ilDB;
1328 $role_obj = $rolf_obj->createRole(
"il_crs_admin_".$this->
getRefId(),
"Admin of course obj_no.".$this->
getId());
1329 $admin_id = $role_obj->getId();
1332 $query =
"SELECT obj_id FROM object_data ".
1333 " WHERE type='rolt' AND title='il_crs_admin'";
1336 $rbacadmin->copyRoleTemplatePermissions(
$res->obj_id,ROLE_FOLDER_ID,$rolf_obj->getRefId(),$role_obj->getId());
1339 $ops = $rbacreview->getOperationsOfRole($role_obj->getId(),
"crs",$rolf_obj->getRefId());
1340 $rbacadmin->grantPermission($role_obj->getId(),$ops,$this->
getRefId());
1348 $role_obj = $rolf_obj->createRole(
"il_crs_tutor_".$this->
getRefId(),
"Tutors of course obj_no.".$this->
getId());
1349 $member_id = $role_obj->getId();
1352 $query =
"SELECT obj_id FROM object_data ".
1353 " WHERE type='rolt' AND title='il_crs_tutor'";
1355 $rbacadmin->copyRoleTemplatePermissions(
$res->obj_id,ROLE_FOLDER_ID,$rolf_obj->getRefId(),$role_obj->getId());
1358 $ops = $rbacreview->getOperationsOfRole($role_obj->getId(),
"crs",$rolf_obj->getRefId());
1359 $rbacadmin->grantPermission($role_obj->getId(),$ops,$this->
getRefId());
1367 $role_obj = $rolf_obj->createRole(
"il_crs_member_".$this->
getRefId(),
"Member of course obj_no.".$this->
getId());
1368 $member_id = $role_obj->getId();
1371 $query =
"SELECT obj_id FROM object_data ".
1372 " WHERE type='rolt' AND title='il_crs_member'";
1374 $rbacadmin->copyRoleTemplatePermissions(
$res->obj_id,ROLE_FOLDER_ID,$rolf_obj->getRefId(),$role_obj->getId());
1377 $ops = $rbacreview->getOperationsOfRole($role_obj->getId(),
"crs",$rolf_obj->getRefId());
1378 $rbacadmin->grantPermission($role_obj->getId(),$ops,$this->
getRefId());
1412 global $rbacadmin, $rbacreview, $rbacsystem;
1415 $rolf_data = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1418 $arr_parentRoles = $rbacreview->getParentRoleIds($this->
getRefId());
1419 $arr_relevantParentRoleIds = array_diff(array_keys($arr_parentRoles),$this->
getDefaultCourseRoles());
1424 if (is_null($template_id))
1426 $template_ops = array();
1428 $template_ops = $rbacreview->getOperationsOfRole($template_id,
'crs', ROLE_FOLDER_ID);
1431 foreach ($arr_relevantParentRoleIds as $parentRole)
1433 if ($rbacreview->isProtected($arr_parentRoles[$parentRole][
'parent'],$parentRole))
1438 $granted_permissions = array();
1442 $rbacadmin->deleteLocalRole($parentRole,$rolf_data[
"child"]);
1449 $current_ops = $rbacreview->getRoleOperationsOnObject($parentRole, $this->
getRefId());
1450 $rbacadmin->revokePermission($this->
getRefId(), $parentRole);
1451 foreach ($template_ops as $template_op)
1453 if (in_array($template_op,$current_ops))
1455 array_push($granted_permissions,$template_op);
1458 if (!empty($granted_permissions))
1460 $rbacadmin->grantPermission($parentRole, $granted_permissions, $this->
getRefId());
1467 if (! is_null($template_id))
1469 $rbacadmin->copyRolePermissionIntersection(
1470 $template_id, ROLE_FOLDER_ID,
1471 $parentRole, $arr_parentRoles[$parentRole][
'parent'],
1472 $rolf_data[
"child"], $parentRole
1475 $rbacadmin->assignRoleToFolder($parentRole,$rolf_data[
"child"],
"false");
1489 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_crs_non_member'";
1490 $res = $this->ilias->db->query($q);
1493 return $row[
"obj_id"];
1504 global $rbacadmin,$rbacreview;
1506 if (empty($this->local_roles))
1508 $this->local_roles = array();
1509 $rolf = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1510 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"]);
1512 foreach ($role_arr as $role_id)
1514 if ($rbacreview->isAssignable($role_id,$rolf[
"ref_id"]) ==
true)
1516 $role_Obj = $this->ilias->obj_factory->getInstanceByObjId($role_id);
1524 $role_name = $role_Obj->getTitle();
1526 $this->local_roles[$role_name] = $role_Obj->getId();
1531 return $this->local_roles;
1547 global $rbacadmin, $rbacreview;
1549 if (strlen($a_crs_id) > 0)
1551 $crs_id = $a_crs_id;
1558 $rolf = $rbacreview->getRoleFolderOfObject($crs_id);
1559 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"]);
1561 foreach ($role_arr as $role_id)
1563 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1565 $crs_Member =
"il_crs_member_".$crs_id;
1566 $crs_Admin =
"il_crs_admin_".$crs_id;
1567 $crs_Tutor =
"il_crs_tutor_".$crs_id;
1569 if (strcmp($role_Obj->getTitle(), $crs_Member) == 0 )
1571 $arr_crsDefaultRoles[
"crs_member_role"] = $role_Obj->getId();
1574 if (strcmp($role_Obj->getTitle(), $crs_Admin) == 0)
1576 $arr_crsDefaultRoles[
"crs_admin_role"] = $role_Obj->getId();
1579 if (strcmp($role_Obj->getTitle(), $crs_Tutor) == 0)
1581 $arr_crsDefaultRoles[
"crs_tutor_role"] = $role_Obj->getId();
1585 return $arr_crsDefaultRoles;
1594 $rolf = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1596 return $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
1603 $query =
"DELETE FROM crs_settings ".
1604 "WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer').
" ";
1616 foreach($local_roles as $role_id)
1620 if(!strcmp($tmp_role->getTitle(),
"il_crs_member_".$this->getRefId()))
1632 foreach($local_roles as $role_id)
1636 if(!strcmp($tmp_role->getTitle(),
"il_crs_tutor_".$this->getRefId()))
1648 foreach($local_roles as $role_id)
1652 if(!strcmp($tmp_role->getTitle(),
"il_crs_admin_".$this->getRefId()))
1666 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
1668 include_once
"./Modules/Course/classes/class.ilCourseParticipants.php";
1684 include_once
'./Modules/Course/classes/class.ilCourseLMHistory.php';
1687 include_once
'./Modules/Course/classes/class.ilCourseParticipants.php';
1691 include_once
'./Modules/Course/classes/class.ilCourseObjectiveResult.php';
1708 include_once(
'./Services/WebServices/ECS/classes/class.ilECSContentWriter.php');
1711 $writer->setExportable($a_export);
1712 $writer->setOwnerId($a_owner);
1713 $writer->setParticipantIds((array) $a_mids);
1759 include_once(
'./Services/WebServices/ECS/classes/class.ilECSSettings.php');
1761 if(!$settings->isEnabled())
1768 include_once(
'./Services/WebServices/ECS/classes/class.ilECSContentWriter.php');
1770 $writer->refreshSettings();
1774 $ilLog->write(__METHOD__.
': Cannot save ECS settings. '.$exc->getMessage());
1788 $ilBench->start(
"Course",
"initCourseItemObject");
1790 $ilBench->stop(
"Course",
"initCourseItemObject");
1792 $ilBench->start(
"Course",
"addAdditionalSubItemInformation");
1793 $this->items_obj->addAdditionalSubItemInformation($a_item_data);
1794 $ilBench->stop(
"Course",
"addAdditionalSubItemInformation");
1806 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentTemplate.php');
1807 include_once(
'./Services/Calendar/classes/class.ilDateTime.php');
1817 $app->setSubtitle(
'crs_cal_activation_start');
1825 $app->setSubtitle(
'crs_cal_activation_end');
1835 $app->setSubtitle(
'crs_cal_reg_start');
1843 $app->setSubtitle(
'crs_cal_reg_end');
1850 return $apps ? $apps : array();
1858 ###### Interface ilMembershipRegistrationCodes
1867 $query =
"SELECT obj_id FROM crs_settings ".
1868 "WHERE reg_ac_enabled = ".$ilDB->quote(1,
'integer').
" ".
1869 "AND reg_ac = ".$ilDB->quote($a_code,
'text');
1875 $obj_ids[] =
$row->obj_id;
1888 include_once
'./Services/Membership/exceptions/class.ilMembershipRegistrationException.php';
1889 include_once
"./Modules/Course/classes/class.ilCourseParticipants.php";
1892 if($part->isAssigned($a_user_id))
1897 if(!$a_force_registration)
1900 if(!self::_registrationEnabled($this->
getId()))
1902 $this->lng->loadLanguageModule(
'crs');
1909 include_once(
'./Modules/Course/classes/class.ilCourseWaitingList.php');
1918 $part->add($a_user_id,$a_role);
1919 $part->sendNotification($part->NOTIFY_ACCEPT_USER, $a_user_id);