Exemplo n.º 1
0
/**
* 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;
}
Exemplo n.º 2
0
/**
* 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;
}
Exemplo n.º 3
0
/**
* 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;
    }
}
Exemplo n.º 4
0
/**
* 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;
}
Exemplo n.º 5
0
// ---------------------------------------------------------------------------
// Error checking
// ---------------------------------------------------------------------------
if (!isset($_SESSION['users_id'])) {
    failure('Invalid user id');
}
if (!isset($_POST['id']) || !filter_var($_POST['id'], FILTER_VALIDATE_INT) || $_POST['id'] < 1) {
    failure('Invalid id');
}
$id = $_POST['id'];
// ---------------------------------------------------------------------------
// Secondary error checking
// ---------------------------------------------------------------------------
$user = new suxUser();
$log = new suxLog();
if (!$user->isRoot()) {
    failure('Not admin');
}
// ---------------------------------------------------------------------------
// Go
// ---------------------------------------------------------------------------
try {
    $image = 'lock2.gif';
    $flag = $log->toggleLogPrivateFlag($id);
    if ($flag) {
        $image = 'lock1.gif';
    }
    // Log, private
    $log->write($_SESSION['users_id'], "sux0r::admin::toggle() users_log_id: {$id}", 1);
} catch (Exception $e) {
    $message = $e->getMessage();
Exemplo n.º 6
0
/**
* Render userInfo
*
* @global string $CONFIG['URL']
* @global string $CONFIG['PARTITION']
* @param array $params smarty {insert} parameters
* @return string html
*/
function insert_userInfo($params)
{
    unset($params);
    // Not used
    $tpl = new suxTemplate('globals');
    $r = new suxRenderer('globals');
    // Renderer
    $tpl->assignByRef('r', $r);
    // Renderer referenced in template
    if (!empty($_SESSION['nickname'])) {
        $u = new suxUser();
        if ($u->isRoot()) {
            $r->bool['root'] = true;
        }
        $r->text['nickname'] = $_SESSION['nickname'];
        return $tpl->fetch('userinfo.tpl');
    } else {
        return $tpl->fetch('userlogin.tpl');
    }
}
Exemplo n.º 7
0
/**
* 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;
}