/**
  * Completes the registration process of a new user by activating the account
  *
  * @return string
  */
 private function completeRegistration()
 {
     $strReturn = "";
     if ($this->getSystemid() != "") {
         $objUser = new class_module_user_user($this->getParam("systemid"));
         if ($objUser->getStrEmail() != "") {
             if ($objUser->getIntActive() == 0 && $objUser->getIntLogins() == 0 && $objUser->getStrAuthcode() == $this->getParam("authcode") && $objUser->getStrAuthcode() != "") {
                 $objUser->setIntActive(1);
                 $objUser->setStrAuthcode("");
                 if ($objUser->updateObjectToDb()) {
                     $strReturn .= $this->getLang("pr_completionSuccess");
                     if ($this->arrElementData["portalregistration_success"] != "") {
                         $this->portalReload(class_link::getLinkPortalHref($this->arrElementData["portalregistration_success"]));
                     }
                 }
             } else {
                 $strReturn .= $this->getLang("pr_completionErrorStatus");
             }
         } else {
             $strReturn .= $this->getLang("pr_completionErrorStatus");
         }
     }
     return $strReturn;
 }
示例#2
0
 /**
  * Sends, finally, the mail
  *
  * @return bool
  */
 public function sendMail()
 {
     $bitReturn = false;
     //Do we have all neccessary arguments?
     if (count($this->arrayTo) > 0) {
         $bitReturn = true;
     }
     if ($bitReturn) {
         //Building the mail
         $strTo = implode(", ", $this->arrayTo);
         //Sender
         if ($this->strSender == "") {
             //try to load the current users' mail adress
             if (validateSystemid(class_carrier::getInstance()->getObjSession()->getUserID())) {
                 $objUser = new class_module_user_user(class_carrier::getInstance()->getObjSession()->getUserID());
                 if (checkEmailaddress($objUser->getStrEmail())) {
                     $this->strSender = $objUser->getStrEmail();
                 }
             }
         }
         if ($this->strSender == "" || class_module_system_setting::getConfigValue("_system_email_forcesender_") == "true") {
             $this->strSender = class_module_system_setting::getConfigValue("_system_email_defaultsender_");
         }
         if ($this->strSender != "") {
             //build the from-arguments
             if ($this->strSenderName != "") {
                 $strFrom = $this->encodeText($this->strSenderName) . " <" . $this->strSender . ">";
             } else {
                 $strFrom = $this->strSender;
             }
             $this->arrHeader[] = "From: " . $strFrom . $this->strEndOfLine;
             $this->arrHeader[] = "Reply-To: " . $this->strSender . $this->strEndOfLine;
         }
         //cc
         if (count($this->arrayCc) > 0) {
             $this->arrHeader[] = "Cc: " . implode(", ", $this->arrayCc) . $this->strEndOfLine;
         }
         //bcc
         if (count($this->arrayBcc) > 0) {
             $this->arrHeader[] = "Bcc: " . implode(", ", $this->arrayBcc) . $this->strEndOfLine;
         }
         //Kajona Headers to avoid being marked as spam
         $this->arrHeader[] = "X-Mailer: Kajona Mailer V4" . $this->strEndOfLine;
         $this->arrHeader[] = "Message-ID: <" . generateSystemid() . "_kajona@" . getServer("SERVER_NAME") . ">" . $this->strEndOfLine;
         //header for multipartmails?
         $strBoundary = generateSystemid();
         if ($this->bitMultipart || $this->bitFileAttached) {
             $this->arrHeader[] = 'MIME-Version: 1.0' . $this->strEndOfLine;
             //file attached?
             if ($this->bitFileAttached) {
                 $this->arrHeader[] = "Content-Type: multipart/related; boundary=\"" . $strBoundary . "\"" . $this->strEndOfLine;
             } else {
                 $this->arrHeader[] = "Content-Type: multipart/alternative; boundary=\"" . $strBoundary . "\"" . $this->strEndOfLine;
             }
         }
         //generate the mail-body
         $strBody = "";
         //multipart mail using html?
         if ($this->bitMultipart) {
             //multipart encoded mail
             $strBoundaryAlt = generateSystemid();
             //if a file should attached, a splitter is needed here
             if ($this->bitFileAttached) {
                 $strBody .= "--" . $strBoundary . $this->strEndOfLine;
                 $strBody .= "Content-Type: multipart/alternative; boundary=\"" . $strBoundaryAlt . "\"" . $this->strEndOfLine;
             } else {
                 //no new boundary-section, use old boundary instead
                 $strBoundaryAlt = $strBoundary;
             }
             //place a body for strange mail-clients
             $strBody .= "This is a multi-part message in MIME format." . $this->strEndOfLine . $this->strEndOfLine;
             //text-version
             $strBody .= "--" . $strBoundaryAlt . $this->strEndOfLine;
             $strBody .= "Content-Type: text/plain; charset=UTF-8" . $this->strEndOfLine;
             $strText = strip_tags($this->strText == "" ? str_replace(array("<br />", "<br />"), array("\n", "\n"), $this->strHtml) : $this->strText);
             if (function_exists("quoted_printable_encode")) {
                 $strBody .= "Content-Transfer-Encoding: quoted-printable" . $this->strEndOfLine . $this->strEndOfLine;
                 $strBody .= quoted_printable_encode($strText);
             } else {
                 $strBody .= "Content-Transfer-Encoding: 8bit" . $this->strEndOfLine . $this->strEndOfLine;
                 $strBody .= $strText;
             }
             $strBody .= $this->strEndOfLine . $this->strEndOfLine;
             //html-version
             if ($this->strHtml != "") {
                 $strBody .= "--" . $strBoundaryAlt . $this->strEndOfLine;
                 $strBody .= "Content-Type: text/html; charset=UTF-8" . $this->strEndOfLine;
                 $strBody .= "Content-Transfer-Encoding: 8bit" . $this->strEndOfLine . $this->strEndOfLine;
                 $strBody .= $this->strHtml;
                 $strBody .= $this->strEndOfLine . $this->strEndOfLine;
             }
             if ($this->bitFileAttached) {
                 $strBody .= "--" . $strBoundaryAlt . "--" . $this->strEndOfLine . $this->strEndOfLine;
             }
         } else {
             $this->arrHeader[] = "Content-Type: text/plain; charset=UTF-8" . $this->strEndOfLine;
             if (function_exists("quoted_printable_encode")) {
                 $this->arrHeader[] = "Content-Transfer-Encoding: quoted-printable" . $this->strEndOfLine;
                 $strBody .= quoted_printable_encode($this->strText);
             } else {
                 $strBody .= $this->strText;
             }
         }
         //any files to place in the mail body?
         if ($this->bitFileAttached) {
             foreach ($this->arrFiles as $arrOneFile) {
                 $strFileContents = chunk_split(base64_encode(file_get_contents($arrOneFile["filename"])));
                 //place file in mailbody
                 $strBody .= "--" . $strBoundary . $this->strEndOfLine;
                 $strBody .= "Content-Type: " . $arrOneFile["mimetype"] . "; name=\"" . basename($arrOneFile["filename"]) . "\"" . $this->strEndOfLine;
                 $strBody .= "Content-Transfer-Encoding: base64" . $this->strEndOfLine;
                 if ($arrOneFile["inline"] === true) {
                     $strBody .= "Content-Disposition: inline; filename=\"" . basename($arrOneFile["filename"]) . "\"" . $this->strEndOfLine;
                     $strBody .= "Content-ID: <" . basename($arrOneFile["filename"]) . ">" . $this->strEndOfLine . $this->strEndOfLine;
                 } else {
                     $strBody .= "Content-Disposition: attachment; filename=\"" . basename($arrOneFile["filename"]) . "\"" . $this->strEndOfLine . $this->strEndOfLine;
                 }
                 $strBody .= $strFileContents;
                 $strBody .= $this->strEndOfLine . $this->strEndOfLine;
             }
         }
         //finish mail
         if ($this->bitFileAttached || $this->bitMultipart) {
             $strBody .= "--" . $strBoundary . "--" . $this->strEndOfLine . $this->strEndOfLine;
         }
         //send mail
         // in some cases, the optional param "-f test@kajona.de" may be added as mail()s' 5th param
         class_logger::getInstance()->addLogRow("sent mail to " . $strTo, class_logger::$levelInfo);
         $bitReturn = mail($strTo, $this->encodeText($this->strSubject), $strBody, implode("", $this->arrHeader));
     }
     return $bitReturn;
 }
 /**
  * @return string
  * @permissions edit
  */
 protected function actionSendPasswordFinal()
 {
     $strReturn = "";
     $objUser = new class_module_user_user($this->getSystemid());
     //add a one-time token and reset the password
     $strToken = generateSystemid();
     $objUser->setStrAuthcode($strToken);
     $objUser->updateObjectToDb();
     $strActivationLink = class_link::getLinkAdminHref("login", "pwdReset", "&systemid=" . $objUser->getSystemid() . "&authcode=" . $strToken, false);
     class_carrier::getInstance()->getObjLang()->setStrTextLanguage($objUser->getStrAdminlanguage());
     $objMail = new class_mail();
     $objMail->addTo($objUser->getStrEmail());
     $objMail->setSubject($this->getLang("user_password_resend_subj"));
     $objMail->setText($this->getLang("user_password_resend_body", array($strActivationLink)));
     if ($this->getParam("form_user_sendusername") != "") {
         $objMail->setText($this->getLang("user_password_resend_body_username", array($objUser->getStrUsername(), $strActivationLink)));
     }
     $objMail->sendMail();
     $this->adminReload(class_link::getLinkAdminHref($this->getArrModule("modul")));
     return $strReturn;
 }
 /**
  * Sends a copy of the message to the user by mail
  *
  * @param class_module_messaging_message $objMessage
  * @param class_module_user_user $objUser
  * @return bool
  */
 private function sendMessageByMail(class_module_messaging_message $objMessage, class_module_user_user $objUser)
 {
     $strOriginalLang = class_carrier::getInstance()->getObjLang()->getStrTextLanguage();
     class_carrier::getInstance()->getObjLang()->setStrTextLanguage($objUser->getStrAdminlanguage());
     $strSubject = $objMessage->getStrTitle() != "" ? $objMessage->getStrTitle() : class_carrier::getInstance()->getObjLang()->getLang("message_notification_subject", "messaging");
     $strBody = class_carrier::getInstance()->getObjLang()->getLang("message_prolog", "messaging");
     $strBody .= "\n\n" . class_link::getLinkAdminHref("messaging", "view", "&systemid=" . $objMessage->getSystemid(), false) . "\n\n";
     $strBody .= $objMessage->getStrBody();
     $objMail = new class_mail();
     //try to get a matching sender and place it into the mail
     if (validateSystemid($objMessage->getStrSenderId())) {
         $objSenderUser = new class_module_user_user($objMessage->getStrSenderId());
         $objValidator = new class_email_validator();
         if ($objValidator->validate($objSenderUser->getStrEmail())) {
             $objMail->setSender($objSenderUser->getStrEmail());
         }
     }
     $objMail->setSubject($strSubject);
     $objMail->setText($strBody);
     $objMail->addTo($objUser->getStrEmail());
     class_carrier::getInstance()->getObjLang()->setStrTextLanguage($strOriginalLang);
     return $objMail->sendMail();
 }
 /**
  * @return string
  */
 public function getStrEmail()
 {
     if (validateSystemid($this->getStrUserId())) {
         $objUser = new class_module_user_user($this->getStrUserId());
         return $objUser->getStrEmail();
     }
     return $this->strEmail;
 }
 /**
  * Sends an email. In most cases this mail was generated using the form
  * provided by actionMailForm
  *
  * @return string
  * @since 3.4
  * @permissions view
  */
 protected function actionSendMail()
 {
     $objForm = $this->getMailForm();
     if (!$objForm->validateForm()) {
         return $this->actionMailForm($objForm);
     }
     $this->setArrModuleEntry("template", "/folderview.tpl");
     $objUser = new class_module_user_user($this->objSession->getUserID());
     //mail or internal message?
     $objMailValidator = new class_email_validator();
     $objEmail = new class_mail();
     $objEmail->setSender($objUser->getStrEmail());
     $arrRecipients = explode(",", $this->getParam("mail_recipient"));
     foreach ($arrRecipients as $strOneRecipient) {
         if ($objMailValidator->validate($strOneRecipient)) {
             $objEmail->addTo($strOneRecipient);
         }
     }
     if ($objForm->getField("mail_cc")->getStrValue() != "") {
         $objUser = new class_module_user_user($objForm->getField("mail_cc")->getStrValue());
         $objEmail->addCc($objUser->getStrEmail());
     }
     $objEmail->setSubject($objForm->getField("mail_subject")->getStrValue());
     $objEmail->setText($objForm->getField("mail_body")->getStrValue());
     if ($objEmail->sendMail()) {
         return $this->getLang("mail_send_success");
     } else {
         return $this->getLang("mail_send_error");
     }
 }