コード例 #1
0
ファイル: menu.php プロジェクト: hashimmm/sux0r
/**
* menu
*
* @author     Dac Chartrand <*****@*****.**>
* @license    http://www.fsf.org/licensing/licenses/gpl-3.0.html
*/
function bookmarks_menu()
{
    if (!isset($_SESSION['users_id'])) {
        return null;
    }
    // Check access
    $user = new suxUser();
    if (!$user->isRoot()) {
        $access = $user->getAccess('bookmarks');
        if ($access < $GLOBALS['CONFIG']['ACCESS']['bookmarks']['admin']) {
            return null;
        }
    }
    $query = 'SELECT COUNT(*) FROM bookmarks WHERE draft = true ';
    $db = suxDB::get();
    $st = $db->query($query);
    $menu = array();
    $count = $st->fetchColumn();
    $text = suxFunct::gtext('bookmarks');
    $menu[$text['admin']] = suxFunct::makeUrl('/bookmarks/admin/');
    $tmp = "{$text['approve_2']} ({$count})";
    $menu[$tmp] = suxFunct::makeUrl('/bookmarks/approve/');
    $menu[$text['new']] = suxFunct::makeUrl('/bookmarks/edit/');
    return $menu;
}
コード例 #2
0
ファイル: menu.php プロジェクト: hashimmm/sux0r
/**
* menu
*
* @author     Dac Chartrand <*****@*****.**>
* @license    http://www.fsf.org/licensing/licenses/gpl-3.0.html
*/
function blog_menu()
{
    if (!isset($_SESSION['users_id'])) {
        return null;
    }
    // Check that the user is allowed to admin
    $user = new suxUser();
    $text = suxFunct::gtext('blog');
    $menu = array();
    $is_root = $user->isRoot();
    $access = $user->getAccess('blog');
    if (!$is_root) {
        if ($access < $GLOBALS['CONFIG']['ACCESS']['blog']['publisher']) {
            return null;
        }
    }
    if ($is_root || $access >= $GLOBALS['CONFIG']['ACCESS']['blog']['admin']) {
        $menu[$text['admin']] = suxFunct::makeUrl('/blog/admin');
    }
    $menu[$text['new']] = suxFunct::makeUrl('/blog/edit');
    return $menu;
}
コード例 #3
0
ファイル: photosRenderer.php プロジェクト: hashimmm/sux0r
/**
* Render edit links
*
* @param array $params smarty {insert} parameters
* @return string html
*/
function insert_editLinks($params)
{
    if (!isset($_SESSION['users_id'])) {
        return null;
    }
    if (empty($params['album_id'])) {
        return null;
    }
    if (!filter_var($params['album_id'], FILTER_VALIDATE_INT) || $params['album_id'] < 1) {
        return null;
    }
    $br = null;
    if (isset($params['br'])) {
        $br = '<br />';
    }
    // Check that the user is allowed to edit this album
    $u = new suxUser();
    if (!$u->isRoot()) {
        $photo = new suxPhoto();
        $access = $u->getAccess('photos');
        if ($access < $GLOBALS['CONFIG']['ACCESS']['photos']['admin']) {
            if ($access < $GLOBALS['CONFIG']['ACCESS']['photos']['publisher']) {
                return null;
            } elseif (!$photo->isAlbumOwner($params['album_id'], $_SESSION['users_id'])) {
                return null;
            }
        }
    }
    $edit = suxFunct::makeUrl('/photos/album/edit/' . $params['album_id']);
    $annotate = suxFunct::makeUrl('/photos/album/annotate/' . $params['album_id']);
    $upload = suxFunct::makeUrl('/photos/upload/' . $params['album_id']);
    $text = suxFunct::gtext('photos');
    $html = '';
    $html .= "<a href='{$edit}'>{$text['edit_2']}</a>{$br}";
    $html .= "<a href='{$upload}'>{$text['upload']}</a>{$br}";
    $html .= "<a href='{$annotate}'>{$text['annotate_2']}</a>{$br}";
    if (isset($params['div'])) {
        return '<div class="editLinks">' . $html . '</div>';
    } else {
        return $html;
    }
}
コード例 #4
0
ファイル: blogRenderer.php プロジェクト: hashimmm/sux0r
/**
* Render edit div
*
*/
function insert_edit($params)
{
    if (!isset($_SESSION['users_id'])) {
        return null;
    }
    if (!isset($params['id'])) {
        return null;
    }
    // Cache
    static $allowed = null;
    // Admin permissions
    $allowed2 = true;
    // Publisher permissions
    if ($allowed == null) {
        // Check if a user is an administrator
        $u = new suxUser();
        $allowed = true;
        if (!$u->isRoot()) {
            $access = $u->getAccess('blog');
            if ($access < $GLOBALS['CONFIG']['ACCESS']['blog']['admin']) {
                $allowed = false;
            }
        }
    }
    if (!$allowed) {
        // Check if a user is the publisher of the message
        $m = new suxThreadedMessages();
        $m->setPublished(null);
        if ($access < $GLOBALS['CONFIG']['ACCESS']['blog']['publisher']) {
            $allowed = false;
            $allowed2 = false;
        } else {
            $tmp = $m->getByID($params['id']);
            if ($tmp['users_id'] != $_SESSION['users_id']) {
                $allowed2 = false;
            }
        }
        if (!$allowed2) {
            return null;
        }
    }
    $url = suxFunct::makeUrl('/blog/edit/' . $params['id']);
    $text = suxFunct::gtext('blog');
    $html = "<div class='edit'>[ <a href='{$url}'>{$text['edit']}</a> ]</div>";
    return $html;
}
コード例 #5
0
ファイル: bookmarksRenderer.php プロジェクト: hashimmm/sux0r
/**
* Render edit div
*
*/
function insert_bookmarksEdit($params)
{
    if (!isset($_SESSION['users_id'])) {
        return null;
    }
    if (!isset($params['id'])) {
        return null;
    }
    // Cache
    static $allowed = null;
    if ($allowed === null) {
        $u = new suxUser();
        $allowed = true;
        if (!$u->isRoot()) {
            $access = $u->getAccess('bookmarks');
            if ($access < $GLOBALS['CONFIG']['ACCESS']['bookmarks']['admin']) {
                $allowed = false;
            }
        }
    }
    if (!$allowed) {
        return null;
    }
    $url = suxFunct::makeUrl('/bookmarks/edit/' . $params['id']);
    $text = suxFunct::gtext('bookmarks');
    $html = "<div class='edit'>[ <a href='{$url}'>{$text['edit']}</a> ]</div>";
    return $html;
}