/**
  * send notification about new user accounts
  *
  * @access protected
  */
 protected static function _sendNotification(ilECSSetting $server, ilObjUser $user_obj)
 {
     if (!count($server->getUserRecipients())) {
         return true;
     }
     // If sub id is set => mail was send
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     $import = new ilECSImport($server->getServerId(), $user_obj->getId());
     if ($import->getSubId()) {
         return false;
     }
     include_once './Services/Language/classes/class.ilLanguageFactory.php';
     $lang = ilLanguageFactory::_getLanguage();
     $lang->loadLanguageModule('ecs');
     include_once './Services/Mail/classes/class.ilMail.php';
     $mail = new ilMail(6);
     $mail->enableSoap(false);
     $subject = $lang->txt('ecs_new_user_subject');
     // build body
     $body = $lang->txt('ecs_new_user_body') . "\n\n";
     $body .= $lang->txt('ecs_new_user_profile') . "\n\n";
     $body .= $user_obj->getProfileAsString($lang) . "\n\n";
     $body .= ilMail::_getAutoGeneratedMessageString($lang);
     $mail->sendMail($server->getUserRecipientsAsString(), "", "", $subject, $body, array(), array("normal"));
     // Store sub_id = 1 in ecs import which means mail is send
     $import->setSubId(1);
     $import->save();
     return true;
 }
Exemplo n.º 2
0
 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&reg_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&reg_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&reg_confirmation_msg=' . $exception->getMessage() . "&lang=" . $usr_lang);
     } catch (ilRegistrationHashNotFoundException $exception) {
         ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg=' . $exception->getMessage() . "&lang=" . $usr_lang);
     }
 }
 /**
  * Send notification
  *
  * @access private
  * @param
  * 
  */
 private function sendNotification($user_obj)
 {
     if (!count($this->getCurrentServer()->getUserRecipients())) {
         return true;
     }
     include_once './Services/Language/classes/class.ilLanguageFactory.php';
     include_once './Services/Language/classes/class.ilLanguage.php';
     $lang = ilLanguageFactory::_getLanguage();
     $GLOBALS['lng'] = $lang;
     $GLOBALS['ilUser'] = $user_obj;
     $lang->loadLanguageModule('ecs');
     include_once './Services/Mail/classes/class.ilMail.php';
     $mail = new ilMail(6);
     $mail->enableSoap(false);
     $subject = $lang->txt('ecs_new_user_subject');
     // build body
     $body = $lang->txt('ecs_new_user_body') . "\n\n";
     $body .= $lang->txt('ecs_new_user_profile') . "\n\n";
     $body .= $user_obj->getProfileAsString($lang) . "\n\n";
     $body .= ilMail::_getAutoGeneratedMessageString($lang);
     $mail->sendMail($this->getCurrentServer()->getUserRecipientsAsString(), "", "", $subject, $body, array(), array("normal"));
 }