33 require_once
"./Services/Container/classes/class.ilContainer.php";
35 define(
'IL_CRS_ACTIVATION_OFFLINE',0);
36 define(
'IL_CRS_ACTIVATION_UNLIMITED',1);
37 define(
'IL_CRS_ACTIVATION_LIMITED',2);
39 define(
'IL_CRS_SUBSCRIPTION_DEACTIVATED',0);
40 define(
'IL_CRS_SUBSCRIPTION_UNLIMITED',1);
41 define(
'IL_CRS_SUBSCRIPTION_LIMITED',2);
43 define(
'IL_CRS_SUBSCRIPTION_CONFIRMATION',2);
44 define(
'IL_CRS_SUBSCRIPTION_DIRECT',3);
45 define(
'IL_CRS_SUBSCRIPTION_PASSWORD',4);
47 define(
'IL_CRS_VIEW_SESSIONS', 0);
48 define(
'IL_CRS_VIEW_OBJECTIVE', 1);
49 define(
'IL_CRS_VIEW_TIMING', 2);
50 define(
'IL_CRS_VIEW_ARCHIVE', 3);
51 define(
'IL_CRS_VIEW_SIMPLE', 4);
52 define(
'IL_CRS_VIEW_BY_TYPE', 5);
54 define(
'IL_CRS_ARCHIVE_DOWNLOAD',3);
55 define(
'IL_CRS_ARCHIVE_NONE',0);
77 #define("ILIAS_MODULE","course");
78 #define("KEEP_IMAGE_PATH",1);
80 $this->SUBSCRIPTION_DEACTIVATED = 1;
81 $this->SUBSCRIPTION_CONFIRMATION = 2;
82 $this->SUBSCRIPTION_DIRECT = 3;
83 $this->SUBSCRIPTION_PASSWORD = 4;
84 $this->SUBSCRIPTION_AUTOSUBSCRIPTION = 5;
85 $this->ARCHIVE_DISABLED = 1;
86 $this->ARCHIVE_READ = 2;
87 $this->ARCHIVE_DOWNLOAD = 3;
88 $this->ABO_ENABLED = 1;
89 $this->ABO_DISABLED = 0;
90 $this->SHOW_MEMBERS_ENABLED = 1;
91 $this->SHOW_MEMBERS_DISABLED = 0;
95 parent::__construct($a_id,$a_call_by_reference);
99 #$this->__initMetaObject();
110 return $this->important;
114 $this->important = $a_info;
118 return $this->syllabus;
122 $this->syllabus = $a_syllabus;
126 return $this->contact_name;
130 $this->contact_name = $a_cn;
134 return $this->contact_consultation;
138 $this->contact_consultation = $a_value;
142 return $this->contact_phone;
146 $this->contact_phone = $a_value;
150 return $this->contact_email;
154 $this->contact_email = $a_value;
158 return $this->contact_responsibility;
162 $this->contact_responsibility = $a_value;
167 return (
int) $this->activation_type;
171 $this->activation_type = $a_type;
181 return $this->activation_start ? $this->activation_start : time();
185 $this->activation_start = $a_value;
189 return $this->activation_end ? $this->activation_end : mktime(0,0,0,12,12,date(
"Y",time())+2);
193 $this->activation_end = $a_value;
203 return $this->subscription_limitation_type;
207 $this->subscription_limitation_type = $a_type;
215 return $this->subscription_start ? $this->subscription_start : time();
219 $this->subscription_start = $a_value;
223 return $this->subscription_end ? $this->subscription_end : mktime(0,0,0,12,12,date(
"Y",time())+2);
227 $this->subscription_end = $a_value;
232 #return $this->subscription_type ? $this->subscription_type : $this->SUBSCRIPTION_DEACTIVATED;
236 $this->subscription_type = $a_value;
240 return $this->subscription_password;
244 $this->subscription_password = $a_value;
253 return (
bool) $this->waiting_list;
258 $this->waiting_list = (bool) $a_status;
283 $this->subscription_membership_limitation = $a_status;
295 return (
bool) $this->subscription_membership_limitation;
300 return $this->subscription_max_members;
304 $this->subscription_max_members = $a_value;
319 $query =
"SELECT * FROM crs_settings ".
320 "WHERE obj_id = ".$ilDB->quote($a_course_id).
" ".
321 "AND subscription_notify = 1";
322 $res = $ilDB->query($query);
323 return $res->numRows() ?
true :
false;
329 return $this->subscription_notify ?
true :
false;
333 $this->subscription_notify = $a_value ?
true :
false;
338 $this->view_mode = $a_mode;
342 return $this->view_mode;
349 $query =
"SELECT view_mode FROM crs_settings WHERE obj_id = ".$ilDB->quote($a_id).
" ";
350 $res = $ilDB->query($query);
353 return $row->view_mode;
362 $query =
"SELECT abo FROM crs_settings WHERE obj_id = ".$ilDB->quote($a_id).
" ";
363 $res = $ilDB->query($query);
373 return $this->archive_start ? $this->archive_start : time();
377 $this->archive_start = $a_value;
381 return $this->archive_end ? $this->archive_end : mktime(0,0,0,12,12,date(
"Y",time())+2);
385 $this->archive_end = $a_value;
393 $this->archive_type = $a_value;
397 $this->abo = $a_status;
405 $this->show_members = $a_status;
409 return $this->show_members;
414 return $this->message;
418 $this->message = $a_message;
424 $this->message .=
"<br /> ";
426 $this->message .= $a_message;
431 return $this->members_obj->getMembers();
470 $query =
"SELECT * FROM crs_settings ".
471 "WHERE obj_id = ".$ilDB->quote($a_obj_id).
" ";
473 $res = $ilDB->query($query);
476 $type = $row->activation_type;
477 $start = $row->activation_start;
478 $end = $row->activation_end;
489 if(time() < $start or
505 $query =
"SELECT * FROM crs_settings ".
506 "WHERE obj_id = ".$ilDB->quote($a_obj_id).
" ";
508 $res = $ilDB->query($query);
511 $type = $row->subscription_limitation_type;
512 $reg_start = $row->subscription_start;
513 $reg_end = $row->subscription_end;
525 if(time() > $reg_start and
551 return $this->ABO == $this->ABO_ENABLED;
554 function read($a_force_db =
false)
562 global $ilAppEventHandler;
572 $ilAppEventHandler->raise(
'Modules/Course',
574 array(
'object' => $this,
575 'obj_id' => $this->
getId(),
587 $this->latitude = $a_latitude;
597 return $this->latitude;
607 $this->longitude = $a_longitude;
617 return $this->longitude;
627 $this->locationzoom = $a_locationzoom;
637 return $this->locationzoom;
647 $this->enablemap = $a_enablemap;
657 return $this->enablemap;
670 global $ilDB,$ilUser;
678 $new_obj->initCourseMemberObject();
679 $new_obj->members_obj->add($ilUser->getId(),
IL_CRS_ADMIN);
685 include_once(
'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
689 include_once(
'Modules/Course/classes/class.ilCourseFile.php');
693 include_once(
'Services/Tracking/classes/class.ilLPObjSettings.php');
695 $obj_settings->cloneSettings($new_obj->getId());
696 unset($obj_settings);
700 $ilLog->write(__METHOD__.
': '.$this->getBigIconPath().
' '.$this->
getSmallIconPath());
718 global $ilObjDataCache;
723 include_once(
'Modules/Course/classes/class.ilCourseStart.php');
725 $start->cloneDependencies($a_target_id,$a_copy_id);
729 $this->items_obj->cloneDependencies($a_target_id,$a_copy_id);
732 include_once(
'Modules/Course/classes/class.ilCourseObjective.php');
734 $crs_objective->ilClone($a_target_id,$a_copy_id);
736 include_once(
'Services/Tracking/classes/class.ilLPCollections.php');
738 $lp_collection->cloneCollections($a_target_id,$a_copy_id);
752 global
$ilLog,$rbacadmin,$rbacreview;
755 $new_admin = $new_obj->getDefaultAdminRole();
756 $source_rolf = $rbacreview->getRoleFolderIdOfObject($this->
getRefId());
757 $target_rolf = $rbacreview->getRoleFolderIdOfObject($new_obj->getRefId());
759 if(!$admin || !$new_admin || !$source_rolf || !$target_rolf)
761 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_crs_admin');
763 $rbacadmin->copyRolePermissions($admin,$source_rolf,$target_rolf,$new_admin,
true);
764 $ilLog->write(__METHOD__.
' : Finished copying of role crs_admin.');
767 $new_tutor = $new_obj->getDefaultTutorRole();
768 if(!$tutor || !$new_tutor)
770 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_crs_tutor');
772 $rbacadmin->copyRolePermissions($tutor,$source_rolf,$target_rolf,$new_tutor,
true);
773 $ilLog->write(__METHOD__.
' : Finished copying of role crs_tutor.');
776 $new_member = $new_obj->getDefaultMemberRole();
777 if(!$member || !$new_member)
779 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_crs_member');
781 $rbacadmin->copyRolePermissions($member,$source_rolf,$target_rolf,$new_member,
true);
782 $ilLog->write(__METHOD__.
' : Finished copying of role crs_member.');
794 #if(($this->getSubscriptionLimitationType() != IL_CRS_SUBSCRIPTION_DEACTIVATED) and
795 # $this->getSubscriptionType() == )
797 # $this->appendMessage($this->lng->txt('crs_select_registration_type'));
803 $this->
appendMessage($this->lng->txt(
"activation_times_not_valid"));
808 $this->
appendMessage($this->lng->txt(
"subscription_times_not_valid"));
810 #if((!$this->getActivationUnlimitedStatus() and
811 # !$this->getSubscriptionUnlimitedStatus()) and
812 # ($this->getSubscriptionStart() > $this->getActivationEnd() or
813 # $this->getSubscriptionStart() < $this->getActivationStart() or
814 # $this->getSubscriptionEnd() > $this->getActivationEnd() or
815 # $this->getSubscriptionEnd() < $this->getActivationStart()))
818 # $this->appendMessage($this->lng->txt("subscription_time_not_within_activation"));
822 $this->
appendMessage($this->lng->txt(
"crs_password_required"));
826 $this->
appendMessage($this->lng->txt(
"max_members_not_numeric"));
831 $this->
appendMessage($this->lng->txt(
"archive_times_not_valid"));
843 foreach ($emails as $email) {
844 $email = trim($email);
847 $ilErr->appendMessage($this->lng->txt(
'contact_email_not_valid').
" '".$email.
"'");
873 global $ilAppEventHandler;
876 if (!parent::delete())
889 $this->items_obj->deleteAllEntries();
891 include_once(
'Modules/Course/classes/class.ilCourseParticipants.php');
895 $this->archives_obj->deleteAll();
897 include_once
'./Modules/Course/classes/class.ilCourseObjective.php';
900 include_once
'./Modules/Course/classes/class.ilObjCourseGrouping.php';
903 include_once
'./Modules/Course/classes/class.ilCourseFile.php';
906 include_once(
'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
909 $ilAppEventHandler->raise(
'Modules/Course',
911 array(
'object' => $this,
912 'obj_id' => $this->
getId(),
926 global $ilAppEventHandler;
928 include_once(
'./Services/Container/classes/class.ilContainerSortingSettings.php');
937 $ilAppEventHandler->raise(
'Modules/Course',
939 array(
'object' => $this,
940 'obj_id' => $this->
getId(),
951 $query =
"SELECT * FROM crs_settings WHERE obj_id = ".$ilDB->quote($this->
getId()).
" ";
952 $res = $ilDB->query($query);
959 $query =
"UPDATE crs_settings SET ".
960 "syllabus = ".$ilDB->quote($this->
getSyllabus()).
", ".
967 #"activation_unlimited = '".(int) $this->getActivationUnlimitedStatus()."', ".
970 #"activation_offline = '".(int) $this->getOfflineStatus()."', ".
972 #"subscription_unlimited = '".(int) $this->getSubscriptionUnlimitedStatus()."', ".
980 "view_mode = ".$ilDB->quote($this->
getViewMode()).
", ".
985 #"objective_view = '".(int) $this->enabledObjectiveView()."', ".
989 "latitude = ".$ilDB->quote($this->
getLatitude()).
", ".
990 "longitude = ".$ilDB->quote($this->
getLongitude()).
", ".
993 "WHERE obj_id = ".$ilDB->quote($this->
getId()).
"";
995 $res = $ilDB->query($query);
1040 $query =
"INSERT INTO crs_settings SET ".
1041 "obj_id = ".$ilDB->quote($this->
getId()).
", ".
1042 "syllabus = ".$ilDB->quote($this->
getSyllabus()).
", ".
1049 #"activation_unlimited = '1', ".
1052 #"activation_offline = '1', ".
1054 #"subscription_unlimited = '1', ".
1059 "subscription_membership_limitation = ".$ilDB->quote(0).
", ".
1061 "subscription_notify = '1', ".
1062 "view_mode = '0', ".
1066 "abo = ".$ilDB->quote($this->ABO_ENABLED).
", ".
1067 "latitude = ".$ilDB->quote($this->
getLatitude()).
", ".
1068 "longitude = ".$ilDB->quote($this->
getLongitude()).
", ".
1071 #"objective_view = '0', ".
1072 "waiting_list = '1', ".
1073 "show_members = '1'";
1076 $res = $ilDB->query($query);
1079 include_once(
'./Services/Container/classes/class.ilContainerSortingSettings.php');
1090 $query =
"SELECT * FROM crs_settings WHERE obj_id = ".$ilDB->quote($this->
getId()).
"";
1092 $res = $ilDB->query($query);
1102 #$this->setActivationUnlimitedStatus($row->activation_unlimited);
1105 #$this->setOfflineStatus($row->activation_offline);
1107 #$this->setSubscriptionUnlimitedStatus($row->subscription_unlimited);
1133 include_once
"./Modules/Course/classes/class.ilCourseWaitingList.php";
1135 if(!is_object($this->waiting_list_obj))
1145 include_once
"./Modules/Course/classes/class.ilCourseParticipants.php";
1152 include_once
"./Modules/Course/classes/class.ilCourseItems.php";
1154 if(!is_object($this->items_obj))
1170 if(is_object($this->items_obj))
1181 include_once
"./Modules/Course/classes/class.ilCourseArchives.php";
1183 if(!is_object($this->archives_obj))
1195 global $rbacadmin,$rbacreview,$ilDB;
1200 $role_obj = $rolf_obj->createRole(
"il_crs_admin_".$this->
getRefId(),
"Admin of course obj_no.".$this->
getId());
1201 $admin_id = $role_obj->getId();
1204 $query =
"SELECT obj_id FROM object_data ".
1205 " WHERE type='rolt' AND title='il_crs_admin'";
1208 $rbacadmin->copyRoleTemplatePermissions(
$res->obj_id,ROLE_FOLDER_ID,$rolf_obj->getRefId(),$role_obj->getId());
1211 $ops = $rbacreview->getOperationsOfRole($role_obj->getId(),
"crs",$rolf_obj->getRefId());
1212 $rbacadmin->grantPermission($role_obj->getId(),$ops,$this->
getRefId());
1220 $role_obj = $rolf_obj->createRole(
"il_crs_tutor_".$this->
getRefId(),
"Tutors of course obj_no.".$this->
getId());
1221 $member_id = $role_obj->getId();
1224 $query =
"SELECT obj_id FROM object_data ".
1225 " WHERE type='rolt' AND title='il_crs_tutor'";
1227 $rbacadmin->copyRoleTemplatePermissions(
$res->obj_id,ROLE_FOLDER_ID,$rolf_obj->getRefId(),$role_obj->getId());
1230 $ops = $rbacreview->getOperationsOfRole($role_obj->getId(),
"crs",$rolf_obj->getRefId());
1231 $rbacadmin->grantPermission($role_obj->getId(),$ops,$this->
getRefId());
1239 $role_obj = $rolf_obj->createRole(
"il_crs_member_".$this->
getRefId(),
"Member of course obj_no.".$this->
getId());
1240 $member_id = $role_obj->getId();
1243 $query =
"SELECT obj_id FROM object_data ".
1244 " WHERE type='rolt' AND title='il_crs_member'";
1246 $rbacadmin->copyRoleTemplatePermissions(
$res->obj_id,ROLE_FOLDER_ID,$rolf_obj->getRefId(),$role_obj->getId());
1249 $ops = $rbacreview->getOperationsOfRole($role_obj->getId(),
"crs",$rolf_obj->getRefId());
1250 $rbacadmin->grantPermission($role_obj->getId(),$ops,$this->
getRefId());
1284 global $rbacadmin, $rbacreview, $rbacsystem;
1287 $rolf_data = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1290 $arr_parentRoles = $rbacreview->getParentRoleIds($this->
getRefId());
1291 $arr_relevantParentRoleIds = array_diff(array_keys($arr_parentRoles),$this->
getDefaultCourseRoles());
1296 if (is_null($template_id))
1298 $template_ops = array();
1300 $template_ops = $rbacreview->getOperationsOfRole($template_id,
'crs', ROLE_FOLDER_ID);
1303 foreach ($arr_relevantParentRoleIds as $parentRole)
1305 if ($rbacreview->isProtected($arr_parentRoles[$parentRole][
'parent'],$parentRole))
1310 $granted_permissions = array();
1314 $rbacadmin->deleteLocalRole($parentRole,$rolf_data[
"child"]);
1321 $current_ops = $rbacreview->getRoleOperationsOnObject($parentRole, $this->
getRefId());
1322 $rbacadmin->revokePermission($this->
getRefId(), $parentRole);
1323 foreach ($template_ops as $template_op)
1325 if (in_array($template_op,$current_ops))
1327 array_push($granted_permissions,$template_op);
1330 if (!empty($granted_permissions))
1332 $rbacadmin->grantPermission($parentRole, $granted_permissions, $this->
getRefId());
1339 if (! is_null($template_id))
1341 $rbacadmin->copyRolePermissionIntersection(
1342 $template_id, ROLE_FOLDER_ID,
1343 $parentRole, $arr_parentRoles[$parentRole][
'parent'],
1344 $rolf_data[
"child"], $parentRole
1347 $rbacadmin->assignRoleToFolder($parentRole,$rolf_data[
"child"],
"false");
1361 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_crs_non_member'";
1362 $res = $this->ilias->db->query($q);
1365 return $row[
"obj_id"];
1376 global $rbacadmin,$rbacreview;
1378 if (empty($this->local_roles))
1380 $this->local_roles = array();
1381 $rolf = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1382 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"]);
1384 foreach ($role_arr as $role_id)
1386 if ($rbacreview->isAssignable($role_id,$rolf[
"ref_id"]) ==
true)
1388 $role_Obj = $this->ilias->obj_factory->getInstanceByObjId($role_id);
1396 $role_name = $role_Obj->getTitle();
1398 $this->local_roles[$role_name] = $role_Obj->getId();
1403 return $this->local_roles;
1419 global $rbacadmin, $rbacreview;
1421 if (strlen($a_crs_id) > 0)
1423 $crs_id = $a_crs_id;
1430 $rolf = $rbacreview->getRoleFolderOfObject($crs_id);
1431 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"]);
1433 foreach ($role_arr as $role_id)
1435 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1437 $crs_Member =
"il_crs_member_".$crs_id;
1438 $crs_Admin =
"il_crs_admin_".$crs_id;
1439 $crs_Tutor =
"il_crs_tutor_".$crs_id;
1441 if (strcmp($role_Obj->getTitle(), $crs_Member) == 0 )
1443 $arr_crsDefaultRoles[
"crs_member_role"] = $role_Obj->getId();
1446 if (strcmp($role_Obj->getTitle(), $crs_Admin) == 0)
1448 $arr_crsDefaultRoles[
"crs_admin_role"] = $role_Obj->getId();
1451 if (strcmp($role_Obj->getTitle(), $crs_Tutor) == 0)
1453 $arr_crsDefaultRoles[
"crs_tutor_role"] = $role_Obj->getId();
1457 return $arr_crsDefaultRoles;
1466 $rolf = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1468 return $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
1475 $query =
"DELETE FROM crs_settings ".
1476 "WHERE obj_id = ".$ilDB->quote($this->
getId()).
" ";
1478 $this->ilias->db->query($query);
1487 foreach($local_roles as $role_id)
1491 if(!strcmp($tmp_role->getTitle(),
"il_crs_member_".$this->getRefId()))
1503 foreach($local_roles as $role_id)
1507 if(!strcmp($tmp_role->getTitle(),
"il_crs_tutor_".$this->getRefId()))
1519 foreach($local_roles as $role_id)
1523 if(!strcmp($tmp_role->getTitle(),
"il_crs_admin_".$this->getRefId()))
1537 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
1539 include_once
"./Modules/Course/classes/class.ilCourseParticipants.php";
1555 include_once
'./Modules/Course/classes/class.ilCourseLMHistory.php';
1558 include_once
'./Modules/Course/classes/class.ilCourseParticipants.php';
1562 include_once
'./Modules/Course/classes/class.ilCourseObjectiveResult.php';
1579 include_once(
'./Services/WebServices/ECS/classes/class.ilECSContentWriter.php');
1582 $writer->setExportable($a_export);
1583 $writer->setOwnerId($a_owner);
1584 $writer->setParticipantIds((array) $a_mids);
1630 include_once(
'./Services/WebServices/ECS/classes/class.ilECSSettings.php');
1632 if(!$settings->isEnabled())
1639 include_once(
'./Services/WebServices/ECS/classes/class.ilECSContentWriter.php');
1641 $writer->refreshSettings();
1645 $ilLog->write(__METHOD__.
': Cannot save ECS settings. '.$exc->getMessage());
1659 $ilBench->start(
"Course",
"initCourseItemObject");
1661 $ilBench->stop(
"Course",
"initCourseItemObject");
1663 $ilBench->start(
"Course",
"addAdditionalSubItemInformation");
1664 $this->items_obj->addAdditionalSubItemInformation($a_item_data);
1665 $ilBench->stop(
"Course",
"addAdditionalSubItemInformation");
1677 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentTemplate.php');
1678 include_once(
'./Services/Calendar/classes/class.ilDateTime.php');
1688 $app->setSubtitle(
'crs_cal_activation_start');
1696 $app->setSubtitle(
'crs_cal_activation_end');
1706 $app->setSubtitle(
'crs_cal_reg_start');
1714 $app->setSubtitle(
'crs_cal_reg_end');
1721 return $apps ? $apps : array();