public function confirmRegistration() { global $lng, $ilias, $ilLog; ilUtil::setCookie('iltest', 'cookie', false); if (!isset($_GET['rh']) || !strlen(trim($_GET['rh']))) { ilUtil::redirect('./login.php?cmd=force_login®_confirmation_msg=reg_confirmation_hash_not_passed'); } try { require_once 'Services/Registration/classes/class.ilRegistrationSettings.php'; $oRegSettings = new ilRegistrationSettings(); $usr_id = ilObjUser::_verifyRegistrationHash(trim($_GET['rh'])); $oUser = ilObjectFactory::getInstanceByObjId($usr_id); $oUser->setActive(true); if ($oRegSettings->passwordGenerationEnabled()) { $passwd = ilUtil::generatePasswords(1); $password = $passwd[0]; $oUser->setPasswd($password, IL_PASSWD_PLAIN); $oUser->setLastPasswordChangeTS(time()); } $oUser->update(); $usr_lang = $oUser->getPref('language'); if ($lng->getLangKey() != $usr_lang) { $lng = new ilLanguage($usr_lang); } // send email // try individual account mail in user administration include_once "Services/Mail/classes/class.ilAccountMail.php"; include_once './Services/User/classes/class.ilObjUserFolder.php'; $amail = ilObjUserFolder::_lookupNewAccountMail($usr_lang); if (trim($amail["body"]) != "" && trim($amail["subject"]) != "") { $acc_mail = new ilAccountMail(); $acc_mail->setUser($oUser); if ($oRegSettings->passwordGenerationEnabled()) { $acc_mail->setUserPassword($password); } $acc_mail->send(); } else { include_once 'Services/Mail/classes/class.ilMail.php'; $mail_obj = new ilMail(ANONYMOUS_USER_ID); // mail subject $subject = $lng->txt("reg_mail_subject"); // mail body $body = $lng->txt("reg_mail_body_salutation") . " " . $oUser->getFullname() . ",\n\n" . $lng->txt("reg_mail_body_text1") . "\n\n" . $lng->txt("reg_mail_body_text2") . "\n" . ILIAS_HTTP_PATH . "/login.php?client_id=" . CLIENT_ID . "\n"; $body .= $lng->txt("login") . ": " . $oUser->getLogin() . "\n"; if ($oRegSettings->passwordGenerationEnabled()) { $body .= $lng->txt("passwd") . ": " . $password . "\n"; } $body .= "\n"; $body .= $lng->txt('reg_mail_body_forgot_password_info') . "\n"; $body .= "\n"; $body .= $lng->txt("reg_mail_body_text3") . "\n\r"; $body .= $oUser->getProfileAsString($lng); $mail_obj->enableSoap(false); $mail_obj->appendInstallationSignature(true); $mail_obj->sendMail($oUser->getEmail(), '', '', $subject, $body, array(), array('normal')); } ilUtil::redirect('./login.php?cmd=force_login®_confirmation_msg=reg_account_confirmation_successful&lang=' . $usr_lang); } catch (ilRegConfirmationLinkExpiredException $exception) { include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php'; $soap_client = new ilSoapClient(); $soap_client->setResponseTimeout(1); $soap_client->enableWSDL(true); $soap_client->init(); $ilLog->write(__METHOD__ . ': Triggered soap call (background process) for deletion of inactive user objects with expired confirmation hash values (dual opt in) ...'); $soap_client->call('deleteExpiredDualOptInUserObjects', array($_COOKIE['PHPSESSID'] . '::' . $_COOKIE['ilClientId'], $exception->getCode())); ilUtil::redirect('./login.php?cmd=force_login®_confirmation_msg=' . $exception->getMessage() . "&lang=" . $usr_lang); } catch (ilRegistrationHashNotFoundException $exception) { ilUtil::redirect('./login.php?cmd=force_login®_confirmation_msg=' . $exception->getMessage() . "&lang=" . $usr_lang); } }
/** * Called after login and successful call of fetch data * @return * @param object $a_username * @param object $a_auth */ public function loginObserver($a_username, $a_auth) { global $ilias, $rbacadmin, $lng, $ilSetting; $GLOBALS['ilLog']->write(__METHOD__ . ': SOAP login observer called'); // TODO: handle passed credentials via GET /* if (empty($_GET["ext_uid"]) || empty($_GET["soap_pw"])) { $this->status = AUTH_WRONG_LOGIN; return; } */ // Not required anymore /* $validation_data = $this->validateSoapUser($_GET["ext_uid"], $_GET["soap_pw"]); if (!$validation_data["valid"]) { $this->status = AUTH_WRONG_LOGIN; return; } */ $local_user = $this->response["local_user"]; if ($local_user != "") { // to do: handle update of user $a_auth->setAuth($local_user); return true; } if (!$ilSetting->get("soap_auth_create_users")) { $a_auth->status = AUTH_SOAP_NO_ILIAS_USER; $a_auth->logout(); return false; } //echo "1"; // try to map external user via e-mail to ILIAS user if ($this->response["email"] != "") { //echo "2"; //var_dump ($_POST); $email_user = ilObjUser::_getLocalAccountsForEmail($this->response["email"]); // check, if password has been provided in user mapping screen // (see ilStartUpGUI::showUserMappingSelection) // FIXME if ($_POST["LoginMappedUser"] != "") { if (count($email_user) > 0) { $user = ilObjectFactory::getInstanceByObjId($_POST["usr_id"]); require_once 'Services/User/classes/class.ilUserPasswordManager.php'; if (ilUserPasswordManager::getInstance()->verifyPassword($user, ilUtil::stripSlashes($_POST["password"]))) { // password is correct -> map user //$this->setAuth($local_user); (use login not id) ilObjUser::_writeExternalAccount($_POST["usr_id"], $_GET["ext_uid"]); ilObjUser::_writeAuthMode($_POST["usr_id"], "soap"); $_GET["cmd"] = $_POST["cmd"] = $_GET["auth_stat"] = ""; $local_user = ilObjUser::_lookupLogin($_POST["usr_id"]); $a_auth->status = ''; $a_auth->setAuth($local_user); return true; } else { //echo "6"; exit; $a_auth->status = AUTH_SOAP_NO_ILIAS_USER_BUT_EMAIL; $a_auth->setSubStatus(AUTH_WRONG_LOGIN); $a_auth->logout(); return false; } } } if (count($email_user) > 0 && $_POST["CreateUser"] == "") { $_GET["email"] = $this->response["email"]; $a_auth->status = AUTH_SOAP_NO_ILIAS_USER_BUT_EMAIL; $a_auth->logout(); return false; } } $userObj = new ilObjUser(); $local_user = ilAuthUtils::_generateLogin($a_username); $newUser["firstname"] = $this->response["firstname"]; $newUser["lastname"] = $this->response["lastname"]; $newUser["email"] = $this->response["email"]; $newUser["login"] = $local_user; // to do: set valid password and send mail $newUser["passwd"] = ""; $newUser["passwd_type"] = IL_PASSWD_CRYPTED; // generate password, if local authentication is allowed // and account mail is activated $pw = ""; if ($ilSetting->get("soap_auth_allow_local") && $ilSetting->get("soap_auth_account_mail")) { $pw = ilUtil::generatePasswords(1); $pw = $pw[0]; $newUser["passwd"] = $pw; $newUser["passwd_type"] = IL_PASSWD_PLAIN; } //$newUser["gender"] = "m"; $newUser["auth_mode"] = "soap"; $newUser["ext_account"] = $a_username; $newUser["profile_incomplete"] = 1; // system data $userObj->assignData($newUser); $userObj->setTitle($userObj->getFullname()); $userObj->setDescription($userObj->getEmail()); // set user language to system language $userObj->setLanguage($lng->lang_default); // Time limit $userObj->setTimeLimitOwner(7); $userObj->setTimeLimitUnlimited(1); $userObj->setTimeLimitFrom(time()); $userObj->setTimeLimitUntil(time()); // Create user in DB $userObj->setOwner(0); $userObj->create(); $userObj->setActive(1); $userObj->updateOwner(); //insert user data in table user_data $userObj->saveAsNew(false); // setup user preferences $userObj->writePrefs(); // to do: test this $rbacadmin->assignUser($ilSetting->get('soap_auth_user_default_role'), $userObj->getId(), true); // send account mail if ($ilSetting->get("soap_auth_account_mail")) { include_once './Services/User/classes/class.ilObjUserFolder.php'; $amail = ilObjUserFolder::_lookupNewAccountMail($ilSetting->get("language")); if (trim($amail["body"]) != "" && trim($amail["subject"]) != "") { include_once "Services/Mail/classes/class.ilAccountMail.php"; $acc_mail = new ilAccountMail(); if ($pw != "") { $acc_mail->setUserPassword($pw); } $acc_mail->setUser($userObj); $acc_mail->send(); } } unset($userObj); $a_auth->setAuth($local_user); return true; }
protected function __distributeMails($password, $a_language = null) { global $ilSetting; include_once './Services/Language/classes/class.ilLanguage.php'; include_once './Services/User/classes/class.ilObjUser.php'; include_once "Services/Mail/classes/class.ilFormatMail.php"; include_once './Services/Registration/classes/class.ilRegistrationMailNotification.php'; // Always send mail to approvers if ($this->registration_settings->getRegistrationType() == IL_REG_APPROVE && !$this->code_was_used) { $mail = new ilRegistrationMailNotification(); $mail->setType(ilRegistrationMailNotification::TYPE_NOTIFICATION_CONFIRMATION); $mail->setRecipients($this->registration_settings->getApproveRecipients()); $mail->setAdditionalInformation(array('usr' => $this->userObj)); $mail->send(); } else { $mail = new ilRegistrationMailNotification(); $mail->setType(ilRegistrationMailNotification::TYPE_NOTIFICATION_APPROVERS); $mail->setRecipients($this->registration_settings->getApproveRecipients()); $mail->setAdditionalInformation(array('usr' => $this->userObj)); $mail->send(); } // Send mail to new user // Registration with confirmation link ist enabled if ($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION && !$this->code_was_used) { include_once './Services/Registration/classes/class.ilRegistrationMimeMailNotification.php'; $mail = new ilRegistrationMimeMailNotification(); $mail->setType(ilRegistrationMimeMailNotification::TYPE_NOTIFICATION_ACTIVATION); $mail->setRecipients(array($this->userObj)); $mail->setAdditionalInformation(array('usr' => $this->userObj, 'hash_lifetime' => $this->registration_settings->getRegistrationHashLifetime())); $mail->send(); } else { // try individual account mail in user administration include_once "Services/Mail/classes/class.ilAccountMail.php"; include_once './Services/User/classes/class.ilObjUserFolder.php'; $amail = ilObjUserFolder::_lookupNewAccountMail($a_language); if (trim($amail["body"]) == "" || trim($amail["subject"]) == "") { $amail = ilObjUserFolder::_lookupNewAccountMail($GLOBALS["lng"]->getDefaultLanguage()); } if (trim($amail["body"]) != "" && trim($amail["subject"]) != "") { $acc_mail = new ilAccountMail(); $acc_mail->setUser($this->userObj); if ($this->registration_settings->passwordGenerationEnabled()) { $acc_mail->setUserPassword($password); } if ($amail["att_file"]) { include_once "Services/User/classes/class.ilFSStorageUserFolder.php"; $fs = new ilFSStorageUserFolder(USER_FOLDER_ID); $fs->create(); $path = $fs->getAbsolutePath() . "/"; $acc_mail->addAttachment($path . "/" . $amail["lang"], $amail["att_file"]); } $acc_mail->send(); } else { include_once "Services/Mail/classes/class.ilMimeMail.php"; $mmail = new ilMimeMail(); $mmail->autoCheck(false); $mmail->From($ilSetting->get("admin_email")); $mmail->To($this->userObj->getEmail()); // mail subject $subject = $this->lng->txt("reg_mail_subject"); // mail body $body = $this->lng->txt("reg_mail_body_salutation") . " " . $this->userObj->getFullname() . ",\n\n" . $this->lng->txt("reg_mail_body_text1") . "\n\n" . $this->lng->txt("reg_mail_body_text2") . "\n" . ILIAS_HTTP_PATH . "/login.php?client_id=" . CLIENT_ID . "\n"; $body .= $this->lng->txt("login") . ": " . $this->userObj->getLogin() . "\n"; if ($this->registration_settings->passwordGenerationEnabled()) { $body .= $this->lng->txt("passwd") . ": " . $password . "\n"; } $body .= "\n"; // Info about necessary approvement if ($this->registration_settings->getRegistrationType() == IL_REG_APPROVE && !$this->code_was_used) { $body .= $this->lng->txt('reg_mail_body_pwd_generation') . "\n\n"; } $body .= $this->lng->txt("reg_mail_body_text3") . "\n\r"; $body .= $this->userObj->getProfileAsString($this->lng); $mmail->Subject($subject); $mmail->Body($body); $mmail->Send(); } } }
/** * save user data * @access public */ function saveObject() { global $ilAccess, $ilSetting, $tpl, $ilUser, $rbacadmin, $rbacsystem; include_once './Services/Authentication/classes/class.ilAuthUtils.php'; // User folder if (!$rbacsystem->checkAccess('create_usr', $this->usrf_ref_id) && !$ilAccess->checkAccess('cat_administrate_users', "", $this->usrf_ref_id)) { $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE); } $this->initCreate(); $this->initForm("create"); // Manipulate form so ignore required fields are no more required. This has to be done before ilPropertyFormGUI::checkInput() is called. $profileMaybeIncomplete = false; if ($this->form_gui->getInput('ignore_rf', false)) { $profileMaybeIncomplete = $this->handleIgnoredRequiredFields(); } if ($this->form_gui->checkInput()) { // @todo: external account; time limit check and savings // checks passed. save user $userObj = $this->loadValuesFromForm(); $userObj->setPasswd($this->form_gui->getInput('passwd'), IL_PASSWD_PLAIN); $userObj->setTitle($userObj->getFullname()); $userObj->setDescription($userObj->getEmail()); $udf = array(); foreach ($_POST as $k => $v) { if (substr($k, 0, 4) == "udf_") { $udf[substr($k, 4)] = $v; } } $userObj->setUserDefinedData($udf); $userObj->create(); include_once './Services/Authentication/classes/class.ilAuthUtils.php'; if (ilAuthUtils::_isExternalAccountEnabled()) { $userObj->setExternalAccount($_POST["ext_account"]); } // set a timestamp for last_password_change // this ts is needed by ilSecuritySettings $userObj->setLastPasswordChangeTS(time()); //insert user data in table user_data $userObj->saveAsNew(); // setup user preferences if ($this->isSettingChangeable('language')) { $userObj->setLanguage($_POST["language"]); } // Set disk quota require_once 'Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php'; if (ilDiskQuotaActivationChecker::_isActive()) { // The disk quota is entered in megabytes but stored in bytes $userObj->setPref("disk_quota", trim($_POST["disk_quota"]) * ilFormat::_getSizeMagnitude() * ilFormat::_getSizeMagnitude()); } if ($this->isSettingChangeable('skin_style')) { //set user skin and style $sknst = explode(":", $_POST["skin_style"]); if ($userObj->getPref("style") != $sknst[1] || $userObj->getPref("skin") != $sknst[0]) { $userObj->setPref("skin", $sknst[0]); $userObj->setPref("style", $sknst[1]); } } if ($this->isSettingChangeable('hits_per_page')) { $userObj->setPref("hits_per_page", $_POST["hits_per_page"]); } if ($this->isSettingChangeable('show_users_online')) { $userObj->setPref("show_users_online", $_POST["show_users_online"]); } if ($this->isSettingChangeable('hide_own_online_status')) { $userObj->setPref("hide_own_online_status", $_POST["hide_own_online_status"] ? 'y' : 'n'); } if ((int) $ilSetting->get('session_reminder_enabled')) { $userObj->setPref('session_reminder_enabled', (int) $_POST['session_reminder_enabled']); } $userObj->writePrefs(); //set role entries $rbacadmin->assignUser($_POST["default_role"], $userObj->getId(), true); $msg = $this->lng->txt("user_added"); $ilUser->setPref('send_info_mails', $_POST['send_mail'] == 'y' ? 'y' : 'n'); $ilUser->writePrefs(); $this->object = $userObj; if ($this->isSettingChangeable('upload')) { $this->uploadUserPictureObject(); } if ($profileMaybeIncomplete) { include_once 'Services/User/classes/class.ilUserProfile.php'; if (ilUserProfile::isProfileIncomplete($this->object)) { $this->object->setProfileIncomplete(true); $this->object->update(); } } // send new account mail if ($_POST['send_mail'] == 'y') { include_once 'Services/Mail/classes/class.ilAccountMail.php'; $acc_mail = new ilAccountMail(); $acc_mail->useLangVariablesAsFallback(true); $acc_mail->setUserPassword($_POST['passwd']); $acc_mail->setUser($userObj); if ($acc_mail->send()) { $msg = $msg . '<br />' . $this->lng->txt('mail_sent'); ilUtil::sendSuccess($msg, true); } else { $msg = $msg . '<br />' . $this->lng->txt('mail_not_sent'); ilUtil::sendInfo($msg, true); } } else { ilUtil::sendSuccess($msg, true); } if (strtolower($_GET["baseClass"]) == 'iladministrationgui') { $this->ctrl->redirectByClass("ilobjuserfoldergui", "view"); } else { $this->ctrl->redirectByClass('ilobjcategorygui', 'listUsers'); } } else { $this->form_gui->setValuesByPost(); $tpl->setContent($this->form_gui->getHtml()); } }