24 require_once
"./Services/Container/classes/class.ilContainer.php";
25 include_once
'./Modules/Course/classes/class.ilCourseConstants.php';
64 #define("ILIAS_MODULE","course");
65 #define("KEEP_IMAGE_PATH",1);
67 $this->SUBSCRIPTION_DEACTIVATED = 1;
68 $this->SUBSCRIPTION_CONFIRMATION = 2;
69 $this->SUBSCRIPTION_DIRECT = 3;
70 $this->SUBSCRIPTION_PASSWORD = 4;
71 $this->SUBSCRIPTION_AUTOSUBSCRIPTION = 5;
72 $this->ARCHIVE_DISABLED = 1;
73 $this->ARCHIVE_READ = 2;
74 $this->ARCHIVE_DOWNLOAD = 3;
75 $this->ABO_ENABLED = 1;
76 $this->ABO_DISABLED = 0;
77 $this->SHOW_MEMBERS_ENABLED = 1;
78 $this->SHOW_MEMBERS_DISABLED = 0;
82 parent::__construct($a_id,$a_call_by_reference);
86 #$this->__initMetaObject();
97 return $this->important;
101 $this->important = $a_info;
105 return $this->syllabus;
109 $this->syllabus = $a_syllabus;
113 return $this->contact_name;
117 $this->contact_name = $a_cn;
121 return $this->contact_consultation;
125 $this->contact_consultation = $a_value;
129 return $this->contact_phone;
133 $this->contact_phone = $a_value;
137 return $this->contact_email;
141 $this->contact_email = $a_value;
145 return $this->contact_responsibility;
149 $this->contact_responsibility = $a_value;
154 return (
int) $this->activation_type;
158 $this->activation_type = $a_type;
168 return $this->activation_start ? $this->activation_start : time();
172 $this->activation_start = $a_value;
176 return $this->activation_end ? $this->activation_end : mktime(0,0,0,12,12,date(
"Y",time())+2);
180 $this->activation_end = $a_value;
190 return $this->subscription_limitation_type;
194 $this->subscription_limitation_type = $a_type;
202 return $this->subscription_start ? $this->subscription_start : time();
206 $this->subscription_start = $a_value;
210 return $this->subscription_end ? $this->subscription_end : mktime(0,0,0,12,12,date(
"Y",time())+2);
214 $this->subscription_end = $a_value;
219 #return $this->subscription_type ? $this->subscription_type : $this->SUBSCRIPTION_DEACTIVATED;
223 $this->subscription_type = $a_value;
227 return $this->subscription_password;
231 $this->subscription_password = $a_value;
240 return (
bool) $this->waiting_list;
245 $this->waiting_list = (bool) $a_status;
268 $this->session_limit = $a_status;
285 $this->subscription_membership_limitation = $a_status;
295 $this->session_prev = $a_num;
314 $this->session_next = $a_num;
334 return (
bool) $this->subscription_membership_limitation;
339 return $this->subscription_max_members;
343 $this->subscription_max_members = $a_value;
358 $query =
"SELECT * FROM crs_settings ".
359 "WHERE obj_id = ".$ilDB->quote($a_course_id ,
'integer').
" ".
360 "AND sub_notify = 1";
362 return $res->numRows() ?
true :
false;
371 public function getSubItems($a_admin_panel_enabled =
false, $a_include_side_block =
false)
374 if (is_array($this->items[(
int) $a_admin_panel_enabled][(
int) $a_include_side_block]))
376 return $this->items[(int) $a_admin_panel_enabled][(
int) $a_include_side_block];
383 if(!is_array($this->items[
'sess']) or !$this->items[
'sess'])
385 return $this->items[(int) $a_admin_panel_enabled][(
int) $a_include_side_block];
390 return $this->items[(int) $a_admin_panel_enabled][(
int) $a_include_side_block];
399 foreach($sessions as
$key => $item)
401 if($item[
'start'] >= $today)
408 $previous = $sessions;
412 $previous = array_slice($previous, 0, $num);
418 array_splice($previous, 0, $to_remove);
422 $next = array_slice($next, $num);
428 $sessions = array_merge($previous,$next);
429 $this->items[
'sess'] = $sessions;
430 $this->items[(int) $a_admin_panel_enabled][(
int) $a_include_side_block] = $this->items;
431 return $this->items[(int) $a_admin_panel_enabled][(
int) $a_include_side_block];
437 return $this->subscription_notify ?
true :
false;
441 $this->subscription_notify = $a_value ?
true :
false;
446 $this->view_mode = $a_mode;
450 return $this->view_mode;
457 $query =
"SELECT view_mode FROM crs_settings WHERE obj_id = ".$ilDB->quote($a_id ,
'integer').
" ";
461 return $row->view_mode;
470 $query =
"SELECT abo FROM crs_settings WHERE obj_id = ".$ilDB->quote($a_id ,
'integer').
" ";
481 return $this->archive_start ? $this->archive_start : time();
485 $this->archive_start = $a_value;
489 return $this->archive_end ? $this->archive_end : mktime(0,0,0,12,12,date(
"Y",time())+2);
493 $this->archive_end = $a_value;
501 $this->archive_type = $a_value;
505 $this->abo = $a_status;
513 $this->show_members = $a_status;
517 return $this->show_members;
522 return $this->message;
526 $this->message = $a_message;
532 $this->message .=
"<br /> ";
534 $this->message .= $a_message;
539 return $this->members_obj->getMembers();
576 include_once(
"./Modules/Course/classes/class.ilObjCourseAccess.php");
588 include_once(
"./Modules/Course/classes/class.ilObjCourseAccess.php");
607 return $this->ABO == $this->ABO_ENABLED;
610 function read($a_force_db =
false)
618 global $ilAppEventHandler;
628 $ilAppEventHandler->raise(
'Modules/Course',
630 array(
'object' => $this,
631 'obj_id' => $this->
getId(),
643 $this->latitude = $a_latitude;
663 $this->longitude = $a_longitude;
683 $this->locationzoom = $a_locationzoom;
703 $this->enablemap = $a_enablemap;
726 global
$ilDB,$ilUser;
734 $new_obj->initCourseMemberObject();
735 $new_obj->members_obj->add($ilUser->getId(),
IL_CRS_ADMIN);
741 include_once(
'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
745 include_once(
'Modules/Course/classes/class.ilCourseFile.php');
749 include_once(
'Services/Tracking/classes/class.ilLPObjSettings.php');
751 $obj_settings->cloneSettings($new_obj->getId());
752 unset($obj_settings);
756 $ilLog->write(__METHOD__.
': '.$this->getBigIconPath().
' '.$this->
getSmallIconPath());
774 global $ilObjDataCache;
779 include_once(
'Modules/Course/classes/class.ilCourseStart.php');
781 $start->cloneDependencies($a_target_id,$a_copy_id);
785 $this->items_obj->cloneDependencies($a_target_id,$a_copy_id);
788 include_once(
'Modules/Course/classes/class.ilCourseObjective.php');
790 $crs_objective->ilClone($a_target_id,$a_copy_id);
792 include_once(
'Services/Tracking/classes/class.ilLPCollections.php');
794 $lp_collection->cloneCollections($a_target_id,$a_copy_id);
808 global
$ilLog,$rbacadmin,$rbacreview;
811 $new_admin = $new_obj->getDefaultAdminRole();
812 $source_rolf = $rbacreview->getRoleFolderIdOfObject($this->
getRefId());
813 $target_rolf = $rbacreview->getRoleFolderIdOfObject($new_obj->getRefId());
815 if(!$admin || !$new_admin || !$source_rolf || !$target_rolf)
817 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_crs_admin');
819 $rbacadmin->copyRolePermissions($admin,$source_rolf,$target_rolf,$new_admin,
true);
820 $ilLog->write(__METHOD__.
' : Finished copying of role crs_admin.');
823 $new_tutor = $new_obj->getDefaultTutorRole();
824 if(!$tutor || !$new_tutor)
826 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_crs_tutor');
828 $rbacadmin->copyRolePermissions($tutor,$source_rolf,$target_rolf,$new_tutor,
true);
829 $ilLog->write(__METHOD__.
' : Finished copying of role crs_tutor.');
832 $new_member = $new_obj->getDefaultMemberRole();
833 if(!$member || !$new_member)
835 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_crs_member');
837 $rbacadmin->copyRolePermissions($member,$source_rolf,$target_rolf,$new_member,
true);
838 $ilLog->write(__METHOD__.
' : Finished copying of role crs_member.');
850 #if(($this->getSubscriptionLimitationType() != IL_CRS_SUBSCRIPTION_DEACTIVATED) and
851 # $this->getSubscriptionType() == )
853 # $this->appendMessage($this->lng->txt('crs_select_registration_type'));
859 $this->
appendMessage($this->lng->txt(
"activation_times_not_valid"));
864 $this->
appendMessage($this->lng->txt(
"subscription_times_not_valid"));
866 #if((!$this->getActivationUnlimitedStatus() and
867 # !$this->getSubscriptionUnlimitedStatus()) and
868 # ($this->getSubscriptionStart() > $this->getActivationEnd() or
869 # $this->getSubscriptionStart() < $this->getActivationStart() or
870 # $this->getSubscriptionEnd() > $this->getActivationEnd() or
871 # $this->getSubscriptionEnd() < $this->getActivationStart()))
874 # $this->appendMessage($this->lng->txt("subscription_time_not_within_activation"));
878 $this->
appendMessage($this->lng->txt(
"crs_password_required"));
882 $this->
appendMessage($this->lng->txt(
"max_members_not_numeric"));
887 $this->
appendMessage($this->lng->txt(
"archive_times_not_valid"));
899 foreach ($emails as $email) {
900 $email = trim($email);
903 $ilErr->appendMessage($this->lng->txt(
'contact_email_not_valid').
" '".$email.
"'");
929 global $ilAppEventHandler;
932 if (!parent::delete())
945 $this->items_obj->deleteAllEntries();
947 include_once(
'Modules/Course/classes/class.ilCourseParticipants.php');
951 $this->archives_obj->deleteAll();
953 include_once
'./Modules/Course/classes/class.ilCourseObjective.php';
956 include_once
'./Modules/Course/classes/class.ilObjCourseGrouping.php';
959 include_once
'./Modules/Course/classes/class.ilCourseFile.php';
962 include_once(
'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
965 $ilAppEventHandler->raise(
'Modules/Course',
967 array(
'object' => $this,
968 'obj_id' => $this->
getId(),
982 global $ilAppEventHandler,
$ilLog;
984 include_once(
'./Services/Container/classes/class.ilContainerSortingSettings.php');
993 $ilAppEventHandler->raise(
'Modules/Course',
995 array(
'object' => $this,
996 'obj_id' => $this->
getId(),
1007 $query =
"SELECT * FROM crs_settings WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer').
" ";
1010 if(!
$res->numRows())
1015 $query =
"UPDATE crs_settings SET ".
1016 "syllabus = ".$ilDB->quote($this->
getSyllabus() ,
'text').
", ".
1017 "contact_name = ".$ilDB->quote($this->
getContactName() ,
'text').
", ".
1019 "contact_phone = ".$ilDB->quote($this->
getContactPhone() ,
'text').
", ".
1020 "contact_email = ".$ilDB->quote($this->
getContactEmail() ,
'text').
", ".
1024 "activation_end = ".$ilDB->quote($this->
getActivationEnd() ,
'integer').
", ".
1033 "view_mode = ".$ilDB->quote($this->
getViewMode() ,
'integer').
", ".
1034 "archive_start = ".$ilDB->quote($this->
getArchiveStart() ,
'integer').
", ".
1035 "archive_end = ".$ilDB->quote($this->
getArchiveEnd() ,
'integer').
", ".
1036 "archive_type = ".$ilDB->quote($this->
getArchiveType() ,
'integer').
", ".
1037 "abo = ".$ilDB->quote($this->
getAboStatus() ,
'integer').
", ".
1040 "show_members = ".$ilDB->quote($this->
getShowMembers() ,
'integer').
", ".
1041 "latitude = ".$ilDB->quote($this->
getLatitude() ,
'text').
", ".
1042 "longitude = ".$ilDB->quote($this->
getLongitude() ,
'text').
", ".
1043 "location_zoom = ".$ilDB->quote($this->
getLocationZoom() ,
'integer').
", ".
1044 "enable_course_map = ".$ilDB->quote((
int) $this->
getEnableCourseMap() ,
'integer').
", ".
1048 "WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer').
"";
1098 $query =
"INSERT INTO crs_settings (obj_id,syllabus,contact_name,contact_responsibility,".
1099 "contact_phone,contact_email,contact_consultation,activation_type,activation_start,".
1100 "activation_end,sub_limitation_type,sub_start,sub_end,sub_type,sub_password,sub_mem_limit,".
1101 "sub_max_members,sub_notify,view_mode,archive_start,archive_end,archive_type,abo," .
1102 "latitude,longitude,location_zoom,enable_course_map,waiting_list,show_members, ".
1103 "session_limit,session_prev,session_next ) ".
1105 $ilDB->quote($this->
getId() ,
'integer').
", ".
1127 $ilDB->quote($this->ABO_ENABLED ,
'integer').
", ".
1132 #"objective_view = '0', ".
1143 include_once(
'./Services/Container/classes/class.ilContainerSortingSettings.php');
1154 $query =
"SELECT * FROM crs_settings WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer').
"";
1197 include_once
"./Modules/Course/classes/class.ilCourseWaitingList.php";
1199 if(!is_object($this->waiting_list_obj))
1209 include_once
"./Modules/Course/classes/class.ilCourseParticipants.php";
1216 include_once
"./Modules/Course/classes/class.ilCourseItems.php";
1218 if(!is_object($this->items_obj))
1234 if(is_object($this->items_obj))
1245 include_once
"./Modules/Course/classes/class.ilCourseArchives.php";
1247 if(!is_object($this->archives_obj))
1259 global $rbacadmin,$rbacreview,
$ilDB;
1264 $role_obj = $rolf_obj->createRole(
"il_crs_admin_".$this->
getRefId(),
"Admin of course obj_no.".$this->
getId());
1265 $admin_id = $role_obj->getId();
1268 $query =
"SELECT obj_id FROM object_data ".
1269 " WHERE type='rolt' AND title='il_crs_admin'";
1272 $rbacadmin->copyRoleTemplatePermissions(
$res->obj_id,ROLE_FOLDER_ID,$rolf_obj->getRefId(),$role_obj->getId());
1275 $ops = $rbacreview->getOperationsOfRole($role_obj->getId(),
"crs",$rolf_obj->getRefId());
1276 $rbacadmin->grantPermission($role_obj->getId(),$ops,$this->
getRefId());
1284 $role_obj = $rolf_obj->createRole(
"il_crs_tutor_".$this->
getRefId(),
"Tutors of course obj_no.".$this->
getId());
1285 $member_id = $role_obj->getId();
1288 $query =
"SELECT obj_id FROM object_data ".
1289 " WHERE type='rolt' AND title='il_crs_tutor'";
1291 $rbacadmin->copyRoleTemplatePermissions(
$res->obj_id,ROLE_FOLDER_ID,$rolf_obj->getRefId(),$role_obj->getId());
1294 $ops = $rbacreview->getOperationsOfRole($role_obj->getId(),
"crs",$rolf_obj->getRefId());
1295 $rbacadmin->grantPermission($role_obj->getId(),$ops,$this->
getRefId());
1303 $role_obj = $rolf_obj->createRole(
"il_crs_member_".$this->
getRefId(),
"Member of course obj_no.".$this->
getId());
1304 $member_id = $role_obj->getId();
1307 $query =
"SELECT obj_id FROM object_data ".
1308 " WHERE type='rolt' AND title='il_crs_member'";
1310 $rbacadmin->copyRoleTemplatePermissions(
$res->obj_id,ROLE_FOLDER_ID,$rolf_obj->getRefId(),$role_obj->getId());
1313 $ops = $rbacreview->getOperationsOfRole($role_obj->getId(),
"crs",$rolf_obj->getRefId());
1314 $rbacadmin->grantPermission($role_obj->getId(),$ops,$this->
getRefId());
1348 global $rbacadmin, $rbacreview, $rbacsystem;
1351 $rolf_data = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1354 $arr_parentRoles = $rbacreview->getParentRoleIds($this->
getRefId());
1355 $arr_relevantParentRoleIds = array_diff(array_keys($arr_parentRoles),$this->
getDefaultCourseRoles());
1360 if (is_null($template_id))
1362 $template_ops = array();
1364 $template_ops = $rbacreview->getOperationsOfRole($template_id,
'crs', ROLE_FOLDER_ID);
1367 foreach ($arr_relevantParentRoleIds as $parentRole)
1369 if ($rbacreview->isProtected($arr_parentRoles[$parentRole][
'parent'],$parentRole))
1374 $granted_permissions = array();
1378 $rbacadmin->deleteLocalRole($parentRole,$rolf_data[
"child"]);
1385 $current_ops = $rbacreview->getRoleOperationsOnObject($parentRole, $this->
getRefId());
1386 $rbacadmin->revokePermission($this->
getRefId(), $parentRole);
1387 foreach ($template_ops as $template_op)
1389 if (in_array($template_op,$current_ops))
1391 array_push($granted_permissions,$template_op);
1394 if (!empty($granted_permissions))
1396 $rbacadmin->grantPermission($parentRole, $granted_permissions, $this->
getRefId());
1403 if (! is_null($template_id))
1405 $rbacadmin->copyRolePermissionIntersection(
1406 $template_id, ROLE_FOLDER_ID,
1407 $parentRole, $arr_parentRoles[$parentRole][
'parent'],
1408 $rolf_data[
"child"], $parentRole
1411 $rbacadmin->assignRoleToFolder($parentRole,$rolf_data[
"child"],
"false");
1425 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_crs_non_member'";
1426 $res = $this->ilias->db->query(
$q);
1429 return $row[
"obj_id"];
1440 global $rbacadmin,$rbacreview;
1442 if (empty($this->local_roles))
1444 $this->local_roles = array();
1445 $rolf = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1446 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"]);
1448 foreach ($role_arr as $role_id)
1450 if ($rbacreview->isAssignable($role_id,$rolf[
"ref_id"]) ==
true)
1452 $role_Obj = $this->ilias->obj_factory->getInstanceByObjId($role_id);
1460 $role_name = $role_Obj->getTitle();
1462 $this->local_roles[$role_name] = $role_Obj->getId();
1467 return $this->local_roles;
1483 global $rbacadmin, $rbacreview;
1485 if (strlen($a_crs_id) > 0)
1487 $crs_id = $a_crs_id;
1494 $rolf = $rbacreview->getRoleFolderOfObject($crs_id);
1495 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"]);
1497 foreach ($role_arr as $role_id)
1499 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1501 $crs_Member =
"il_crs_member_".$crs_id;
1502 $crs_Admin =
"il_crs_admin_".$crs_id;
1503 $crs_Tutor =
"il_crs_tutor_".$crs_id;
1505 if (strcmp($role_Obj->getTitle(), $crs_Member) == 0 )
1507 $arr_crsDefaultRoles[
"crs_member_role"] = $role_Obj->getId();
1510 if (strcmp($role_Obj->getTitle(), $crs_Admin) == 0)
1512 $arr_crsDefaultRoles[
"crs_admin_role"] = $role_Obj->getId();
1515 if (strcmp($role_Obj->getTitle(), $crs_Tutor) == 0)
1517 $arr_crsDefaultRoles[
"crs_tutor_role"] = $role_Obj->getId();
1521 return $arr_crsDefaultRoles;
1530 $rolf = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1532 return $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
1539 $query =
"DELETE FROM crs_settings ".
1540 "WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer').
" ";
1552 foreach($local_roles as $role_id)
1556 if(!strcmp($tmp_role->getTitle(),
"il_crs_member_".$this->getRefId()))
1568 foreach($local_roles as $role_id)
1572 if(!strcmp($tmp_role->getTitle(),
"il_crs_tutor_".$this->getRefId()))
1584 foreach($local_roles as $role_id)
1588 if(!strcmp($tmp_role->getTitle(),
"il_crs_admin_".$this->getRefId()))
1602 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
1604 include_once
"./Modules/Course/classes/class.ilCourseParticipants.php";
1620 include_once
'./Modules/Course/classes/class.ilCourseLMHistory.php';
1623 include_once
'./Modules/Course/classes/class.ilCourseParticipants.php';
1627 include_once
'./Modules/Course/classes/class.ilCourseObjectiveResult.php';
1644 include_once(
'./Services/WebServices/ECS/classes/class.ilECSContentWriter.php');
1647 $writer->setExportable($a_export);
1648 $writer->setOwnerId($a_owner);
1649 $writer->setParticipantIds((array) $a_mids);
1695 include_once(
'./Services/WebServices/ECS/classes/class.ilECSSettings.php');
1697 if(!$settings->isEnabled())
1704 include_once(
'./Services/WebServices/ECS/classes/class.ilECSContentWriter.php');
1706 $writer->refreshSettings();
1710 $ilLog->write(__METHOD__.
': Cannot save ECS settings. '.$exc->getMessage());
1724 $ilBench->start(
"Course",
"initCourseItemObject");
1726 $ilBench->stop(
"Course",
"initCourseItemObject");
1728 $ilBench->start(
"Course",
"addAdditionalSubItemInformation");
1729 $this->items_obj->addAdditionalSubItemInformation($a_item_data);
1730 $ilBench->stop(
"Course",
"addAdditionalSubItemInformation");
1742 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentTemplate.php');
1743 include_once(
'./Services/Calendar/classes/class.ilDateTime.php');
1753 $app->setSubtitle(
'crs_cal_activation_start');
1761 $app->setSubtitle(
'crs_cal_activation_end');
1771 $app->setSubtitle(
'crs_cal_reg_start');
1779 $app->setSubtitle(
'crs_cal_reg_end');
1786 return $apps ? $apps : array();