function RateComment($sname, $item, $dir) { session_start(); $objResponse = new xajaxResponse(); $uid = get_uid(false); if (!$uid) { return $objResponse; } $obj = null; switch (strtolower($sname)) { case 'commune': if (!commune_carma::isAllowedVote()) { return $objResponse; } require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/comments/CommentsCommune.php'; $comments = new CommentsCommune($item); $data = $comments->getData($item); if ($data['author'] == $uid) { return $objResponse; } // За свой коммент голосовать нельзя break; default: return $objResponse; } $result = $comments->RateComment($uid, $item, $dir); $jsfunct = 'RateCommentCallback'; if ($comments->is_new_template) { $jsfunct = 'RateCommentCallbackNew'; } $objResponse->call($jsfunct, $item, $dir); return $objResponse; }
/** * Отдает HTML для Редактирование комментария в сообществах * * @param object $objResponse xajaxResponse * @param string $rec_id идентификатор записи * @param string $rec_type тип записи * @param array $aParams дополнительные параметры с UID отправителя. остальные - опционально * @return string */ function _admEditCommunityCommParseForm(&$objResponse, $rec_id = '', $rec_type = '', $aParams = array()) { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/attachedfiles.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/comments/CommentsCommune.php'; // получение данных комментария $oComments = new CommentsCommune(); $mess = $oComments->getData($rec_id); $aModel = $oComments->model(); $mess['parent_id'] = $mess['parent_id2']; ob_start(); include_once $_SERVER['DOCUMENT_ROOT'] . '/user/adm_edit_tpl/comments.php'; $sHtml = ob_get_contents(); ob_end_clean(); // аттачи $aAttach = _getCommentFilesIds($mess, $aModel); $sAttach = getAttachedFilesJs($aAttach, TComments::MAX_FILE_COUNT, TComments::MAX_FILE_SIZE, 'commune'); $objResponse->assign('h4_adm_edit', 'innerHTML', 'Редактировать комментарий'); $objResponse->assign('div_adm_edit', 'innerHTML', $sHtml); $objResponse->script("\$('div_adm_reason').setStyle('display', 'none');"); $objResponse->script("adm_edit_content.editMenuItems = ['', 'Файлы'];"); $objResponse->script('adm_edit_content.edit();'); $objResponse->script($sAttach); $objResponse->script('xajax_getAdmEditReasons(' . admin_log::ACT_ID_EDIT_COMMUNITY . ');'); }
/** * Сообщества. Утверждение/удаление записи * * @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; }
if (!$params['is_permission'] && $is_top_author) { $params['is_permission'] = 4; } if (commune::isBannedCommune($user_mod) || $top['deleted_id']) { $params['readonly'] = 1; } if (!commune_carma::isAllowedVote()) { $params['deny_vote'] = true; } if (__paramInit('string', 'cmtask', 'cmtask') == 'delete' || __paramInit('string', 'cmtask', 'cmtask') == 'restore') { if ($_GET['token'] != $_SESSION['rand']) { header('Location: /404.php'); exit; } } $comments = new CommentsCommune($top['id'], $top['last_viewed_time'], $params); $comments->tpl_path = $_SERVER['DOCUMENT_ROOT'] . '/classes/comments/'; $comments_html = $comments->render(); $js_file_utf8[] = '/scripts/ckedit/ckeditor.js'; $js_file[] = '/scripts/commune_card.js'; // если собираемся редактировать пост if (__paramInit('string', 'taction') === 'edit') { if (!get_uid(1)) { header_location_exit('/fbd.php'); } if (!$action) { $action = 'Edit.post'; } $commune_output = 'tpl.topic_form.php'; $js_file = array_merge($js_file, array('comment_form.js')); } else {