Public Member Functions | Private Member Functions | Private Attributes

ilCourseAgreementGUI Class Reference

Public Member Functions

 __construct ($a_ref_id)
 Constructor.
 executeCommand ()
 Execute Command.

Private Member Functions

 showAgreement ($send_info=true)
 show agreement
 save ()
 Save.
 showCourseDefinedFields ()
 checkCourseDefinedFields ()
 Check required course fields.
 checkAgreement ()
 Check Agreement.
 init ()
 Read setting.
 sendInfoMessage ()
 Send info message.

Private Attributes

 $ref_id
 $obj_id
 $db
 $ctrl
 $lng
 $tpl
 $privacy
 $agreement

Detailed Description

Author:
Stefan Meyer <smeyer@databay.de>
Version:
$Id$

ilCourseAgreementGUI:

Definition at line 38 of file class.ilCourseAgreementGUI.php.


Constructor & Destructor Documentation

ilCourseAgreementGUI::__construct ( a_ref_id  ) 

Constructor.

public

Definition at line 57 of file class.ilCourseAgreementGUI.php.

References $ilCtrl, $lng, $tpl, ilPrivacySettings::_getInstance(), and init().

        {
                global $ilDB,$ilCtrl,$lng,$tpl,$ilUser,$ilObjDataCache;
                
                $this->ref_id = $a_ref_id;
                $this->obj_id = $ilObjDataCache->lookupObjId($this->ref_id);
                $this->ctrl = $ilCtrl;
                $this->tpl = $tpl;
                $this->lng = $lng;
                $this->lng->loadLanguageModule('ps');
                
                $this->privacy = ilPrivacySettings::_getInstance();
                $this->agreement = new ilCourseAgreement($ilUser->getId(),$this->obj_id);
                $this->init();
        }

Here is the call graph for this function:


Member Function Documentation

ilCourseAgreementGUI::checkAgreement (  )  [private]

Check Agreement.

private

Definition at line 259 of file class.ilCourseAgreementGUI.php.

References ilCourseDefinedFieldDefinition::_hasFields().

Referenced by save().

        {
                global $ilUser;
                
                if($_POST['agreed'])
                {
                        return true;
                }
                if(!$this->privacy->confirmationRequired() and !ilCourseDefinedFieldDefinition::_hasFields($this->obj_id))
                {
                        return true;
                }
                return false;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseAgreementGUI::checkCourseDefinedFields (  )  [private]

Check required course fields.

private

Definition at line 220 of file class.ilCourseAgreementGUI.php.

References ilCourseDefinedFieldDefinition::_getFields(), and ilUtil::stripSlashes().

Referenced by save().

        {
                global $ilUser;
                
                include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
                include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
                
                $all_required = true;
                foreach(ilCourseDefinedFieldDefinition::_getFields($this->obj_id) as $field_obj)
                {
                        switch($field_obj->getType())
                        {
                                case IL_CDF_TYPE_SELECT:
                                        $value = ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]);
                                        break;
                                
                                case IL_CDF_TYPE_TEXT:
                                        $value = ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]);      
                                        break;
                        }
                        $course_user_data = new ilCourseUserData($ilUser->getId(),$field_obj->getId());
                        $course_user_data->setValue($value);
                        $course_user_data->update();
                        
                        if($field_obj->isRequired() and !strlen($value))
                        {
                                $all_required = false;
                        }
                }       
                return $all_required;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseAgreementGUI::executeCommand (  ) 

Execute Command.

public

Definition at line 79 of file class.ilCourseAgreementGUI.php.

References $cmd.

        {
                $next_class = $this->ctrl->getNextClass($this);
                $cmd = $this->ctrl->getCmd();

                switch($next_class)
                {
                        default:
                                if(!$cmd)
                                {
                                        $cmd = 'showAgreement';
                                }
                                $this->$cmd();
                                break;
                }               
        }

ilCourseAgreementGUI::init (  )  [private]

Read setting.

private

Parameters:
 

Definition at line 283 of file class.ilCourseAgreementGUI.php.

References ilCourseUserData::_checkRequired().

Referenced by __construct().

        {
                global $ilUser;
                
                $this->required_fullfilled = ilCourseUserData::_checkRequired($ilUser->getId(),$this->obj_id);
                $this->agreement_required = $this->agreement->agreementRequired();
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseAgreementGUI::save (  )  [private]

Save.

private

Parameters:
 

Definition at line 146 of file class.ilCourseAgreementGUI.php.

References checkAgreement(), checkCourseDefinedFields(), ilUtil::sendInfo(), and showAgreement().

        {
                if(!$this->checkCourseDefinedFields())
                {
                        ilUtil::sendInfo($this->lng->txt('fill_out_all_required_fields'));
                        $this->showAgreement(false);
                        return false;
                }
                if(!$this->checkAgreement())
                {
                        ilUtil::sendInfo($this->lng->txt('crs_agreement_required'));
                        $this->showAgreement(false);
                        return false;
                }
                $this->agreement->setAccepted(true);
                $this->agreement->setAcceptanceTime(time());
                $this->agreement->save();
                
                $this->ctrl->returnToParent($this);
        }

Here is the call graph for this function:

ilCourseAgreementGUI::sendInfoMessage (  )  [private]

Send info message.

private

Definition at line 296 of file class.ilCourseAgreementGUI.php.

References ilUtil::sendInfo().

Referenced by showAgreement().

        {
                $message = '';
                if($this->agreement_required)
                {
                        $message = $this->lng->txt('ps_agreement_req_info');
                }
                if(!$this->required_fullfilled)
                {
                        if(strlen($message))
                        {
                                $message .= '<br />';
                        }
                        $message .= $this->lng->txt('ps_required_info');
                }
                
                if(strlen($message))
                {
                        ilUtil::sendInfo($message);
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseAgreementGUI::showAgreement ( send_info = true  )  [private]

show agreement

private

Definition at line 102 of file class.ilCourseAgreementGUI.php.

References ilExportFieldsInfo::_getInstance(), ilCourseDefinedFieldDefinition::_hasFields(), ilUtil::formCheckbox(), sendInfoMessage(), and showCourseDefinedFields().

Referenced by save().

        {
                
                $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.crs_user_agreement.html','Modules/Course');
                $this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
                
                if($send_info)
                {
                        $this->sendInfoMessage();
                }
                $this->showCourseDefinedFields();
                
                include_once('Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php');
                $fields_info = ilExportFieldsInfo::_getInstance();
                
                foreach($fields_info->getExportableFields() as $field)
                {
                        $this->tpl->setCurrentBlock('field');
                        $this->tpl->setVariable('FIELD_NAME',$this->lng->txt($field));
                        $this->tpl->parseCurrentBlock();
                }
                
                $this->tpl->setVariable('AGREEMENT_HEADER',$this->lng->txt('crs_agreement_header'));
                $this->tpl->setVariable('TXT_AGREEMENT',$this->lng->txt('crs_user_agreement'));
                $this->tpl->setVariable('TXT_INFO_AGREEMENT',$this->lng->txt('crs_info_agreement'));

                if($this->privacy->confirmationRequired() or ilCourseDefinedFieldDefinition::_hasFields($this->obj_id))
                {
                        $this->tpl->setCurrentBlock('agreement');
                        $this->tpl->setVariable('CHECK_AGREE',ilUtil::formCheckbox(0,'agreed',1));
                        $this->tpl->setVariable('INFO_AGREE',$this->lng->txt('crs_info_agree'));
                        $this->tpl->setVariable('TXT_AGREE',$this->lng->txt('crs_agree'));
                        $this->tpl->parseCurrentBlock();
                }
                $this->tpl->setVariable('TXT_SAVE',$this->lng->txt('save'));
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseAgreementGUI::showCourseDefinedFields (  )  [private]

Definition at line 167 of file class.ilCourseAgreementGUI.php.

References ilCourseDefinedFieldDefinition::_getFields(), and ilUtil::formSelect().

Referenced by showAgreement().

        {
                global $ilUser;
                
                include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
                include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');

                if(!count($cdf_fields = ilCourseDefinedFieldDefinition::_getFields($this->obj_id)))
                {
                        return true;
                }
                
                foreach($cdf_fields as $field_obj)
                {
                        $course_user_data = new ilCourseUserData($ilUser->getId(),$field_obj->getId());
                        
                        switch($field_obj->getType())
                        {
                                case IL_CDF_TYPE_SELECT:
                                        $this->tpl->setCurrentBlock('sel_row');
                                        $this->tpl->setVariable('SEL_SELECT',ilUtil::formSelect($course_user_data->getValue(),
                                                                                                                                                        'cdf['.$field_obj->getId().']',
                                                                                                                                                        $field_obj->prepareSelectBox(),
                                                                                                                                                        false,
                                                                                                                                                        true));
                                        break;
                                case IL_CDF_TYPE_TEXT:
                                        $this->tpl->setCurrentBlock('txt_row');
                                        $this->tpl->setVariable('TXT_ROW_NAME',$field_obj->getId());
                                        $this->tpl->setVariable('TXT_ROW_VALUE',$course_user_data->getValue());
                                        break;
                        }
                        if($field_obj->isRequired())
                        {
                                $this->show_required_info = true;
                                $this->tpl->touchBlock('cdf_required');
                        }
                        
                        $this->tpl->setCurrentBlock('cdf_row');
                        $this->tpl->setVariable('CDF_FIELD_NAME',$field_obj->getName());
                        $this->tpl->parseCurrentBlock();
                }
                $this->tpl->setCurrentBlock('cdf');
                $this->tpl->setVariable('CDF_TXT',$this->lng->txt('ps_cdf_info'));
                $this->tpl->parseCurrentBlock();
        }

Here is the call graph for this function:

Here is the caller graph for this function:


Field Documentation

ilCourseAgreementGUI::$agreement [private]

Definition at line 49 of file class.ilCourseAgreementGUI.php.

ilCourseAgreementGUI::$ctrl [private]

Definition at line 44 of file class.ilCourseAgreementGUI.php.

ilCourseAgreementGUI::$db [private]

Definition at line 43 of file class.ilCourseAgreementGUI.php.

ilCourseAgreementGUI::$lng [private]

Definition at line 45 of file class.ilCourseAgreementGUI.php.

Referenced by __construct().

ilCourseAgreementGUI::$obj_id [private]

Definition at line 41 of file class.ilCourseAgreementGUI.php.

ilCourseAgreementGUI::$privacy [private]

Definition at line 48 of file class.ilCourseAgreementGUI.php.

ilCourseAgreementGUI::$ref_id [private]

Definition at line 40 of file class.ilCourseAgreementGUI.php.

ilCourseAgreementGUI::$tpl [private]

Definition at line 46 of file class.ilCourseAgreementGUI.php.

Referenced by __construct().


The documentation for this class was generated from the following file: