Пример #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 comment_form($post_id)
{
    if (!user_signed_in()) {
        ?>
        <p>
            Извините, комментарии могут оставлять только <a href="<?php 
        echo site_url('user/register');
        ?>
">зарегистрированные</a> пользователи.<br/>
            Если вы помните свой логин и пароль, то вы можете <a href="<?php 
        echo site_url('user/login');
        ?>
">войти здесь</a>
        </p>
        <?php 
        return;
    }
    $user = current_user();
    ?>
    <a name="comment_form"></a>
    <form method="POST" action="<?php 
    echo site_url('post/comment/' . $post_id);
    ?>
" onSubmit="return AC.comment.on_submit()">
        <input type="hidden" name="post_id" id="post_id" value="<?php 
    echo form_prep($post_id);
    ?>
"/>
        <input type="hidden" name="parent_id" id="parent_id" value="0" />
        <textarea name="text" id="text" style="width:90%;height:195px"></textarea><br/>
        <input type="submit" value="Написать" class="btn btn-success" />
    </form>
    <?php 
}
Пример #3
0
function user_is($role)
{
    if (!user_signed_in()) {
        return FALSE;
    }
    $user = current_user();
    return strtolower($user['role']) == strtolower($role) ? TRUE : FALSE;
}
Пример #4
0
                    <li><a href="<?php 
echo site_url('blog/videos');
?>
" class="active">Видео</a></li>
                    <li><a href="<?php 
echo site_url('blog/photos');
?>
" class="active">Картинки</a></li>
                    <li><a href="<?php 
echo site_url('page/about');
?>
">О нас</a></li>
                </ul>
                <div id="login">
<?php 
if (user_signed_in()) {
    $user = current_user();
    ?>
    <?php 
    echo user_avatar($user, 'mini');
    ?>
 <?php 
    echo anchor('user/profile/' . $user['login'], $user['login']);
    ?>
 | <?php 
    echo anchor('user/logout', 'Выйти');
    ?>
    <?php 
} else {
    ?>
    <?php