示例#1
0
 /**
  * Отсылает сообщение фрилансеру о добавлении комментария к его предложению в конкурсе
  *
  * @param   string|array    $ids        идентификаторы новых комментариев
  * @param   resource        $connect    соединение к БД (необходимо в PgQ) или NULL -- создать новое.
  * @return  integer                     количество отправленных уведомлений.
  */
 function ContestNewComment($ids, $connect = NULL)
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/contest.php';
     $contest = new contest(0, 0);
     if (!($comments = $contest->getContestNewComment($ids, $connect))) {
         return NULL;
     }
     foreach ($comments as $comment) {
         // Письмо организатору конкурса, если подписан и не он оставил коммент
         if (substr($comment['p_subscr'], 8, 1) == '1' && $comment['p_uid'] != $comment['uid'] && $comment['p_email'] && $comment['p_banned'] == '0') {
             $this->subject = 'Комментарии в вашем конкурсе «' . htmlspecialchars_decode($comment['project_name'], ENT_QUOTES) . '» на сайте FL.ru';
             $comment['project_name'] = htmlspecialchars($comment['project_name'], ENT_QUOTES, 'CP1251', false);
             $body = '<a href="' . $GLOBALS['host'] . '/users/' . $comment['login'] . $this->_addUrlParams('e') . '">' . $comment['uname'] . ' ' . $comment['usurname'] . '</a> [<a href="' . $GLOBALS['host'] . '/users/' . $comment['login'] . $this->_addUrlParams('e') . '">' . $comment['login'] . '</a>] 
             оставил(а) комментарий на <a href="' . $GLOBALS['host'] . getFriendlyURL("project", $comment['project_id']) . '?offer=' . $comment['offer_id'] . $this->_addUrlParams('e', '&') . '#offer-' . $comment['offer_id'] . '">работу</a> 
             в вашем конкурсе «<a href="' . $GLOBALS['host'] . getFriendlyURL("project", $comment['project_id']) . $this->_addUrlParams('e') . '">' . $comment['project_name'] . '</a>». 
             Ознакомиться с данным <a href="' . $GLOBALS['host'] . getFriendlyURL("project", $comment['project_id']) . '?comm=' . $comment['comment_id'] . $this->_addUrlParams('e', '&') . '#comment-' . $comment['comment_id'] . '">комментарием</a> можно на странице конкурса.';
             $this->message = $this->GetHtml($comment['p_uname'], $body, array('header' => 'default', 'footer' => 'default'), array('login' => $comment['p_login']));
             $this->recipient = $comment['p_uname'] . " " . $comment['p_usurname'] . " [" . $comment['p_login'] . "] <" . $comment['p_email'] . ">";
             $this->SmtpMail('text/html');
         }
         // Письмо автору предложения, если подписан и не он оставил коммент
         if (substr($comment['o_subscr'], 8, 1) == '1' && $comment['o_uid'] != $comment['uid'] && $comment['o_email'] && $comment['o_banned'] == '0') {
             $this->subject = 'Вашу работу в конкурсе «' . htmlspecialchars_decode($comment['project_name'], ENT_QUOTES) . '» прокомментировали';
             $comment['project_name'] = htmlspecialchars($comment['project_name'], ENT_QUOTES, 'CP1251', false);
             $body = '<a href="' . $GLOBALS['host'] . '/users/' . $comment['login'] . $this->_addUrlParams('f') . '">' . $comment['uname'] . ' ' . $comment['usurname'] . '</a> [<a href="' . $GLOBALS['host'] . '/users/' . $comment['login'] . $this->_addUrlParams('f') . '">' . $comment['login'] . '</a>] 
             прокомментировал(a) вашу <a href="' . $GLOBALS['host'] . getFriendlyURL("project", $comment['project_id']) . '?offer=' . $comment['offer_id'] . $this->_addUrlParams('f', '&') . '#offer-' . $comment['offer_id'] . '">работу</a> 
             в&nbsp;конкурсе «<a href="' . $GLOBALS['host'] . getFriendlyURL("project", $comment['project_id']) . $this->_addUrlParams('f') . '">' . $comment['project_name'] . '</a>».
             Ознакомиться с данным <a href="' . $GLOBALS['host'] . getFriendlyURL("project", $comment['project_id']) . '?comm=' . $comment['comment_id'] . $this->_addUrlParams('f', '&') . '#comment-' . $comment['comment_id'] . '">комментарием</a> можно на странице конкурса.';
             $this->message = $this->GetHtml($comment['o_uname'], $body, array('header' => 'default', 'footer' => 'default'), array('login' => $comment['o_login']));
             $this->recipient = $comment['o_uname'] . " " . $comment['o_usurname'] . " [" . $comment['o_login'] . "] <" . $comment['o_email'] . ">";
             $this->SmtpMail('text/html');
         }
         // Письмо автору родительского комментария, если нужно
         if (substr($comment['m_subscr'], 8, 1) == '1' && $comment['m_uid'] != $comment['uid'] && $comment['m_uid'] != $comment['p_uid'] && $comment['m_uid'] != $comment['o_uid'] && $comment['m_email'] && $comment['m_banned'] == '0') {
             $this->subject = 'Комментарии в конкурсе "' . htmlspecialchars_decode($comment['project_name'], ENT_QUOTES) . '" на сайте FL.ru';
             $comment['project_name'] = htmlspecialchars($comment['project_name'], ENT_QUOTES, 'CP1251', false);
             $body = '<a href="' . $GLOBALS['host'] . '/users/' . $comment['login'] . $this->_addUrlParams('b') . '">' . $comment['uname'] . ' ' . $comment['usurname'] . '</a> [<a href="' . $GLOBALS['host'] . '/users/' . $comment['login'] . $this->_addUrlParams('b') . '">' . $comment['login'] . '</a>] 
             оставил(а) вам комментарий в конкурсе <a href="' . $GLOBALS['host'] . getFriendlyURL("project", $comment['project_id']) . $this->_addUrlParams('b') . '">"' . $comment['project_name'] . '"</a>. 
             <br/>Вы можете прочитать данный <a href="' . $GLOBALS['host'] . getFriendlyURL("project", $comment['project_id']) . '?comm=' . $comment['comment_id'] . $this->_addUrlParams('b') . '#comment-' . $comment['comment_id'] . '">комментарий</a>.';
             $this->message = $this->GetHtml($comment['m_uname'], $body, array('header' => 'default', 'footer' => 'default'), array('login' => $comment['m_login']));
             $this->recipient = $comment['m_uname'] . " " . $comment['m_usurname'] . " [" . $comment['m_login'] . "] <" . $comment['m_email'] . ">";
             $this->SmtpMail('text/html');
         }
     }
     return $this->sended;
 }