00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00033 require_once "./classes/class.ilContainer.php";
00034
00035 define('IL_CRS_ACTIVATION_OFFLINE',0);
00036 define('IL_CRS_ACTIVATION_UNLIMITED',1);
00037 define('IL_CRS_ACTIVATION_LIMITED',2);
00038
00039 define('IL_CRS_SUBSCRIPTION_DEACTIVATED',0);
00040 define('IL_CRS_SUBSCRIPTION_UNLIMITED',1);
00041 define('IL_CRS_SUBSCRIPTION_LIMITED',2);
00042
00043 define('IL_CRS_SUBSCRIPTION_CONFIRMATION',2);
00044 define('IL_CRS_SUBSCRIPTION_DIRECT',3);
00045 define('IL_CRS_SUBSCRIPTION_PASSWORD',4);
00046
00047 define('IL_CRS_VIEW_STANDARD',0);
00048 define('IL_CRS_VIEW_OBJECTIVE',1);
00049 define('IL_CRS_VIEW_TIMING',2);
00050 define('IL_CRS_VIEW_ARCHIVE',3);
00051
00052 define('IL_CRS_ARCHIVE_DOWNLOAD',3);
00053 define('IL_CRS_ARCHIVE_NONE',0);
00054
00055 define('IL_CRS_SORT_MANUAL',1);
00056 define('IL_CRS_SORT_TITLE',2);
00057 define('IL_CRS_SORT_ACTIVATION',3);
00058
00059 class ilObjCourse extends ilContainer
00060 {
00061 var $members_obj;
00062 var $archives_obj;
00063 var $items_obj;
00064
00071 function ilObjCourse($a_id = 0,$a_call_by_reference = true)
00072 {
00073 #define("ILIAS_MODULE","course");
00074 #define("KEEP_IMAGE_PATH",1);
00075
00076 $this->SUBSCRIPTION_DEACTIVATED = 1;
00077 $this->SUBSCRIPTION_CONFIRMATION = 2;
00078 $this->SUBSCRIPTION_DIRECT = 3;
00079 $this->SUBSCRIPTION_PASSWORD = 4;
00080 $this->SUBSCRIPTION_AUTOSUBSCRIPTION = 5;
00081 $this->SORT_MANUAL = 1;
00082 $this->SORT_TITLE = 2;
00083 $this->SORT_ACTIVATION = 3;
00084 $this->ARCHIVE_DISABLED = 1;
00085 $this->ARCHIVE_READ = 2;
00086 $this->ARCHIVE_DOWNLOAD = 3;
00087 $this->ABO_ENABLED = 1;
00088 $this->ABO_DISABLED = 0;
00089 $this->SHOW_MEMBERS_ENABLED = 1;
00090 $this->SHOW_MEMBERS_DISABLED = 0;
00091
00092 $this->type = "crs";
00093 $this->ilObject($a_id,$a_call_by_reference);
00094
00095 if($a_id)
00096 {
00097 #$this->__initMetaObject();
00098 $this->initCourseMemberObject();
00099 }
00100 else
00101 {
00102
00103 }
00104
00105 }
00106
00107 function getImportantInformation()
00108 {
00109 return $this->important;
00110 }
00111 function setImportantInformation($a_info)
00112 {
00113 $this->important = $a_info;
00114 }
00115 function getSyllabus()
00116 {
00117 return $this->syllabus;
00118 }
00119 function setSyllabus($a_syllabus)
00120 {
00121 $this->syllabus = $a_syllabus;
00122 }
00123 function getContactName()
00124 {
00125 return $this->contact_name;
00126 }
00127 function setContactName($a_cn)
00128 {
00129 $this->contact_name = $a_cn;
00130 }
00131 function getContactConsultation()
00132 {
00133 return $this->contact_consultation;
00134 }
00135 function setContactConsultation($a_value)
00136 {
00137 $this->contact_consultation = $a_value;
00138 }
00139 function getContactPhone()
00140 {
00141 return $this->contact_phone;
00142 }
00143 function setContactPhone($a_value)
00144 {
00145 $this->contact_phone = $a_value;
00146 }
00147 function getContactEmail()
00148 {
00149 return $this->contact_email;
00150 }
00151 function setContactEmail($a_value)
00152 {
00153 $this->contact_email = $a_value;
00154 }
00155 function getContactResponsibility()
00156 {
00157 return $this->contact_responsibility;
00158 }
00159 function setContactResponsibility($a_value)
00160 {
00161 $this->contact_responsibility = $a_value;
00162 }
00163
00164 function getActivationType()
00165 {
00166 return (int) $this->activation_type;
00167 }
00168 function setActivationType($a_type)
00169 {
00170 $this->activation_type = $a_type;
00171 }
00172 function getActivationUnlimitedStatus()
00173 {
00174 return $this->activation_type == IL_CRS_ACTIVATION_UNLIMITED;
00175
00176 }
00177 function getActivationStart()
00178 {
00179 return $this->activation_start ? $this->activation_start : time();
00180 }
00181 function setActivationStart($a_value)
00182 {
00183 $this->activation_start = $a_value;
00184 }
00185 function getActivationEnd()
00186 {
00187 return $this->activation_end ? $this->activation_end : mktime(0,0,0,12,12,date("Y",time())+2);
00188 }
00189 function setActivationEnd($a_value)
00190 {
00191 $this->activation_end = $a_value;
00192 }
00193 function getOfflineStatus()
00194 {
00195 return $this->activation_type == IL_CRS_ACTIVATION_OFFLINE;
00196 }
00197
00198
00199 function getSubscriptionLimitationType()
00200 {
00201 return $this->subscription_limitation_type;
00202 }
00203 function setSubscriptionLimitationType($a_type)
00204 {
00205 $this->subscription_limitation_type = $a_type;
00206 }
00207 function getSubscriptionUnlimitedStatus()
00208 {
00209 return $this->subscription_limitation_type == IL_CRS_SUBSCRIPTION_UNLIMITED;
00210 }
00211 function getSubscriptionStart()
00212 {
00213 return $this->subscription_start ? $this->subscription_start : time();
00214 }
00215 function setSubscriptionStart($a_value)
00216 {
00217 $this->subscription_start = $a_value;
00218 }
00219 function getSubscriptionEnd()
00220 {
00221 return $this->subscription_end ? $this->subscription_end : mktime(0,0,0,12,12,date("Y",time())+2);
00222 }
00223 function setSubscriptionEnd($a_value)
00224 {
00225 $this->subscription_end = $a_value;
00226 }
00227 function getSubscriptionType()
00228 {
00229 return $this->subscription_type ? $this->subscription_type : IL_CRS_SUBSCRIPTION_DIRECT;
00230 #return $this->subscription_type ? $this->subscription_type : $this->SUBSCRIPTION_DEACTIVATED;
00231 }
00232 function setSubscriptionType($a_value)
00233 {
00234 $this->subscription_type = $a_value;
00235 }
00236 function getSubscriptionPassword()
00237 {
00238 return $this->subscription_password;
00239 }
00240 function setSubscriptionPassword($a_value)
00241 {
00242 $this->subscription_password = $a_value;
00243 }
00244 function enabledObjectiveView()
00245 {
00246 return $this->view_mode == IL_CRS_VIEW_OBJECTIVE;
00247 }
00248
00249 function enabledWaitingList()
00250 {
00251 return (bool) $this->waiting_list;
00252 }
00253
00254 function enableWaitingList($a_status)
00255 {
00256 $this->waiting_list = (bool) $a_status;
00257 }
00258
00259 function inSubscriptionTime()
00260 {
00261 if($this->getSubscriptionUnlimitedStatus())
00262 {
00263 return true;
00264 }
00265 if(time() > $this->getSubscriptionStart() and time() < $this->getSubscriptionEnd())
00266 {
00267 return true;
00268 }
00269 return false;
00270 }
00271
00272 function getSubscriptionMaxMembers()
00273 {
00274 return $this->subscription_max_members;
00275 }
00276 function setSubscriptionMaxMembers($a_value)
00277 {
00278 $this->subscription_max_members = $a_value;
00279 }
00280
00289 public static function _isSubscriptionNotificationEnabled($a_course_id)
00290 {
00291 global $ilDB;
00292
00293 $query = "SELECT * FROM crs_settings ".
00294 "WHERE obj_id = ".$ilDB->quote($a_course_id)." ".
00295 "AND subscription_notify = 1";
00296 $res = $ilDB->query($query);
00297 return $res->numRows() ? true : false;
00298 }
00299
00300 function getSubscriptionNotify()
00301 {
00302 return $this->subscription_notify ? true : false;
00303 }
00304 function setSubscriptionNotify($a_value)
00305 {
00306 $this->subscription_notify = $a_value ? true : false;
00307 }
00308
00309 function setViewMode($a_mode)
00310 {
00311 $this->view_mode = $a_mode;
00312 }
00313 function getViewMode()
00314 {
00315 return $this->view_mode;
00316 }
00317
00318 function _lookupViewMode($a_id)
00319 {
00320 global $ilDB;
00321
00322 $query = "SELECT view_mode FROM crs_settings WHERE obj_id = ".$ilDB->quote($a_id)." ";
00323 $res = $ilDB->query($query);
00324 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00325 {
00326 return $row->view_mode;
00327 }
00328 return false;
00329 }
00330
00331
00332 function getOrderType()
00333 {
00334 return $this->order_type ? $this->order_type : IL_CRS_SORT_TITLE;
00335 }
00336 function setOrderType($a_value)
00337 {
00338 $this->order_type = $a_value;
00339 }
00340 function getArchiveStart()
00341 {
00342 return $this->archive_start ? $this->archive_start : time();
00343 }
00344 function setArchiveStart($a_value)
00345 {
00346 $this->archive_start = $a_value;
00347 }
00348 function getArchiveEnd()
00349 {
00350 return $this->archive_end ? $this->archive_end : mktime(0,0,0,12,12,date("Y",time())+2);
00351 }
00352 function setArchiveEnd($a_value)
00353 {
00354 $this->archive_end = $a_value;
00355 }
00356 function getArchiveType()
00357 {
00358 return $this->archive_type ? IL_CRS_ARCHIVE_DOWNLOAD : IL_CRS_ARCHIVE_NONE;
00359 }
00360 function setArchiveType($a_value)
00361 {
00362 $this->archive_type = $a_value;
00363 }
00364 function setAboStatus($a_status)
00365 {
00366 $this->abo = $a_status;
00367 }
00368 function getAboStatus()
00369 {
00370 return $this->abo;
00371 }
00372 function setShowMembers($a_status)
00373 {
00374 $this->show_members = $a_status;
00375 }
00376 function getShowMembers()
00377 {
00378 return $this->show_members;
00379 }
00380
00381 function getMessage()
00382 {
00383 return $this->message;
00384 }
00385 function setMessage($a_message)
00386 {
00387 $this->message = $a_message;
00388 }
00389 function appendMessage($a_message)
00390 {
00391 if($this->getMessage())
00392 {
00393 $this->message .= "<br /> ";
00394 }
00395 $this->message .= $a_message;
00396 }
00397
00398 function getMembers()
00399 {
00400 return $this->members_obj->getMembers();
00401 }
00402
00403
00404 function isActivated($a_check_archive = false)
00405 {
00406 if($a_check_archive)
00407 {
00408 if($this->isArchived())
00409 {
00410 return true;
00411 }
00412 }
00413 if($this->getOfflineStatus())
00414 {
00415 return false;
00416 }
00417 if($this->getActivationUnlimitedStatus())
00418 {
00419 return true;
00420 }
00421 if(time() < $this->getActivationStart() or
00422 time() > $this->getActivationEnd())
00423 {
00424 return false;
00425 }
00426 return true;
00427 }
00428
00435 function _isActivated($a_obj_id)
00436 {
00437 global $ilDB;
00438
00439 $query = "SELECT * FROM crs_settings ".
00440 "WHERE obj_id = ".$ilDB->quote($a_obj_id)." ";
00441
00442 $res = $ilDB->query($query);
00443 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00444 {
00445 $type = $row->activation_type;
00446 $start = $row->activation_start;
00447 $end = $row->activation_end;
00448 }
00449 switch($type)
00450 {
00451 case IL_CRS_ACTIVATION_OFFLINE:
00452 return false;
00453
00454 case IL_CRS_ACTIVATION_UNLIMITED:
00455 return true;
00456
00457 case IL_CRS_ACTIVATION_LIMITED:
00458 if(time() < $start or
00459 time() > $end)
00460 {
00461 return false;
00462 }
00463 return true;
00464
00465 default:
00466 return false;
00467 }
00468 }
00469
00470 function _registrationEnabled($a_obj_id)
00471 {
00472 global $ilDB;
00473
00474 $query = "SELECT * FROM crs_settings ".
00475 "WHERE obj_id = ".$ilDB->quote($a_obj_id)." ";
00476
00477 $res = $ilDB->query($query);
00478 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00479 {
00480 $type = $row->subscription_limitation_type;
00481 $reg_start = $row->subscription_start;
00482 $reg_end = $row->subscription_end;
00483 }
00484
00485 switch($type)
00486 {
00487 case IL_CRS_SUBSCRIPTION_UNLIMITED:
00488 return true;
00489
00490 case IL_CRS_SUBSCRIPTION_DEACTIVATED:
00491 return false;
00492
00493 case IL_CRS_SUBSCRIPTION_LIMITED:
00494 if(time() > $reg_start and
00495 time() < $reg_end)
00496 {
00497 return true;
00498 }
00499 default:
00500 return false;
00501 }
00502 return false;
00503 }
00504
00505 function isArchived()
00506 {
00507 if($this->getViewMode() != IL_CRS_VIEW_ARCHIVE)
00508 {
00509 return false;
00510 }
00511 if(time() < $this->getArchiveStart() or time() > $this->getArchiveEnd())
00512 {
00513 return false;
00514 }
00515 return true;
00516 }
00517
00518 function allowAbo()
00519 {
00520 return $this->ABO == $this->ABO_ENABLED;
00521 }
00522
00523 function read($a_force_db = false)
00524 {
00525 parent::read($a_force_db);
00526
00527 $this->__readSettings();
00528 }
00529 function create($a_upload = false)
00530 {
00531 parent::create($a_upload);
00532
00533 if(!$a_upload)
00534 {
00535 $this->createMetaData();
00536 }
00537 $this->__createDefaultSettings();
00538 }
00539
00545 function setLatitude($a_latitude)
00546 {
00547 $this->latitude = $a_latitude;
00548 }
00549
00555 function getLatitude()
00556 {
00557 return $this->latitude;
00558 }
00559
00565 function setLongitude($a_longitude)
00566 {
00567 $this->longitude = $a_longitude;
00568 }
00569
00575 function getLongitude()
00576 {
00577 return $this->longitude;
00578 }
00579
00585 function setLocationZoom($a_locationzoom)
00586 {
00587 $this->locationzoom = $a_locationzoom;
00588 }
00589
00595 function getLocationZoom()
00596 {
00597 return $this->locationzoom;
00598 }
00599
00605 function setEnableCourseMap($a_enablemap)
00606 {
00607 $this->enablemap = $a_enablemap;
00608 }
00609
00615 function getEnableCourseMap()
00616 {
00617 return $this->enablemap;
00618 }
00619
00628 public function cloneObject($a_target_id,$a_copy_id = 0)
00629 {
00630 global $ilDB,$ilUser;
00631
00632 $new_obj = parent::cloneObject($a_target_id,$a_copy_id);
00633
00634 $this->cloneAutoGeneratedRoles($new_obj);
00635 $this->cloneMetaData($new_obj);
00636
00637
00638 $new_obj->initCourseMemberObject();
00639 $new_obj->members_obj->add($ilUser->getId(),IL_CRS_ADMIN);
00640
00641
00642 $this->cloneSettings($new_obj);
00643
00644
00645 include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
00646 ilCourseDefinedFieldDefinition::_clone($this->getId(),$new_obj->getId());
00647
00648
00649 include_once('Modules/Course/classes/class.ilCourseFile.php');
00650 ilCourseFile::_cloneFiles($this->getId(),$new_obj->getId());
00651
00652
00653 include_once('Services/Tracking/classes/class.ilLPObjSettings.php');
00654 $obj_settings = new ilLPObjSettings($this->getId());
00655 $obj_settings->cloneSettings($new_obj->getId());
00656 unset($obj_settings);
00657
00658 return $new_obj;
00659 }
00660
00669 public function cloneDependencies($a_target_id,$a_copy_id)
00670 {
00671 global $ilObjDataCache;
00672
00673
00674 include_once('Modules/Course/classes/class.ilCourseStart.php');
00675 $start = new ilCourseStart($this->getRefId(),$this->getId());
00676 $start->cloneDependencies($a_target_id,$a_copy_id);
00677
00678
00679 $this->initCourseItemObject();
00680 $this->items_obj->cloneDependencies($a_target_id,$a_copy_id);
00681
00682
00683 include_once('Modules/Course/classes/class.ilCourseObjective.php');
00684 $crs_objective = new ilCourseObjective($this);
00685 $crs_objective->ilClone($a_target_id,$a_copy_id);
00686
00687 include_once('Services/Tracking/classes/class.ilLPCollections.php');
00688 $lp_collection = new ilLPCollections($this->getId());
00689 $lp_collection->cloneCollections($a_target_id,$a_copy_id);
00690
00691
00692 include_once('Modules/Course/classes/Event/class.ilEvent.php');
00693 ilEvent::_cloneEvent($this->getId(),$ilObjDataCache->lookupObjId($a_target_id),$a_copy_id);
00694
00695 return true;
00696 }
00697
00705 public function cloneAutoGeneratedRoles($new_obj)
00706 {
00707 global $ilLog,$rbacadmin,$rbacreview;
00708
00709 $admin = $this->getDefaultAdminRole();
00710 $new_admin = $new_obj->getDefaultAdminRole();
00711 $source_rolf = $rbacreview->getRoleFolderIdOfObject($this->getRefId());
00712 $target_rolf = $rbacreview->getRoleFolderIdOfObject($new_obj->getRefId());
00713
00714 if(!$admin || !$new_admin || !$source_rolf || !$target_rolf)
00715 {
00716 $ilLog->write(__METHOD__.' : Error cloning auto generated role: il_crs_admin');
00717 }
00718 $rbacadmin->copyRolePermissions($admin,$source_rolf,$target_rolf,$new_admin,true);
00719 $ilLog->write(__METHOD__.' : Finished copying of role crs_admin.');
00720
00721 $tutor = $this->getDefaultTutorRole();
00722 $new_tutor = $new_obj->getDefaultTutorRole();
00723 if(!$tutor || !$new_tutor)
00724 {
00725 $ilLog->write(__METHOD__.' : Error cloning auto generated role: il_crs_tutor');
00726 }
00727 $rbacadmin->copyRolePermissions($tutor,$source_rolf,$target_rolf,$new_tutor,true);
00728 $ilLog->write(__METHOD__.' : Finished copying of role crs_tutor.');
00729
00730 $member = $this->getDefaultMemberRole();
00731 $new_member = $new_obj->getDefaultMemberRole();
00732 if(!$member || !$new_member)
00733 {
00734 $ilLog->write(__METHOD__.' : Error cloning auto generated role: il_crs_member');
00735 }
00736 $rbacadmin->copyRolePermissions($member,$source_rolf,$target_rolf,$new_member,true);
00737 $ilLog->write(__METHOD__.' : Finished copying of role crs_member.');
00738
00739 return true;
00740 }
00741
00742
00743 function validate()
00744 {
00745 $this->initCourseMemberObject();
00746
00747 $this->setMessage('');
00748
00749 #if(($this->getSubscriptionLimitationType() != IL_CRS_SUBSCRIPTION_DEACTIVATED) and
00750 # $this->getSubscriptionType() == )
00751 #{
00752 # $this->appendMessage($this->lng->txt('crs_select_registration_type'));
00753 #}
00754
00755 if(($this->getActivationType() == IL_CRS_ACTIVATION_LIMITED) and
00756 $this->getActivationEnd() < $this->getActivationStart())
00757 {
00758 $this->appendMessage($this->lng->txt("activation_times_not_valid"));
00759 }
00760 if(($this->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_LIMITED) and
00761 $this->getSubscriptionStart() > $this->getSubscriptionEnd())
00762 {
00763 $this->appendMessage($this->lng->txt("subscription_times_not_valid"));
00764 }
00765 #if((!$this->getActivationUnlimitedStatus() and
00766 # !$this->getSubscriptionUnlimitedStatus()) and
00767 # ($this->getSubscriptionStart() > $this->getActivationEnd() or
00768 # $this->getSubscriptionStart() < $this->getActivationStart() or
00769 # $this->getSubscriptionEnd() > $this->getActivationEnd() or
00770 # $this->getSubscriptionEnd() < $this->getActivationStart()))
00771 #
00772 #{
00773 # $this->appendMessage($this->lng->txt("subscription_time_not_within_activation"));
00774 #}
00775 if($this->getSubscriptionType() == IL_CRS_SUBSCRIPTION_PASSWORD and !$this->getSubscriptionPassword())
00776 {
00777 $this->appendMessage($this->lng->txt("crs_password_required"));
00778 }
00779 if($this->getSubscriptionMaxMembers() and !is_numeric($this->getSubscriptionMaxMembers()))
00780 {
00781 $this->appendMessage($this->lng->txt("max_members_not_numeric"));
00782 }
00783 if(($this->getViewMode() == IL_CRS_VIEW_ARCHIVE) and
00784 $this->getArchiveStart() > $this->getArchiveEnd())
00785 {
00786 $this->appendMessage($this->lng->txt("archive_times_not_valid"));
00787 }
00788 return $this->getMessage() ? false : true;
00789 }
00790
00791 function validateInfoSettings()
00792 {
00793 global $ilErr;
00794 $error = false;
00795 if($this->getContactEmail()) {
00796 $emails = split(",",$this->getContactEmail());
00797
00798 foreach ($emails as $email) {
00799 $email = trim($email);
00800 if (!(ilUtil::is_email($email) or ilObjUser::getUserIdByLogin($email)))
00801 {
00802 $ilErr->appendMessage($this->lng->txt('contact_email_not_valid')." '".$email."'");
00803 $error = true;
00804 }
00805 }
00806 }
00807 return !$error;
00808 }
00809
00810 function hasContactData()
00811 {
00812 return strlen($this->getContactName()) or
00813 strlen($this->getContactResponsibility()) or
00814 strlen($this->getContactEmail()) or
00815 strlen($this->getContactPhone()) or
00816 strlen($this->getContactConsultation());
00817 }
00818
00819
00826 function delete()
00827 {
00828
00829 if (!parent::delete())
00830 {
00831 return false;
00832 }
00833
00834
00835
00836 $this->deleteMetaData();
00837
00838
00839
00840 $this->__deleteSettings();
00841
00842 $this->initCourseItemObject();
00843 $this->items_obj->deleteAllEntries();
00844
00845 include_once('Modules/Course/classes/class.ilCourseParticipants.php');
00846 ilCourseParticipants::_deleteAllEntries($this->getId());
00847
00848 $this->initCourseArchiveObject();
00849 $this->archives_obj->deleteAll();
00850
00851 include_once './Modules/Course/classes/class.ilCourseObjective.php';
00852 ilCourseObjective::_deleteAll($this->getId());
00853
00854 include_once './Modules/Course/classes/class.ilObjCourseGrouping.php';
00855 ilObjCourseGrouping::_deleteAll($this->getId());
00856
00857 include_once './Modules/Course/classes/Event/class.ilEvent.php';
00858 ilEvent::_deleteAll($this->getId());
00859
00860 include_once './Modules/Course/classes/class.ilCourseFile.php';
00861 ilCourseFile::_deleteByCourse($this->getId());
00862
00863 include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
00864 ilCourseDefinedFieldDefinition::_deleteByContainer($this->getId());
00865
00866 return true;
00867 }
00868
00869
00870
00874 function update()
00875 {
00876 $this->updateMetaData();
00877 $this->updateSettings();
00878 parent::update();
00879 }
00880
00881 function updateSettings()
00882 {
00883 global $ilDB;
00884
00885
00886
00887 $query = "SELECT * FROM crs_settings WHERE obj_id = ".$ilDB->quote($this->getId())." ";
00888 $res = $ilDB->query($query);
00889
00890 if(!$res->numRows())
00891 {
00892 $this->__createDefaultSettings();
00893 }
00894
00895 $query = "UPDATE crs_settings SET ".
00896 "syllabus = ".$ilDB->quote($this->getSyllabus()).", ".
00897 "contact_name = ".$ilDB->quote($this->getContactName()).", ".
00898 "contact_responsibility = ".$ilDB->quote($this->getContactResponsibility()).", ".
00899 "contact_phone = ".$ilDB->quote($this->getContactPhone()).", ".
00900 "contact_email = ".$ilDB->quote($this->getContactEmail()).", ".
00901 "contact_consultation = ".$ilDB->quote($this->getContactConsultation()).", ".
00902 "activation_type = ".$ilDB->quote($this->getActivationType()).", ".
00903 #"activation_unlimited = '".(int) $this->getActivationUnlimitedStatus()."', ".
00904 "activation_start = ".$ilDB->quote($this->getActivationStart()).", ".
00905 "activation_end = ".$ilDB->quote($this->getActivationEnd()).", ".
00906 #"activation_offline = '".(int) $this->getOfflineStatus()."', ".
00907 "subscription_limitation_type = ".$ilDB->quote($this->getSubscriptionLimitationType()).", ".
00908 #"subscription_unlimited = '".(int) $this->getSubscriptionUnlimitedStatus()."', ".
00909 "subscription_start = ".$ilDB->quote($this->getSubscriptionStart()).", ".
00910 "subscription_end = ".$ilDB->quote($this->getSubscriptionEnd()).", ".
00911 "subscription_type = ".$ilDB->quote($this->getSubscriptionType()).", ".
00912 "subscription_password = ".$ilDB->quote($this->getSubscriptionPassword()).", ".
00913 "subscription_max_members = ".$ilDB->quote($this->getSubscriptionMaxMembers()).", ".
00914 "subscription_notify = ".$ilDB->quote($this->getSubscriptionNotify()).", ".
00915 "view_mode = ".$ilDB->quote($this->getViewMode()).", ".
00916 "sortorder = ".$ilDB->quote($this->getOrderType()).", ".
00917 "archive_start = ".$ilDB->quote($this->getArchiveStart()).", ".
00918 "archive_end = ".$ilDB->quote($this->getArchiveEnd()).", ".
00919 "archive_type = ".$ilDB->quote($this->getArchiveType()).", ".
00920 "abo = ".$ilDB->quote($this->getAboStatus()).", ".
00921 #"objective_view = '".(int) $this->enabledObjectiveView()."', ".
00922 "waiting_list = ".$ilDB->quote($this->enabledWaitingList()).", ".
00923 "important = ".$ilDB->quote($this->getImportantInformation()).", ".
00924 "show_members = ".$ilDB->quote($this->getShowMembers()).", ".
00925 "latitude = ".$ilDB->quote($this->getLatitude()).", ".
00926 "longitude = ".$ilDB->quote($this->getLongitude()).", ".
00927 "location_zoom = ".$ilDB->quote($this->getLocationZoom()).", ".
00928 "enable_course_map = ".$ilDB->quote($this->getEnableCourseMap())." ".
00929 "WHERE obj_id = ".$ilDB->quote($this->getId())."";
00930
00931 $res = $ilDB->query($query);
00932 }
00933
00941 public function cloneSettings($new_obj)
00942 {
00943 $new_obj->setSyllabus($this->getSyllabus());
00944 $new_obj->setContactName($this->getContactName());
00945 $new_obj->setContactResponsibility($this->getContactResponsibility());
00946 $new_obj->setContactPhone($this->getContactPhone());
00947 $new_obj->setContactEmail($this->getContactEmail());
00948 $new_obj->setContactConsultation($this->getContactConsultation());
00949 $new_obj->setActivationType($this->getActivationType());
00950 $new_obj->setActivationStart($this->getActivationStart());
00951 $new_obj->setActivationEnd($this->getActivationEnd());
00952 $new_obj->setSubscriptionLimitationType($this->getSubscriptionLimitationType());
00953 $new_obj->setSubscriptionStart($this->getSubscriptionStart());
00954 $new_obj->setSubscriptionEnd($this->getSubscriptionEnd());
00955 $new_obj->setSubscriptionType($this->getSubscriptionType());
00956 $new_obj->setSubscriptionPassword($this->getSubscriptionPassword());
00957 $new_obj->setSubscriptionMaxMembers($this->getSubscriptionMaxMembers());
00958 $new_obj->setSubscriptionNotify($this->getSubscriptionNotify());
00959 $new_obj->setViewMode($this->getViewMode());
00960 $new_obj->setOrderType($this->getOrderType());
00961 $new_obj->setArchiveStart($this->getArchiveStart());
00962 $new_obj->setArchiveEnd($this->getArchiveEnd());
00963 $new_obj->setArchiveType($this->getArchiveType());
00964 $new_obj->setAboStatus($this->getAboStatus());
00965 $new_obj->enableWaitingList($this->enabledWaitingList());
00966 $new_obj->setImportantInformation($this->getImportantInformation());
00967 $new_obj->setShowMembers($this->getShowMembers());
00968 $new_obj->update();
00969 }
00970
00971 function __createDefaultSettings()
00972 {
00973 global $ilDB;
00974
00975 $query = "INSERT INTO crs_settings SET ".
00976 "obj_id = ".$ilDB->quote($this->getId()).", ".
00977 "syllabus = ".$ilDB->quote($this->getSyllabus()).", ".
00978 "contact_name = ".$ilDB->quote($this->getContactName()).", ".
00979 "contact_responsibility = ".$ilDB->quote($this->getContactResponsibility()).", ".
00980 "contact_phone = ".$ilDB->quote($this->getContactPhone()).", ".
00981 "contact_email = ".$ilDB->quote($this->getContactEmail()).", ".
00982 "contact_consultation = ".$ilDB->quote($this->getContactConsultation()).", ".
00983 "activation_type = ".$ilDB->quote(IL_CRS_ACTIVATION_UNLIMITED).", ".
00984 #"activation_unlimited = '1', ".
00985 "activation_start = ".$ilDB->quote($this->getActivationStart()).", ".
00986 "activation_end = ".$ilDB->quote($this->getActivationEnd()).", ".
00987 #"activation_offline = '1', ".
00988 "subscription_limitation_type = ".$ilDB->quote(IL_CRS_SUBSCRIPTION_DEACTIVATED).", ".
00989 #"subscription_unlimited = '1', ".
00990 "subscription_start = ".$ilDB->quote($this->getSubscriptionStart()).", ".
00991 "subscription_end = ".$ilDB->quote($this->getSubscriptionEnd()).", ".
00992 "subscription_type = ".$ilDB->quote(IL_CRS_SUBSCRIPTION_DIRECT).", ".
00993 "subscription_password = ".$ilDB->quote($this->getSubscriptionPassword()).", ".
00994 "subscription_max_members = ".$ilDB->quote($this->getSubscriptionMaxMembers()).", ".
00995 "subscription_notify = '1', ".
00996 "view_mode = '0', ".
00997 "sortorder = ".$ilDB->quote(IL_CRS_SORT_TITLE).", ".
00998 "archive_start = ".$ilDB->quote($this->getArchiveStart()).", ".
00999 "archive_end = ".$ilDB->quote($this->getArchiveEnd()).", ".
01000 "archive_type = ".$ilDB->quote(IL_CRS_ARCHIVE_NONE).", ".
01001 "abo = ".$ilDB->quote($this->ABO_ENABLED).", ".
01002 "latitude = ".$ilDB->quote($this->getLatitude()).", ".
01003 "longitude = ".$ilDB->quote($this->getLongitude()).", ".
01004 "location_zoom = ".$ilDB->quote($this->getLocationZoom()).", ".
01005 "enable_course_map = ".$ilDB->quote($this->getEnableCourseMap()).", ".
01006 #"objective_view = '0', ".
01007 "waiting_list = '1', ".
01008 "show_members = '1'";
01009
01010 $res = $ilDB->query($query);
01011 }
01012
01013
01014 function __readSettings()
01015 {
01016 global $ilDB;
01017
01018 $query = "SELECT * FROM crs_settings WHERE obj_id = ".$ilDB->quote($this->getId())."";
01019
01020 $res = $ilDB->query($query);
01021 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
01022 {
01023 $this->setSyllabus($row->syllabus);
01024 $this->setContactName($row->contact_name);
01025 $this->setContactResponsibility($row->contact_responsibility);
01026 $this->setContactPhone($row->contact_phone);
01027 $this->setContactEmail($row->contact_email);
01028 $this->setContactConsultation($row->contact_consultation);
01029 $this->setActivationType($row->activation_type);
01030 #$this->setActivationUnlimitedStatus($row->activation_unlimited);
01031 $this->setActivationStart($row->activation_start);
01032 $this->setActivationEnd($row->activation_end);
01033 #$this->setOfflineStatus($row->activation_offline);
01034 $this->setSubscriptionLimitationType($row->subscription_limitation_type);
01035 #$this->setSubscriptionUnlimitedStatus($row->subscription_unlimited);
01036 $this->setSubscriptionStart($row->subscription_start);
01037 $this->setSubscriptionEnd($row->subscription_end);
01038 $this->setSubscriptionType($row->subscription_type);
01039 $this->setSubscriptionPassword($row->subscription_password);
01040 $this->setSubscriptionMaxMembers($row->subscription_max_members);
01041 $this->setSubscriptionNotify($row->subscription_notify);
01042 $this->setViewMode($row->view_mode);
01043 $this->setOrderType($row->sortorder);
01044 $this->setArchiveStart($row->archive_start);
01045 $this->setArchiveEnd($row->archive_end);
01046 $this->setArchiveType($row->archive_type);
01047 $this->setAboStatus($row->abo);
01048 $this->enableWaitingList($row->waiting_list);
01049 $this->setImportantInformation($row->important);
01050 $this->setShowMembers($row->show_members);
01051 $this->setLatitude($row->latitude);
01052 $this->setLongitude($row->longitude);
01053 $this->setLocationZoom($row->location_zoom);
01054 $this->setEnableCourseMap($row->enable_course_map);
01055 }
01056 return true;
01057 }
01058
01059 function initWaitingList()
01060 {
01061 include_once "./Modules/Course/classes/class.ilCourseWaitingList.php";
01062
01063 if(!is_object($this->waiting_list_obj))
01064 {
01065 $this->waiting_list_obj =& new ilCourseWaitingList($this->getId());
01066 }
01067 return true;
01068 }
01069
01070
01071 function initCourseMemberObject()
01072 {
01073 include_once "./Modules/Course/classes/class.ilCourseParticipants.php";
01074 $this->members_obj = ilCourseParticipants::_getInstanceByObjId($this->getId());
01075 return true;
01076 }
01077
01078 function initCourseItemObject($a_child_id = 0)
01079 {
01080 include_once "./Modules/Course/classes/class.ilCourseItems.php";
01081
01082 if(!is_object($this->items_obj))
01083 {
01084 $this->items_obj =& new ilCourseItems($this,$a_child_id);
01085 }
01086 return true;
01087 }
01088
01089 function initCourseArchiveObject()
01090 {
01091 include_once "./Modules/Course/classes/class.ilCourseArchives.php";
01092
01093 if(!is_object($this->archives_obj))
01094 {
01095 $this->archives_obj =& new ilCourseArchives($this);
01096 }
01097 return true;
01098 }
01099
01100
01101
01102
01103 function initDefaultRoles()
01104 {
01105 global $rbacadmin,$rbacreview,$ilDB;
01106
01107 $rolf_obj = $this->createRoleFolder();
01108
01109
01110 $role_obj = $rolf_obj->createRole("il_crs_admin_".$this->getRefId(),"Admin of course obj_no.".$this->getId());
01111 $admin_id = $role_obj->getId();
01112
01113
01114 $query = "SELECT obj_id FROM object_data ".
01115 " WHERE type='rolt' AND title='il_crs_admin'";
01116
01117 $res = $this->ilias->db->getRow($query, DB_FETCHMODE_OBJECT);
01118 $rbacadmin->copyRoleTemplatePermissions($res->obj_id,ROLE_FOLDER_ID,$rolf_obj->getRefId(),$role_obj->getId());
01119
01120
01121 $ops = $rbacreview->getOperationsOfRole($role_obj->getId(),"crs",$rolf_obj->getRefId());
01122 $rbacadmin->grantPermission($role_obj->getId(),$ops,$this->getRefId());
01123
01124
01125
01126
01127
01128
01129
01130 $role_obj = $rolf_obj->createRole("il_crs_tutor_".$this->getRefId(),"Tutors of course obj_no.".$this->getId());
01131 $member_id = $role_obj->getId();
01132
01133
01134 $query = "SELECT obj_id FROM object_data ".
01135 " WHERE type='rolt' AND title='il_crs_tutor'";
01136 $res = $this->ilias->db->getRow($query, DB_FETCHMODE_OBJECT);
01137 $rbacadmin->copyRoleTemplatePermissions($res->obj_id,ROLE_FOLDER_ID,$rolf_obj->getRefId(),$role_obj->getId());
01138
01139
01140 $ops = $rbacreview->getOperationsOfRole($role_obj->getId(),"crs",$rolf_obj->getRefId());
01141 $rbacadmin->grantPermission($role_obj->getId(),$ops,$this->getRefId());
01142
01143
01144
01145
01146
01147
01148
01149 $role_obj = $rolf_obj->createRole("il_crs_member_".$this->getRefId(),"Member of course obj_no.".$this->getId());
01150 $member_id = $role_obj->getId();
01151
01152
01153 $query = "SELECT obj_id FROM object_data ".
01154 " WHERE type='rolt' AND title='il_crs_member'";
01155 $res = $this->ilias->db->getRow($query, DB_FETCHMODE_OBJECT);
01156 $rbacadmin->copyRoleTemplatePermissions($res->obj_id,ROLE_FOLDER_ID,$rolf_obj->getRefId(),$role_obj->getId());
01157
01158
01159 $ops = $rbacreview->getOperationsOfRole($role_obj->getId(),"crs",$rolf_obj->getRefId());
01160 $rbacadmin->grantPermission($role_obj->getId(),$ops,$this->getRefId());
01161
01162
01163
01164
01165
01166 unset($role_obj);
01167 unset($rolf_obj);
01168
01169
01170
01171 $this->__setCourseStatus();
01172
01173 return true;
01174 }
01175
01192 function __setCourseStatus()
01193 {
01194 global $rbacadmin, $rbacreview, $rbacsystem;
01195
01196
01197 $rolf_data = $rbacreview->getRoleFolderOfObject($this->getRefId());
01198
01199
01200 $arr_parentRoles = $rbacreview->getParentRoleIds($this->getRefId());
01201 $arr_relevantParentRoleIds = array_diff(array_keys($arr_parentRoles),$this->getDefaultCourseRoles());
01202
01203 $template_id = $this->__getCrsNonMemberTemplateId();
01204
01205
01206 if (is_null($template_id))
01207 {
01208 $template_ops = array();
01209 } else {
01210 $template_ops = $rbacreview->getOperationsOfRole($template_id, 'crs', ROLE_FOLDER_ID);
01211 }
01212
01213 foreach ($arr_relevantParentRoleIds as $parentRole)
01214 {
01215 if ($rbacreview->isProtected($arr_parentRoles[$parentRole]['parent'],$parentRole))
01216 {
01217 continue;
01218 }
01219
01220 $granted_permissions = array();
01221
01222
01223
01224 $rbacadmin->deleteLocalRole($parentRole,$rolf_data["child"]);
01225
01226
01227
01228
01229
01230
01231 $current_ops = $rbacreview->getRoleOperationsOnObject($parentRole, $this->getRefId());
01232 $rbacadmin->revokePermission($this->getRefId(), $parentRole);
01233 foreach ($template_ops as $template_op)
01234 {
01235 if (in_array($template_op,$current_ops))
01236 {
01237 array_push($granted_permissions,$template_op);
01238 }
01239 }
01240 if (!empty($granted_permissions))
01241 {
01242 $rbacadmin->grantPermission($parentRole, $granted_permissions, $this->getRefId());
01243 }
01244
01245
01246
01247
01248
01249 if (! is_null($template_id))
01250 {
01251 $rbacadmin->copyRolePermissionIntersection(
01252 $template_id, ROLE_FOLDER_ID,
01253 $parentRole, $arr_parentRoles[$parentRole]['parent'],
01254 $rolf_data["child"], $parentRole
01255 );
01256 }
01257 $rbacadmin->assignRoleToFolder($parentRole,$rolf_data["child"],"false");
01258 }
01259 }
01260
01267 function __getCrsNonMemberTemplateId()
01268 {
01269 global $ilDB;
01270
01271 $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_crs_non_member'";
01272 $res = $this->ilias->db->query($q);
01273 $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
01274
01275 return $row["obj_id"];
01276 }
01277
01278
01288 public function getDefaultCourseRoles($a_crs_id = "")
01289 {
01290 global $rbacadmin, $rbacreview;
01291
01292 if (strlen($a_crs_id) > 0)
01293 {
01294 $crs_id = $a_crs_id;
01295 }
01296 else
01297 {
01298 $crs_id = $this->getRefId();
01299 }
01300
01301 $rolf = $rbacreview->getRoleFolderOfObject($crs_id);
01302 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"]);
01303
01304 foreach ($role_arr as $role_id)
01305 {
01306 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
01307
01308 $crs_Member ="il_crs_member_".$crs_id;
01309 $crs_Admin ="il_crs_admin_".$crs_id;
01310 $crs_Tutor ="il_crs_tutor_".$crs_id;
01311
01312 if (strcmp($role_Obj->getTitle(), $crs_Member) == 0 )
01313 {
01314 $arr_crsDefaultRoles["crs_member_role"] = $role_Obj->getId();
01315 }
01316
01317 if (strcmp($role_Obj->getTitle(), $crs_Admin) == 0)
01318 {
01319 $arr_crsDefaultRoles["crs_admin_role"] = $role_Obj->getId();
01320 }
01321
01322 if (strcmp($role_Obj->getTitle(), $crs_Tutor) == 0)
01323 {
01324 $arr_crsDefaultRoles["crs_tutor_role"] = $role_Obj->getId();
01325 }
01326 }
01327
01328 return $arr_crsDefaultRoles;
01329 }
01330
01331 function __getLocalRoles()
01332 {
01333 global $rbacreview;
01334
01335
01336
01337 $rolf = $rbacreview->getRoleFolderOfObject($this->getRefId());
01338
01339 return $rbacreview->getRolesOfRoleFolder($rolf["ref_id"],false);
01340 }
01341
01342 function __deleteSettings()
01343 {
01344 global $ilDB;
01345
01346 $query = "DELETE FROM crs_settings ".
01347 "WHERE obj_id = ".$ilDB->quote($this->getId())." ";
01348
01349 $this->ilias->db->query($query);
01350
01351 return true;
01352 }
01353
01354 function getDefaultMemberRole()
01355 {
01356 $local_roles = $this->__getLocalRoles();
01357
01358 foreach($local_roles as $role_id)
01359 {
01360 if($tmp_role =& ilObjectFactory::getInstanceByObjId($role_id,false))
01361 {
01362 if(!strcmp($tmp_role->getTitle(),"il_crs_member_".$this->getRefId()))
01363 {
01364 return $role_id;
01365 }
01366 }
01367 }
01368 return false;
01369 }
01370 function getDefaultTutorRole()
01371 {
01372 $local_roles = $this->__getLocalRoles();
01373
01374 foreach($local_roles as $role_id)
01375 {
01376 if($tmp_role =& ilObjectFactory::getInstanceByObjId($role_id,false))
01377 {
01378 if(!strcmp($tmp_role->getTitle(),"il_crs_tutor_".$this->getRefId()))
01379 {
01380 return $role_id;
01381 }
01382 }
01383 }
01384 return false;
01385 }
01386 function getDefaultAdminRole()
01387 {
01388 $local_roles = $this->__getLocalRoles();
01389
01390 foreach($local_roles as $role_id)
01391 {
01392 if($tmp_role =& ilObjectFactory::getInstanceByObjId($role_id,false))
01393 {
01394 if(!strcmp($tmp_role->getTitle(),"il_crs_admin_".$this->getRefId()))
01395 {
01396 return $role_id;
01397 }
01398 }
01399 }
01400 return false;
01401 }
01402
01403
01404 function _checkCondition($a_obj_id,$a_operator,$a_value)
01405 {
01406 global $ilUser;
01407
01408 include_once "./Modules/Course/classes/class.ilCourseParticipants.php";
01409
01410 switch($a_operator)
01411 {
01412 case 'passed':
01413 return ilCourseParticipants::_hasPassed($a_obj_id,$ilUser->getId());
01414
01415 default:
01416 return true;
01417 }
01418 }
01419
01420 function _deleteUser($a_usr_id)
01421 {
01422
01423
01424 include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
01425 ilCourseLMHistory::_deleteUser($a_usr_id);
01426
01427 include_once './Modules/Course/classes/class.ilCourseParticipants.php';
01428 ilCourseParticipants::_deleteUser($a_usr_id);
01429
01430
01431 include_once './Modules/Course/classes/class.ilCourseObjectiveResult.php';
01432 ilCourseObjectiveResult::_deleteUser($a_usr_id);
01433 }
01434
01435 }
01436 ?>