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
00035 require_once "./classes/class.ilContainer.php";
00036
00037 define('IL_CRS_ACTIVATION_OFFLINE',0);
00038 define('IL_CRS_ACTIVATION_UNLIMITED',1);
00039 define('IL_CRS_ACTIVATION_LIMITED',2);
00040
00041 define('IL_CRS_SUBSCRIPTION_DEACTIVATED',0);
00042 define('IL_CRS_SUBSCRIPTION_UNLIMITED',1);
00043 define('IL_CRS_SUBSCRIPTION_LIMITED',2);
00044
00045 define('IL_CRS_SUBSCRIPTION_CONFIRMATION',2);
00046 define('IL_CRS_SUBSCRIPTION_DIRECT',3);
00047 define('IL_CRS_SUBSCRIPTION_PASSWORD',4);
00048
00049 define('IL_CRS_VIEW_STANDARD',0);
00050 define('IL_CRS_VIEW_OBJECTIVE',1);
00051 define('IL_CRS_VIEW_TIMING',2);
00052 define('IL_CRS_VIEW_ARCHIVE',3);
00053
00054 define('IL_CRS_ARCHIVE_DOWNLOAD',3);
00055 define('IL_CRS_ARCHIVE_NONE',0);
00056
00057 define('IL_CRS_SORT_MANUAL',1);
00058 define('IL_CRS_SORT_TITLE',2);
00059 define('IL_CRS_SORT_ACTIVATION',3);
00060
00061 class ilObjCourse extends ilContainer
00062 {
00063 var $members_obj;
00064 var $archives_obj;
00065 var $items_obj;
00066
00073 function ilObjCourse($a_id = 0,$a_call_by_reference = true)
00074 {
00075 #define("ILIAS_MODULE","course");
00076 #define("KEEP_IMAGE_PATH",1);
00077
00078 $this->SUBSCRIPTION_DEACTIVATED = 1;
00079 $this->SUBSCRIPTION_CONFIRMATION = 2;
00080 $this->SUBSCRIPTION_DIRECT = 3;
00081 $this->SUBSCRIPTION_PASSWORD = 4;
00082 $this->SUBSCRIPTION_AUTOSUBSCRIPTION = 5;
00083 $this->SORT_MANUAL = 1;
00084 $this->SORT_TITLE = 2;
00085 $this->SORT_ACTIVATION = 3;
00086 $this->ARCHIVE_DISABLED = 1;
00087 $this->ARCHIVE_READ = 2;
00088 $this->ARCHIVE_DOWNLOAD = 3;
00089 $this->ABO_ENABLED = 1;
00090 $this->ABO_DISABLED = 0;
00091 $this->SHOW_MEMBERS_ENABLED = 1;
00092 $this->SHOW_MEMBERS_DISABLED = 0;
00093
00094 $this->type = "crs";
00095 $this->ilObject($a_id,$a_call_by_reference);
00096
00097 if($a_id)
00098 {
00099 #$this->__initMetaObject();
00100 $this->initCourseMemberObject();
00101 }
00102 else
00103 {
00104
00105 }
00106
00107 }
00108
00109 function getImportantInformation()
00110 {
00111 return $this->important;
00112 }
00113 function setImportantInformation($a_info)
00114 {
00115 $this->important = $a_info;
00116 }
00117 function getSyllabus()
00118 {
00119 return $this->syllabus;
00120 }
00121 function setSyllabus($a_syllabus)
00122 {
00123 $this->syllabus = $a_syllabus;
00124 }
00125 function getContactName()
00126 {
00127 return $this->contact_name;
00128 }
00129 function setContactName($a_cn)
00130 {
00131 $this->contact_name = $a_cn;
00132 }
00133 function getContactConsultation()
00134 {
00135 return $this->contact_consultation;
00136 }
00137 function setContactConsultation($a_value)
00138 {
00139 $this->contact_consultation = $a_value;
00140 }
00141 function getContactPhone()
00142 {
00143 return $this->contact_phone;
00144 }
00145 function setContactPhone($a_value)
00146 {
00147 $this->contact_phone = $a_value;
00148 }
00149 function getContactEmail()
00150 {
00151 return $this->contact_email;
00152 }
00153 function setContactEmail($a_value)
00154 {
00155 $this->contact_email = $a_value;
00156 }
00157 function getContactResponsibility()
00158 {
00159 return $this->contact_responsibility;
00160 }
00161 function setContactResponsibility($a_value)
00162 {
00163 $this->contact_responsibility = $a_value;
00164 }
00165
00166 function getActivationType()
00167 {
00168 return (int) $this->activation_type;
00169 }
00170 function setActivationType($a_type)
00171 {
00172 $this->activation_type = $a_type;
00173 }
00174 function getActivationUnlimitedStatus()
00175 {
00176 return $this->activation_type == IL_CRS_ACTIVATION_UNLIMITED;
00177
00178 }
00179 function getActivationStart()
00180 {
00181 return $this->activation_start ? $this->activation_start : time();
00182 }
00183 function setActivationStart($a_value)
00184 {
00185 $this->activation_start = $a_value;
00186 }
00187 function getActivationEnd()
00188 {
00189 return $this->activation_end ? $this->activation_end : mktime(0,0,0,12,12,date("Y",time())+2);
00190 }
00191 function setActivationEnd($a_value)
00192 {
00193 $this->activation_end = $a_value;
00194 }
00195 function getOfflineStatus()
00196 {
00197 return $this->activation_type == IL_CRS_ACTIVATION_OFFLINE;
00198 }
00199
00200
00201 function getSubscriptionLimitationType()
00202 {
00203 return $this->subscription_limitation_type;
00204 }
00205 function setSubscriptionLimitationType($a_type)
00206 {
00207 $this->subscription_limitation_type = $a_type;
00208 }
00209 function getSubscriptionUnlimitedStatus()
00210 {
00211 return $this->subscription_limitation_type == IL_CRS_SUBSCRIPTION_UNLIMITED;
00212 }
00213 function getSubscriptionStart()
00214 {
00215 return $this->subscription_start ? $this->subscription_start : time();
00216 }
00217 function setSubscriptionStart($a_value)
00218 {
00219 $this->subscription_start = $a_value;
00220 }
00221 function getSubscriptionEnd()
00222 {
00223 return $this->subscription_end ? $this->subscription_end : mktime(0,0,0,12,12,date("Y",time())+2);
00224 }
00225 function setSubscriptionEnd($a_value)
00226 {
00227 $this->subscription_end = $a_value;
00228 }
00229 function getSubscriptionType()
00230 {
00231 return $this->subscription_type ? $this->subscription_type : IL_CRS_SUBSCRIPTION_DIRECT;
00232 #return $this->subscription_type ? $this->subscription_type : $this->SUBSCRIPTION_DEACTIVATED;
00233 }
00234 function setSubscriptionType($a_value)
00235 {
00236 $this->subscription_type = $a_value;
00237 }
00238 function getSubscriptionPassword()
00239 {
00240 return $this->subscription_password;
00241 }
00242 function setSubscriptionPassword($a_value)
00243 {
00244 $this->subscription_password = $a_value;
00245 }
00246 function enabledObjectiveView()
00247 {
00248 return $this->view_mode == IL_CRS_VIEW_OBJECTIVE;
00249 }
00250
00251 function enabledWaitingList()
00252 {
00253 return (bool) $this->waiting_list;
00254 }
00255
00256 function enableWaitingList($a_status)
00257 {
00258 $this->waiting_list = (bool) $a_status;
00259 }
00260
00261 function inSubscriptionTime()
00262 {
00263 if($this->getSubscriptionUnlimitedStatus())
00264 {
00265 return true;
00266 }
00267 if(time() > $this->getSubscriptionStart() and time() < $this->getSubscriptionEnd())
00268 {
00269 return true;
00270 }
00271 return false;
00272 }
00273
00274 function getSubscriptionMaxMembers()
00275 {
00276 return $this->subscription_max_members;
00277 }
00278 function setSubscriptionMaxMembers($a_value)
00279 {
00280 $this->subscription_max_members = $a_value;
00281 }
00282 function getSubscriptionNotify()
00283 {
00284 return $this->subscription_notify ? true : false;
00285 }
00286 function setSubscriptionNotify($a_value)
00287 {
00288 $this->subscription_notify = $a_value ? true : false;
00289 }
00290
00291 function setViewMode($a_mode)
00292 {
00293 $this->view_mode = $a_mode;
00294 }
00295 function getViewMode()
00296 {
00297 return $this->view_mode;
00298 }
00299
00300 function _lookupViewMode($a_id)
00301 {
00302 global $ilDB;
00303
00304 $query = "SELECT view_mode FROM crs_settings WHERE obj_id = '".$a_id."'";
00305 $res = $ilDB->query($query);
00306 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00307 {
00308 return $row->view_mode;
00309 }
00310 return false;
00311 }
00312
00313
00314 function getOrderType()
00315 {
00316 return $this->order_type ? $this->order_type : IL_CRS_SORT_TITLE;
00317 }
00318 function setOrderType($a_value)
00319 {
00320 $this->order_type = $a_value;
00321 }
00322 function getArchiveStart()
00323 {
00324 return $this->archive_start ? $this->archive_start : time();
00325 }
00326 function setArchiveStart($a_value)
00327 {
00328 $this->archive_start = $a_value;
00329 }
00330 function getArchiveEnd()
00331 {
00332 return $this->archive_end ? $this->archive_end : mktime(0,0,0,12,12,date("Y",time())+2);
00333 }
00334 function setArchiveEnd($a_value)
00335 {
00336 $this->archive_end = $a_value;
00337 }
00338 function getArchiveType()
00339 {
00340 return $this->archive_type ? IL_CRS_ARCHIVE_DOWNLOAD : IL_CRS_ARCHIVE_NONE;
00341 }
00342 function setArchiveType($a_value)
00343 {
00344 $this->archive_type = $a_value;
00345 }
00346 function setAboStatus($a_status)
00347 {
00348 $this->abo = $a_status;
00349 }
00350 function getAboStatus()
00351 {
00352 return $this->abo;
00353 }
00354 function setShowMembers($a_status)
00355 {
00356 $this->show_members = $a_status;
00357 }
00358 function getShowMembers()
00359 {
00360 return $this->show_members;
00361 }
00362
00363 function getMessage()
00364 {
00365 return $this->message;
00366 }
00367 function setMessage($a_message)
00368 {
00369 $this->message = $a_message;
00370 }
00371 function appendMessage($a_message)
00372 {
00373 if($this->getMessage())
00374 {
00375 $this->message .= "<br /> ";
00376 }
00377 $this->message .= $a_message;
00378 }
00379
00380 function getMembers()
00381 {
00382 return $this->members_obj->getMembers();
00383 }
00384
00385
00386 function isActivated($a_check_archive = false)
00387 {
00388 if($a_check_archive)
00389 {
00390 if($this->isArchived())
00391 {
00392 return true;
00393 }
00394 }
00395 if($this->getOfflineStatus())
00396 {
00397 return false;
00398 }
00399 if($this->getActivationUnlimitedStatus())
00400 {
00401 return true;
00402 }
00403 if(time() < $this->getActivationStart() or
00404 time() > $this->getActivationEnd())
00405 {
00406 return false;
00407 }
00408 return true;
00409 }
00410
00417 function _isActivated($a_obj_id)
00418 {
00419 global $ilDB;
00420
00421 $query = "SELECT * FROM crs_settings ".
00422 "WHERE obj_id = '".$a_obj_id."'";
00423
00424 $res = $ilDB->query($query);
00425 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00426 {
00427 $type = $row->activation_type;
00428 $start = $row->activation_start;
00429 $end = $row->activation_end;
00430 }
00431 switch($type)
00432 {
00433 case IL_CRS_ACTIVATION_OFFLINE:
00434 return false;
00435
00436 case IL_CRS_ACTIVATION_UNLIMITED:
00437 return true;
00438
00439 case IL_CRS_ACTIVATION_LIMITED:
00440 if(time() < $start or
00441 time() > $end)
00442 {
00443 return false;
00444 }
00445 return true;
00446
00447 default:
00448 return false;
00449 }
00450 }
00451
00452 function _registrationEnabled($a_obj_id)
00453 {
00454 global $ilDB;
00455
00456 $query = "SELECT * FROM crs_settings ".
00457 "WHERE obj_id = '".$a_obj_id."'";
00458
00459 $res = $ilDB->query($query);
00460 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00461 {
00462 $type = $row->subscription_limitation_type;
00463 $reg_start = $row->subscription_start;
00464 $reg_end = $row->subscription_end;
00465 }
00466
00467 switch($type)
00468 {
00469 case IL_CRS_SUBSCRIPTION_UNLIMITED:
00470 return true;
00471
00472 case IL_CRS_SUBSCRIPTION_DEACTIVATED:
00473 return false;
00474
00475 case IL_CRS_SUBSCRIPTION_LIMITED:
00476 if(time() > $reg_start and
00477 time() < $reg_end)
00478 {
00479 return true;
00480 }
00481 default:
00482 return false;
00483 }
00484 return false;
00485 }
00486
00487 function isArchived()
00488 {
00489 if($this->getViewMode() != IL_CRS_VIEW_ARCHIVE)
00490 {
00491 return false;
00492 }
00493 if(time() < $this->getArchiveStart() or time() > $this->getArchiveEnd())
00494 {
00495 return false;
00496 }
00497 return true;
00498 }
00499
00500 function allowAbo()
00501 {
00502 return $this->ABO == $this->ABO_ENABLED;
00503 }
00504
00505 function read($a_force_db = false)
00506 {
00507 parent::read($a_force_db);
00508
00509 $this->__readSettings();
00510 }
00511 function create($a_upload = false)
00512 {
00513 parent::create($a_upload);
00514
00515 if(!$a_upload)
00516 {
00517 $this->createMetaData();
00518 }
00519 $this->__createDefaultSettings();
00520 }
00521
00522 function validate()
00523 {
00524 $this->initCourseMemberObject();
00525
00526 $this->setMessage('');
00527
00528 #if(($this->getSubscriptionLimitationType() != IL_CRS_SUBSCRIPTION_DEACTIVATED) and
00529 # $this->getSubscriptionType() == )
00530 #{
00531 # $this->appendMessage($this->lng->txt('crs_select_registration_type'));
00532 #}
00533
00534 if(($this->getActivationType() == IL_CRS_ACTIVATION_LIMITED) and
00535 $this->getActivationEnd() < $this->getActivationStart())
00536 {
00537 $this->appendMessage($this->lng->txt("activation_times_not_valid"));
00538 }
00539 if(($this->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_LIMITED) and
00540 $this->getSubscriptionStart() > $this->getSubscriptionEnd())
00541 {
00542 $this->appendMessage($this->lng->txt("subscription_times_not_valid"));
00543 }
00544 #if((!$this->getActivationUnlimitedStatus() and
00545 # !$this->getSubscriptionUnlimitedStatus()) and
00546 # ($this->getSubscriptionStart() > $this->getActivationEnd() or
00547 # $this->getSubscriptionStart() < $this->getActivationStart() or
00548 # $this->getSubscriptionEnd() > $this->getActivationEnd() or
00549 # $this->getSubscriptionEnd() < $this->getActivationStart()))
00550 #
00551 #{
00552 # $this->appendMessage($this->lng->txt("subscription_time_not_within_activation"));
00553 #}
00554 if($this->getSubscriptionType() == IL_CRS_SUBSCRIPTION_PASSWORD and !$this->getSubscriptionPassword())
00555 {
00556 $this->appendMessage($this->lng->txt("crs_password_required"));
00557 }
00558 if($this->getSubscriptionMaxMembers() and !is_numeric($this->getSubscriptionMaxMembers()))
00559 {
00560 $this->appendMessage($this->lng->txt("max_members_not_numeric"));
00561 }
00562 #if($this->getSubscriptionMaxMembers() and
00563 # $this->getSubscriptionMaxMembers() < $this->members_obj->getCountMembers())
00564 #{
00565 # $this->appendMessage($this->lng->txt("crs_max_members_smaller_members"));
00566 #}
00567 if(($this->getViewMode() == IL_CRS_VIEW_ARCHIVE) and
00568 $this->getArchiveStart() > $this->getArchiveEnd())
00569 {
00570 $this->appendMessage($this->lng->txt("archive_times_not_valid"));
00571 }
00572 return $this->getMessage() ? false : true;
00573 }
00574
00575 function validateInfoSettings()
00576 {
00577 global $ilErr;
00578
00579 if($this->getContactEmail() and
00580 !(ilUtil::is_email($this->getContactEmail()) or
00581 ilObjUser::getUserIdByLogin($this->getContactEmail())))
00582 {
00583 $ilErr->appendMessage($this->lng->txt('contact_email_not_valid'));
00584 return false;
00585 }
00586 return true;
00587 }
00588
00589 function hasContactData()
00590 {
00591 return strlen($this->getContactName()) or
00592 strlen($this->getContactResponsibility()) or
00593 strlen($this->getContactEmail()) or
00594 strlen($this->getContactPhone()) or
00595 strlen($this->getContactConsultation());
00596 }
00597
00598
00605 function delete()
00606 {
00607
00608 if (!parent::delete())
00609 {
00610 return false;
00611 }
00612
00613
00614
00615 $this->deleteMetaData();
00616
00617
00618
00619 $this->__deleteSettings();
00620
00621 $this->initCourseItemObject();
00622 $this->items_obj->deleteAllEntries();
00623
00624 $this->initCourseMemberObject();
00625 $this->members_obj->deleteAllEntries();
00626
00627 $this->initCourseArchiveObject();
00628 $this->archives_obj->deleteAll();
00629
00630 include_once './course/classes/class.ilCourseObjective.php';
00631 ilCourseObjective::_deleteAll($this->getId());
00632
00633 include_once './course/classes/class.ilObjCourseGrouping.php';
00634 ilObjCourseGrouping::_deleteAll($this->getId());
00635
00636 include_once './course/classes/Event/class.ilEvent.php';
00637 ilEvent::_deleteAll($this->getId());
00638
00639 include_once './course/classes/class.ilCourseFile.php';
00640 ilCourseFile::_deleteByCourse($this->getId());
00641
00642 return true;
00643 }
00644
00645
00646
00650 function update()
00651 {
00652 $this->updateMetaData();
00653 $this->updateSettings();
00654 parent::update();
00655 }
00656
00657 function updateSettings()
00658 {
00659 global $ilDB;
00660
00661
00662
00663 $query = "SELECT * FROM crs_settings WHERE obj_id = '".$this->getId()."'";
00664 $res = $ilDB->query($query);
00665
00666 if(!$res->numRows())
00667 {
00668 $this->__createDefaultSettings();
00669 }
00670
00671 $query = "UPDATE crs_settings SET ".
00672 "syllabus = '".ilUtil::prepareDBString($this->getSyllabus())."', ".
00673 "contact_name = '".ilUtil::prepareDBString($this->getContactName())."', ".
00674 "contact_responsibility = '".ilUtil::prepareDBString($this->getContactResponsibility())."', ".
00675 "contact_phone = '".ilUtil::prepareDBString($this->getContactPhone())."', ".
00676 "contact_email = '".ilUtil::prepareDBString($this->getContactEmail())."', ".
00677 "contact_consultation = '".ilUtil::prepareDBString($this->getContactConsultation())."', ".
00678 "activation_type = '".(int) $this->getActivationType()."', ".
00679 #"activation_unlimited = '".(int) $this->getActivationUnlimitedStatus()."', ".
00680 "activation_start = '".$this->getActivationStart()."', ".
00681 "activation_end = '".$this->getActivationEnd()."', ".
00682 #"activation_offline = '".(int) $this->getOfflineStatus()."', ".
00683 "subscription_limitation_type = '".$this->getSubscriptionLimitationType()."', ".
00684 #"subscription_unlimited = '".(int) $this->getSubscriptionUnlimitedStatus()."', ".
00685 "subscription_start = '".$this->getSubscriptionStart()."', ".
00686 "subscription_end = '".$this->getSubscriptionEnd()."', ".
00687 "subscription_type = '".(int) $this->getSubscriptionType()."', ".
00688 "subscription_password = '".ilUtil::prepareDBString($this->getSubscriptionPassword())."', ".
00689 "subscription_max_members = '".(int) $this->getSubscriptionMaxMembers()."', ".
00690 "subscription_notify = '".(int) $this->getSubscriptionNotify()."', ".
00691 "view_mode = '".(int) $this->getViewMode()."', ".
00692 "sortorder = '".(int) $this->getOrderType()."', ".
00693 "archive_start = '".$this->getArchiveStart()."', ".
00694 "archive_end = '".$this->getArchiveEnd()."', ".
00695 "archive_type = '".(int) $this->getArchiveType()."', ".
00696 "abo = '".(int) $this->getAboStatus()."', ".
00697 #"objective_view = '".(int) $this->enabledObjectiveView()."', ".
00698 "waiting_list = '".(int) $this->enabledWaitingList()."', ".
00699 "important = '".ilUtil::prepareDBString($this->getImportantInformation())."', ".
00700 "show_members = '".(int) $this->getShowMembers()."' ".
00701 "WHERE obj_id = '".$this->getId()."'";
00702
00703 $res = $ilDB->query($query);
00704 }
00705
00706 function __createDefaultSettings()
00707 {
00708 global $ilDB;
00709
00710 $query = "INSERT INTO crs_settings SET ".
00711 "obj_id = '".$this->getId()."', ".
00712 "syllabus = '".ilUtil::prepareDBString($this->getSyllabus())."', ".
00713 "contact_name = '".ilUtil::prepareDBString($this->getContactName())."', ".
00714 "contact_responsibility = '".ilUtil::prepareDBString($this->getContactResponsibility())."', ".
00715 "contact_phone = '".ilUtil::prepareDBString($this->getContactPhone())."', ".
00716 "contact_email = '".ilUtil::prepareDBString($this->getContactEmail())."', ".
00717 "contact_consultation = '".ilUtil::prepareDBString($this->getContactConsultation())."', ".
00718 "activation_type = '".IL_CRS_ACTIVATION_UNLIMITED."', ".
00719 #"activation_unlimited = '1', ".
00720 "activation_start = '".$this->getActivationStart()."', ".
00721 "activation_end = '".$this->getActivationEnd()."', ".
00722 #"activation_offline = '1', ".
00723 "subscription_limitation_type = '".IL_CRS_SUBSCRIPTION_DEACTIVATED."', ".
00724 #"subscription_unlimited = '1', ".
00725 "subscription_start = '".$this->getSubscriptionStart()."', ".
00726 "subscription_end = '".$this->getSubscriptionEnd()."', ".
00727 "subscription_type = '".(int) IL_CRS_SUBSCRIPTION_DIRECT."', ".
00728 "subscription_password = '".ilUtil::prepareDBString($this->getSubscriptionPassword())."', ".
00729 "subscription_max_members = '".(int) $this->getSubscriptionMaxMembers()."', ".
00730 "subscription_notify = '1', ".
00731 "view_mode = '0', ".
00732 "sortorder = '".(int) IL_CRS_SORT_TITLE."', ".
00733 "archive_start = '".$this->getArchiveStart()."', ".
00734 "archive_end = '".$this->getArchiveEnd()."', ".
00735 "archive_type = '".IL_CRS_ARCHIVE_NONE."', ".
00736 "abo = '".(int) $this->ABO_ENABLED."', ".
00737 #"objective_view = '0', ".
00738 "waiting_list = '1', ".
00739 "show_members = '1'";
00740
00741 $res = $ilDB->query($query);
00742 }
00743
00744
00745 function __readSettings()
00746 {
00747 global $ilDB;
00748
00749 $query = "SELECT * FROM crs_settings WHERE obj_id = '".$this->getId()."'";
00750
00751 $res = $ilDB->query($query);
00752 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00753 {
00754 $this->setSyllabus($row->syllabus);
00755 $this->setContactName($row->contact_name);
00756 $this->setContactResponsibility($row->contact_responsibility);
00757 $this->setContactPhone($row->contact_phone);
00758 $this->setContactEmail($row->contact_email);
00759 $this->setContactConsultation($row->contact_consultation);
00760 $this->setActivationType($row->activation_type);
00761 #$this->setActivationUnlimitedStatus($row->activation_unlimited);
00762 $this->setActivationStart($row->activation_start);
00763 $this->setActivationEnd($row->activation_end);
00764 #$this->setOfflineStatus($row->activation_offline);
00765 $this->setSubscriptionLimitationType($row->subscription_limitation_type);
00766 #$this->setSubscriptionUnlimitedStatus($row->subscription_unlimited);
00767 $this->setSubscriptionStart($row->subscription_start);
00768 $this->setSubscriptionEnd($row->subscription_end);
00769 $this->setSubscriptionType($row->subscription_type);
00770 $this->setSubscriptionPassword($row->subscription_password);
00771 $this->setSubscriptionMaxMembers($row->subscription_max_members);
00772 $this->setSubscriptionNotify($row->subscription_notify);
00773 $this->setViewMode($row->view_mode);
00774 $this->setOrderType($row->sortorder);
00775 $this->setArchiveStart($row->archive_start);
00776 $this->setArchiveEnd($row->archive_end);
00777 $this->setArchiveType($row->archive_type);
00778 $this->setAboStatus($row->abo);
00779 $this->enableWaitingList($row->waiting_list);
00780 $this->setImportantInformation($row->important);
00781 $this->setShowMembers($row->show_members);
00782 }
00783 return true;
00784 }
00785
00786 function initWaitingList()
00787 {
00788 include_once "./course/classes/class.ilCourseWaitingList.php";
00789
00790 if(!is_object($this->waiting_list_obj))
00791 {
00792 $this->waiting_list_obj =& new ilCourseWaitingList($this->getId());
00793 }
00794 return true;
00795 }
00796
00797
00798 function initCourseMemberObject()
00799 {
00800 include_once "./course/classes/class.ilCourseMembers.php";
00801
00802 if(!is_object($this->members_obj))
00803 {
00804 $this->members_obj =& new ilCourseMembers($this);
00805 }
00806 return true;
00807 }
00808
00809 function initCourseItemObject($a_child_id = 0)
00810 {
00811 include_once "./course/classes/class.ilCourseItems.php";
00812
00813 if(!is_object($this->items_obj))
00814 {
00815 $this->items_obj =& new ilCourseItems($this,$a_child_id);
00816 }
00817 return true;
00818 }
00819
00820 function initCourseArchiveObject()
00821 {
00822 include_once "./course/classes/class.ilCourseArchives.php";
00823
00824 if(!is_object($this->archives_obj))
00825 {
00826 $this->archives_obj =& new ilCourseArchives($this);
00827 }
00828 return true;
00829 }
00830
00831
00832
00833
00834 function initDefaultRoles()
00835 {
00836 global $rbacadmin,$rbacreview;
00837
00838 $rolf_obj = $this->createRoleFolder();
00839
00840
00841 $role_obj = $rolf_obj->createRole("il_crs_admin_".$this->getRefId(),"Admin of course obj_no.".$this->getId());
00842 $admin_id = $role_obj->getId();
00843
00844
00845 $query = "SELECT obj_id FROM object_data ".
00846 " WHERE type='rolt' AND title='il_crs_admin'";
00847
00848 $res = $this->ilias->db->getRow($query, DB_FETCHMODE_OBJECT);
00849 $rbacadmin->copyRolePermission($res->obj_id,ROLE_FOLDER_ID,$rolf_obj->getRefId(),$role_obj->getId());
00850
00851
00852 $ops = $rbacreview->getOperationsOfRole($role_obj->getId(),"crs",$rolf_obj->getRefId());
00853 $rbacadmin->grantPermission($role_obj->getId(),$ops,$this->getRefId());
00854
00855
00856
00857
00858
00859
00860
00861 $role_obj = $rolf_obj->createRole("il_crs_tutor_".$this->getRefId(),"Tutors of course obj_no.".$this->getId());
00862 $member_id = $role_obj->getId();
00863
00864
00865 $query = "SELECT obj_id FROM object_data ".
00866 " WHERE type='rolt' AND title='il_crs_tutor'";
00867 $res = $this->ilias->db->getRow($query, DB_FETCHMODE_OBJECT);
00868 $rbacadmin->copyRolePermission($res->obj_id,ROLE_FOLDER_ID,$rolf_obj->getRefId(),$role_obj->getId());
00869
00870
00871 $ops = $rbacreview->getOperationsOfRole($role_obj->getId(),"crs",$rolf_obj->getRefId());
00872 $rbacadmin->grantPermission($role_obj->getId(),$ops,$this->getRefId());
00873
00874
00875
00876
00877
00878
00879
00880 $role_obj = $rolf_obj->createRole("il_crs_member_".$this->getRefId(),"Member of course obj_no.".$this->getId());
00881 $member_id = $role_obj->getId();
00882
00883
00884 $query = "SELECT obj_id FROM object_data ".
00885 " WHERE type='rolt' AND title='il_crs_member'";
00886 $res = $this->ilias->db->getRow($query, DB_FETCHMODE_OBJECT);
00887 $rbacadmin->copyRolePermission($res->obj_id,ROLE_FOLDER_ID,$rolf_obj->getRefId(),$role_obj->getId());
00888
00889
00890 $ops = $rbacreview->getOperationsOfRole($role_obj->getId(),"crs",$rolf_obj->getRefId());
00891 $rbacadmin->grantPermission($role_obj->getId(),$ops,$this->getRefId());
00892
00893
00894
00895
00896
00897 unset($role_obj);
00898 unset($rolf_obj);
00899
00900
00901
00902 $this->__setCourseStatus();
00903
00904 return true;
00905 }
00906
00923 function __setCourseStatus()
00924 {
00925 global $rbacadmin, $rbacreview, $rbacsystem;
00926
00927
00928 $rolf_data = $rbacreview->getRoleFolderOfObject($this->getRefId());
00929
00930
00931 $arr_parentRoles = $rbacreview->getParentRoleIds($this->getRefId());
00932 $arr_relevantParentRoleIds = array_diff(array_keys($arr_parentRoles),$this->__getDefaultCourseRoles());
00933
00934 $template_id = $this->__getCrsNonMemberTemplateId();
00935
00936
00937 if (is_null($template_id))
00938 {
00939 $template_ops = array();
00940 } else {
00941 $template_ops = $rbacreview->getOperationsOfRole($template_id, 'crs', ROLE_FOLDER_ID);
00942 }
00943
00944 foreach ($arr_relevantParentRoleIds as $parentRole)
00945 {
00946 if ($rbacreview->isProtected($arr_parentRoles[$parentRole]['parent'],$parentRole))
00947 {
00948 continue;
00949 }
00950
00951 $granted_permissions = array();
00952
00953
00954
00955 $rbacadmin->deleteLocalRole($parentRole,$rolf_data["child"]);
00956
00957
00958
00959
00960
00961
00962 $current_ops = $rbacreview->getRoleOperationsOnObject($parentRole, $this->getRefId());
00963 $rbacadmin->revokePermission($this->getRefId(), $parentRole);
00964 foreach ($template_ops as $template_op)
00965 {
00966 if (in_array($template_op,$current_ops))
00967 {
00968 array_push($granted_permissions,$template_op);
00969 }
00970 }
00971 if (!empty($granted_permissions))
00972 {
00973 $rbacadmin->grantPermission($parentRole, $granted_permissions, $this->getRefId());
00974 }
00975
00976
00977
00978
00979
00980 if (! is_null($template_id))
00981 {
00982 $rbacadmin->copyRolePermissionIntersection(
00983 $template_id, ROLE_FOLDER_ID,
00984 $parentRole, $arr_parentRoles[$parentRole]['parent'],
00985 $rolf_data["child"], $parentRole
00986 );
00987 }
00988 $rbacadmin->assignRoleToFolder($parentRole,$rolf_data["child"],"false");
00989 }
00990 }
00991
00998 function __getCrsNonMemberTemplateId()
00999 {
01000 $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_crs_non_member'";
01001 $res = $this->ilias->db->query($q);
01002 $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
01003
01004 return $row["obj_id"];
01005 }
01006
01007
01017 function __getDefaultCourseRoles($a_crs_id="")
01018 {
01019 global $rbacadmin, $rbacreview;
01020
01021 if (strlen($a_crs_id) > 0)
01022 {
01023 $crs_id = $a_crs_id;
01024 }
01025 else
01026 {
01027 $crs_id = $this->getRefId();
01028 }
01029
01030 $rolf = $rbacreview->getRoleFolderOfObject($crs_id);
01031 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"]);
01032
01033 foreach ($role_arr as $role_id)
01034 {
01035 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
01036
01037 $crs_Member ="il_crs_member_".$crs_id;
01038 $crs_Admin ="il_crs_admin_".$crs_id;
01039 $crs_Tutor ="il_crs_tutor_".$crs_id;
01040
01041 if (strcmp($role_Obj->getTitle(), $crs_Member) == 0 )
01042 {
01043 $arr_crsDefaultRoles["crs_member_role"] = $role_Obj->getId();
01044 }
01045
01046 if (strcmp($role_Obj->getTitle(), $crs_Admin) == 0)
01047 {
01048 $arr_crsDefaultRoles["crs_admin_role"] = $role_Obj->getId();
01049 }
01050
01051 if (strcmp($role_Obj->getTitle(), $crs_Tutor) == 0)
01052 {
01053 $arr_crsDefaultRoles["crs_tutor_role"] = $role_Obj->getId();
01054 }
01055 }
01056
01057 return $arr_crsDefaultRoles;
01058 }
01059
01060 function __getLocalRoles()
01061 {
01062 global $rbacreview;
01063
01064
01065
01066 $rolf = $rbacreview->getRoleFolderOfObject($this->getRefId());
01067
01068 return $rbacreview->getRolesOfRoleFolder($rolf["ref_id"],false);
01069 }
01070
01071 function __deleteSettings()
01072 {
01073 $query = "DELETE FROM crs_settings ".
01074 "WHERE obj_id = '".$this->getId()."'";
01075
01076 $this->ilias->db->query($query);
01077
01078 return true;
01079 }
01080
01081 function getDefaultMemberRole()
01082 {
01083 $local_roles = $this->__getLocalRoles();
01084
01085 foreach($local_roles as $role_id)
01086 {
01087 if($tmp_role =& ilObjectFactory::getInstanceByObjId($role_id,false))
01088 {
01089 if(!strcmp($tmp_role->getTitle(),"il_crs_member_".$this->getRefId()))
01090 {
01091 return $role_id;
01092 }
01093 }
01094 }
01095 return false;
01096 }
01097 function getDefaultTutorRole()
01098 {
01099 $local_roles = $this->__getLocalRoles();
01100
01101 foreach($local_roles as $role_id)
01102 {
01103 if($tmp_role =& ilObjectFactory::getInstanceByObjId($role_id,false))
01104 {
01105 if(!strcmp($tmp_role->getTitle(),"il_crs_tutor_".$this->getRefId()))
01106 {
01107 return $role_id;
01108 }
01109 }
01110 }
01111 return false;
01112 }
01113 function getDefaultAdminRole()
01114 {
01115 $local_roles = $this->__getLocalRoles();
01116
01117 foreach($local_roles as $role_id)
01118 {
01119 if($tmp_role =& ilObjectFactory::getInstanceByObjId($role_id,false))
01120 {
01121 if(!strcmp($tmp_role->getTitle(),"il_crs_admin_".$this->getRefId()))
01122 {
01123 return $role_id;
01124 }
01125 }
01126 }
01127 return false;
01128 }
01129
01130
01131 function _checkCondition($a_obj_id,$a_operator,$a_value)
01132 {
01133 global $ilias;
01134
01135 include_once "./course/classes/class.ilCourseMembers.php";
01136
01137 switch($a_operator)
01138 {
01139 case 'passed':
01140 return ilCourseMembers::_hasPassed($a_obj_id,$ilias->account->getId());
01141
01142 default:
01143 return true;
01144 }
01145 }
01146
01147 function _deleteUser($a_usr_id)
01148 {
01149
01150
01151 include_once './course/classes/class.ilCourseLMHistory.php';
01152 ilCourseLMHistory::_deleteUser($a_usr_id);
01153
01154 include_once './course/classes/class.ilCourseMembers.php';
01155 ilCourseMembers::_deleteUser($a_usr_id);
01156
01157
01158 include_once './course/classes/class.ilCourseObjectiveResult.php';
01159 ilCourseObjectiveResult::_deleteUser($a_usr_id);
01160 }
01161
01162 }
01163 ?>