コード例 #1
0
ファイル: pmail.php プロジェクト: Nikitian/fl-ru-damp
 /**
  * Отправляет уведомление автору проекта о новом сообщении от юзера, ранее ответившего на данный проект.
  *
  * @param   string|array    $ids        идентификаторы ответов автору проекта
  * @param   resource        $connect    соединение к БД (необходимо в PgQ) или NULL -- создать новое.
  * @return  integer                     количество отправленных уведомлений.
  */
 function NewPrjMessageOnOffer($ids, $connect = NULL)
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects_offers.php';
     $offers = new projects_offers();
     if (!($dialog = $offers->getNewPrjMessageOnOffer($ids, $connect))) {
         return NULL;
     }
     foreach ($dialog as $offer) {
         $project_name = $offer['project_name'];
         $project_id = $offer['project_id'];
         $msg = $offer['msg'];
         if ($offer['usr_dialog'] == $offer['emp_uid']) {
             if (!$offer['frl_email'] || substr($offer['frl_subscr'], 4, 1) != '1') {
                 continue;
             }
             // если не нужны уведомления пропускаем отсылку
             $this->subject = "Новое сообщение по проекту «" . html_entity_decode($project_name) . "»";
             //Если не исполнитель и не ПРО то скрываем контакты заказчика в уведомлении
             $emp_contact = '';
             if (isset($offer['is_view_contacts']) && $offer['is_view_contacts'] == 't') {
                 $userlink = $GLOBALS["host"] . "/users/" . $offer['emp_login'];
                 $emp_contact = "<a href=\"{$userlink}\">{$offer['emp_name']}</a> <a href=\"{$userlink}\">{$offer['emp_uname']}</a> [<a href=\"{$userlink}\">{$offer['emp_login']}</a>] ";
             }
             $project_name = htmlspecialchars($project_name, ENT_QUOTES, 'CP1251', false);
             $body = "Заказчик {$emp_contact}оставил(а) вам новое сообщение по проекту «<a href='{$GLOBALS['host']}" . getFriendlyURL("project", $project_id) . $this->_addUrlParams('f') . "#freelancer_" . $offer['frl_uid'] . "'>{$project_name}</a> ».\n                        <br/><br/>\n                        ------\n                        <br/>\n                        " . (html_entity_decode(strip_tags(input_ref(LenghtFormatEx($msg, 300), 1)), ENT_COMPAT, "CP1251") . "\n") . "\n                        <br/>\n                        ------";
             $this->recipient = "{$offer['frl_name']} {$offer['frl_uname']} [{$offer['frl_login']}] <" . $offer['frl_email'] . ">";
             $this->message = $this->GetHtml($offer['frl_name'], $body, array('header' => 'default', 'footer' => 'default'), array('login' => $offer['frl_login']));
             $this->SmtpMail('text/html');
             //++$count;
         } else {
             if (!$offer['emp_email'] || substr($offer['emp_subscr'], 4, 1) != '1') {
                 continue;
             }
             // если не нужны уведомления пропускаем отсылку
             $this->subject = "Новое сообщение по проекту «" . html_entity_decode($project_name) . "»";
             $userlink = $GLOBALS["host"] . "/users/" . $offer['frl_login'];
             $project_name = htmlspecialchars($project_name, ENT_QUOTES, 'CP1251', false);
             $body = "Фрилансер <a href=\"{$userlink}\">{$offer['frl_name']}</a> <a href=\"{$userlink}\">{$offer['frl_uname']}</a> [<a href=\"{$userlink}\">{$offer['frl_login']}</a>] оставил(а) вам <a href='{$GLOBALS['host']}" . getFriendlyURL("project", $project_id) . $this->_addUrlParams('e') . "#comment" . $offer['spoiler_id'] . "'>" . "новое сообщение </a> по опубликованному вами проекту «<a href='{$GLOBALS['host']}" . getFriendlyURL("project", $project_id) . $this->_addUrlParams('e') . "'>{$project_name}</a>».\n                        <br/><br/>\n                        ------\n                        <br/>\n                        " . (html_entity_decode(strip_tags(input_ref(LenghtFormatEx($msg, 300), 1)), ENT_COMPAT, "CP1251") . "\n") . "\n                        <br/>\n                        ------";
             $this->recipient = "{$offer['emp_name']} {$offer['emp_uname']} [{$offer['emp_login']}] <" . $offer['emp_email'] . ">";
             $this->message = $this->GetHtml($offer['emp_name'], $body, array('header' => 'default', 'footer' => 'default'), array('login' => $offer['emp_login']));
             $this->SmtpMail('text/html');
             //++$count;
         }
     }
     return $this->sended;
 }