public function sendPwForget($session_id, $context_id, $identification) { $xml = ""; $valid = true; $errorArray = array(); if ($this->_isSessionValid($session_id)) { $this->_environment->setCurrentContextID($context_id); $translator = $this->_environment->getTranslationObject(); $portalItem = $this->_environment->getCurrentPortalItem(); $authSourceList = $portalItem->getAuthSourceListEnabled(); $authSourceItem = $authSourceList->getFirst(); $defaultAuthSource = null; while ($authSourceItem) { if ($authSourceItem->isCommSyDefault()) { $defaultAuthSource = $authSourceItem; break; } else { $authSourceItem = $authSourceList->getNext(); } } $userManager = $this->_environment->getUserManager(); $checkUser = $userManager->exists($identification, $authSourceItem->getItemId()); if (!$checkUser) { $errorArray['missing'] = "Die Kennung " . $identification . " existiert nicht. Bitte überprüfen Sie Ihre Eingabe."; } else { $userManager->resetLimits(); $userManager->setContextLimit($context_id); $userManager->setUserIDLimit($identification); $userManager->setAuthSourceLimit($authSourceItem->getItemId()); $userManager->select(); $userList = $userManager->get(); $userItem = $userList->getFirst(); $authSourceManager = $this->_environment->getAuthSourceManager(); $sessionManager = $this->_environment->getSessionManager(); while ($userItem) { $authSourceItem = $authSourceManager->getItem($userItem->getAuthSource()); if ($authSourceItem->allowAddAccount()) { include_once 'classes/cs_session_item.php'; $specialSessionItem = new cs_session_item(); $specialSessionItem->createSssionID($identification); $specialSessionItem->setValue('auth_source', $userItem->getAuthSource()); if ($identification == 'root') { $specialSessionItem->setValue('commsy_id', $this->_environment->getServerID()); } else { $specialSessionItem->setValue('commsy_id', $this->_environment->getCurrentPortalID()); } // if ( isset($_SERVER["SERVER_ADDR"]) and !empty($_SERVER["SERVER_ADDR"])) { // $new_special_session_item->setValue('password_forget_ip',$_SERVER["SERVER_ADDR"]); // } else { // $new_special_session_item->setValue('password_forget_ip',$_SERVER["HTTP_HOST"]); // } include_once 'functions/date_functions.php'; $specialSessionItem->setValue('passwort_forget_time', getCurrentDateTimeInMySQL()); $specialSessionItem->setValue('javascript', -1); $specialSessionItem->setValue('cookie', 0); $sessionManager->save($specialSessionItem); } $userEmail = $userItem->getEMail(); $userFullname = $userItem->getFullname(); $url = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"] . "?cid=" . $this->_environment->getCurrentPortalID(); if ($authSourceItem->allowAddAccount()) { $url .= "&SID=" . $specialSessionItem->getSessionId(); } // send email $modText = ""; $modList = $portalitem->getModeratorList(); if (!$modList->isEmpty()) { $modItem = $modList->getFirst(); $contactModerator = $modItem; while ($modItem) { if (!empty($modText)) { $modText .= "," . LF; } $modText .= $modItem->getFullname(); $modText .= " (" . $modItem->getEmail() . ")"; $modItem = $modList->getNext(); } } include_once 'classes/cs_mail.php'; $mail = new cs_mail(); $mail->set_to($userEmail); $serverItem = $this->_environment->getServerItem(); $defaultSenderAddress = $serverItem->getDefaultSenderAddress(); if (!empty($defaultSenderAddress)) { $mail->set_from_email($defaultSenderAddress); } else { $mail->set_from_email("@"); } if (!empty($contactModerator)) { $mail->set_reply_to_email($contactModerator->getEmail()); $mail->set_reply_to_name($contactModerator->getFullname()); } $mail->set_from_name($translator->getMessage('SYSTEM_MAIL_MESSAGE', $portalItem->getTitle())); $mail->set_subject($translator->getMessage('USER_PASSWORD_MAIL_SUBJECT', $portalItem->getTitle())); $body = $translator->getMessage('MAIL_AUTO', $translator->getDateInLang(getCurrentDateTimeInMySQL()), $translator->getTimeInLang(getCurrentDateTimeInMySQL())); $body .= LF . LF; $body .= $translator->getEmailMessage('MAIL_BODY_HELLO', $userFullname); $body .= LF . LF; if ($authSourceItem->allowAddAccount()) { $body .= $translator->getMessage('USER_PASSWORD_MAIL_BODY', $identification, $portalItem->getTitle(), $url, '15'); } else { $body .= $translator->getMessage('USER_PASSWORD_MAIL_BODY_SORRY', $identification, $portalItem->getTitle()); $body .= LF . LF; $body .= $translator->getMessage('USER_PASSWORD_MAIL_BODY_SORRY2', $authSourceItem->getTitle()); $link = $authSourceItem->getPasswordChangeLink(); $contactMail = $authSourceItem->getContactEMail(); if (!empty($link)) { $body .= LF . LF; $body .= $translator->getMessage('USER_PASSWORD_MAIL_BODY_SORRY2_LINK', $link); } if (!empty($contact_mail)) { $body .= LF . LF; $body .= $translator->getMessage('USER_PASSWORD_MAIL_BODY_SORRY2_MAIL', $authSourceItem->getTitle(), $contactMail); } $body .= LF . LF; $body .= $translator->getMessage('USER_PASSWORD_MAIL_BODY_SORRY3'); } $body .= LF . LF; if (empty($contactModerator)) { $body .= $translator->getMessage('SYSTEM_MAIL_REPLY_INFO') . LF; $body .= $modText; $body .= LF . LF; } else { $body .= $translator->getEmailMessage('MAIL_BODY_CIAO', $contactModerator->getFullname(), $contextItem->getTitle()); $body .= LF . LF; } $mail->set_message($body); if (!$mail->send()) { $errorArray["send_" . $userItem->getItemId()] = ''; } $userItem = $userList->getNext(); } } if (sizeof($errorArray) > 0) { $xml = "<errors>\n"; foreach ($errorArray as $code => $description) { $xml .= "<" . $code . "><![CDATA[" . $description . "]]></" . $code . ">\n"; } $xml .= "</errors>"; } else { $xml = "<success></success>"; } $xml = $this->_encode_output($xml); } else { return new SoapFault('ERROR', 'Session (' . $session_id . ') not valid!'); } return $xml; }