/**
  * @return bool
  */
 public function getStatus()
 {
     return ilTermsOfServiceHelper::isEnabled();
 }
 /**
  * 
  */
 protected function getAcceptedContentAsynch()
 {
     require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceJsonResponse.php';
     $response = new ilTermsOfServiceJsonResponse();
     if (!isset($_GET['tosv_id'])) {
         $response->setStatus(ilTermsOfServiceJsonResponse::STATUS_FAILURE);
         echo $response;
     }
     $entity = ilTermsOfServiceHelper::getById(ilUtil::stripSlashes($_GET['tosv_id']));
     $response->setBody($entity->getText());
     echo $response;
 }
Example #3
0
 /**
  * @param bool|null $status
  * @return void|bool
  */
 public function hasToAcceptTermsOfServiceInSession($status = null)
 {
     if (null === $status) {
         return ilSession::get('has_to_accept_agr_in_session');
     }
     require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
     if (ilTermsOfServiceHelper::isEnabled()) {
         ilSession::set('has_to_accept_agr_in_session', (int) $status);
     }
 }
Example #4
0
 /**
  * Show terms of service
  */
 protected function showTermsOfService()
 {
     /**
      * @var $lng       ilLanguage
      * @var $tpl       ilTemplate
      * @var $ilUser    ilObjUser
      * @var $ilSetting ilSetting
      */
     global $lng, $tpl, $ilUser, $ilSetting;
     $back_to_login = '******' != $this->ctrl->getCmd();
     self::initStartUpTemplate('tpl.view_terms_of_service.html', $back_to_login, !$back_to_login);
     $tpl->setVariable('TXT_PAGEHEADLINE', $lng->txt('usr_agreement'));
     try {
         require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
         $document = ilTermsOfServiceSignableDocumentFactory::getByLanguageObject($lng);
         if ('getAcceptance' == $this->ctrl->getCmd()) {
             if (isset($_POST['status']) && 'accepted' == $_POST['status']) {
                 require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
                 ilTermsOfServiceHelper::trackAcceptance($ilUser, $document);
                 if (ilSession::get('orig_request_target')) {
                     $target = ilSession::get('orig_request_target');
                     ilSession::set('orig_request_target', '');
                     ilUtil::redirect($target);
                 } else {
                     ilUtil::redirect('index.php?target=' . $_GET['target'] . '&client_id=' . CLIENT_ID);
                 }
             }
             $tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, $this->ctrl->getCmd()));
             $tpl->setVariable('ACCEPT_CHECKBOX', ilUtil::formCheckbox(0, 'status', 'accepted'));
             $tpl->setVariable('ACCEPT_TERMS_OF_SERVICE', $lng->txt('accept_usr_agreement'));
             $tpl->setVariable('TXT_SUBMIT', $lng->txt('submit'));
         }
         $tpl->setVariable('TERMS_OF_SERVICE_CONTENT', $document->getContent());
     } catch (ilTermsOfServiceNoSignableDocumentFoundException $e) {
         $tpl->setVariable('TERMS_OF_SERVICE_CONTENT', sprintf($lng->txt('no_agreement_description'), 'mailto:' . ilUtil::prepareFormOutput($ilSetting->get('feedback_recipient'))));
     }
     $tpl->show();
 }
 /**
  * @param string $a_component
  * @param string $a_event
  * @param array  $a_parameter
  */
 public static function handleEvent($a_component, $a_event, $a_parameter)
 {
     if ('deleteUser' == $a_event && 'Services/User' == $a_component) {
         ilTermsOfServiceHelper::deleteAcceptanceHistoryByUser($a_parameter['usr_id']);
     }
 }
 protected function __createUser($a_role)
 {
     /**
      * @var $ilSetting ilSetting
      * @var $rbacadmin ilRbacAdmin
      * @var $lng       ilLanguage
      */
     global $ilSetting, $rbacadmin, $lng;
     // something went wrong with the form validation
     if (!$a_role) {
         global $ilias;
         $ilias->raiseError("Invalid role selection in registration" . ", IP: " . $_SERVER["REMOTE_ADDR"], $ilias->error_obj->FATAL);
     }
     $this->userObj = new ilObjUser();
     include_once "./Services/User/classes/class.ilUserProfile.php";
     $up = new ilUserProfile();
     $up->setMode(ilUserProfile::MODE_REGISTRATION);
     $map = array();
     $up->skipGroup("preferences");
     $up->skipGroup("settings");
     $up->skipGroup("instant_messengers");
     $up->skipField("password");
     $up->skipField("birthday");
     $up->skipField("upload");
     foreach ($up->getStandardFields() as $k => $v) {
         if ($v["method"]) {
             $method = "set" . substr($v["method"], 3);
             if (method_exists($this->userObj, $method)) {
                 if ($k != "username") {
                     $k = "usr_" . $k;
                 }
                 $field_obj = $this->form->getItemByPostVar($k);
                 if ($field_obj) {
                     $this->userObj->{$method}($this->form->getInput($k));
                 }
             }
         }
     }
     $this->userObj->setFullName();
     $birthday_obj = $this->form->getItemByPostVar("usr_birthday");
     if ($birthday_obj) {
         $birthday = $this->form->getInput("usr_birthday");
         $birthday = $birthday["date"];
         // when birthday was not set, array will not be substituted with string by ilBirthdayInputGui
         if (!is_array($birthday)) {
             $this->userObj->setBirthday($birthday);
         }
     }
     // messenger
     $map = array("icq", "yahoo", "msn", "aim", "skype", "jabber", "voip");
     foreach ($map as $client) {
         $field = "usr_im_" . $client;
         $field_obj = $this->form->getItemByPostVar($field);
         if ($field_obj) {
             $this->userObj->setInstantMessengerId($client, $this->form->getInput($field));
         }
     }
     $this->userObj->setTitle($this->userObj->getFullname());
     $this->userObj->setDescription($this->userObj->getEmail());
     if ($this->registration_settings->passwordGenerationEnabled()) {
         $password = ilUtil::generatePasswords(1);
         $password = $password[0];
     } else {
         $password = $this->form->getInput("usr_password");
     }
     $this->userObj->setPasswd($password);
     // Set user defined data
     include_once './Services/User/classes/class.ilUserDefinedFields.php';
     $user_defined_fields =& ilUserDefinedFields::_getInstance();
     $defs = $user_defined_fields->getRegistrationDefinitions();
     $udf = array();
     foreach ($_POST as $k => $v) {
         if (substr($k, 0, 4) == "udf_") {
             $f = substr($k, 4);
             $udf[$f] = $v;
         }
     }
     $this->userObj->setUserDefinedData($udf);
     $this->userObj->setTimeLimitOwner(7);
     $access_limit = null;
     $this->code_was_used = false;
     if ($this->code_enabled) {
         $code_local_roles = $code_has_access_limit = null;
         // #10853 - could be optional
         $code = $this->form->getInput('usr_registration_code');
         if ($code) {
             include_once './Services/Registration/classes/class.ilRegistrationCode.php';
             // set code to used
             ilRegistrationCode::useCode($code);
             $this->code_was_used = true;
             // handle code attached local role(s) and access limitation
             $code_data = ilRegistrationCode::getCodeData($code);
             if ($code_data["role_local"]) {
                 // need user id before we can assign role(s)
                 $code_local_roles = explode(";", $code_data["role_local"]);
             }
             if ($code_data["alimit"]) {
                 // see below
                 $code_has_access_limit = true;
                 switch ($code_data["alimit"]) {
                     case "absolute":
                         $abs = date_parse($code_data["alimitdt"]);
                         $access_limit = mktime(23, 59, 59, $abs['month'], $abs['day'], $abs['year']);
                         break;
                     case "relative":
                         $rel = unserialize($code_data["alimitdt"]);
                         $access_limit = $rel["d"] * 86400 + $rel["m"] * 2592000 + $rel["y"] * 31536000 + time();
                         break;
                 }
             }
         }
     }
     // code access limitation will override any other access limitation setting
     if (!($this->code_was_used && $code_has_access_limit) && $this->registration_settings->getAccessLimitation()) {
         include_once 'Services/Registration/classes/class.ilRegistrationRoleAccessLimitations.php';
         $access_limitations_obj = new ilRegistrationRoleAccessLimitations();
         switch ($access_limitations_obj->getMode($a_role)) {
             case 'absolute':
                 $access_limit = $access_limitations_obj->getAbsolute($a_role);
                 break;
             case 'relative':
                 $rel_d = (int) $access_limitations_obj->getRelative($a_role, 'd');
                 $rel_m = (int) $access_limitations_obj->getRelative($a_role, 'm');
                 $rel_y = (int) $access_limitations_obj->getRelative($a_role, 'y');
                 $access_limit = $rel_d * 86400 + $rel_m * 2592000 + $rel_y * 31536000 + time();
                 break;
         }
     }
     if ($access_limit) {
         $this->userObj->setTimeLimitUnlimited(0);
         $this->userObj->setTimeLimitUntil($access_limit);
     } else {
         $this->userObj->setTimeLimitUnlimited(1);
         $this->userObj->setTimeLimitUntil(time());
     }
     $this->userObj->setTimeLimitFrom(time());
     $this->userObj->create();
     if ($this->registration_settings->getRegistrationType() == IL_REG_DIRECT || $this->registration_settings->getRegistrationType() == IL_REG_CODES || $this->code_was_used) {
         $this->userObj->setActive(1, 0);
     } else {
         if ($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION) {
             $this->userObj->setActive(0, 0);
         } else {
             $this->userObj->setActive(0, 0);
         }
     }
     $this->userObj->updateOwner();
     // set a timestamp for last_password_change
     // this ts is needed by ilSecuritySettings
     $this->userObj->setLastPasswordChangeTS(time());
     $this->userObj->setIsSelfRegistered(true);
     //insert user data in table user_data
     $this->userObj->saveAsNew();
     try {
         require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
         ilTermsOfServiceHelper::trackAcceptance($this->userObj, ilTermsOfServiceSignableDocumentFactory::getByLanguageObject($lng));
     } catch (ilTermsOfServiceNoSignableDocumentFoundException $e) {
     }
     // setup user preferences
     $this->userObj->setLanguage($this->form->getInput('usr_language'));
     $hits_per_page = $ilSetting->get("hits_per_page");
     if ($hits_per_page < 10) {
         $hits_per_page = 10;
     }
     $this->userObj->setPref("hits_per_page", $hits_per_page);
     $show_online = $ilSetting->get("show_users_online");
     if ($show_online == "") {
         $show_online = "y";
     }
     $this->userObj->setPref("show_users_online", $show_online);
     $this->userObj->writePrefs();
     $rbacadmin->assignUser((int) $a_role, $this->userObj->getId());
     // local roles from code
     if ($this->code_was_used && is_array($code_local_roles)) {
         foreach (array_unique($code_local_roles) as $local_role_obj_id) {
             // is given role (still) valid?
             if (ilObject::_lookupType($local_role_obj_id) == "role") {
                 $rbacadmin->assignUser($local_role_obj_id, $this->userObj->getId());
             }
         }
     }
     return $password;
 }
Example #7
0
 /**
  * 
  */
 protected function showAcceptedTermsOfService()
 {
     /**
      * @var $agree_date ilNonEditableValueGUI
      */
     $agree_date = $this->form_gui->getItemByPostVar('agree_date');
     if ($agree_date && $agree_date->getValue()) {
         $this->lng->loadLanguageModule('tos');
         require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
         /**
          * @var $entity ilTermsOfServiceAcceptanceEntity
          */
         $entity = ilTermsOfServiceHelper::getCurrentAcceptanceForUser($this->object);
         if ($entity->getId()) {
             $show_agreement_text = new ilCheckboxInputGUI($this->lng->txt('tos_show_signed_text'), 'tos_show_signed_text');
             $agreement_lang = new ilNonEditableValueGUI($this->lng->txt('language'), '');
             $agreement_lang->setValue($this->lng->txt('meta_l_' . $entity->getIso2LanguageCode()));
             $show_agreement_text->addSubItem($agreement_lang);
             require_once 'Services/TermsOfService/classes/form/class.ilTermsOfServiceSignedDocumentFormElementGUI.php';
             $agreement_document = new ilTermsOfServiceSignedDocumentFormElementGUI($this->lng->txt('tos_agreement_document'), '', $entity);
             $show_agreement_text->addSubItem($agreement_document);
             $agree_date->addSubItem($show_agreement_text);
         }
     } else {
         if ($agree_date) {
             $agree_date->setValue($this->lng->txt('tos_not_accepted_yet'));
         }
     }
 }
 /**
  * Show terms of service
  */
 protected function showTermsOfService()
 {
     /**
      * @var $lng       ilLanguage
      * @var $tpl       ilTemplate
      * @var $ilUser    ilObjUser
      * @var $ilSetting ilSetting
      */
     global $lng, $tpl, $ilUser, $ilSetting;
     $back_to_login = '******' != $this->ctrl->getCmd();
     self::initStartUpTemplate('tpl.view_terms_of_service.html', $back_to_login, !$back_to_login);
     $tpl->setVariable('TXT_PAGEHEADLINE', $lng->txt('usr_agreement'));
     // #9728
     $lang_opts = array();
     foreach ($lng->getInstalledLanguages() as $lang_key) {
         $lang_opts[$lang_key] = ilLanguage::_lookupEntry($lang_key, "meta", "meta_l_" . $lang_key);
     }
     if (sizeof($lang_opts) > 1) {
         asort($lang_opts);
         foreach ($lang_opts as $lang_key => $lang_caption) {
             $tpl->setCurrentBlock('lang_headline_languages');
             $tpl->setVariable('LANG_HEADLINE_LANGUAGES_LANG_NAME', $lang_caption);
             $tpl->setVariable('LANG_HEADLINE_LANGUAGES_LANG_KEY', $lang_key);
             if ($lang_key == $lng->getLangKey()) {
                 $tpl->setVariable('LANG_HEADLINE_LANGUAGES_SELECTED_LANG', ' selected="selected"');
             }
             $tpl->parseCurrentBlock();
         }
         $tpl->setCurrentBlock('lang_headline');
         $tpl->setVariable('LANG_CHANGE_CMD', $this->ctrl->getCmd());
         $tpl->setVariable('LANG_CHANGE_FORMACTION', $this->ctrl->getFormAction($this, $this->ctrl->getCmd()));
         $tpl->setVariable('LANG_CHANGE_TXT_OK', $lng->txt('ok'));
         $tpl->setVariable('LANG_CHANGE_TXT_CHOOSE_LANGUAGE', $lng->txt('choose_language'));
         $tpl->setCurrentBlock('lang_headline');
     }
     try {
         require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
         $document = ilTermsOfServiceSignableDocumentFactory::getByLanguageObject($lng);
         if ('getAcceptance' == $this->ctrl->getCmd()) {
             if (isset($_POST['status']) && 'accepted' == $_POST['status']) {
                 require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
                 ilTermsOfServiceHelper::trackAcceptance($ilUser, $document);
                 if (ilSession::get('orig_request_target')) {
                     $target = ilSession::get('orig_request_target');
                     ilSession::set('orig_request_target', '');
                     ilUtil::redirect($target);
                 } else {
                     ilUtil::redirect('index.php?target=' . $_GET['target'] . '&client_id=' . CLIENT_ID);
                 }
             }
             $tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, $this->ctrl->getCmd()));
             $tpl->setVariable('ACCEPT_CHECKBOX', ilUtil::formCheckbox(0, 'status', 'accepted'));
             $tpl->setVariable('ACCEPT_TERMS_OF_SERVICE', $lng->txt('accept_usr_agreement'));
             $tpl->setVariable('TXT_SUBMIT', $lng->txt('submit'));
         }
         $tpl->setVariable('TERMS_OF_SERVICE_CONTENT', $document->getContent());
     } catch (ilTermsOfServiceNoSignableDocumentFoundException $e) {
         $tpl->setVariable('TERMS_OF_SERVICE_CONTENT', sprintf($lng->txt('no_agreement_description'), 'mailto:' . $ilSetting->get('feedback_recipient')));
     }
     $tpl->show();
 }
 /**
  * 
  */
 protected function showAcceptedTermsOfService()
 {
     /**
      * @var $agree_date ilNonEditableValueGUI
      */
     $agree_date = $this->form_gui->getItemByPostVar('agree_date');
     if ($agree_date && $agree_date->getValue()) {
         $this->lng->loadLanguageModule('tos');
         require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
         /**
          * @var $entity ilTermsOfServiceAcceptanceEntity
          */
         $entity = ilTermsOfServiceHelper::getCurrentAcceptanceForUser($this->object);
         if ($entity->getId()) {
             $show_agreement_text = new ilCheckboxInputGUI($this->lng->txt('tos_show_signed_text'), 'tos_show_signed_text');
             $agreement_lang = new ilNonEditableValueGUI($this->lng->txt('language'), '');
             $agreement_lang->setValue($this->lng->txt('meta_l_' . $entity->getIso2LanguageCode()));
             $show_agreement_text->addSubItem($agreement_lang);
             $agreement_document = new ilNonEditableValueGUI($this->lng->txt('tos_agreement_document'), '', true);
             require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
             $action = new ilAdvancedSelectionListGUI();
             $action->setId('asl_content_accepted_content');
             $action->setListTitle($this->lng->txt('tos_accepted_content'));
             $action->setHeaderIcon(ilUtil::getImagePath('icon_preview.png'));
             $action->setAsynch(true);
             $action->setAsynchUrl($this->ctrl->getLinkTarget($this, 'showAgreementTextAsynch', '', true, false));
             $agreement_document->setValue($entity->getSource() . $action->getHtml());
             $show_agreement_text->addSubItem($agreement_document);
             $agree_date->addSubItem($show_agreement_text);
         }
     } else {
         if ($agree_date) {
             $agree_date->setValue($this->lng->txt('tos_not_accepted_yet'));
         }
     }
 }