コード例 #1
0
ファイル: EmailUtils.php プロジェクト: romeo14/wallfeet
 public static function sendEmail($scenario, $userId = "", $messageId = "", $tempPassword = "", $cc = "", $bcc = "")
 {
     $model = EmailTemplateApi::getTemplateByScenario($scenario);
     if ($userId) {
         $user = UserApi::getUser($userId);
     }
     if ($user) {
         $data["verification_link"] = SecurityUtils::getVerificationLink($user["activation_code"]);
         $data["email_id"] = $user["email_id"];
         $data["name"] = UserApi::getNameByUserId($userId);
     }
     if ($tempPassword) {
         $data["temp_password"] = $tempPassword;
     }
     if ($messageId) {
         $message = PmbApi::loadMessage($messageId);
     }
     if ($message) {
         $data["message_subject"] = $message->subject;
         $data["message_content"] = $message->content;
         $data["message_from"] = UserApi::getNameByUserId($message->from_user_id);
     }
     if ($model) {
         $htmlEmail = self::changeTemplate($data, $model->body_html);
         $plainEmail = self::changeTemplate($data, $model->body_plain);
         $emailData["from_email"] = $model->from_email;
         $emailData["from_name"] = $model->from_name;
         $emailData["subject"] = $model->subject;
         $emailData["body_html"] = $htmlEmail;
         $emailData["body_plain"] = $plainEmail;
         return EmailQueueApi::addToQueue($user["email_id"], $cc, $bcc, "", $emailData);
     }
     return false;
 }
コード例 #2
0
ファイル: EmailApi.php プロジェクト: romeo14/pow
 public static function sendEmail($to, $scenario, $data = "", $cc = "", $bcc = "")
 {
     $model = EmailTemplateApi::getTemplateByScenario($scenario);
     $template = array();
     if ($model) {
         $template["home_link"] = Yii::app()->createAbsoluteUrl('/');
         $template["signin_link"] = Yii::app()->createAbsoluteUrl('/account');
         $template["logo_link"] = Yii::app()->createAbsoluteUrl('/') . Yii::app()->theme->baseUrl . '/images/logo-newsletter.jpg';
         if ($data) {
             if (is_array($data)) {
                 foreach ($data as $key => $value) {
                     if ($key == "user") {
                         $user = UserApi::getUser($value);
                         if ($user) {
                             $template["verification_link"] = SecurityUtils::getVerificationLink($user["activation_code"], $user["email_id"]);
                             $template["email_id"] = $user["email_id"];
                             $template["name"] = UserApi::getNameByUserId($value);
                         }
                         continue;
                     } else {
                         if ($key == "temp_password") {
                             $template["temp_password"] = $value;
                             continue;
                         } else {
                             if ($key == "message") {
                                 $message = PmbApi::loadMessage($value);
                                 if ($message) {
                                     $template["message_subject"] = $message->subject;
                                     $template["message_content"] = $message->content;
                                     $template["message_body"] = $message->content;
                                     $template["message_from"] = UserApi::getNameByUserId($message->from_user_id);
                                 }
                                 continue;
                             } else {
                                 if ($key == "feedback") {
                                     $user = UserApi::getUserById($value);
                                     $feedback = FeedbackApi::getLatestFeedback($toId, $entityId, $type);
                                     if ($user) {
                                         $template["first_name"] = $user->first_name;
                                         $template["feedback"] = $feedback->feedback;
                                         $template["specialist_rating"] = SpecialistRatingApi::getRating($specialist->user_id);
                                     }
                                     continue;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $htmlEmail = self::changeTemplate($template, $model->body_html);
         $plainEmail = self::changeTemplate($template, $model->body_plain);
         $emailData["from_email"] = $model->from_email;
         $emailData["from_name"] = $model->from_name;
         $emailData["subject"] = self::changeTemplate($template, $model->subject);
         $emailData["body_html"] = $htmlEmail;
         $emailData["body_plain"] = $plainEmail;
         return EmailQueueApi::addToQueue($to, $cc, $bcc, "", $emailData);
     }
     return false;
 }