function sendOrderEmail($params) { $ini = eZINI::instance(); if (isset($params['order']) and isset($params['email'])) { $order = $params['order']; $email = $params['email']; $tpl = eZTemplate::factory(); $tpl->setVariable('order', $order); $templateResult = $tpl->fetch('design:shop/orderemail.tpl'); $subject = $tpl->variable('subject'); $mail = new eZMail(); $emailSender = $ini->variable('MailSettings', 'EmailSender'); if (!$emailSender) { $emailSender = $ini->variable("MailSettings", "AdminEmail"); } if ($tpl->hasVariable('content_type')) { $mail->setContentType($tpl->variable('content_type')); } $mail->setReceiver($email); $mail->setSender($emailSender); $mail->setSubject($subject); $mail->setBody($templateResult); $mailResult = eZMailTransport::send($mail); $email = $ini->variable('MailSettings', 'AdminEmail'); $mail = new eZMail(); if ($tpl->hasVariable('content_type')) { $mail->setContentType($tpl->variable('content_type')); } $mail->setReceiver($email); $mail->setSender($emailSender); $mail->setSubject($subject); $mail->setBody($templateResult); $mailResult = eZMailTransport::send($mail); } }
function sendConfirmation() { if ($this->attribute('status') != eZSubscription::StatusPending) { return; } $res = eZTemplateDesignResource::instance(); $ini = eZINI::instance(); $hostname = eZSys::hostname(); $template = 'design:eznewsletter/sendout/registration.tpl'; $tpl = eZNewsletterTemplateWrapper::templateInit(); $tpl->setVariable('userData', eZUserSubscriptionData::fetch($this->attribute('email'))); $tpl->setVariable('hostname', $hostname); $tpl->setVariable('subscription', $this); $tpl->setVariable('subscriptionList', $this->attribute('subscription_list')); $templateResult = $tpl->fetch($template); if ($tpl->hasVariable('subject')) { $subject = $tpl->variable('subject'); } $mail = new eZMail(); $mail->setSender($ini->variable('MailSettings', 'EmailSender'), $ini->variable('SiteSettings', 'SiteName')); $mail->setReceiver($this->attribute('email')); $mail->setBody($templateResult); $mail->setSubject($subject); eZMailTransport::send($mail); }
function execute( $xml ) { $template = $xml->getAttribute( 'template' ); $receiverID = $xml->getAttribute( 'receiver' ); $nodeID = $xml->getAttribute( 'node' ); $ini = eZINI::instance(); $mail = new eZMail(); $tpl = eZTemplate::factory(); $node = eZContentObjectTreeNode::fetch( $nodeID ); if ( !$node ) { $node = eZContentObjectTreeNode::fetch( 2 ); } $emailSender = $ini->variable( 'MailSettings', 'EmailSender' ); if ( !$emailSender ) $emailSender = $ini->variable( "MailSettings", "AdminEmail" ); $receiver = eZUser::fetch( $receiverID ); if ( !$receiver ) { $emailReceiver = $emailSender; } else { $emailReceiver = $receiver->attribute( 'email' ); } $tpl->setVariable( 'node', $node ); $tpl->setVariable( 'receiver', $receiver ); $body = $tpl->fetch( 'design:' . $template ); $subject = $tpl->variable( 'subject' ); $mail->setReceiver( $emailReceiver ); $mail->setSender( $emailSender ); $mail->setSubject( $subject ); $mail->setBody( $body ); $mailResult = eZMailTransport::send( $mail ); return $mailResult; }
public function executeBeforeLastRedirect($node) { $survey = $this->fetchFeedbackSurvey(); $surveyQuestions = $this->feedbackQuestionList(); $mailTo = $this->fetchMailTo($surveyQuestions); if ($survey = $this->fetchFeedbackSurvey() and $survey instanceof eZSurvey and $surveyQuestions = $this->feedbackQuestionList() and $mailTo = $this->fetchMailTo($surveyQuestions) and eZMail::validate($mailTo)) { $tpl_email = eZTemplate::factory(); $tpl_email->setVariable('intro', $this->Text2); $tpl_email->setVariable('survey', $survey); $tpl_email->setVariable('survey_questions', $surveyQuestions); $tpl_email->setVariable('survey_node', $node); $templateResult = $tpl_email->fetch('design:survey/feedbackfield_mail.tpl'); if (trim($this->Text3) != '') { $subject = $this->Text3; } else { $subject = $tpl_email->variable('subject'); } $mail = new eZMail(); $ini = eZINI::instance(); $emailSender = $ini->variable('MailSettings', 'EmailSender'); if (!$emailSender) { $emailSender = $ini->variable('MailSettings', 'AdminEmail'); } $mail->setSenderText($emailSender); $mail->setReceiver($mailTo); $mail->setSubject($subject); $mail->setBody($templateResult); if ($this->Num == 1) { $adminReceiver = $ini->variable('MailSettings', 'AdminEmail'); $mail->addBcc($adminReceiver); } $mailResult = eZMailTransport::send($mail); } }
/** * Processes user activation * * @param eZUser $user * @param string $password */ public static function processUserActivation($user, $password) { $ini = eZINI::instance(); $tpl = eZTemplate::factory(); $tpl->setVariable('user', $user); $tpl->setVariable('object', $user->contentObject()); $tpl->setVariable('hostname', eZSys::hostname()); $tpl->setVariable('password', $password); // Check whether account activation is required. $verifyUserType = $ini->variable('UserSettings', 'VerifyUserType'); $sendUserMail = !!$verifyUserType; // For compatibility with old setting if ($verifyUserType === 'email' && $ini->hasVariable('UserSettings', 'VerifyUserEmail') && $ini->variable('UserSettings', 'VerifyUserEmail') !== 'enabled') { $verifyUserType = false; } if ($verifyUserType === 'email') { // Disable user account and send verification mail to the user $userID = $user->attribute('contentobject_id'); // Create enable account hash and send it to the newly registered user $hash = md5(mt_rand() . time() . $userID); if (eZOperationHandler::operationIsAvailable('user_activation')) { eZOperationHandler::execute('user', 'activation', array('user_id' => $userID, 'user_hash' => $hash, 'is_enabled' => false)); } else { eZUserOperationCollection::activation($userID, $hash, false); } // Log out current user eZUser::logoutCurrent(); $tpl->setVariable('hash', $hash); $sendUserMail = true; } else { if ($verifyUserType) { $verifyUserTypeClass = false; // load custom verify user settings if ($ini->hasGroup('VerifyUserType_' . $verifyUserType)) { if ($ini->hasVariable('VerifyUserType_' . $verifyUserType, 'File')) { include_once $ini->variable('VerifyUserType_' . $verifyUserType, 'File'); } $verifyUserTypeClass = $ini->variable('VerifyUserType_' . $verifyUserType, 'Class'); } // try to call the verify user class with function verifyUser if ($verifyUserTypeClass && method_exists($verifyUserTypeClass, 'verifyUser')) { $sendUserMail = call_user_func(array($verifyUserTypeClass, 'verifyUser'), $user, $tpl); } else { eZDebug::writeWarning("Unknown VerifyUserType '{$verifyUserType}'", 'ngconnect/profile'); } } } // send verification mail to user if email type or custom verify user type returned true if ($sendUserMail) { $mail = new eZMail(); $templateResult = $tpl->fetch('design:user/registrationinfo.tpl'); if ($tpl->hasVariable('content_type')) { $mail->setContentType($tpl->variable('content_type')); } $emailSender = $ini->variable('MailSettings', 'EmailSender'); if ($tpl->hasVariable('email_sender')) { $emailSender = $tpl->variable('email_sender'); } else { if (!$emailSender) { $emailSender = $ini->variable('MailSettings', 'AdminEmail'); } } $mail->setSender($emailSender); if ($tpl->hasVariable('subject')) { $subject = $tpl->variable('subject'); } else { $subject = ezpI18n::tr('kernel/user/register', 'Registration info'); } $mail->setSubject($subject); $mail->setReceiver($user->attribute('email')); $mail->setBody($templateResult); eZMailTransport::send($mail); } }
/** * @return bool */ function init() { if ( $this->hasKickstartData() ) { $data = $this->kickstartData(); $this->PersistenceList['email_info']['send'] = isset( $data['Send'] ) ? ( $data['Send'] == 'true' ) : true; $this->PersistenceList['email_info']['user_data'] = isset( $data['UserData'] ) ? $data['UserData'] : $this->defaultUserData; if ( $this->kickstartContinueNextStep() ) { if ( $this->PersistenceList['email_info']['send'] ) { $mailTpl = eZTemplate::factory(); $bodyText = $this->generateRegistration( $mailTpl, $this->PersistenceList['email_info']['user_data'] ); $subject = $mailTpl->variable( 'subject' ); // Fill in E-Mail data and send it $mail = new eZMail(); $mail->setReceiver( '*****@*****.**', 'eZ Site Registration' ); $mail->setSender( '*****@*****.**' ); $mail->setSubject( $subject ); $mail->setBody( $bodyText ); $mailResult = eZMailTransport::send( $mail ); $this->PersistenceList['email_info']['result'] = $mailResult; } else { $this->PersistenceList['email_info']['result'] = false; } return true; } else { return false; } } return false; // Always display registration information }
if ($http->hasPostVariable('SurveyReceiverID')) { $surveyList = $survey->fetchQuestionList(); $mailTo = $surveyList[$http->postVariable('SurveyReceiverID')]->answer(); $tpl_email = eZTemplate::factory(); $tpl_email->setVariable('survey', $survey); $tpl_email->setVariable('survey_questions', $surveyList); $templateResult = $tpl_email->fetch('design:survey/mail.tpl'); $subject = $tpl_email->variable('subject'); $mail = new eZMail(); $ini = eZINI::instance(); $emailSender = $ini->variable('MailSettings', 'EmailSender'); if (!$emailSender) { $emailSender = $ini->variable('MailSettings', 'AdminEmail'); } $mail->setSenderText($emailSender); $mail->setReceiver($mailTo); $mail->setSubject($subject); $mail->setBody($templateResult); $mailResult = eZMailTransport::send($mail); } $Module->redirectTo($survey->attribute('redirect_submit')); } $res = eZTemplateDesignResource::instance(); $res->setKeys(array(array('survey', $surveyID))); $tpl = eZTemplate::factory(); $tpl->setVariable('preview', false); $tpl->setVariable('survey', $survey); $tpl->setVariable('survey_validation', $validation); $Result = array(); $Result['content'] = $tpl->fetch('design:survey/view.tpl'); $Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('survey', 'Survey')));
function processViewActions($objectAttribute, &$survey, &$validation) { $http = eZHTTPTool::instance(); $actionContinue = false; $postNodeID = self::PREFIX_ATTRIBUTE . '_ezsurvey_node_id_' . $objectAttribute->attribute('id'); $postContentObjectAttributeID = self::PREFIX_ATTRIBUTE . '_ezsurvey_contentobjectattribute_id_' . $objectAttribute->attribute('id'); $postSurveyID = self::PREFIX_ATTRIBUTE . '_ezsurvey_id_' . $objectAttribute->attribute('id'); $continueViewActions = true; if ($survey->attribute('one_answer') == 1) { $user = eZUser::currentUser(); if ($user->isLoggedIn() === true) { $contentObjectID = $objectAttribute->attribute('contentobject_id'); $contentClassAttributeID = $objectAttribute->attribute('contentclassattribute_id'); $languageCode = $objectAttribute->attribute('language_code'); $surveyID = $survey->attribute('id'); $exist = eZSurveyResult::exist($surveyID, $user->attribute('contentobject_id'), $contentObjectID, $contentClassAttributeID, $languageCode); if ($exist === true) { $continueViewActions = false; } } else { $continueViewActions = false; } } if ($continueViewActions === true) { if ($http->hasPostVariable($postNodeID) and $http->hasPostVariable($postContentObjectAttributeID) and $http->hasPostVariable($postSurveyID)) { $surveyID = $http->postVariable($postSurveyID); $contentObjectAttributeID = $http->postVariable($postContentObjectAttributeID); $nodeID = $http->postVariable($postNodeID); $node = eZContentObjectTreeNode::fetch($nodeID); if (get_class($node) == 'eZContentObjectTreeNode' and $node->canRead() === true) { // verify that our attribute is included in this node. $dataMap = $node->dataMap(); foreach ($dataMap as $attribute) { $attributeObjectID = $attribute->attribute('id'); if ($attributeObjectID == $contentObjectAttributeID) { $actionContinue = true; break; } } } else { if (get_class($node) == 'eZContentObjectTreeNode') { eZDebug::writeWarning("Not enough permissions to read node with ID: " . $nodeID . ".", 'eZSurveyType::processViewActions'); } else { eZDebug::writeWarning("node with ID: " . $nodeID . " does not exist.", 'eZSurveyType::processViewActions'); return false; } } } else { eZDebug::writeWarning("All the postvariables {$postNodeID}, {$postContentObjectAttributeID} and {$postSurveyID} need to be supplied.", 'eZSurveyType::processViewActions'); return false; } $nodeID = $http->postVariable($postNodeID); $node = eZContentObjectTreeNode::fetch($nodeID); if ($actionContinue === true) { $survey = eZSurvey::fetch($surveyID); $status = $survey->validateContentObjectAttributeID($contentObjectAttributeID); if (!$survey or !$survey->published() or !$survey->enabled() or !$survey->valid()) { eZDebug::writeWarning('Survey is not valid', 'eZSurveyType::processViewActions'); return; } $params = array('prefix_attribute' => self::PREFIX_ATTRIBUTE, 'contentobjectattribute_id' => $contentObjectAttributeID); $variableArray = $survey->processViewActions($validation, $params); $postSurveyStoreButton = self::PREFIX_ATTRIBUTE . '_ezsurvey_store_button_' . $contentObjectAttributeID; $user = eZUser::currentUser(); if ($survey->attribute('persistent')) { $result = eZSurveyResult::instance($surveyID, $user->id()); } else { $result = eZSurveyResult::instance($surveyID); } $result->setAttribute('user_id', $user->id()); $http = eZHTTPTool::instance(); $sessionID = $http->sessionID(); $result->setAttribute('user_session_id', $sessionID); if ($http->hasPostVariable($postSurveyStoreButton) && $validation['error'] == false) { $result->storeResult($params); $postReceiverID = self::PREFIX_ATTRIBUTE . '_ezsurvey_receiver_id_' . $contentObjectAttributeID; if ($http->hasPostVariable($postReceiverID) and $questionList = $survey->fetchQuestionList() and $postReceiverQuestionID = $http->postVariable($postReceiverID) and isset($questionList[$postReceiverQuestionID])) { $mailTo = $questionList[$postReceiverQuestionID]->answer(); $emailSenderList = explode('_', $questionList[$postReceiverQuestionID]->attribute('text3')); if (isset($emailSenderList[1]) and $emailSenderID = $emailSenderList[1] and is_numeric($emailSenderID) and $emailSenderID > 0 and isset($questionList[$emailSenderID]) and $senderQuestion = $questionList[$emailSenderID] and $senderQuestion->attribute('type') == 'EmailEntry' and eZMail::validate($senderQuestion->attribute('answer'))) { $emailSender = $senderQuestion->attribute('answer'); } else { $ini = eZINI::instance(); $emailSender = $ini->variable('MailSettings', 'EmailSender'); if (!$emailSender) { $emailSender = $ini->variable('MailSettings', 'AdminEmail'); } } require_once 'kernel/common/template.php'; $tpl_email = templateInit(); $tpl_email->setVariable('survey', $survey); $tpl_email->setVariable('survey_questions', $questionList); $tpl_email->setVariable('survey_node', $node); $templateResult = $tpl_email->fetch('design:survey/mail.tpl'); $subject = $tpl_email->variable('subject'); $mail = new eZMail(); $mail->setSenderText($emailSender); $mail->setReceiver($mailTo); $mail->setSubject($subject); $mail->setBody($templateResult); $mailResult = eZMailTransport::send($mail); } $survey->executeBeforeLastRedirect($node); $href = trim($survey->attribute('redirect_submit')); $module = $GLOBALS['module']; if ($module instanceof eZModule) { if (trim($href) != "") { if (preg_match("/^http:\\/\\/.+/", $href)) { $module->redirectTo($href); } else { $originalHref = $href; $status = eZURI::transformURI($href); if ($status === true) { // Need to keep the original href, since it's // already changed here. $module->redirectTo($originalHref); } else { $http->redirect($href); } } } } } else { if ($validation['error'] == true and $survey->attribute('persistent') == true) { // Fix prevous results. $validation['post_variables']['active'] = true; $validation['post_variables']['variables'] = $variableArray; } } } } else { eZDebug::writeWarning('Answer for survey with userid: ' . $user->id() . ' does already exist', 'eZSurveyType::processViewActions'); $validation['one_answer']['warning'] = true; } }
/** * @todo set up soap and webdav tests */ public static function runTests() { $status_tests = array('db' => '0', 'cluster db' => '0', 'ldap server' => '0', 'web access' => '0', 'ezfind' => '0', 'mail' => '0'); $db = eZDB::instance(); if ($db->isConnected() === true) { $status_tests['db'] = '1'; } $clusterDBHandler = ezSysinfoClusterManager::clusterDBHandler(); if ($clusterDBHandler instanceof eZDBFileHandler) { // warning - we dig into the private parts of the cluster file handler, // as no real API are provided for it (yet) if (is_resource($clusterDBHandler->backend->db)) { $status_tests['cluster db'] = '1'; } } else { if (is_object($clusterDBHandler)) { // This is even worse: we have no right to know if db connection is ok. // So we replicate some code here... try { $clusterDBHandler->_connect(); $status_tests['cluster db'] = '1'; } catch (exception $e) { } } else { $status_tests['cluster db'] = 'X'; } } if (in_array('ezfind', eZExtension::activeExtensions())) { $ini = eZINI::instance('solr.ini'); $ezfinpingurl = $ini->variable('SolrBase', 'SearchServerURI') . "/admin/ping"; $data = eZHTTPTool::getDataByURL($ezfinpingurl, false); $pos2 = stripos($data, '<str name="status">OK</str>'); if ($pos2 !== false) { $status_tests['ezfind'] = '1'; } else { $status_tests['ezfind'] = '0'; } } else { $status_tests['ezfind'] = 'X'; } $ini = eZINI::instance('ldap.ini'); if ($ini->variable('LDAPSettings', 'LDAPEnabled') == 'true' && $ini->variable('LDAPSettings', 'LDAPServer') != '') { if (function_exists('ldap_connect')) { // code copied over ezldapuser class... $LDAPVersion = $ini->variable('LDAPSettings', 'LDAPVersion'); $LDAPServer = $ini->variable('LDAPSettings', 'LDAPServer'); $LDAPPort = $ini->variable('LDAPSettings', 'LDAPPort'); $LDAPBindUser = $ini->variable('LDAPSettings', 'LDAPBindUser'); $LDAPBindPassword = $ini->variable('LDAPSettings', 'LDAPBindPassword'); $ds = ldap_connect($LDAPServer, $LDAPPort); if ($ds) { ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $LDAPVersion); if ($LDAPBindUser == '') { $r = ldap_bind($ds); } else { $r = ldap_bind($ds, $LDAPBindUser, $LDAPBindPassword); } if ($r) { $status_tests['ldap server'] = '1'; } } } } else { $status_tests['ldap server'] = 'X'; } $ini = eZINI::instance('sysinfo.ini'); $websites = $ini->variable('SystemStatus', 'WebBeacons'); if (is_string($websites)) { $websites = array($websites); } foreach ($websites as $key => $site) { if (trim($site) == '') { unset($websites[$key]); } } if (count($websites)) { foreach ($websites as $site) { // current eZ code is broken if no curl is installed, as it does not check for 404 or such. // besides, it does not even support proxies... if (extension_loaded('curl')) { if (eZHTTPTool::getDataByURL($site, true)) { $status_tests['web access'] = '1'; break; } } else { $data = eZHTTPTool::getDataByURL($site, false); if ($data !== false && sysInfoTools::isHTTP200($data)) { $status_tests['web access'] = '1'; break; } } } } else { $status_tests['web access'] = 'X'; } $ini = eZINI::instance('sysinfo.ini'); $recipient = $ini->variable('SystemStatus', 'MailReceiver'); $mail = new eZMail(); if (trim($recipient) != '' && $mail->validate($recipient)) { $mail->setReceiver($recipient); $ini = eZINI::instance(); $sender = $ini->variable('MailSettings', 'EmailSender'); $mail->setSender($sender); $mail->setSubject("Test email"); $mail->setBody("This email was automatically sent while testing eZ Publish connectivity to the mail server. Please do not reply."); $mailResult = eZMailTransport::send($mail); if ($mailResult) { $status_tests['mail'] = '1'; } } else { $status_tests['mail'] = 'X'; } /* $ini = eZINI::instance( 'soap.ini' ); if ( $ini->variable( 'GeneralSettings', 'EnableSOAP' ) == 'true' ) { /// @todo... } else { $status_tests['ez soap'] = 'X'; } $ini = eZINI::instance( 'webdav.ini' ); if ( $ini->variable( 'GeneralSettings', 'EnableWebDAV' ) == 'true' ) { /// @todo... } else { $status_tests['ez webdav'] = 'X'; } */ return $status_tests; }
/** * * @param unknown_type $emailSender * @param unknown_type $emailReciever * @param unknown_type $emailSubject * @param unknown_type $emailBody * @param string $emailContentType * @param string $emailCharset * @return array */ function sendEmailWithEz($emailSender, $emailReciever, $emailSubject, $emailBody, $emailContentType = 'text/html', $emailCharset = 'utf-8') { $mail = new eZMail(); $redirectURL = false; $mail->setReceiver(trim($emailReciever)); $mail->setSender(trim($emailSender)); $mail->setSubject($emailSubject); $mail->setBody($emailBody); // $mail->setContentType( $type = 'text/html', $charset = false, $transferEncoding = false, $disposition = false, $boundary = false); $mail->setContentType($emailContentType, $emailCharset, $transferEncoding = false, $disposition = false, $boundary = false); $emailResultArray = array(); $emailResult = eZMailTransport::send($mail); $emailResult = array('email_result' => $emailResult, 'email_sender' => $emailSender, 'email_reciever' => $emailReciever, 'email_subject' => $emailSubject, 'email_content_type' => $emailContentType, 'email_charset' => $emailCharset); if ($mailResult === true) { $message = "send - " . $receiver['email'] . " - " . $receiver['name']; } else { $message = "not send - " . $receiver['email'] . " - " . $receiver['name']; } return $emailResult; }
public function testRegressionWrongPasswordCatchException() { ezpINIHelper::setINISetting('site.ini', 'MailSettings', 'TransportPassword', 'wrong password'); $mail = new eZMail(); $mail->setSender($this->adminEmail, $this->adminName); $mail->setReceiver($this->adminEmail, $this->adminName); $mail->setSubject(__FUNCTION__); $mail->setBody(__FUNCTION__); // catching the exception of wrong password and turning it into return false $this->assertEquals(false, eZMailTransport::send($mail)); }
/** * Remplace le destinataire du mail par le "faut" destinataire, * supprime tous les cc et bcc et les rajoute en entête du corp du message * * @param eZMail $mail L'objet mail à traiter */ private function doFakeRecepient (eZMail $mail) { $fakeHead = array(); $fakeHead[]='To: ' . $mail->receiverText(); foreach ($mail->ccReceiverTextList() as $aCcReceiver) { $fakeHead[] = 'Cc: ' . $aCcReceiver; } foreach ($mail->bccReceiverTextList() as $aBccReceiver) { $fakeHead[] = 'Bcc: ' . $aBccReceiver; } $mail->setReceiver($this->fakeReceiver); $mail->setCcElements(array()); $mail->setBccElements(array()); $origBody = $mail->body(); $newBody = '------' . __CLASS__ . '------' . "\n"; $newBody .= ':: Original parameters ::' . "\n\n"; $newBody .= implode("\n", $fakeHead) . "\n"; $newBody .= '------' . __CLASS__ . '------' . "\n\n"; $newBody .= $origBody; $mail->setBody($newBody); }
if ($fromEmail == null) { $fromEmail = $yourEmail; } if ($http->hasSessionVariable('ezpContentTipafriendList')) { if (strpos($http->sessionVariable('ezpContentTipafriendList'), $NodeID . '|' . $receiversEmail) !== false) { $error_strings[] = ezpI18n::tr('kernel/content', "You have already sent a tipafriend mail to this receiver regarding '%1' content", null, array($nodeName)); } } if (!isset($error_strings[0]) && !eZTipafriendRequest::checkReceiver($receiversEmail)) { $error_strings[] = ezpI18n::tr('kernel/content', 'The receiver has already received the maximum number of tipafriend mails the last hours'); } // no validation errors if (count($error_strings) == 0) { $mail = new eZMail(); $mail->setSender($fromEmail, $yourName); $mail->setReceiver($receiversEmail, $receiversName); $mail->setSubject($subject); // fetch $sectionID = $object->attribute('section_id'); $section = eZSection::fetch($sectionID); $res = eZTemplateDesignResource::instance(); $res->setKeys(array(array('object', $object->attribute('id')), array('remote_id', $object->attribute('remote_id')), array('node_remote_id', $node->attribute('remote_id')), array('class', $object->attribute('contentclass_id')), array('class_identifier', $object->attribute('class_identifier')), array('class_group', $object->attribute('match_ingroup_id_list')), array('section', $object->attribute('section_id')), array('section_identifier', $section->attribute('identifier')), array('node', $NodeID), array('parent_node', $node->attribute('parent_node_id')), array('depth', $node->attribute('depth')), array('url_alias', $node->attribute('url_alias')))); $overrideKeysAreSet = true; // fetch text from mail template $mailtpl = eZTemplate::factory(); $mailtpl->setVariable('hostname', $hostName); $mailtpl->setVariable('nodename', $nodeName); $mailtpl->setVariable('node_id', $NodeID); $mailtpl->setVariable('node', $node); $mailtpl->setVariable('your_name', $yourName); $mailtpl->setVariable('your_email', $yourEmail);
$res->setKeys(array(array('newsletter_view', 'register_subscription'))); $NewsletterItem = eZSendNewsletterItem::fetchByHash($Params['UserHash']); if (!$NewsletterItem) { return $Module->handleError(3, 'kernel'); } $sub = $NewsletterItem->userData(); $subscription = eZSubscription::fetch($NewsletterItem->attribute('subscription_id')); $tpl->setVariable('NewsletterItem', $NewsletterItem); $tpl->setVariable('UserHash', $Params['UserHash']); $tpl->setVariable('subscriptions', $subscription); if ($http->hasPostVariable('OKButton')) { $subscription->unsubscribe(); $siteini = eZINI::instance(); $sender = $siteini->variable('MailSettings', 'EmailSender'); $mail = new eZMail(); $mail->setReceiver($sub['email']); $mail->setSender($sender); $mail->setSubject(ezpI18n::tr('newsletteraddons', "Your subscription removal")); $hostName = eZSys::hostname(); $mailtpl = eZTemplate::instance(); $mailtpl->setVariable('hostname', $hostName); $mailtpl->setVariable('siteaccess', $GLOBALS['eZCurrentAccess']['name']); $mailtpl->setVariable('NewsletterItem', $NewsletterItem); $mailtext = $mailtpl->fetch('design:eznewsletter/unregister_subscription_email.tpl'); $mail->setBody($mailtext); eZMailTransport::send($mail); $Result = array(); $Result['content'] = $tpl->fetch("design:eznewsletter/unregister_subscription_success.tpl"); $Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('eznewsletter', 'Remove subscription'))); return; }
function sendConfirmation($email, $subscription, $subscribe) { //send mail $res = eZTemplateDesignResource::instance(); $ini = eZINI::instance(); $hostname = eZSys::hostname(); if ($subscribe) { $template = 'design:eznewsletter/sendout/subscription.tpl'; } else { $template = 'design:eznewsletter/sendout/unsubscription.tpl'; } $tpl = eZNewsletterTemplateWrapper::templateInit(); $tpl->setVariable('userData', eZUserSubscriptionData::fetch($email)); $tpl->setVariable('hostname', $hostname); $tpl->setVariable('subscription', $subscription); $subscriptionList = eZSubscriptionList::fetch($subscription->attribute('subscriptionlist_id'), eZSubscriptionList::StatusPublished, true, true); $tpl->setVariable('subscriptionList', $subscriptionList); $templateResult = $tpl->fetch($template); if ($tpl->hasVariable('subject')) { $subject = $tpl->variable('subject'); } $mail = new eZMail(); $mail->setSender($ini->variable('MailSettings', 'EmailSender')); $mail->setReceiver($email); $mail->setBody($templateResult); $mail->setSubject($subject); eZMailTransport::send($mail); }
/** * @todo we should return an error if the scalar values are queried without a .0 appendeded... */ function get($oid) { // warm up list of existing oids, if not yet done $this->oidList(); $internaloid = preg_replace('/\\.0$/', '', $oid); if (array_key_exists($internaloid, self::$simplequeries)) { $count = -1; if (strpos($internaloid, '2.1.4.') === 0) { // session-related queries: return -1 if not using db-based storage $ini = eZINI::instance(); $sessionHandler = $ini->variable('Session', 'Handler'); if ($sessionHandler != 'ezpSessionHandlerDB') { return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $count); } } if (strpos($internaloid, '2.1.6.') === 0) { // async-publication-related queries: return -1 if not using it $ini = eZINI::instance('content.ini'); if ($ini->variable('PublishingSettings', 'AsynchronousPublishing') != 'enabled') { return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $count); } } $db = self::eZDBinstance(); if ($db) { $results = $db->arrayQuery(str_replace('/*anonymousId*/', eZUser::anonymousId(), self::$simplequeries[$internaloid])); $db->close(); if (is_array($results) && count($results)) { $count = $results[0]['count']; } } return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $count); } if (array_key_exists($internaloid, self::$orderstatuslist)) { $oids = explode('.', $internaloid); switch ($oids[5]) { case '1': return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => self::$orderstatuslist[$internaloid]); case '2': return array('oid' => $oid, 'type' => eZSNMPd::TYPE_STRING, 'value' => self::$orderstatuslist[$internaloid]); case '3': case '4': $count = -1; $db = self::eZDBinstance(); if ($db) { $status = $db->arrayQuery('select count(*) as num from ezorder where is_temporary=0 and is_archived=' . ($oids[5] + 1) % 2 . ' and status_id=' . self::$orderstatuslist[$internaloid], array('column' => 'num')); $db->close(); if (is_array($status) && count($status)) { $count = $status[0]; } } return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $count); } } if (array_key_exists($internaloid, self::$cachelist)) { $cacheinfo = eZCache::fetchByID(self::$cachelist[$internaloid]); $oids = explode('.', $internaloid); switch ($oids[3]) { case '1': return array('oid' => $oid, 'type' => eZSNMPd::TYPE_STRING, 'value' => $cacheinfo['name']); case '2': return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => (int) $cacheinfo['enabled']); case '3': case '4': $fileINI = eZINI::instance('file.ini'); $handlerName = $fileINI->variable('ClusteringSettings', 'FileHandler'); switch ($handlerName) { case 'ezfs': case 'eZFSFileHandler': case 'eZFS2FileHandler': break; default: // the db-based filehandlers + dfs one not yet supported return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => -1); } // take care: this is hardcoded from knowledge of cache structure... if (strpos($cacheinfo['path'], 'var/cache/') === 0) { $cachedir = $cacheinfo['path']; } else { $cachedir = eZSys::cacheDirectory() . '/' . $cacheinfo['path']; } if ($oids[3] == '3') { $out = (int) eZsnmpdTools::countFilesInDir($cachedir); } else { $out = (int) eZsnmpdTools::countFilesSizeInDir($cachedir); } return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $out); } } if (array_key_exists($internaloid, self::$storagedirlist)) { $oids = explode('.', $internaloid); switch ($oids[3]) { case '1': return array('oid' => $oid, 'type' => eZSNMPd::TYPE_STRING, 'value' => self::$storagedirlist[$internaloid]); case '2': case '3': $fileINI = eZINI::instance('file.ini'); $handlerName = $fileINI->variable('ClusteringSettings', 'FileHandler'); switch ($handlerName) { case 'ezfs': case 'eZFSFileHandler': case 'eZFS2FileHandler': break; default: // the db-based filehandlers + dfs one not yet supported return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => -1); } if ($oids[3] == '2') { $out = (int) eZsnmpdTools::countFilesInDir(self::$storagedirlist[$internaloid]); } else { $out = (int) eZsnmpdTools::countFilesSizeInDir(self::$storagedirlist[$internaloid]); } return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $out); } } switch ($internaloid) { case '2.1.1': // verify if db can be connected to $ok = 1; $db = self::eZDBinstance(); if (!$db) { $ok = 0; } else { $db->close(); } return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $ok); /*case '2.2.1': // cache-blocks /// @todo ... $handlerName = $fileINI->variable( 'ClusteringSettings', 'FileHandler' ); switch( $handlerName ) { case 'ezfs': break; case 'ezdb': break; default: } case '2.2.2': // view-cache /// @todo ... $handlerName = $fileINI->variable( 'ClusteringSettings', 'FileHandler' ); switch( $handlerName ) { case 'ezfs': break; case 'ezdb': break; default: }*/ /*case '2.2.1': // cache-blocks /// @todo ... $handlerName = $fileINI->variable( 'ClusteringSettings', 'FileHandler' ); switch( $handlerName ) { case 'ezfs': break; case 'ezdb': break; default: } case '2.2.2': // view-cache /// @todo ... $handlerName = $fileINI->variable( 'ClusteringSettings', 'FileHandler' ); switch( $handlerName ) { case 'ezfs': break; case 'ezdb': break; default: }*/ case '2.4.1': // ldap connection $ini = eZINI::instance('ldap.ini'); if ($ini->variable('LDAPSettings', 'LDAPEnabled') == 'true' && $ini->variable('LDAPSettings', 'LDAPServer') != '') { $ok = 0; // code copied over from ezldapuser class... $LDAPVersion = $ini->variable('LDAPSettings', 'LDAPVersion'); $LDAPServer = $ini->variable('LDAPSettings', 'LDAPServer'); $LDAPPort = $ini->variable('LDAPSettings', 'LDAPPort'); $LDAPBindUser = $ini->variable('LDAPSettings', 'LDAPBindUser'); $LDAPBindPassword = $ini->variable('LDAPSettings', 'LDAPBindPassword'); $ds = ldap_connect($LDAPServer, $LDAPPort); if ($ds) { ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $LDAPVersion); if ($LDAPBindUser == '') { $r = ldap_bind($ds); } else { $r = ldap_bind($ds, $LDAPBindUser, $LDAPBindPassword); } if ($r) { $ok = 1; } // added: release resources, be ready for next test ldap_close($ds); } } else { $ok = -1; } return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $ok); case '2.4.2': // web connection $ini = eZINI::instance('snmpd.ini'); $websites = $ini->variable('StatusHandler', 'WebBeacons'); $ok = 0; if (is_string($websites)) { $websites = array($websites); } foreach ($websites as $key => $site) { if (trim($site) == '') { unset($websites[$key]); } } if (count($websites)) { foreach ($websites as $site) { // current eZ code is broken if no curl is installed, as it does not check for 404 or such. // besides, it does not even support proxies... if (extension_loaded('curl')) { if (eZHTTPTool::getDataByURL($site, true)) { $ok = 1; break; } } else { $data = eZHTTPTool::getDataByURL($site, false); if ($data !== false && sysInfoTools::isHTTP200($data)) { $ok = 1; break; } } } } else { $ok = -1; } return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $ok); case '2.4.3': // email connection $ini = eZINI::instance('snmpd.ini'); $recipient = $ini->variable('StatusHandler', 'MailReceiver'); $ok = 0; $mail = new eZMail(); if (trim($recipient) != '' && $mail->validate($recipient)) { $mail->setReceiver($recipient); $ini = eZINI::instance(); $sender = $ini->variable('MailSettings', 'EmailSender'); $mail->setSender($sender); $mail->setSubject("Test email"); $mail->setBody("This email was automatically sent while testing eZ Publish connectivity to the mail server. Please do not reply."); $mailResult = eZMailTransport::send($mail); if ($mailResult) { $ok = 1; } } else { $ok = -1; } return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $ok); case '2.5.1': $fileINI = eZINI::instance('file.ini'); $clusterhandler = $fileINI->variable('ClusteringSettings', 'FileHandler'); if ($clusterhandler == 'ezdb' || $clusterhandler == 'eZDBFileHandler') { $ok = 0; $dbFileHandler = eZClusterFileHandler::instance(); if ($dbFileHandler instanceof eZDBFileHandler) { // warning - we dig into the private parts of the cluster file handler, // as no real API are provided for it (yet) if (is_resource($dbFileHandler->backend->db)) { $ok = 1; } } } else { if ($clusterhandler == 'eZDFSFileHandler') { // This is even worse: we have no right to know if db connection is ok. // So we replicate some code here... $dbbackend = eZExtension::getHandlerClass(new ezpExtensionOptions(array('iniFile' => 'file.ini', 'iniSection' => 'eZDFSClusteringSettings', 'iniVariable' => 'DBBackend'))); try { $dbbackend->_connect(); $ok = 1; } catch (exception $e) { $ok = 0; } } else { $ok = -1; } } return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $ok); } return self::NO_SUCH_OID; // oid not managed }
function checkContentActions($module, $class, $object, $version, $contentObjectAttributes, $EditVersion, $EditLanguage) { if ($module->isCurrentAction('Cancel')) { $http = eZHTTPTool::instance(); if ($http->hasPostVariable('RedirectIfDiscarded')) { eZRedirectManager::redirectTo($module, $http->postVariable('RedirectIfDiscarded')); } else { eZRedirectManager::redirectTo($module, '/'); } $version->removeThis(); $http = eZHTTPTool::instance(); $http->removeSessionVariable("RegisterUserID"); $http->removeSessionVariable('StartedRegistration'); return eZModule::HOOK_STATUS_CANCEL_RUN; } if ($module->isCurrentAction('Publish')) { $http = eZHTTPTool::instance(); $user = eZUser::currentUser(); $operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $object->attribute('id'), 'version' => $version->attribute('version'))); // Break here if the publishing failed if ($operationResult['status'] !== eZModuleOperationInfo::STATUS_CONTINUE) { eZDebug::writeError('User object(' . $object->attribute('id') . ') could not be published.', 'user/register'); $module->redirectTo('/user/register/3'); return; } $object = eZContentObject::fetch($object->attribute('id')); // Check if user should be enabled and logged in unset($user); $user = eZUser::fetch($object->attribute('id')); $user->loginCurrent(); $receiver = $user->attribute('email'); $mail = new eZMail(); if (!$mail->validate($receiver)) { } $ini = eZINI::instance(); $tpl = eZTemplate::factory(); $tpl->setVariable('user', $user); $tpl->setVariable('object', $object); $hostname = eZSys::hostname(); $tpl->setVariable('hostname', $hostname); $password = $http->sessionVariable("GeneratedPassword"); $tpl->setVariable('password', $password); // Check whether account activation is required. $verifyUserType = $ini->variable('UserSettings', 'VerifyUserType'); $sendUserMail = !!$verifyUserType; // For compatibility with old setting if ($verifyUserType === 'email' && $ini->hasVariable('UserSettings', 'VerifyUserEmail') && $ini->variable('UserSettings', 'VerifyUserEmail') !== 'enabled') { $verifyUserType = false; } if ($verifyUserType === 'email') { // Disable user account and send verification mail to the user $userID = $object->attribute('id'); // Create enable account hash and send it to the newly registered user $hash = md5(mt_rand() . time() . $userID); if (eZOperationHandler::operationIsAvailable('user_activation')) { $operationResult = eZOperationHandler::execute('user', 'activation', array('user_id' => $userID, 'user_hash' => $hash, 'is_enabled' => false)); } else { eZUserOperationCollection::activation($userID, $hash, false); } // Log out current user eZUser::logoutCurrent(); $tpl->setVariable('hash', $hash); $sendUserMail = true; } else { if ($verifyUserType) { $verifyUserTypeClass = false; // load custom verify user settings if ($ini->hasGroup('VerifyUserType_' . $verifyUserType)) { if ($ini->hasVariable('VerifyUserType_' . $verifyUserType, 'File')) { include_once $ini->variable('VerifyUserType_' . $verifyUserType, 'File'); } $verifyUserTypeClass = $ini->variable('VerifyUserType_' . $verifyUserType, 'Class'); } // try to call the verify user class with function verifyUser if ($verifyUserTypeClass && method_exists($verifyUserTypeClass, 'verifyUser')) { $sendUserMail = call_user_func(array($verifyUserTypeClass, 'verifyUser'), $user, $tpl); } else { eZDebug::writeWarning("Unknown VerifyUserType '{$verifyUserType}'", 'user/register'); } } } // send verification mail to user if email type or custum verify user type returned true if ($sendUserMail) { $templateResult = $tpl->fetch('design:user/registrationinfo.tpl'); if ($tpl->hasVariable('content_type')) { $mail->setContentType($tpl->variable('content_type')); } $emailSender = $ini->variable('MailSettings', 'EmailSender'); if ($tpl->hasVariable('email_sender')) { $emailSender = $tpl->variable('email_sender'); } else { if (!$emailSender) { $emailSender = $ini->variable('MailSettings', 'AdminEmail'); } } if ($tpl->hasVariable('subject')) { $subject = $tpl->variable('subject'); } else { $subject = ezpI18n::tr('kernel/user/register', 'Registration info'); } $mail->setSender($emailSender); $mail->setReceiver($receiver); $mail->setSubject($subject); $mail->setBody($templateResult); $mailResult = eZMailTransport::send($mail); } $feedbackTypes = $ini->variableArray('UserSettings', 'RegistrationFeedback'); foreach ($feedbackTypes as $feedbackType) { switch ($feedbackType) { case 'email': // send feedback with the default email type $mail = new eZMail(); $tpl->resetVariables(); $tpl->setVariable('user', $user); $tpl->setVariable('object', $object); $tpl->setVariable('hostname', $hostname); $templateResult = $tpl->fetch('design:user/registrationfeedback.tpl'); if ($tpl->hasVariable('content_type')) { $mail->setContentType($tpl->variable('content_type')); } $emailSender = $ini->variable('MailSettings', 'EmailSender'); if ($tpl->hasVariable('email_sender')) { $emailSender = $tpl->variable('email_sender'); } else { if (!$emailSender) { $emailSender = $ini->variable('MailSettings', 'AdminEmail'); } } $feedbackReceiver = $ini->variable('UserSettings', 'RegistrationEmail'); if ($tpl->hasVariable('email_receiver')) { $feedbackReceiver = $tpl->variable('email_receiver'); } else { if (!$feedbackReceiver) { $feedbackReceiver = $ini->variable('MailSettings', 'AdminEmail'); } } if ($tpl->hasVariable('subject')) { $subject = $tpl->variable('subject'); } else { $subject = ezpI18n::tr('kernel/user/register', 'New user registered'); } $mail->setSender($emailSender); $mail->setReceiver($feedbackReceiver); $mail->setSubject($subject); $mail->setBody($templateResult); $mailResult = eZMailTransport::send($mail); break; default: $registrationFeedbackClass = false; // load custom registration feedback settings if ($ini->hasGroup('RegistrationFeedback_' . $feedbackType)) { if ($ini->hasVariable('RegistrationFeedback_' . $feedbackType, 'File')) { include_once $ini->variable('RegistrationFeedback_' . $feedbackType, 'File'); } $registrationFeedbackClass = $ini->variable('RegistrationFeedback_' . $feedbackType, 'Class'); } // try to call the registration feedback class with function registrationFeedback if ($registrationFeedbackClass && method_exists($registrationFeedbackClass, 'registrationFeedback')) { call_user_func(array($registrationFeedbackClass, 'registrationFeedback'), $user, $tpl, $object, $hostname); } else { eZDebug::writeWarning("Unknown feedback type '{$feedbackType}'", 'user/register'); } } } $http->removeSessionVariable("GeneratedPassword"); $http->removeSessionVariable("RegisterUserID"); $http->removeSessionVariable('StartedRegistration'); // check for redirectionvariable if ($http->hasSessionVariable('RedirectAfterUserRegister')) { $module->redirectTo($http->sessionVariable('RedirectAfterUserRegister')); $http->removeSessionVariable('RedirectAfterUserRegister'); } else { if ($http->hasPostVariable('RedirectAfterUserRegister')) { $module->redirectTo($http->postVariable('RedirectAfterUserRegister')); } else { $module->redirectTo('/user/success/'); } } } }
function checkContentActions($module, $class, $object, $version, $contentObjectAttributes, $EditVersion, $EditLanguage) { if ($module->isCurrentAction('Cancel')) { $http = eZHTTPTool::instance(); if ($http->hasPostVariable('RedirectIfDiscarded')) { eZRedirectManager::redirectTo($module, $http->postVariable('RedirectIfDiscarded')); } else { eZRedirectManager::redirectTo($module, '/'); } $version->removeThis(); $http = eZHTTPTool::instance(); $http->removeSessionVariable("RegisterUserID"); $http->removeSessionVariable('StartedRegistration'); return eZModule::HOOK_STATUS_CANCEL_RUN; } if ($module->isCurrentAction('Publish')) { $userID = $object->attribute('id'); $operationResult = eZOperationHandler::execute('user', 'register', array('user_id' => $userID)); // send feedback $ini = eZINI::instance(); $tpl = eZTemplate::factory(); $hostname = eZSys::hostname(); $user = eZUser::fetch($userID); $feedbackTypes = $ini->variableArray('UserSettings', 'RegistrationFeedback'); foreach ($feedbackTypes as $feedbackType) { switch ($feedbackType) { case 'email': // send feedback with the default email type $mail = new eZMail(); $tpl->resetVariables(); $tpl->setVariable('user', $user); $tpl->setVariable('object', $object); $tpl->setVariable('hostname', $hostname); $templateResult = $tpl->fetch('design:user/registrationfeedback.tpl'); if ($tpl->hasVariable('content_type')) { $mail->setContentType($tpl->variable('content_type')); } $emailSender = $ini->variable('MailSettings', 'EmailSender'); if ($tpl->hasVariable('email_sender')) { $emailSender = $tpl->variable('email_sender'); } else { if (!$emailSender) { $emailSender = $ini->variable('MailSettings', 'AdminEmail'); } } $feedbackReceiver = $ini->variable('UserSettings', 'RegistrationEmail'); if ($tpl->hasVariable('email_receiver')) { $feedbackReceiver = $tpl->variable('email_receiver'); } else { if (!$feedbackReceiver) { $feedbackReceiver = $ini->variable('MailSettings', 'AdminEmail'); } } if ($tpl->hasVariable('subject')) { $subject = $tpl->variable('subject'); } else { $subject = ezpI18n::tr('kernel/user/register', 'New user registered'); } $mail->setSender($emailSender); $mail->setReceiver($feedbackReceiver); $mail->setSubject($subject); $mail->setBody($templateResult); $mailResult = eZMailTransport::send($mail); break; default: $registrationFeedbackClass = false; // load custom registration feedback settings if ($ini->hasGroup('RegistrationFeedback_' . $feedbackType)) { if ($ini->hasVariable('RegistrationFeedback_' . $feedbackType, 'File')) { include_once $ini->variable('RegistrationFeedback_' . $feedbackType, 'File'); } $registrationFeedbackClass = $ini->variable('RegistrationFeedback_' . $feedbackType, 'Class'); } // try to call the registration feedback class with function registrationFeedback if ($registrationFeedbackClass && method_exists($registrationFeedbackClass, 'registrationFeedback')) { call_user_func(array($registrationFeedbackClass, 'registrationFeedback'), $user, $tpl, $object, $hostname); } else { eZDebug::writeWarning("Unknown feedback type '{$feedbackType}'", 'user/register'); } } } $http = eZHTTPTool::instance(); $http->removeSessionVariable("GeneratedPassword"); $http->removeSessionVariable("RegisterUserID"); $http->removeSessionVariable('StartedRegistration'); // if everything is passed, login the user if ($operationResult['status'] === eZModuleOperationInfo::STATUS_CONTINUE) { $user->loginCurrent(); } // check for redirectionvariable if ($operationResult['status'] === eZModuleOperationInfo::STATUS_CONTINUE || $operationResult['status'] === eZModuleOperationInfo::STATUS_HALTED) { if ($http->hasSessionVariable('RedirectAfterUserRegister')) { $module->redirectTo($http->sessionVariable('RedirectAfterUserRegister')); $http->removeSessionVariable('RedirectAfterUserRegister'); } else { if ($http->hasPostVariable('RedirectAfterUserRegister')) { $module->redirectTo($http->postVariable('RedirectAfterUserRegister')); } else { $module->redirectTo('/user/success/'); } } } else { eZDebug::writeError('Unexpected operation status: ' . $operationResult['status'], 'user/register'); // @todo: finish the failure code $module->redirectTo('/user/register/5'); } } }
/** * Send password expiry notification to user * * @param eZUser $user ezuser object that contains the destination email address * @return true if notification sent correctly, false if not. */ function sendExpiryNotification($user) { $userToSendEmail = $user; require_once "kernel/common/template.php"; $receiver = $userToSendEmail->attribute('email'); $mail = new eZMail(); if (!$mail->validate($receiver)) { eZDebug::writeError('Invalid email address set in user ' . $user->attribute('contentobject_id'), 'sendExpiryNotification'); return false; } $tpl = templateInit(); $tpl->setVariable('user', $userToSendEmail); $http = eZHTTPTool::instance(); $http->UseFullUrl = false; $templateResult = $tpl->fetch('design:userpaex/expirynotificationmail.tpl'); $ini = eZINI::instance(); $emailSender = $ini->variable('MailSettings', 'EmailSender'); if (!$emailSender) { $emailSender = $ini->variable('MailSettings', 'AdminEmail'); } $mail->setSender($emailSender); $mail->setReceiver($receiver); $subject = ezpI18n::tr('mbpaex/userpaex', 'Your password is about to expire'); if ($tpl->hasVariable('subject')) { $subject = $tpl->variable('subject'); } $mail->setSubject($subject); $mail->setBody($templateResult); return eZMailTransport::send($mail); }
/** * Send the notification after registeration */ public static function sendUserNotification($userID) { eZDebugSetting::writeNotice('Sending approval notification to the user.', 'kernel-user', 'user register'); $user = eZUser::fetch($userID); $ini = eZINI::instance(); // Send mail $tpl = eZTemplate::factory(); $tpl->setVariable('user', $user); $templateResult = $tpl->fetch('design:user/registrationapproved.tpl'); $mail = new eZMail(); if ($tpl->hasVariable('content_type')) { $mail->setContentType($tpl->variable('content_type')); } $emailSender = $ini->variable('MailSettings', 'EmailSender'); if ($tpl->hasVariable('email_sender')) { $emailSender = $tpl->variable('email_sender'); } else { if (!$emailSender) { $emailSender = $ini->variable('MailSettings', 'AdminEmail'); } } if ($tpl->hasVariable('subject')) { $subject = $tpl->variable('subject'); } else { $subject = ezpI18n::tr('kernel/user/register', 'User registration approved'); } $mail->setSender($emailSender); $receiver = $user->attribute('email'); $mail->setReceiver($receiver); $mail->setSubject($subject); $mail->setBody($templateResult); $mailResult = eZMailTransport::send($mail); return array('status' => eZModuleOperationInfo::STATUS_CONTINUE); }
public function testSSLSending() { // test SSL $ini = eZINI::instance('test_ezmail_ssl.ini'); $mailSetting = $ini->group('MailSettings'); //if SSL information is not set, skip this test if (!$mailSetting['TransportServer']) { return; } $siteINI = eZINI::instance(); $backupSetting = $siteINI->group('MailSettings'); $siteINI->setVariables(array('MailSettings' => $mailSetting)); $mail = new eZMail(); $mail->setReceiver($mailSetting['TransportUser'], 'TEST RECEIVER'); $mail->setSender($mailSetting['TransportUser'], 'TEST SENDER'); $mail->setSubject('SSL EMAIL TESTING'); $mail->setBody('This is a mail testing. TEST SSL in ' . __METHOD__); $result = eZMailTransport::send($mail); $this->assertTrue($result); $siteINI->setVariables(array('MailSettings' => $backupSetting)); //todo: delete the received mails in teardown. }
} $tpl = eZTemplate::factory(); $tpl->setVariable( 'user', $userToSendEmail ); $tpl->setVariable( 'object', $userToSendEmail->attribute( 'contentobject' ) ); $tpl->setVariable( 'password', $password ); $tpl->setVariable( 'link', true ); $tpl->setVariable( 'hash_key', $hashKey ); $templateResult = $tpl->fetch( 'design:user/forgotpasswordmail.tpl' ); if ( $tpl->hasVariable( 'content_type' ) ) $mail->setContentType( $tpl->variable( 'content_type' ) ); $emailSender = $ini->variable( 'MailSettings', 'EmailSender' ); if ( !$emailSender ) $emailSender = $ini->variable( 'MailSettings', 'AdminEmail' ); $mail->setSender( $emailSender ); $mail->setReceiver( $receiver ); $subject = ezpI18n::tr( 'kernel/user/register', 'Registration info' ); if ( $tpl->hasVariable( 'subject' ) ) $subject = $tpl->variable( 'subject' ); $mail->setSubject( $subject ); $mail->setBody( $templateResult ); $mailResult = eZMailTransport::send( $mail ); $tpl->setVariable( 'email', $email ); } else { $tpl->setVariable( 'wrong_email', $email ); } } }
/** * See site.ini [MailSettings] ExcludeHeaders */ public function testExcludeHaders() { ezpINIHelper::setINISetting('site.ini', 'MailSettings', 'Transport', 'SMTP'); ezpINIHelper::setINISetting('site.ini', 'MailSettings', 'ExcludeHeaders', array('bcc')); $mail = new eZMail(); $mail->setReceiver('*****@*****.**', 'John Doe'); $mail->setSender('*****@*****.**', 'Jane Doe'); $mail->addBcc('*****@*****.**', 'Jim Doe'); $mail->setSubject('Testing ExcludeHeaders'); $mail->setBody('Jim should not get this email.'); // BCC should be set at this point $this->assertTrue(strpos($mail->Mail->generateHeaders(), 'Bcc: Jim Doe <*****@*****.**>') > 0); // We don't care if the mail gets sent. What's important is what happens to the headers. eZMailTransport::send($mail); // BCC should not be set anymore at this point, because of ExcludeHeaders $this->assertFalse(strpos($mail->Mail->generateHeaders(), 'Bcc: Jim Doe <*****@*****.**>') > 0); }