Exemple #1
0
 /**
  * Отправка уведомления об удалении топика в сообществе
  * Вызывается в тех случаях, когда commune::GetComments4Sending вернула FALSE
  * @param $subscr - массив подписчиков, возвращаемый commune::getThemeSubscribers
  * @param $msg_id - идентификатор темы сообщества или комментария сообщества
  */
 function CommuneDeleteTopic($subscr, $msg_id)
 {
     $subscribers = array();
     $info = commune::getMessageInfoByMsgID($msg_id);
     $link_commune = "<a href='{$GLOBALS['host']}/commune/?id={$info['commune_id']}' target='_blank'>{$info['commune_name']}</a>";
     $friendly_url_topic = getFriendlyURL('commune', $info["top_id"]);
     $link_topic = $info["title"] ? "<a href='{$GLOBALS['host']}{$friendly_url_topic}' target='_blank'>{$info['title']}</a>" : '';
     $skip_users = array();
     $admin_userlink = $GLOBALS["host"] . "/users/" . $info['deleter_login'];
     if ($info['commune_id'] == commune::COMMUNE_BLOGS_ID && $info["commentator_uid"] != $info["deleter_uid"]) {
         $admin_user = "******";
     } else {
         $admin_user = "******";
     }
     //отправка автору комментария
     if ($info["commentator_uid"] != $info["deleter_uid"]) {
         $skip_users[] = $info['commentator_uid'];
         $this->subject = 'Вашe сообщение в сообществе удалено.';
         $body_start = "\n\t{$admin_user} удалил(а) <a href=\"{$GLOBALS['host']}/commune/?id={$info['commune_id']}&site=Topic&post={$info['top_id']}.{$msg_id}{$this->_addUrlParams('b', '&')}#c_{$msg_id}\">ваше сообщение/комментарий</a> в сообществе «<a href=\"{$GLOBALS['host']}/commune/?id={$info['commune_id']}{$this->_addUrlParams('b', '&')}\" target=\"_blank\">{$info['commune_name']}</a>».\n\t<br/><br/>\n\t--------\n\t";
         $body_subscr = "{$admin_user} удалил(а) <a href=\"{$GLOBALS['host']}/commune/?id={$info['commune_id']}&site=Topic&post={$info['top_id']}.{$msg_id}{$this->_addUrlParams('b', '&')}#c_{$msg_id}\">сообщение</a> в сообществе «<a href=\"{$GLOBALS['host']}/commune/?id={$info['commune_id']}{$this->_addUrlParams('b', '&')}\" target=\"_blank\">{$info['commune_name']}</a>».\n\t<br/><br/>\n\t--------\n\t";
         $body = "<br/>" . reformat2($info['msgtext'], 100, 0, 1) . "\n\t<br/><br/>\n\t--------\n\t";
         $this->recipient = $info['commentator_uname'] . " " . $info['commentator_usurname'] . " [" . $info['commentator_login'] . "] <" . $info['commentator_email'] . ">";
         $this->message = $this->GetHtml($info['commentator_uname'], $body_start . $body, array('header' => 'default', 'footer' => 'default'), array('login' => $info['commentator_login']));
         $this->SmtpMail('text/html');
     }
     //отправка автору топика
     if ($info && $info['topicstarter_uid'] && $info['topicstarter_uid'] != $info['deleted_id'] && !in_array($info['topicstarter_uid'], $skip_users)) {
         $this->subject = ($info['parent_id'] ? 'Комментарий к вашему посту' : 'Ваш пост') . ($info['title'] ? ' «' . $info['title'] . '» в сообществе' : ' сообщества') . ' «' . $info['commune_name'] . '» удален.';
         $body_start = "\n        <a href=\"{$GLOBALS['host']}/commune/?id={$info['commune_id']}&site=Topic&post={$msg_id}.{$user['message_id']}{$this->_addUrlParams('b', '&')}\">Комментарий</a> к вашему посту(1) в сообществе «<a href=\"{$GLOBALS['host']}/commune/?id={$info['commune_id']}{$this->_addUrlParams('b', '&')}\" target=\"_blank\">{$info['commune_name']}</a>» удален модератором сообщества.\n        <br/><br/>\n        --------\n        ";
         $body = "<br/>" . reformat2($info['msgtext'], 100, 0, 1) . "\n        <br/><br/>\n        --------\n        ";
         $this->recipient = $info['topicstarter_uname'] . " " . $info['topicstarter_usurname'] . " [" . $info['topicstarter_login'] . "] <" . $info['topicstarter_email'] . ">";
         $this->message = $this->GetHtml($info['topicstarter_uname'], $body_start . $body, array('header' => 'subscribe_delete_post', 'footer' => 'subscribe_delete_post'), array('type' => 0, 'title' => $link_commune, 'topic_name' => $link_topic, 'is_comment' => $info['parent_id'], 'to_topicstarter' => true, 'login' => $info['topicstarter_login'], 'is_author' => $info['deleter_uid'] == $info['topicstarter_uid']));
         $this->SmtpMail('text/html');
         require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/messages.php";
         $msg = "Здравствуйте, {$info['topicstarter_uname']}.\nМодератор сообщества удалил комметарий к Вашему посту {$link_topic} в сообществе {$link_commune}.";
         //messages::Add( users::GetUid($err, 'admin'), $info['topicstarter_login'], $msg, '', 1 );
         $skip_users[] = $info['topicstarter_uid'];
     }
     foreach ($subscr as $user) {
         if (!in_array($user["user_id"], $skip_users)) {
             $this->subject = ($info['parent_id'] ? 'В топике' : 'Топик') . ($info['title'] ? ' «' . $info['title'] . '» в сообществе' : ' сообщества') . ' «' . $info['commune_name'] . '» удален' . ($info['parent_id'] ? ' комментарий' : '');
             $userlink = $GLOBALS["host"] . "/users/" . $info['deleter_login'];
             $body_start = "\n\t\t\t\t{$admin_user} удалил(-а) <a href=\"{$GLOBALS['host']}/commune/?id={$info['commune_id']}&site=Topic&post={$msg_id}.{$user['message_id']}{$this->_addUrlParams('b', '&')}\">сообщение</a> в сообществе «<a href=\"{$GLOBALS['host']}/commune/?id={$info['commune_id']}{$this->_addUrlParams('b', '&')}\" target=\"_blank\">{$info['commune_name']}</a>».\n\t\t\t\t<br/><br/>\n\t\t\t\t--------\n\t\t\t\t";
             $body_subscr = "{$admin_user} удалил(а) <a href=\"{$GLOBALS['host']}/commune/?id={$info['commune_id']}&site=Topic&post={$msg_id}.{$this->_addUrlParams('b', '&')}\">сообщение</a>.\n\t\t\t\t<br/><br/>\n\t\t\t\t--------\n\t\t\t\t";
             $body = "<br/>" . reformat2($info['msgtext'], 100, 0, 1) . "\n\t\t\t\t<br/><br/>\n\t\t\t\t--------\n\t\t\t\t";
             $this->recipient = $user['uname'] . " " . $user['usurname'] . " [" . $user['login'] . "] <" . $user['email'] . ">";
             $this->message = $this->GetHtml($user['uname'], $body_start . $body, array('header' => 'subscribe_delete_post', 'footer' => 'subscribe_delete_post'), array('type' => 0, 'title' => $link_commune, 'topic_name' => $link_topic, 'is_comment' => $info['parent_id'], 'login' => $user['login'], 'is_admin' => $info['deleter_id'] == $info['topicstarter_uid']));
             $this->SmtpMail('text/html');
             require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/messages.php";
         }
     }
 }