コード例 #1
0
ファイル: user_content.php プロジェクト: Nikitian/fl-ru-damp
 /**
  * Сообщества. Утверждение/удаление записи
  * 
  * @param  string $stream_id идентификатор потока
  * @param  int $user_id идентификатор модератора
  * @param  int $from_id идентификатор пользователя
  * @param  int $rec_id идентификатор записи
  * @param  int $rec_type тип записи 
  * @param  int $action действие: 1 - утверждено, 2 - удалено
  * @param  string $is_sent было ли отправлено уведомление
  * @param  string $reason причина удаления
  * @return bool true - успех, false - провал
  */
 function resolveCommunity($stream_id = '', $user_id = 0, $from_id = 0, $rec_id = 0, $rec_type = 0, $action = 1, $is_sent = '', $reason = '')
 {
     $bRet = false;
     $sQuery = 'UPDATE moderation SET moder_num = ?i, status = ?i WHERE rec_id = ?i AND rec_type = ?i AND stream_id = ? RETURNING rec_id';
     $sRecId = $GLOBALS['DB']->val($sQuery, $this->nResolveCnt, $action, $rec_id, self::MODER_COMMUNITY, $stream_id);
     if ($sRecId) {
         $bRet = true;
         if ($rec_type == 1) {
             // топик
             $GLOBALS['DB']->update('commune_messages', array('moderator_status' => $user_id, 'mod_access' => 1), 'id = ?i', $rec_id);
             require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/commune.php';
             require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/admin_log.php';
             $commune = new commune();
             $topic = commune::GetTopMessageByAnyOther($rec_id, $user_id, commune::MOD_ADMIN);
             $sObjName = $topic['title'];
             $sObjLink = getFriendlyURL('commune', $rec_id);
             if ($action == 1 && $topic['is_blocked_s'] == 't') {
                 //утверждаем
                 $commune->unblockedCommuneTheme($topic['theme_id']);
                 admin_log::addLog(admin_log::OBJ_CODE_COMM, 16, $from_id, $topic['theme_id'], $sObjName, $sObjLink, 0, '', 0, '');
             } elseif ($action == 2 && $topic['is_blocked_s'] != 't') {
                 $commune->blockedCommuneTheme($topic, $reason, 0, $user_id, true);
                 admin_log::addLog(admin_log::OBJ_CODE_COMM, 15, $from_id, $topic['theme_id'], $sObjName, $sObjLink, 0, '', 0, $reason, $topic['theme_id']);
             }
         } else {
             // комментарий
             $aData = array('moderator_status' => $user_id, 'mod_access' => 1);
             if ($action == 1 && $is_sent == 'f') {
                 // отправка уведомления о новом сообщении
                 /*require_once( $_SERVER['DOCUMENT_ROOT'] . '/classes/pmail.php' );
                 
                                     $pmail = new pmail;
                                     $pmail->CommuneNewComment( $rec_id );*/
                 $aData['is_sent'] = true;
                 // устанавливаем флаг отправки
             }
             $aRow = $GLOBALS['DB']->row('SELECT theme_id, deleted_id FROM commune_messages WHERE id = ?i', $rec_id);
             require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/comments/CommentsCommune.php';
             $comments = new CommentsCommune($aRow['theme_id']);
             if ($action == 1 && $aRow['deleted_id'] && $aRow['deleted_id'] != $from_id) {
                 $comments->restore($rec_id);
             } elseif ($action == 2 && $aRow['deleted_id'] != $from_id) {
                 $comments->delete($rec_id, $from_id, true);
                 $aData['deleted_reason'] = $reason;
             }
             $GLOBALS['DB']->update('commune_messages', $aData, 'id = ?i', $rec_id);
         }
     }
     return $bRet;
 }
コード例 #2
0
ファイル: banned.server.php プロジェクト: Nikitian/fl-ru-damp
/**
 * Блокировка/разблокировка топика администратором free-lance.ru
 * 
 * @param  int    $commune_id  ID сообщества
 * @param  int    $topic_id    ID топика
 * @param  int    $topic_id    ID сообщения
 * @param  string $reason      Причина
 * @param  int    $reason_id   ID причины, если она выбрана из списка (таблица admin_reasons, где act_id = 15)
 * @param  string $reason_name Краткое описание причины действия (из селекта) для лога админских действий
 * @return object xajaxResponse
 */
function BlockedCommuneTheme($commune_id = 0, $topic_id = 0, $msg_id = 0, $reason, $reason_id = null, $reason_name = '')
{
    global $DB;
    session_start();
    $objResponse = new xajaxResponse();
    $commune_id = intval($commune_id);
    $topic_id = intval($topic_id);
    $msg_id = intval($msg_id);
    if (hasPermissions('communes')) {
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/commune.php';
        if (is_string($reason) && $reason != '') {
            if (hasPermissions('communes')) {
                $count = $DB->val('SELECT COUNT(*) FROM commune_themes WHERE id = ?', $topic_id);
                if ($count) {
                    $commune = new commune();
                    $topic = commune::GetTopMessageByAnyOther($msg_id, $_SESSION['uid'], commune::MOD_ADMIN);
                    // лог админских действий
                    $sObjName = $topic['title'];
                    $sObjLink = '/commune/?id=' . $commune_id . '&site=Topic&post=' . $msg_id;
                    $reason_id = $reason_id ? $reason_id : null;
                    $reason = str_replace('%USERNAME%', $topic['user_uname'] . ' ' . $topic['user_usurname'], $reason);
                    $reason = change_q($reason, FALSE, 0, TRUE);
                    if ($topic['is_blocked_s'] == 't') {
                        $commune->unblockedCommuneTheme($topic_id);
                        // пишем лог админских действий
                        admin_log::addLog(admin_log::OBJ_CODE_COMM, 16, $topic['user_id'], $topic_id, $sObjName, $sObjLink, 0, '', $reason_id, $reason);
                        $objResponse->assign("theme-reason-{$topic_id}", 'innerHTML', ' ');
                        $objResponse->assign("theme-button-{$topic_id}", 'innerHTML', '<a href="javascript:void(0)" onclick="banned.blockedCommuneTheme(' . $commune_id . ',' . $topic_id . ',' . $msg_id . ')" class="lnk-red">Заблокировать</a>');
                    } else {
                        $commune->blockedCommuneTheme($topic, $reason, $reason_id, $_SESSION['uid']);
                        // пишем лог админских действий
                        admin_log::addLog(admin_log::OBJ_CODE_COMM, 15, $topic['user_id'], $topic_id, $sObjName, $sObjLink, 0, '', $reason_id, $reason, $topic_id);
                        $reason = reformat($reason, 24, 0, 0, 1, 24);
                        $html = BlockedCommuneThemeHTML($reason);
                        $objResponse->assign("theme-reason-{$topic_id}", 'innerHTML', $html);
                        $objResponse->assign("theme-button-{$topic_id}", 'innerHTML', '<a href="javascript:void(0)" onclick="banned.unblockedCommuneTheme(' . $commune_id . ',' . $topic_id . ',' . $msg_id . ')" class="lnk-red">Разблокировать</a>');
                    }
                } else {
                    $objResponse->alert('Несуществующее сообщение в сообществе');
                }
            }
        }
    }
    return $objResponse;
}