Exemple #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;
}
Exemple #2
0
 /**
  * @param string $url
  * @return string returns a contine link
  */
 function continueURL($start, $url)
 {
     if (!filter_var($start, FILTER_VALIDATE_INT)) {
         $start = 0;
     }
     if (trim($url) == '') {
         return null;
     }
     $text = suxFunct::gtext();
     // W3C valid url
     $q = mb_strpos($url, '?') ? '&' : '?';
     $url = $url . $q;
     $url = htmlspecialchars($url, ENT_QUOTES, 'UTF-8', false);
     $html = "<a href='{$url}start={$start}' class='nextPage'>{$text['continue']} &raquo;</a> ";
     return "<div class='pager'>{$html}</div> ";
 }
Exemple #3
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;
}
Exemple #4
0
// ---------------------------------------------------------------------------
if (!isset($_SESSION['users_id'])) {
    exit;
}
if (!isset($_POST['id']) || !filter_var($_POST['id'], FILTER_VALIDATE_INT)) {
    exit;
}
if (!isset($_POST['description'])) {
    exit;
}
// ---------------------------------------------------------------------------
// Secondary error checking
// ---------------------------------------------------------------------------
$log = new suxLog();
$photo = new suxPhoto();
$text = suxFunct::gtext('photos');
// Verify if user is allowed to edit this photo.
if (!$photo->isPhotoOwner($_POST['id'], $_SESSION['users_id'])) {
    exit;
}
$clean = array('id' => $_POST['id'], 'description' => $_POST['description']);
try {
    $photo->savePhoto($_SESSION['users_id'], $clean);
    $tmp = $photo->getPhotoByID($clean['id']);
    if ($tmp['description']) {
        echo $tmp['description'];
    } else {
        echo $text['clickme'];
    }
    $log->write($_SESSION['users_id'], "sux0r::photos::describe() photos_id: {$clean['id']}", 1);
    // Private
Exemple #5
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;
    }
}
Exemple #6
0
<?php

// Ajax
// Echo the content of a bayesian document
if (isset($_POST['id']) && filter_var($_POST['id'], FILTER_VALIDATE_INT)) {
    require_once dirname(__FILE__) . '/../../config.php';
    require_once dirname(__FILE__) . '/../../initialize.php';
    $nb = new suxNaiveBayesian();
    $doc = $nb->getDocument($_POST['id']);
    if ($doc) {
        $text = suxFunct::gtext('bayes');
        $tmp = null;
        $link = new suxLink();
        foreach ($link->getLinkTables('bayes_documents') as $table) {
            $links = $link->getLinks($table, 'bayes_documents', $_POST['id']);
            if ($links && count($links)) {
                $table = str_replace('link__', '', $table);
                $table = str_replace('bayes_documents', '', $table);
                $table = str_replace('__', '', $table);
                $tmp .= "[ {$text['to']} {$table}_id -&gt; ";
                foreach ($links as $val) {
                    $tmp .= " {$val},";
                }
                $tmp = rtrim($tmp, ', ');
                $tmp .= ' ]';
            }
        }
        echo '<em>bayes_document_id: ', $_POST['id'], '</em><br />';
        if ($tmp) {
            echo "<em><strong>{$text['is_linked']}</strong></em> ";
            echo $tmp;
Exemple #7
0
/**
* Render lament
*
* @param array $params smarty {insert} parameters
* @return string html
*/
function insert_lament($params)
{
    if (empty($params['users_id'])) {
        return null;
    }
    if (empty($_SESSION['users_id'])) {
        return null;
    }
    if ($_SESSION['users_id'] != $params['users_id']) {
        return null;
    }
    $text = suxFunct::gtext('user');
    $url = $GLOBALS['CONFIG']['URL'] . '/modules/user/ajax.lament.php';
    $html = "\n        <div id='lament'>{$text['lament']}</div>\n        <script type='text/javascript'>\n        // <![CDATA[\n        \$(function() {\n            \$('#lament').editable('{$url}', {\n                name: 'lament',\n                type: 'textarea',\n                rows: 4,\n                placeholder: '{$text['lament']}',\n                submit: '{$text['ok']}',\n                cancel: '{$text['cancel']}'\n            });\n        });\n        // ]]>\n        </script>\n    ";
    return $html;
}
Exemple #8
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;
}
Exemple #9
0
/**
* Render bayesFilters
*
* @param array $params smarty {insert} parameters
* @return string html
*/
function insert_bayesFilters($params)
{
    if ($GLOBALS['CONFIG']['FEATURE']['bayes'] == false) {
        return null;
    }
    // Feature is turned off
    if (!isset($_SESSION['users_id'])) {
        return null;
    }
    // Anonymous user, skip
    $r = new suxBayesRenderer('bayes');
    // Renderer
    if (!$r->getUserCategories()) {
        return null;
    }
    // No categories, skip
    $tpl = new suxTemplate('bayes');
    // Template
    $r->gtext = suxFunct::gtext('bayes');
    // Language
    if (isset($_GET['filter'])) {
        $tpl->assign('filter', $_GET['filter']);
    }
    if (isset($_GET['threshold']) && $_GET['threshold'] !== false) {
        $tpl->assign('threshold', $_GET['threshold']);
    }
    if (isset($_GET['search'])) {
        $tpl->assign('search', strip_tags($_GET['search']));
    }
    if (isset($params['form_url'])) {
        $r->text['form_url'] = $params['form_url'];
    }
    if (isset($params['hidden']) && is_array($params['hidden'])) {
        $r->arr['hidden'] = $params['hidden'];
    }
    if (!$GLOBALS['CONFIG']['CLEAN_URL']) {
        $r->text['c'] = @$_GET['c'];
    }
    // We need this if CLEAN_URL = false
    $tpl->assignByRef('r', $r);
    return $tpl->fetch('filters.tpl');
}
Exemple #10
0
 /**
  * Data License
  *
  * @return string html
  */
 function dataLicense()
 {
     $gtext = suxFunct::gtext();
     return $gtext['data_license'];
 }
Exemple #11
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;
}