Exemplo n.º 1
0
/**
 * Блокирование/разблокирование сообщества
 * 
 * @param  int    $commune_id
 * @param  string $reason        причина
 * @param  int    $reason_id     ID причины, если она выбрана из списка (таблица admin_reasons, где act_id = 11)
 * @param  string $reason_name   Краткое описание причины действия (из селекта) для лога админских действий
 * @return object xajaxResponse
 */
function BlockedCommune($commune_id, $reason, $reason_id = null, $reason_name = '')
{
    global $DB;
    $objResponse = new xajaxResponse();
    $commune_id = intval($commune_id);
    session_start();
    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 WHERE id = ?", $commune_id);
                if ($count) {
                    $commune = new commune();
                    $comm = $commune->GetCommune($commune_id, NULL, $_SESSION['role']);
                    // лог админских действий
                    $sObjName = $comm['name'];
                    $sObjLink = '/commune/?id=' . $commune_id;
                    $reason_id = $reason_id ? $reason_id : null;
                    $reason = str_replace('%USERNAME%', $comm['author_uname'] . ' ' . $comm['author_usurname'], $reason);
                    $reason = change_q($reason, FALSE, 0, TRUE);
                    if ($comm['is_blocked']) {
                        $commune->UnBlocked($commune_id);
                        // пишем лог админских действий
                        admin_log::addLog(admin_log::OBJ_CODE_COMM, 12, $comm['author_id'], $commune_id, $sObjName, $sObjLink, 0, '', $reason_id, $reason);
                        $objResponse->assign("blocked-reason-{$commune_id}", 'innerHTML', ' ');
                        $objResponse->assign("blocked-reason-{$commune_id}", 'style.display', 'none');
                        $objResponse->assign("blocked-button-{$commune_id}", 'innerHTML', '<a class="b-menu__link b-menu__link_fontsize_11 b-menu__link_color_c10600" href="javascript:;" onclick="banned.blockedCommune(' . $comm['id'] . ')">Заблокировать сообщество</a>');
                        $objResponse->assign("commune-reason-{$commune_id}", 'innerHTML', '&nbsp;');
                    } else {
                        $sBlockId = $commune->Blocked($commune_id, $reason, $reason_id, $_SESSION['uid']);
                        // пишем лог админских действий
                        admin_log::addLog(admin_log::OBJ_CODE_COMM, 11, $comm['author_id'], $commune_id, $sObjName, $sObjLink, 0, '', $reason_id, $reason, $sBlockId);
                        $comm = $commune->GetCommune($commune_id, NULL, $_SESSION['role']);
                        $reason = reformat($comm['blocked_reason'], 24, 0, 0, 1, 24);
                        $html = __commPrntBlockedBlock($reason, $comm['blocked_time'], $_SESSION['login'], "{$_SESSION['name']} {$_SESSION['surname']}", $commune_id);
                        $objResponse->assign("blocked-reason-{$commune_id}", 'innerHTML', $html);
                        $objResponse->assign("blocked-reason-{$commune_id}", 'style.display', 'block');
                        $objResponse->assign("blocked-button-{$commune_id}", 'innerHTML', '<a class="b-menu__link b-menu__link_fontsize_11 b-menu__link_color_c10600" href="javascript:;" onclick="banned.unblockedCommune(' . $comm['id'] . ')">Разблокировать сообщество</a>');
                        $objResponse->assign("commune-reason-{$commune_id}", 'innerHTML', '&nbsp;');
                    }
                } else {
                    $objResponse->alert('Несуществующее сообщество');
                }
            }
        }
    }
    return $objResponse;
}
Exemplo n.º 2
0
/**
 * Выставляем роли пользователям сообщества (выставлять может только автор сообщества?? это верно или нет).
 *
 * @param integer $commune_id ИД Сообщества
 * @param integer $member_id  ИД Пользователя
 * @param boolean $is_moder   Флаг модератора
 * @param boolean $is_manager Флаг менеджера
 *
 * @return 
 */
function setRoleUser($commune_id, $member_id, $is_moder, $is_manager)
{
    $objResponse = new xajaxResponse();
    if (!isset($_SESSION['uid'])) {
        return;
    }
    $cm = new commune();
    $comm = $cm->GetCommune($commune_id);
    // Только хозяин сообщества может такое творить @todo нужно уточнить кто может назначать админов и менеджеров.
    if ($comm['author_id'] == $_SESSION['uid']) {
        $cm->UpdateAdmin($member_id, '', $is_moder, $is_manager, $comm);
        if ($is_moder or $is_manager) {
            $objResponse->assign('cau_admin' . $member_id, 'innerHTML', 'Admin&nbsp;');
        } else {
            if (!$is_moder and !$is_manager) {
                $objResponse->assign('cau_admin' . $member_id, 'innerHTML', '');
            }
        }
        $objResponse->script('$("is_mod_value' . $member_id . '").set("value", ' . intval($is_moder) . ');');
        $objResponse->script('$("is_men_value' . $member_id . '").set("value", ' . intval($is_manager) . ');');
    }
    return $objResponse;
}
Exemplo n.º 3
0
/**
 * возвращает html блока с разделами сообщества, который в левом столбце
 * @param type $commune_id ID сообщества
 * @param type $om сортировка
 * @param type $curr_cat текущая активная категория
 * @param type $page страница
 * @return string html-код
 */
function __commPrintCategoriesList($commune_id, $om, $curr_cat = '', $page = 0)
{
    $comm = NULL;
    $user_mod = 0;
    $uid = get_uid(false);
    if ($uid) {
        $status = commune::GetUserCommuneRel($commune_id, $uid);
    }
    $comm = commune::GetCommune($commune_id, !$uid ? NULL : $uid, $user_mod);
    if ($comm) {
        $communeThemesCounts = commune::getCommuneThemesCount($comm['id']);
        if (hasPermissions('communes')) {
            $themes_count = $communeThemesCounts['count'];
            $for_admin = true;
        } elseif ($status['is_moderator'] == 1 || $status['is_admin'] == 1 || $status['is_author'] == 1) {
            $themes_count = $communeThemesCounts['count'] - $communeThemesCounts['admin_hidden_count'];
            $for_commune_admin = true;
        } else {
            $themes_count = $communeThemesCounts['count'] - $communeThemesCounts['hidden_count'];
            $for_admin = false;
        }
        $categories = commune::getCategories($commune_id, true);
        ob_start();
        include $_SERVER['DOCUMENT_ROOT'] . '/commune/tpl.categories_list.php';
        return ob_get_clean();
    } else {
        return null;
    }
}