Пример #1
0
/**
 * Buttons to edit, delete post
 * 
 * @param type $post
 * @return type 
 */
function post_control($post)
{
    if (!user_signed_in()) {
        return;
    }
    $user = current_user();
    if ($user['banned']) {
        return;
    }
    $type = array_search($post['type'], blog_types());
    // now we have got 'news' key
    if (user_is('admin') or $user['id'] == $post['user_id']) {
        ?>
        <span class="post-control">
            <a href="<?php 
        echo site_url('post/form/' . $post['id']);
        ?>
"  title="Редактировать"><i class="icon-pencil"></i></a>
            <a href="#" class="delete" id="destroy-<?php 
        echo $post['id'];
        ?>
" title="Удалить"><i class="icon-trash"></i></a>
        </span>
        <?php 
    }
}
Пример #2
0
function show_comment($comment, $lvl = 0)
{
    $style = 'style="margin-left: ' . $lvl * 20 . 'px"';
    ?>
    <div class="comment" id="comment-<?php 
    echo $comment['id'];
    ?>
" <?php 
    echo $style;
    ?>
>
        <a name="com<?php 
    echo $comment['id'];
    ?>
"></a>
        <?php 
    echo avatar($comment);
    ?>
        <div class="author">Написал: <a href="<?php 
    echo site_url('user/profile/' . $comment['login']);
    ?>
"><?php 
    echo $comment['login'];
    ?>
</a> <?php 
    echo human_read_date($comment['added_at']);
    ?>
</div>
        <p><?php 
    echo $comment['deleted'] == 1 ? '[комментарий был удалён администратором]' : $comment['text'];
    ?>
</p>
        <?php 
    if (user_is('admin')) {
        ?>
<a href="#" class="delcomment ctrl" id="destroy-<?php 
        echo $comment['id'];
        ?>
"><span class="ui-icon ui-icon-trash"></span> удал.</a><?php 
    }
    ?>
        
        <a href="#comment_form" id="reply-<?php 
    echo $comment['id'];
    ?>
" class="reply">ответить</a>
    </div>
    <?php 
}
Пример #3
0
function user_can_rule($post = array())
{
    // $user = CI()->user->profile();
    // if( empty($user['id']) OR ($user['banned'] != 0) ) show_error( 'Увы и ах, у вас нет прав', 500 );
    if (!user_signed_in()) {
        show_error('Необходима авторизация', 401);
    }
    $user = current_user();
    if ($user['banned']) {
        show_error('Вы забанены', 403);
    }
    if (!empty($post)) {
        if (!user_is('admin') or $user['id'] != $post['user_id']) {
            show_error('Нет прав и доступа', 403);
        }
    }
}
Пример #4
0
 protected function get_admin_user_params()
 {
     if (!user_is('admin')) {
         show_error('Что-то нет прав? Не получается, да?', 500);
         exit;
     }
     $user_id = param('user_id');
     if (empty($user_id)) {
         set_flash_error('Нет id нужного пользователя');
         redirect();
     }
     $user = $this->user->find($user_id, 1);
     if (empty($user)) {
         set_flash_error('Такого пользователя у нас нет');
     }
     return $user;
 }
Пример #5
0
 /**
  * Mark comment as deleted
  * 
  * @return type
  */
 public function comment_destroy()
 {
     if (!user_is('admin')) {
         return $this->ajax(array('error' => 'Извините, но у вас нет прав на удаление комментариев'));
     }
     $id = param('id');
     $this->load->model('comment');
     if (empty($id)) {
         return $this->ajax(array('error' => 'Почему-то не указан ID комментария для удаления'));
     }
     $this->comment->save(array('id' => $id, 'deleted' => 1));
     return $this->ajax(array('ok' => 'Комментарий успешно удалён', 'id' => $id));
 }
Пример #6
0
 function user_is_not($id = FALSE, $role = FALSE)
 {
     return !user_is($id, $role);
 }
Пример #7
0
    <input type="submit" value="Сохранить" class="button" />
</form>
<script language="JavaScript" type="text/javascript">
$(document).ready(function() {
    $('#showcharacters').click(function() {
        if ($(this).attr('checked')) {
            $('#new_password').replaceWith('<input id="new_password" name="new_password" class="input" style="width:120px" type="text" value="' + $('#new_password').attr('value') + '" />');
        } else {
            $('#new_password').replaceWith('<input id="new_password" name="new_password" class="input" style="width:120px" type="password" value="' + $('#new_password').attr('value') + '" />');
        }
    });
});
</script>
    <?php 
}
if (user_is('admin') and !is_current_user($user)) {
    if ($user['banned'] == 0) {
        ?>
            <br/><form method="POST" action="<?php 
        echo site_url('user/ban');
        ?>
">
                <input type="hidden" name="user_id" value="<?php 
        echo form_prep($user['id']);
        ?>
" />
                <input type="submit" value="Забанить пользователя" class="button danger" />
            </form>
            <?php 
    } elseif ($user['banned'] == 1) {
        ?>
Пример #8
0
<?php

if (basename(__FILE__) == basename($_SERVER['SCRIPT_FILENAME']) || !user_is('admin')) {
    exit(header('Location: index.php'));
}
if (isset($_POST['new_user'])) {
    if ($error = $scadmin->add_user($_POST)) {
        echo '<p class="message">', $error, '</p>';
    }
}
?>

<?php 
if (isset($message)) {
    echo '<br /><p class="message">', $message, '</p>';
}
?>

<script type="text/javascript" language="Javascript">
window.addEvent('domready', function() {
	var name = $('name');
	var login = $('login');
	var email = $('email');
	var pass = $('pass');
	var pass2 = $('pass2');
	name.addEvent('keyup', function() {
		(function() {
		$('nerror').empty();
		if(this.value.length < 3) {
			$('nerror').set('text', 'User Name is too short!');
			return false;
Пример #9
0
function is_client($user = '')
{
    if (user_is($user, 'client')) {
        return true;
    }
    return false;
}