Example #1
0
 /**
  * Отправляет уведомления о редактировании комментария в блоге.
  * 
  * @param   string|array   $message_ids  идентификаторы комментариев.
  * @param   resource       $connect      соединение к БД (необходимо в PgQ) или NULL -- создать новое.
  * @return  integer                      количество отправленных уведомлений.
  */
 function BlogUpdateComment($message_ids, $connect = NULL)
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/blogs.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/messages.php';
     $blogs = new blogs();
     if (!($comments = $blogs->GetComments4Sending($message_ids, $connect))) {
         return NULL;
     }
     $this->subject = "Комментарии в сообществе на сайте FL.ru";
     $userSubscribe = $blogs->getUsersSubscribe($message_ids, $connect, true);
     foreach ($comments as $comment) {
         // Отправляем родителю.
         if (substr($comment['p_subscr'], 2, 1) == '1' && ($comment['p_uid'] != $comment['uid'] || $comment['uid'] != $comment['modified_id']) && $comment['p_email'] && $comment['p_banned'] == '0') {
             $this->message = $this->GetHtml($comment['p_uname'], "\n<a href='{$GLOBALS['host']}/users/{$comment['m_login']}/{$this->_addUrlParams('b')}'>{$comment['m_uname']} {$comment['m_usurname']}</a> [<a href='{$GLOBALS['host']}/users/{$comment['m_login']}{$this->_addUrlParams('b')}'>{$comment['m_login']}</a>]\nотредактировал(а) <a href='{$GLOBALS['host']}/blogs/view.php?tr={$comment['thread_id']}&openlevel={$comment['id']}{$this->_addUrlParams('b', '&')}#o{$comment['id']}'>комментарий</a> к вашим сообщениям/комментариям в сообществе на сайте FL.ru.\n<br /> --------\n<br />" . ($comment['title'] ? $this->ToHtml(LenghtFormatEx(strip_tags($comment['title']), 300)) . "<br />---<br />" : "") . $this->ToHtml(LenghtFormatEx(strip_tags($comment['msgtext']), 300)) . "\n<br /> --------\n<br />\n", 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');
             $notSend[$comment['p_uid']] = $comment['p_uid'];
         }
         // Отправляем автору топика.
         if (substr($comment['t_subscr'], 2, 1) == '1' && ($comment['t_uid'] != $comment['uid'] || $comment['t_uid'] != $comment['modified_id']) && ($comment['t_uid'] != $comment['p_uid'] || $comment['t_uid'] != $comment['modified_id']) && $comment['t_email'] && !$notSend[$comment['t_uid']] && $comment['t_banned'] == '0') {
             $post_type = "<a target='_blank' href='{$GLOBALS['host']}/blogs/view.php?tr={$comment['thread_id']}&openlevel={$comment['id']}{$this->_addUrlParams('b', '&')}#o{$comment['id']}'>комментарий</a> к вашим сообщениям/комментариям";
             if ($comment['reply_to'] == '') {
                 $post_type = "<a target='_blank' href='{$GLOBALS['host']}/blogs/view.php?tr={$comment['thread_id']}&openlevel={$comment['id']}{$this->_addUrlParams('b', '&')}#o{$comment['id']}'>ваше сообщение</a> ";
                 $this->subject = "Блоги FL.ru";
             }
             $this->message = $this->GetHtml($comment['t_uname'], "\n<a href='{$GLOBALS['host']}/users/{$comment['m_login']}{$this->_addUrlParams('b')}'>{$comment['m_uname']} {$comment['m_usurname']}</a> [<a href='{$GLOBALS['host']}/users/{$comment['m_login']}{$this->_addUrlParams('b')}'>{$comment['m_login']}</a>]\nотредактировал(а) {$post_type} в блогах на сайте FL.ru.\n<br /> --------\n<br />" . ($comment['title'] ? $this->ToHtml(LenghtFormatEx(strip_tags($comment['title']), 300)) . "<br />---<br />" : "") . $this->ToHtml(LenghtFormatEx(strip_tags($comment['msgtext']), 300)) . "\n<br /> --------\n<br />\n", array('header' => 'default', 'footer' => 'default'), array('login' => $comment['t_login']));
             $this->recipient = $comment['t_uname'] . " " . $comment['t_usurname'] . " [" . $comment['t_login'] . "] <" . $comment['t_email'] . ">";
             $this->SmtpMail('text/html');
             $notSend[$comment['t_uid']] = $comment['t_uid'];
             $message = "<a href='{$GLOBALS['host']}/users/{$comment['m_login']}{$this->_addUrlParams('b')}'>{$comment['m_uname']} {$comment['m_usurname']}</a> [<a href='{$GLOBALS['host']}/users/{$comment['m_login']}{$this->_addUrlParams('b')}'>{$comment['m_login']}</a>]\nотредактировал(а) {$post_type} в сообществе на сайте FL.ru.\n --------\n\n" . ($comment['title'] ? $this->ToHtml(LenghtFormatEx(strip_tags($comment['title']), 300)) . "\n---\n" : "") . $this->ToHtml(LenghtFormatEx(strip_tags($comment['msgtext']), 300)) . "\n --------";
             messages::Add(users::GetUid($err, 'admin'), $comment['t_login'], $message, '', 1);
         }
     }
     // Посылаем подписавшимся на темы
     if ($userSubscribe) {
         foreach ($userSubscribe as $comment) {
             $this->subject = "Комментарии в сообществе на сайте FL.ru";
             if (substr($comment['s_subscr'], 2, 1) == '1' && !$notSend[$comment['s_uid']] && $comment['s_email']) {
                 $post_type = "<a href='{$GLOBALS['host']}/blogs/view.php?tr={$comment['thread_id']}&openlevel={$comment['id']}{$this->_addUrlParams('b', '&')}#o{$comment['id']}'>комментарий</a> к сообщениям/комментариям в сообществе";
                 $message_template = "subscribe_edit_comment";
                 if ($comment['reply_to'] == '') {
                     $post_type = "<a href='{$GLOBALS['host']}/blogs/view.php?tr={$comment['thread_id']}&openlevel={$comment['id']}{$this->_addUrlParams('b', '&')}#o{$comment['id']}'>пост в сообществе</a> на который вы подписаны";
                     $message_template = "subscribe_edit_post";
                 }
                 $link_title = "<a href='{$GLOBALS['host']}/blogs/view.php?tr={$comment['thread_id']}{$this->_addUrlParams('b', '&')}' target='_blank'>" . ($comment['blog_title'] == '' ? 'Без названия' : $comment['blog_title']) . "</a>";
                 $this->message = $this->GetHtml($comment['s_uname'], "\n<a href='{$GLOBALS['host']}/users/{$comment['m_login']}/{$this->_addUrlParams('b')}'>{$comment['m_uname']} {$comment['m_usurname']}</a> [<a href='{$GLOBALS['host']}/users/{$comment['login']}{$this->_addUrlParams('b')}'>{$comment['m_login']}</a>]\nотредактровал(а) {$post_type} на сайте FL.ru.\n<br /> --------\n<br />" . ($comment['title'] ? $this->ToHtml(input_ref(LenghtFormatEx($comment['title'], 300), 1)) . "<br />---<br />" : "") . $this->ToHtml(input_ref(LenghtFormatEx($comment['msgtext'], 300), 1)) . "\n<br /> --------\n<br />\n", array('header' => $message_template, 'footer' => 'subscribe'), array('type' => 1, 'title' => $link_title));
                 $this->recipient = $comment['s_uname'] . " " . $comment['s_usurname'] . " [" . $comment['s_login'] . "] <" . $comment['s_email'] . ">";
                 $this->SmtpMail('text/html');
                 $message = "Здравствуйте, " . $comment['s_uname'] . ".                \n<a href='{$GLOBALS['host']}/users/{$comment['m_login']}/{$this->_addUrlParams('b')}'>{$comment['m_uname']} {$comment['m_usurname']}</a> [<a href='{$GLOBALS['host']}/users/{$comment['login']}{$this->_addUrlParams('b')}'>{$comment['m_login']}</a>]\nотредактровал(а) {$post_type} на сайте FL.ru.\n--------" . ($comment['title'] ? $this->ToHtml(input_ref(LenghtFormatEx($comment['title'], 300), 1)) . "\n---\n" : "") . $this->ToHtml(input_ref(LenghtFormatEx($comment['msgtext'], 300), 1)) . "\n --------\n ";
                 messages::Add(users::GetUid($err, 'admin'), $comment['s_login'], $message, '', 1);
             }
         }
     }
     return $this->sended;
 }