コード例 #1
0
/**
 * Возвращает список предупреждение пользователя для попап окна.
 * 
 * @param int    $uid       UID пользователя
 * @param array  $contextId Контекст (для лога админских действий)
 * @param string $draw_func способ отображения
 *
 * @return object xajaxResponse
 */
function getUserWarns($uid = 0, $contextId = '', $draw_func = '')
{
    session_start();
    $objResponse = new xajaxResponse();
    if (hasPermissions('users')) {
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/permissions.php';
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/users.php';
        $user = new users();
        $user->GetUserByUID($uid);
        if ($user->uid) {
            $aPermissions = permissions::getUserPermissions($_SESSION['uid']);
            $admin_log = new admin_log('user', $_SESSION['uid'], $aPermissions);
            $aWarns = $admin_log->getUserWarns($nCount, $uid);
            $sCount = $nCount ? $nCount : '0';
            $sWarns = $user->warn ? $user->warn : '0';
            $objResponse->assign('a_user_warns', 'href', '/users/' . $user->login);
            $objResponse->assign('s_user_warns', 'innerHTML', $user->uname . ' ' . $user->usurname . ' [' . $user->login . ']');
            $objResponse->assign('e_user_warns', 'innerHTML', $sWarns);
            $objResponse->assign('n_user_warns', 'innerHTML', $sCount);
            if ($nCount) {
                $sTable = '<table id="t_user_warns" class="notice-table">';
                $nCount = 1;
                foreach ($aWarns as $aOne) {
                    $sReason = $aOne['admin_comment'] ? hyphen_words($aOne['admin_comment'], true) : '&lt;без причины&gt;';
                    $sAdmin = $aOne['adm_login'] ? '<a target="_blank" href="/users/' . $aOne['adm_login'] . '">' . $aOne['adm_login'] . '</a>' : 'не известно';
                    $sDate = $aOne['act_time'] ? date('d.m.Y H:i', strtotime($aOne['act_time'])) : 'не известно';
                    $sTable .= '<tr>
                    	<td class="cell-number">' . $nCount . '.</td>
                    	<td class="cell-uwarn">' . $sReason . '</td>
                    	<td class="cell-who">Выдан: [' . $sAdmin . ']
                    	<td class="cell-date">' . $sDate . '</td>
                        <td' . ($aOne['src_id'] ? ' id="i_user_warns_' . $aOne['src_id'] . '"' : '') . '>' . ($aOne['src_id'] ? '<a href="javascript:void(0);" onclick="banned.warnUser(' . $uid . ',' . $aOne['src_id'] . ',\'' . $draw_func . '\',\'' . $contextId . '\',0);"><img src="/images/btn-remove2.png" alt="" width="11" height="11" /></a>' : '') . '</td>
                    </tr>';
                    ++$nCount;
                }
                $sTable .= '</table>';
                $objResponse->assign('d_user_warns', 'innerHTML', $sTable);
            } else {
                $objResponse->assign('d_user_warns', 'innerHTML', '&nbsp;');
            }
            $sBanTitle = $user->is_banned || $user->ban_where ? 'Разбанить' : 'Забанить';
            $objResponse->script('adminLogOverlayClose();');
            $objResponse->script("\$('ov-notice4').setStyle('display', '');");
            $objResponse->script('adjustUserWarnsHTML();');
            $objResponse->assign('b_user_warns', 'innerHTML', '<button onclick="adminLogOverlayClose();banned.userBan(' . $uid . ', \'' . $contextId . '\',0)">' . $sBanTitle . '</button><a class="lnk-dot-grey" href="javascript:void(0);" onclick="adminLogOverlayClose();">Отмена</a>');
        }
    }
    return $objResponse;
}