• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Modules/Course/classes/class.ilCourseRegisterGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 include_once('Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
00025 
00035 class ilCourseRegisterGUI
00036 {
00037         var $ctrl;
00038         var $ilias;
00039         var $tree;
00040         var $ilErr;
00041         var $lng;
00042         var $tpl;
00043 
00044         var $course_obj;
00045         var $course_id;
00046         var $user_id;
00047 
00048         private $course_obj_id;
00049         private $validation = true;
00050         private $agreement;
00051         private $privacy;
00052         
00053         function __construct($a_course_id)
00054         {
00055                 global $ilCtrl,$lng,$ilErr,$ilias,$tpl,$tree,$ilObjDataCache;
00056 
00057                 $this->ctrl =& $ilCtrl;
00058                 $this->ctrl->saveParameter($this,array("ref_id"));
00059 
00060                 $this->ilErr =& $ilErr;
00061                 $this->lng =& $lng;
00062                 $this->lng->loadLanguageModule('ps');
00063                 $this->tpl =& $tpl;
00064                 $this->tree =& $tree;
00065 
00066                 $this->user_id = $ilias->account->getId();
00067 
00068                 $this->course_id = $a_course_id;
00069                 $this->course_obj_id = $ilObjDataCache->lookupObjId($this->course_id);
00070                 $this->__initCourseObject();
00071                 $this->__initWaitingList();
00072                 
00073                 $this->initAgreement();
00074                 $this->privacy = ilPrivacySettings::_getInstance();
00075         }
00076 
00080         function &executeCommand()
00081         {
00082                 global $ilTabs;
00083 
00084                 $ilTabs->setTabActive('join');
00085 
00086                 switch($cmd = $this->ctrl->getCmd())
00087                 {
00088                         case '':
00089                                 $this->ctrl->returnToParent($this);
00090                                 break;
00091 
00092                         case 'archive':
00093                         case 'join':
00094                         case 'view':
00095                                 $cmd = "showRegistrationForm";
00096                                 break;
00097                 }
00098                 $this->$cmd();
00099         }
00100 
00101         function cancel()
00102         {
00103                 ilUtil::sendInfo($this->lng->txt("action_aborted"),true);
00104 
00105                 ilUtil::redirect('repository.php?ref_id='.$this->tree->getParentId($this->course_id));
00106         }
00107 
00108         function subscribe()
00109         {
00110                 global $ilAccess,$ilErr;
00111 
00112                 if(!$ilAccess->checkAccess("join","",$this->course_obj->getRefId(),'crs'))
00113                 {
00114                         $ilErr->raiseError($this->lng->txt("msg_no_perm_read"),$ilErr->MESSAGE);
00115                 }
00116                 
00117                 $this->setAccepted(true);
00118                 
00119                 if(!$this->checkCourseDefinedFields())
00120                 {
00121                         $this->course_obj->appendMessage($this->lng->txt('fill_out_all_required_fields'));
00122                         $this->validation = false;
00123                         $this->showRegistrationForm();
00124                         return false;
00125                 }
00126                 
00127                 if(!$this->checkAgreement())
00128                 {
00129                         $this->course_obj->appendMessage($this->lng->txt('crs_agreement_required'));
00130                         $this->validation = false;
00131                         $this->showRegistrationForm();
00132                         return false;
00133                 }
00134 
00135                 if($this->course_obj->getSubscriptionMaxMembers())
00136                 {
00137                         $free = $this->course_obj->getSubscriptionMaxMembers() - 
00138                                 $this->course_obj->members_obj->getCountMembers() - $this->course_obj->members_obj->getCountSubscribers();
00139                         $free = $free > 0 ? true : false;
00140                 }
00141                 if($this->course_obj->getSubscriptionMaxMembers() and
00142                    !$free and
00143                    !$this->course_obj->enabledWaitingList())
00144                 {
00145                         $ilErr->raiseError($this->lng->txt("crs_reg_subscription_max_members_reached"),$ilErr->MESSAGE);
00146                 }
00147 
00148                 if($this->course_obj->getSubscriptionMaxMembers() and (!$free or $this->waiting_list->getCountUsers()))
00149                 {
00150                         #if((($this->course_obj->getSubscriptionMaxMembers() <= $this->course_obj->members_obj->getCountMembers())
00151                         #       and $this->course_obj->getSubscriptionMaxMembers() != 0) or
00152                         #   $this->waiting_list->getCountUsers())
00153                         // First check password
00154                         if($this->course_obj->getSubscriptionType() == $this->course_obj->SUBSCRIPTION_PASSWORD)
00155                         {
00156                                 if($this->course_obj->getSubscriptionPassword() != $_POST["password"])
00157                                 {
00158                                         $this->course_obj->appendMessage($this->lng->txt("crs_password_not_valid"));
00159                                         $this->validation = false;
00160                                         $this->showRegistrationForm();
00161 
00162                                         return false;
00163                                 }
00164                         }
00165 
00166                         include_once 'Modules/Course/classes/class.ilCourseWaitingList.php';
00167 
00168                         if(!$this->waiting_list->isOnList($this->user_id))
00169                         {
00170                                 $this->waiting_list->addToList($this->user_id);
00171                                 
00172                                 $info = sprintf($this->lng->txt('crs_added_to_list'),$this->waiting_list->getPosition($this->user_id));
00173                                 ilUtil::sendInfo($info,true);
00174 
00175                                 ilUtil::redirect('repository.php?ref_id='.$this->tree->getParentId($this->course_id));
00176                         }
00177                         else
00178                         {
00179                                 ilUtil::sendInfo($this->lng->txt('crs_already_assigned_to_list'),true);
00180                                 ilUtil::redirect('repository.php?ref_id='.$this->tree->getParentId($this->course_id));
00181                         }                               
00182                 }
00183 
00184                 if($this->course_obj->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_DEACTIVATED)
00185                 {
00186                         $this->ilErr->raiseError($this->lng->txt("err_unknown_error"),$this->ilErr->MESSAGE);
00187                 }
00188 
00189                 switch($this->course_obj->getSubscriptionType())
00190                 {
00191                         case $this->course_obj->SUBSCRIPTION_DIRECT:
00192                                 
00193                                 $tmp_obj =& ilObjectFactory::getInstanceByObjId($this->user_id);
00194 
00195                                 if($this->course_obj->members_obj->add($tmp_obj->getId(),IL_CRS_MEMBER))
00196                                 {
00197                                         $this->course_obj->members_obj->sendNotification($this->course_obj->members_obj->NOTIFY_ADMINS,$this->user_id);
00198                                         ilUtil::sendInfo($this->lng->txt("crs_subscription_successful"),true);
00199                                         
00200                                         ilUtil::redirect('repository.php?ref_id='.$this->tree->getParentId($this->course_id));
00201                                 }
00202                                 else
00203                                 {
00204                                         ilUtil::sendInfo("err_unknown_error");
00205                                         $this->showRegistrationForm();
00206                                 }
00207                                 break;
00208 
00209                         case $this->course_obj->SUBSCRIPTION_CONFIRMATION:
00210 
00211                                 if($this->course_obj->members_obj->addSubscriber($this->user_id))
00212                                 {
00213                                         $this->course_obj->members_obj->sendNotification($this->course_obj->members_obj->NOTIFY_SUBSCRIPTION_REQUEST,
00214                                                                                                                                          $this->user_id);
00215                                         ilUtil::sendInfo($this->lng->txt("crs_subscription_requested"),true);
00216                                         $this->ctrl->setParameterByClass("ilRepositoryGUI","ref_id",$this->tree->getParentId($this->course_id));
00217 
00218                                         ilUtil::redirect('repository.php?ref_id='.$this->tree->getParentId($this->course_id));
00219                                 }
00220                                 else
00221                                 {
00222                                         ilUtil::sendInfo("err_unknown_error");
00223                                         $this->showRegistrationForm();
00224                                 }
00225                                 break;
00226 
00227                         case $this->course_obj->SUBSCRIPTION_PASSWORD:
00228 
00229                                 $tmp_obj =& ilObjectFactory::getInstanceByObjId($this->user_id);
00230 
00231                                 if($this->course_obj->getSubscriptionPassword() != $_POST["password"])
00232                                 {
00233                                         ilUtil::sendInfo($this->lng->txt("crs_password_not_valid"),true);
00234                                         $this->showRegistrationForm();
00235                                 }
00236                                 else if($this->course_obj->members_obj->add($tmp_obj->getId(),IL_CRS_MEMBER))
00237                                 {
00238                                         $this->course_obj->members_obj->sendNotification($this->course_obj->members_obj->NOTIFY_ADMINS,$this->user_id);
00239                                         ilUtil::sendInfo($this->lng->txt("crs_subscription_successful"),true);
00240                                         ilUtil::redirect('repository.php?ref_id='.$this->tree->getParentId($this->course_id));
00241                                 }
00242                                 else
00243                                 {
00244                                         ilUtil::sendInfo("err_unknown_error");
00245                                         $this->showRegistrationForm();
00246                                 }
00247                                 break;
00248                 }
00249         }
00250 
00251         function showRegistrationForm()
00252         {
00253                 $really_submit = true;
00254                 if($this->validation)
00255                 {
00256                         $really_submit = $this->__validateStatus();
00257                 }
00258                 else
00259                 {
00260                         $this->setAccepted(false);
00261                 }
00262 
00263                 if($this->course_obj->getMessage())
00264                 {
00265                         ilUtil::sendInfo($this->course_obj->getMessage());
00266                 }
00267 
00268                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_subscription.html",'Modules/Course');
00269                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormActionByClass("ilObjCourseGUI"));
00270                 
00271                 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath("icon_crs.gif"));
00272                 $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_crs"));
00273                 $this->tpl->setVariable("TITLE",$this->lng->txt("crs_registration"));
00274 
00275                 if(strlen($this->course_obj->getSyllabus()))
00276                 {
00277                         $this->tpl->setVariable("TXT_SYLLABUS",$this->lng->txt("crs_syllabus"));
00278                         $this->tpl->setVariable("SYLLABUS",nl2br($this->course_obj->getSyllabus()));
00279                 }
00280 
00281                 $this->tpl->setVariable("TXT_INFO_REG",$this->lng->txt("crs_info_reg"));
00282 
00283 
00284                 // Waiting list
00285                 if($this->course_obj->getSubscriptionMaxMembers() and $this->course_obj->enabledWaitingList())
00286                 {
00287                         $this->tpl->setCurrentBlock("waiting_list");
00288                         $this->tpl->setVariable("TXT_WAITING_LIST",$this->lng->txt('crs_free_places'));
00289 
00290                         $free_places = $this->course_obj->getSubscriptionMaxMembers() - 
00291                                 $this->course_obj->members_obj->getCountMembers() -
00292                                 $this->course_obj->members_obj->getCountSubscribers();
00293 
00294                         $free_places = $free_places >= 0 ? $free_places : 0;
00295                         $this->tpl->setVariable("FREE_PLACES",$free_places);
00296                         $this->tpl->parseCurrentBlock();
00297 
00298                         if($this->waiting_list->isOnList($this->user_id))
00299                         {
00300                                 $this->tpl->setCurrentBlock("waiting_list_info");
00301                                 $this->tpl->setVariable("TXT_WAITING_LIST_INFO",$this->lng->txt('crs_youre_position'));
00302                                 $this->tpl->setVariable("POSITION",$this->waiting_list->getPosition($this->user_id));
00303                                 $this->tpl->parseCurrentBlock();
00304                         }
00305                         else
00306                         {
00307                                 $this->tpl->setCurrentBlock("waiting_list_info");
00308                                 $this->tpl->setVariable("TXT_WAITING_LIST_INFO",$this->lng->txt('crs_persons_on_waiting_list'));
00309                                 $this->tpl->setVariable("POSITION",$this->waiting_list->getCountUsers());
00310                                 $this->tpl->parseCurrentBlock();
00311                         }
00312                 }
00313                 include_once('Modules/Course/classes/class.ilObjCourseGrouping.php');
00314                 if($courses = ilObjCourseGrouping::_getGroupingItemsAsString($this->course_obj))
00315                 {
00316                         $this->tpl->setVariable("INFO_REG_PRE",$this->lng->txt('crs_grp_info_reg').$courses.'<br>');
00317                 }
00318 
00319                 if($this->course_obj->getSubscriptionLimitationType() != IL_CRS_SUBSCRIPTION_DEACTIVATED)
00320                 {
00321                         switch($this->course_obj->getSubscriptionType())
00322                         {
00323                                 case $this->course_obj->SUBSCRIPTION_CONFIRMATION:
00324                                         $this->tpl->setVariable("INFO_REG",$this->lng->txt("crs_info_reg_confirmation"));
00325                                         break;
00326                                 case $this->course_obj->SUBSCRIPTION_DIRECT:
00327                                         $this->tpl->setVariable("INFO_REG",$this->lng->txt("crs_info_reg_direct"));
00328                                         break;
00329                                 case $this->course_obj->SUBSCRIPTION_PASSWORD:
00330                                         $this->tpl->setVariable("INFO_REG",$this->lng->txt("crs_info_reg_password"));
00331                                         break;
00332                         }
00333 
00334                         $this->tpl->setCurrentBlock("reg_until");
00335                         $this->tpl->setVariable("TXT_REG_UNTIL",$this->lng->txt("crs_reg_until"));
00336 
00337                         if($this->course_obj->getSubscriptionUnlimitedStatus())
00338                         {
00339                                 $this->tpl->setVariable("REG_UNTIL",$this->lng->txt("crs_unlimited"));
00340                         }
00341                         else if($this->course_obj->getSubscriptionStart() < time())
00342                         {
00343                                 $this->tpl->setVariable("FROM",$this->lng->txt("crs_to"));
00344                                 $this->tpl->setVariable("REG_UNTIL",ilFormat::formatUnixTime($this->course_obj->getSubscriptionEnd(),true));
00345                         }
00346                         else if($this->course_obj->getSubscriptionStart() > time())
00347                         {
00348                                 $this->tpl->setVariable("FROM",$this->lng->txt("crs_from"));
00349                                 $this->tpl->setVariable("REG_UNTIL",ilFormat::formatUnixTime($this->course_obj->getSubscriptionStart(),true));
00350                         }
00351                         $this->tpl->parseCurrentBlock();
00352                 }
00353                 else
00354                 {
00355                         // Deactivated
00356                         $this->tpl->setVariable("INFO_REG",$this->lng->txt("crs_info_reg_deactivated"));
00357                 }
00358 
00359                 if($this->course_obj->getSubscriptionType() == $this->course_obj->SUBSCRIPTION_PASSWORD and
00360                    $this->course_obj->inSubscriptionTime())
00361                 {
00362                         $this->tpl->setCurrentBlock("pass");
00363                         $this->tpl->setVariable("TXT_PASSWORD",$this->lng->txt("crs_access_password"));
00364                         $this->tpl->parseCurrentBlock();
00365                 }
00366 
00367                 $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt("cancel"));
00368 
00369                 if($really_submit)
00370                 {
00371                         $this->showAgreement();
00372                         
00373                         if($this->show_required_info)
00374                         {
00375                                 $this->tpl->setCurrentBlock('info_required');
00376                                 $this->tpl->setVariable('TXT_REQUIRED',$this->lng->txt('required_field'));
00377                                 $this->tpl->parseCurrentBlock();
00378                         }
00379                         
00380                         $this->tpl->setCurrentBlock("go");
00381                         $this->tpl->setVariable("CMD_SUBMIT","subscribe");
00382                         if ($this->course_obj->getSubscriptionType() == $this->course_obj->SUBSCRIPTION_CONFIRMATION)
00383                         {
00384                                 $this->tpl->setVariable("TXT_SUBMIT",$this->lng->txt("request_membership"));
00385                         }
00386                         else
00387                         {
00388                                 $this->tpl->setVariable("TXT_SUBMIT",$this->lng->txt("join"));
00389                         }
00390                         $this->tpl->parseCurrentBlock();
00391                 }
00392                         
00393 
00394                 return true;
00395         }
00396 
00397 
00398         // PRIVATE
00405         private function showAgreement()
00406         {
00407                 global $ilUser;
00408                 
00409                 include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');         
00410                 if(!$this->privacy->confirmationRequired() and !ilCourseDefinedFieldDefinition::_hasFields($this->course_obj_id))
00411                 {
00412                         return false;
00413                 }
00414                 
00415                 
00416                 $this->showCourseDefinedFields();
00417 
00418                 include_once('Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php');
00419                 $fields_info = ilExportFieldsInfo::_getInstance();
00420                 
00421                 foreach($fields_info->getExportableFields() as $field)
00422                 {
00423                         $this->tpl->setCurrentBlock('field');
00424                         $this->tpl->setVariable('FIELD_NAME',$this->lng->txt($field));
00425                         $this->tpl->parseCurrentBlock();
00426                 }
00427                 
00428                 $this->tpl->setCurrentBlock('agreement');
00429                 $this->tpl->setVariable('AGREEMENT_HEADER',$this->lng->txt('crs_agreement_header'));
00430                 $this->tpl->setVariable('TXT_AGREEMENT',$this->lng->txt('crs_user_agreement'));
00431                 $this->tpl->setVariable('TXT_INFO_AGREEMENT',$this->lng->txt('crs_info_agreement'));
00432                 $this->tpl->setVariable('CHECK_AGREE',ilUtil::formCheckbox(0,'agreed',1));
00433                 $this->tpl->setVariable('INFO_AGREE',$this->lng->txt('crs_info_agree'));
00434                 $this->tpl->setVariable('TXT_AGREE',$this->lng->txt('crs_agree'));
00435                 $this->tpl->parseCurrentBlock();
00436         }
00437         
00443         private function showCourseDefinedFields()
00444         {
00445                 global $ilUser;
00446                 
00447                 include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
00448                 include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
00449 
00450                 if(!count($cdf_fields = ilCourseDefinedFieldDefinition::_getFields($this->course_obj_id)))
00451                 {
00452                         return true;
00453                 }
00454                 
00455                 foreach($cdf_fields as $field_obj)
00456                 {
00457                         $course_user_data = new ilCourseUserData($ilUser->getId(),$field_obj->getId());
00458                         
00459                         switch($field_obj->getType())
00460                         {
00461                                 case IL_CDF_TYPE_SELECT:
00462                                         $this->tpl->setCurrentBlock('sel_row');
00463                                         $this->tpl->setVariable('SEL_SELECT',ilUtil::formSelect($course_user_data->getValue(),
00464                                                                                                                                                         'cdf['.$field_obj->getId().']',
00465                                                                                                                                                         $field_obj->prepareSelectBox(),
00466                                                                                                                                                         false,
00467                                                                                                                                                         true));
00468                                         break;
00469                                 case IL_CDF_TYPE_TEXT:
00470                                         $this->tpl->setCurrentBlock('txt_row');
00471                                         $this->tpl->setVariable('TXT_ROW_NAME',$field_obj->getId());
00472                                         $this->tpl->setVariable('TXT_ROW_VALUE',$course_user_data->getValue());
00473                                         break;
00474                         }
00475                         if($field_obj->isRequired())
00476                         {
00477                                 $this->show_required_info = true;
00478                                 $this->tpl->touchBlock('cdf_required');
00479                         }
00480                         
00481                         $this->tpl->setCurrentBlock('cdf_row');
00482                         $this->tpl->setVariable('CDF_FIELD_NAME',$field_obj->getName());
00483                         $this->tpl->parseCurrentBlock();
00484                 }
00485                 $this->tpl->setCurrentBlock('cdf');
00486                 $this->tpl->setVariable('CDF_TXT',$this->lng->txt('ps_cdf_info'));
00487                 $this->tpl->parseCurrentBlock();
00488         }
00489         
00496         private function checkCourseDefinedFields()
00497         {
00498                 global $ilUser;
00499                 
00500                 include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
00501                 include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
00502                 
00503                 $all_required = true;
00504                 foreach(ilCourseDefinedFieldDefinition::_getFields($this->course_obj_id) as $field_obj)
00505                 {
00506                         switch($field_obj->getType())
00507                         {
00508                                 case IL_CDF_TYPE_SELECT:
00509                                         $value = ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]);
00510                                         break;
00511                                 
00512                                 case IL_CDF_TYPE_TEXT:
00513                                         $value = ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]);      
00514                                         break;
00515                         }
00516                         $course_user_data = new ilCourseUserData($ilUser->getId(),$field_obj->getId());
00517                         $course_user_data->setValue($value);
00518                         $course_user_data->update();
00519                         
00520                         if($field_obj->isRequired() and !strlen($value))
00521                         {
00522                                 $all_required = false;
00523                         }
00524                 }       
00525                 return $all_required;
00526         }
00527         
00528         
00535         private function checkAgreement()
00536         {
00537                 global $ilUser;
00538                 
00539                 if($_POST['agreed'])
00540                 {
00541                         return true;
00542                 }
00543                 include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
00544                 if(!$this->privacy->confirmationRequired() and !ilCourseDefinedFieldDefinition::_hasFields($this->course_obj_id))
00545                 {
00546                         return true;
00547                 }
00548                 return false;
00549         }
00550         
00557         private function setAccepted($a_status)
00558         {
00559                 include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
00560                 if(!$this->privacy->confirmationRequired() and !ilCourseDefinedFieldDefinition::_hasFields($this->course_obj_id))
00561                 {
00562                         return true;
00563                 }
00564                 $this->agreement->setAccepted($a_status);
00565                 $this->agreement->setAcceptanceTime(time());
00566                 $this->agreement->save();
00567         }
00568         
00569         
00570         function __initCourseObject()
00571         {
00572                 if(!$this->course_obj =& ilObjectFactory::getInstanceByRefId($this->course_id,false))
00573                 {
00574                         $this->ilErr->raiseError("ilCourseRegisterGUI: cannot create course object",$this->ilErr->MESSAGE);
00575                         exit;
00576                 }
00577                 $this->course_obj->initCourseMemberObject();
00578 
00579                 return true;
00580         }
00581 
00582         function __initWaitingList()
00583         {
00584                 include_once 'Modules/Course/classes/class.ilCourseWaitingList.php';
00585 
00586                 $this->waiting_list =& new ilCourseWaitingList($this->course_obj->getId());
00587 
00588                 return true;
00589         }
00590         
00598         private function initAgreement()
00599         {
00600                 global $ilUser;
00601                 
00602                 include_once('Modules/Course/classes/class.ilCourseAgreement.php');
00603                 $this->agreement = new ilCourseAgreement($ilUser->getId(),$this->course_obj_id);
00604         }
00605         
00606         function __validateStatus()
00607         {
00608                 include_once 'Modules/Course/classes/class.ilObjCourseGrouping.php';
00609 
00610                 $allow_subscription = true;
00611 
00612                 #$this->course_obj->setMessage('');
00613 
00614                 if($this->course_obj->members_obj->isAssigned($this->user_id))
00615                 {
00616                         $this->course_obj->appendMessage($this->lng->txt("crs_reg_user_already_assigned"));
00617                         $allow_subscription = false;
00618                 }
00619                 if($this->course_obj->members_obj->isBlocked($this->user_id) and $this->course_obj->members_obj->isAssigned($this->user_id))
00620                 {
00621                         $this->course_obj->appendMessage($this->lng->txt("crs_reg_user_blocked"));
00622                         $allow_subscription = false;
00623                 }
00624                 if($this->course_obj->members_obj->isSubscriber($this->user_id))
00625                 {
00626                         $this->course_obj->appendMessage($this->lng->txt("crs_reg_user_already_subscribed"));
00627                         $allow_subscription = false;
00628                 }
00629                 if($this->course_obj->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_DEACTIVATED)
00630                 {
00631                         $this->course_obj->appendMessage($this->lng->txt("crs_reg_subscription_deactivated"));
00632                         $allow_subscription = false;
00633 
00634                         return false;
00635                 }
00636                 if(!$this->course_obj->getSubscriptionUnlimitedStatus() and
00637                    ( time() < $this->course_obj->getSubscriptionStart()))
00638                 {
00639                         $this->course_obj->appendMessage($this->lng->txt("crs_reg_subscription_start_later"));
00640                         $allow_subscription = false;
00641                 }
00642                 if(!$this->course_obj->getSubscriptionUnlimitedStatus() and
00643                    ( time() > $this->course_obj->getSubscriptionEnd()))
00644                 {
00645                         $this->course_obj->appendMessage($this->lng->txt("crs_reg_subscription_end_earlier"));
00646                         $allow_subscription = false;
00647                 }
00648                 if(!ilObjCourseGrouping::_checkGroupingDependencies($this->course_obj))
00649                 {
00650                         $allow_subscription = false;
00651                 }
00652                 if($this->waiting_list->isOnList($this->user_id) and $allow_subscription)
00653                 {
00654                         $this->course_obj->appendMessage($this->lng->txt('crs_already_assigned_to_list'));
00655                         $allow_subscription = false;
00656                 }
00657                 elseif($this->course_obj->getSubscriptionMaxMembers() and 
00658                            (($this->course_obj->members_obj->getCountMembers() + $this->course_obj->members_obj->getCountSubscribers()) 
00659                                 >= $this->course_obj->getSubscriptionMaxMembers()) and
00660                            $allow_subscription)
00661                 {
00662                         $this->course_obj->appendMessage($this->lng->txt("crs_reg_subscription_max_members_reached"));
00663                         if($this->course_obj->enabledWaitingList())
00664                         {
00665                                 $this->course_obj->appendMessage($this->lng->txt('crs_set_on_waiting_list'));
00666                         }
00667                         else
00668                         {
00669                                 $allow_subscription = false;
00670                         }
00671                 }
00672                 elseif($this->waiting_list->getCountUsers() 
00673                            and $allow_subscription
00674                            and $this->course_obj->enabledWaitingList())
00675                 {
00676                         $this->course_obj->appendMessage($this->lng->txt('crs_set_on_waiting_list'));
00677                 }
00678                 return $allow_subscription;
00679         }
00680 
00681 
00682 
00683         function __formatPath($a_path_arr)
00684         {
00685                 $counter = 0;
00686                 foreach($a_path_arr as $data)
00687                 {
00688                         if(!$counter++)
00689                         {
00690                                 continue;
00691                         }
00692                         if($counter++ > 2)
00693                         {
00694                                 $path .= " -> ";
00695                         }
00696                         $path .= $data['title'];
00697                 }
00698 
00699                 return $path;
00700         }
00701 }
00702 ?>

Generated on Fri Dec 13 2013 17:56:49 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1