当前位置: 首页>>代码示例>>PHP>>正文


PHP SiteHelper::mailto方法代码示例

本文整理汇总了PHP中SiteHelper::mailto方法的典型用法代码示例。如果您正苦于以下问题:PHP SiteHelper::mailto方法的具体用法?PHP SiteHelper::mailto怎么用?PHP SiteHelper::mailto使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SiteHelper的用法示例。


在下文中一共展示了SiteHelper::mailto方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: send

 public function send($key, $types, $userId, array $arrayParams = array())
 {
     $status = false;
     $notification = NotificationsType::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("`key`=:key")->setParams(array(":key" => $key)));
     if (!empty($notification) && sizeof($notification) > 0) {
         $notificationMessage = NotificationsActions::fetchAll(DBQueryParamsClass::CreateParams()->setCache(0)->setConditions("type_id=:type_id")->setParams(array(":type_id" => $notification[0]->id)));
         if (!empty($notificationMessage) && sizeof($notificationMessage) > 0) {
             for ($i = 0; $i < sizeof($notificationMessage); $i++) {
                 if (strtolower($notificationMessage[$i]->key_word) == "info") {
                     $NItem = new Notifications();
                     $NItem->type_id = $notification[0]->id;
                     $NItem->is_new = 1;
                     $NItem->action_id = $notificationMessage[$i]->id;
                     $message = $notificationMessage[$i]->mesage;
                     $subject = $notificationMessage[$i]->subject;
                     foreach ($arrayParams as $key => $value) {
                         $message = str_replace("{" . $key . "}", $value, $message);
                         $subject = str_replace("{" . $key . "}", $value, $subject);
                     }
                     $NItem->message = $message;
                     $NItem->subject = $subject;
                     if (!$notificationMessage[$i]->to_user) {
                         $NItem->user_id = $userId;
                     } else {
                         $toUserModel = CatalogUsers::findByAttributes(array("email" => $notificationMessage[$i]->to_user));
                         if ($toUserModel[0]->id > 0) {
                             $NItem->user_id = $toUserModel[0]->id;
                         } else {
                             $this->errors[] = array("Ошибка обработки действвий", "Событие: #" . $notification[$i] . ", Действие: #" . $notificationMessage[$i] . " - Email указыыный в поле TO_USER не зарегестрирован в базе");
                         }
                     }
                     $NItem->date = time();
                     if (!empty($arrayParams["catalog"])) {
                         $NItem->catalog = $arrayParams["catalog"];
                     }
                     if (!empty($arrayParams["item_id"])) {
                         $NItem->item_id = $arrayParams["item_id"];
                     }
                     if (sizeof($this->errors) == 0) {
                         if (!$NItem->save()) {
                             $this->errors[] = print_r($NItem->getErrors(), true);
                         }
                     }
                 }
                 if (strtolower($notificationMessage[$i]->key_word) == "mail") {
                     if (!$notificationMessage[$i]->to_user) {
                         $userTo = CatalogUsers::fetch($userId);
                     } else {
                         $toUserModel = CatalogUsers::findByAttributes(array("email" => $notificationMessage[$i]->to_user));
                         if ($toUserModel[0]->id > 0) {
                             $userTo = $toUserModel[0];
                         } else {
                             $this->errors[] = array("Ошибка обработки действвий", "Событие: #" . $notification[$i] . ", Действие: #" . $notificationMessage[$i] . " - Email указыыный в поле TO_USER не зарегестрирован в базе");
                         }
                     }
                     if (!empty($userTo) && $userTo->id > 0) {
                         $messages = $notificationMessage[$i]->mesage;
                         foreach ($arrayParams as $key => $value) {
                             $messages = str_replace("{" . $key . "}", $value, $messages);
                         }
                         SiteHelper::mailto($notificationMessage[$i]->subject, $notificationMessage[$i]->send_from, $userTo->email, $messages, $notificationMessage[$i]->copy_sender);
                         $status = true;
                     } else {
                         $this->errors[] = array("Ошибка отправки сообщения", "Указан не верный ID пользователя");
                         return false;
                     }
                 }
             }
         } else {
             $this->errors[] = array("Ошибка события", "Для данного соьытия ( #" . $notification[0]->id . " ) не указы события");
         }
     } else {
         $this->errors[] = array("Ошибка события", "Ошибка определения типа события");
     }
     if (is_array($this->errors) && sizeof($this->errors) > 0) {
         throw new Exception(print_r($this->errors, true));
     }
     return $status;
 }
开发者ID:bogiesoft,项目名称:yii-travel,代码行数:79,代码来源:initNotifications.php

示例2: run

 public function run($args)
 {
     $countLimit = SiteHelper::getConfig("subscribee_count_send");
     $emails = array();
     $countSend = 0;
     $res = SubscribeItems::findByAttributes(array("status_id" => 2));
     foreach ($res as $line) {
         // 1 - отправляем и зарегеным и подписчикам
         if ($line->users == 1 || $line->users == 2) {
             $lisUsers = CatalogUsers::sql("SELECT u.* FROM catalog_users u WHERE `active`=1 AND subscribe=1 AND !exists( SELECT id FROM subscribe_send WHERE email=u.email AND item_id='" . $line->id . "' AND is_reg=1 ) LIMIT " . $countLimit);
             foreach ($lisUsers as $userLine) {
                 $emails[] = array("email" => $userLine["email"], "name" => $userLine["name"]);
                 $newSend = new SubscribeSend();
                 $newSend->item_id = $line->id;
                 $newSend->user_id = $userLine["id"];
                 $newSend->email = $userLine["email"];
                 $newSend->is_reg = 1;
                 if (!$newSend->save()) {
                     print_r($newSend->getErrors());
                 }
             }
         }
         if (sizeof($emails) < $countLimit && ($line->users == 1 || $line->users == 3)) {
             $lisUsers = CatalogUsers::sql("SELECT u.* FROM subscribe_users u WHERE !exists( SELECT id FROM subscribe_send WHERE email=u.email AND item_id='" . $line->id . "' AND is_reg=0 ) LIMIT " . ($countLimit - sizeof($emails)));
             foreach ($lisUsers as $userLine) {
                 $emails[] = array("email" => $userLine["email"], "name" => $userLine["name"]);
                 $newSend = new SubscribeSend();
                 $newSend->item_id = $line->id;
                 $newSend->user_id = null;
                 $newSend->email = $userLine["email"];
                 $newSend->is_reg = 0;
                 if (!$newSend->save()) {
                     print_r($newSend->getErrors());
                 }
             }
         }
         if ($line->users == 4) {
             $usersList = trim(strip_tags($line->users_list));
             if (!empty($usersList)) {
                 $listEmail = explode(",", $usersList);
                 for ($m = 0; $m < sizeof($listEmail); $m++) {
                     $listEmail[$m] = trim($listEmail[$m]);
                     $ext = SubscribeSend::findByAttributes(array("item_id" => $line->id, "email" => $listEmail[$m]));
                     if (sizeof($ext) == 0) {
                         $emails[] = array("email" => $listEmail[$m], "name" => "пользователь");
                         $newSend = new SubscribeSend();
                         $newSend->item_id = $line->id;
                         $newSend->user_id = null;
                         $newSend->email = $listEmail[$m];
                         $newSend->is_reg = 0;
                         if (!$newSend->save()) {
                             print_r($newSend->getErrors());
                         }
                     }
                 }
             }
         }
         if (sizeof($emails) > 0) {
             for ($n = 0; $n < sizeof($emails); $n++) {
                 $countSend++;
                 $message = $line->description;
                 $message = str_replace("@user_name@", $emails[$n]["name"], $message);
                 SiteHelper::mailto($line->subject, $line->from, $emails[$n]["email"], stripslashes($message), "", "", array("<!-- @openSubscribeLink@ -->" => "<img src=\"" . Yii::app()->params["baseUrl"] . "site/subscribeOpen/subscribe/" . $line->id . "/email/" . $emails[$n]["email"] . "\" alt=\"\" style=\"width:0px;height:0px\" />"));
             }
         }
         // Сохраняем количество оптравленных, чтобы не считать каждый раз
         if ($countSend > 0) {
             $line->count_send += $countSend;
             $line->save();
         }
         // Если адресатов нет или их количество меньше чем лимит то финализируем рассылку
         if (sizeof($emails) == 0 || $countSend < $countLimit) {
             $line->status_id = 3;
             $line->save();
         }
     }
 }
开发者ID:bogiesoft,项目名称:yii-travel,代码行数:77,代码来源:SubscribeCommand.php


注:本文中的SiteHelper::mailto方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。