Esempio n. 1
0
function render_page($page)
{
    global $core, $blog_settings, $user_settings;
    $user_id = $core->auth->userID();
    if ($user_settings == null) {
        $user_settings = new bpSettings($core, $user_id);
    }
    $planet_theme = $blog_settings->get('planet_theme');
    $tpl = new Hyla_Tpl(dirname(__FILE__) . '/../../themes/' . $planet_theme . '/user');
    $tpl->setL10nCallback('T_');
    $tpl->importFile($page, $page . '.tpl');
    $tpl->setVar('planet', array("url" => BP_PLANET_URL, "theme" => $blog_settings->get('planet_theme'), "title" => $blog_settings->get('planet_title'), "desc" => $blog_settings->get('planet_desc'), "keywords" => $blog_settings->get('planet_keywords'), "desc_meta" => $blog_settings->get('planet_desc_meta'), "msg_info" => $blog_settings->get('planet_msg_info')));
    switch ($page) {
        case 'dashboard':
            $sql = generate_SQL(0, 10, array($user_id), array(), '', '', false, null, 2);
            $rs = $core->con->select($sql);
            while ($rs->fetch()) {
                $status = "";
                if (!$rs->status) {
                    $status = "disabled";
                }
                $post = array('id' => $rs->post_id, 'title' => html_entity_decode($rs->title, ENT_QUOTES, 'UTF-8'), 'title2' => htmlspecialchars($rs->title), 'permalink' => $rs->permalink, 'pubdate' => $rs->pubdate, "date" => mysqldatetime_to_date("d/m/Y", $rs->pubdate), "status" => $status);
                $rs2 = $core->con->select("SELECT tag_id FROM " . $core->prefix . "post_tag\n\t\t\t\tWHERE post_id = " . $rs->post_id);
                $tpl->setVar('post', $post);
                while ($rs2->fetch()) {
                    $tpl->setVar('tag', $rs2->tag_id);
                    $tpl->setVar('post_id', $rs->post_id);
                    $tpl->render('userpost.tags');
                }
                if (!$rs->status) {
                    $tpl->render('userpost.action');
                }
                if ($rs->comment) {
                    $tpl->render('userpost.action.nocomment');
                } else {
                    $tpl->render('userpost.action.comment');
                }
                if ($blog_settings->get('allow_post_modification')) {
                    $tpl->render('userpost.action.activate');
                }
                $tpl->render('userpost.item');
            }
            break;
        case 'profile':
            $rs = $core->con->select("SELECT * FROM " . $core->prefix . "user\n\t\t\tWHERE user_id = '" . $user_id . "'");
            $user = array("user_id" => $user_id, 'user_fullname' => $rs->f('user_fullname'), 'user_email' => $rs->f('user_email'));
            $tpl->setVar('user', $user);
            foreach (getAllSupportedLanguages() as $lang) {
                $tpl->setVar('lang', array("code" => $lang['code'], "name" => $lang['name'], "selected" => $lang['code'] == $rs->f('user_lang') ? 'selected="selected"' : ""));
                $tpl->render("lang.select");
            }
            $rs_feed = $core->con->select("SELECT * FROM " . $core->prefix . "feed\n\t\t\tWHERE user_id ='" . $user_id . "'");
            while ($rs_feed->fetch()) {
                $status = "";
                if (!$rs_feed->feed_status || $rs_feed->feed_status == 2) {
                    $status = "disabled";
                }
                $feed = array("status" => $status, "id" => $rs_feed->feed_id, "url" => $rs_feed->feed_url);
                $tpl->setVar('feed', $feed);
                if (!$rs_feed->feed_comment) {
                    $tpl->render('userfeed.action');
                }
                $rs_tags = $core->con->select("SELECT tag_id FROM " . $core->prefix . "feed_tag\n\t\t\t\tWHERE feed_id=" . $rs_feed->feed_id);
                while ($rs_tags->fetch()) {
                    $tpl->setVar('tag', $rs_tags->tag_id);
                    $tpl->setVar('feed_id', $rs_feed->feed_id);
                    $tpl->render('userfeed.tags');
                }
                if ($blog_settings->get('allow_feed_modification')) {
                    $tpl->render('userfeed.action.activate');
                }
                $tpl->render('userfeed.item');
            }
            $rs_pfeed = $core->con->select("SELECT * FROM " . $core->prefix . "pending_feed\n\t\t\tWHERE user_id ='" . $user_id . "'");
            if ($rs_pfeed->count() > 0) {
                while ($rs_pfeed->fetch()) {
                    $feed = array("site" => $rs_pfeed->site_url, "url" => $rs_pfeed->feed_url);
                    $tpl->setVar('pfeed', $feed);
                    $tpl->render('userpfeed.item');
                }
                $tpl->render('pendingfeed');
            }
            $rs_esite = $core->con->select("SELECT * FROM " . $core->prefix . "site WHERE user_id='" . $user_id . "'");
            while ($rs_esite->fetch()) {
                $tpl->setVar("esite", array("id" => $rs_esite->site_id, "url" => $rs_esite->site_url));
                $tpl->render("existing.site");
            }
            break;
        case 'social':
            $newsletter_options = array("nomail" => array("selected" => "", "value" => "nomail", "text" => T_('Disable newsletter')), "dayly" => array("selected" => "", "value" => "dayly", "text" => T_('Every day')), "weekly" => array("selected" => "", "value" => "weekly", "text" => T_('Every week')), "monthly" => array("selected" => "", "value" => "monthly", "text" => T_('Every month')));
            $option = $user_settings->get('social.newsletter');
            if (!isset($option)) {
                $option = 'nomail';
            }
            $newsletter_options[$option]['selected'] = "selected";
            foreach ($newsletter_options as $news) {
                $tpl->setVar('news', $news);
                $tpl->render('newsletter.option');
            }
            $checked = array("twitter" => $user_settings->get('social.twitter') ? 'checked' : '', "statusnet" => $user_settings->get('social.statusnet') ? 'checked' : '', "shaarli" => $user_settings->get('social.shaarli') ? 'checked' : '', "shaarli-type.remote" => $user_settings->get('social.shaarli.type') == 'remote' ? 'selected="selected"' : '', "shaarli-type.local" => $user_settings->get('social.shaarli.type') == 'local' ? 'selected="selected"' : '', "google" => $user_settings->get('social.google') ? 'checked' : '', "reddit" => $user_settings->get('social.reddit') ? 'checked' : '');
            $tpl->setVar('checked', $checked);
            $tpl->setVar('statusnet_account', $user_settings->get('social.statusnet.account'));
            $tpl->setVar('shaarli_instance', $user_settings->get('social.shaarli.instance'));
            break;
        case 'tribes':
            $rs_users = $core->con->select('SELECT user_id, user_fullname
			FROM ' . $core->prefix . 'user
			WHERE user_status=1');
            while ($rs_users->fetch()) {
                $tpl->setVar('option', array("user_id" => $rs_users->user_id, "user_name" => $rs_users->user_fullname));
                $tpl->render('tribe.option.userlist');
            }
            # On recupere les informtions sur les membres
            $sql = 'SELECT
			user_id,
			tribe_id,
			tribe_name,
			tribe_tags,
			tribe_notags,
			tribe_users,
			tribe_nousers,
			tribe_search,
			tribe_icon,
			visibility,
			ordering
			FROM ' . $core->prefix . 'tribe
			WHERE user_id=\'' . $user_id . '\'
			ORDER by ordering
			ASC LIMIT 100 OFFSET 0';
            $rs = $core->con->select($sql);
            if ($rs->count() > 0) {
                while ($rs->fetch()) {
                    $sql_post = generate_tribe_SQL($rs->tribe_id, 0, 0);
                    $rs_post = $core->con->select($sql_post);
                    $tribe_state = "private";
                    if ($rs->visibility == 1) {
                        $tribe_state = "public";
                    }
                    $tribe_tags = preg_split('/,/', $rs->tribe_tags, -1, PREG_SPLIT_NO_EMPTY);
                    foreach ($tribe_tags as $tag_item) {
                        $tpl->setVar('tribe_tag', $tag_item);
                        $tpl->setVar('tribe_id', $rs->tribe_id);
                        $tpl->render('tribes.tag');
                    }
                    $tribe_notags = preg_split('/,/', $rs->tribe_notags, -1, PREG_SPLIT_NO_EMPTY);
                    foreach ($tribe_notags as $tag_item) {
                        $tpl->setVar('tribe_notag', $tag_item);
                        $tpl->setVar('tribe_id', $rs->tribe_id);
                        $tpl->render('tribes.notag');
                    }
                    $tribe_users = preg_split('/,/', $rs->tribe_users, -1, PREG_SPLIT_NO_EMPTY);
                    foreach ($tribe_users as $user_item) {
                        $tpl->setVar('tribe_user', $user_item);
                        $tpl->setVar('tribe_id', $rs->tribe_id);
                        $tpl->render('tribes.user');
                    }
                    if ($rs->tribe_search) {
                        $tpl->setVar('tribe_id', $rs->tribe_id);
                        $tpl->render('tribes.search');
                    }
                    $tribe_icon = getTribeIcon($rs->tribe_id, $rs->tribe_name, $rs->tribe_icon);
                    $tpl->setVar('tribe_id', $rs->tribe_id);
                    $tpl->render('tribes.icon.action');
                    $tribe_name = html_entity_decode($rs->tribe_name, ENT_QUOTES, 'UTF-8');
                    $tpl->setVar('tribe', array('id' => $rs->tribe_id, 'name' => $rs->tribe_name, 'stripped_name' => addslashes($rs->tribe_name), 'state' => $tribe_state, 'icon' => $tribe_icon, 'last_post' => mysqldatetime_to_date("d/m/Y", $rs_post->last), 'count' => $rs_post->count, 'ordering' => $rs->ordering, 'search' => $rs->tribe_search));
                    $tpl->render('tribes.box');
                }
            }
            break;
        default:
            break;
    }
    return $tpl->render();
}
 # Get search value
 $search_value = !empty($_POST['search']) ? $_POST['search'] : null;
 if (isset($search_value)) {
     $search_value = htmlentities($search_value, ENT_QUOTES, 'UTF-8');
     $search_value = mysql_real_escape_string($search_value);
 }
 # Get filters on tags and users
 $tags = !empty($_POST['tags']) ? getArrayFromList($_POST['tags']) : array();
 $users = !empty($_POST['users']) ? getArrayFromList($_POST['users']) : array();
 # Get the period
 $period = !empty($_POST['period']) ? trim($_POST['period']) : '';
 # Order by most popular
 $popular = !empty($_POST['popular']) ? true : false;
 $post_status = !empty($_POST['post_status']) ? 2 : 1;
 # On recupere les informtions sur les membres
 $sql = generate_SQL($num_start, $nb_items, $users, $tags, $search_value, $period, $popular, null, $post_status);
 //print $sql;
 //exit;
 $rs = $core->con->select($sql);
 $tpl = new Hyla_Tpl(dirname(__FILE__) . '/../themes/' . $blog_settings->get('planet_theme') . '/');
 $tpl->importFile('index', 'index.tpl');
 $tpl->render('menu.filter');
 # Liste des articles
 $tpl = showPosts($rs, $tpl, $search_value, true, $popular);
 $result = array("posts" => $tpl->render('content.posts'), "nb_items" => $nb_items, "page" => $page, "users" => $users, "tags" => $tags, "search" => $search_value);
 #		print json_encode($result);
 print $result['posts'];
 break;
 ##########################################################
 # DEFAULT RETURN
 ##########################################################
Esempio n. 3
0
 debutCache();
 # Get informations about posts
 if (isset($_GET["popular"]) && !empty($_GET['popular'])) {
     $params .= "&popular=true";
     $title_add = " - Popular feed";
 } else {
     $title_add = " - Feed";
 }
 $nb_items = $blog_settings->get('planet_nb_post');
 $num_start = 0;
 if ($tribe_id != null) {
     $sql = generate_tribe_SQL($tribe_id, $num_start, $nb_items);
 }
 if ($sql == "") {
     # Terminaison de la commande SQL
     $sql = generate_SQL($num_start, $blog_settings->get('planet_nb_art_flux'), $users, $tags, $search_value, $period, $popular, null, $post_status);
 }
 //print $sql;
 //exit;
 # Encode specific char
 if ($_GET['type'] == "rss") {
     $params = convert_chars($params);
 } elseif ($_GET['type'] == "atom") {
     $params = str_replace("&", "&", $params);
 }
 # Execute SQL request
 $post_list = $core->con->select($sql);
 $title = convert_chars(html_entity_decode(stripslashes($blog_settings->get('planet_title')), ENT_QUOTES, 'UTF-8')) . $title_add;
 $planet_desc = convert_chars(html_entity_decode(stripslashes($blog_settings->get('planet_desc')), ENT_QUOTES, 'UTF-8'));
 # Head of XML document
 echo '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
Esempio n. 4
0
     $result = array("posts" => $tpl->render('content.posts'), "nb_items" => $nb_items, "page" => $num_page, "users" => $users, "tags" => $tags, "search" => $search_value);
     print $result['posts'];
     break;
     ##########################################################
     # REFRESH TRIBE LIST
     ##########################################################
 ##########################################################
 # REFRESH TRIBE LIST
 ##########################################################
 case 'tribe':
     $tribe_id = $_POST['tribe_id'];
     $page = intval($_POST['page']);
     $num_start = $page * 10;
     $sql_tribe = "SELECT * FROM " . $core->prefix . "tribe WHERE tribe_id='" . $tribe_id . "'";
     if ($tribe_id == "") {
         $sql_tribe = generate_SQL(0, 10, array(), array(), null, "week", true);
         // popular
     }
     $rs = $core->con->select($sql_tribe);
     if ($rs->count() > 0) {
         $tribe_icon = getTribeIcon($rs->f('tribe_id'), $rs->f('tribe_name'), $rs->f('tribe_icon'));
         $tribe = array("title" => $rs->f('tribe_name'), "id" => $rs->f('tribe_id'), "icon" => $tribe_icon, "page" => $page);
         $core->tpl->setVar('tribe', $tribe);
         $sql_posts = generate_tribe_SQL($tribe_id, $num_start);
         $rs_posts = $core->con->select($sql_posts);
         $tpl = showTribe($core->tpl, $rs_posts);
     }
     print $tpl->render('portal.block');
     break;
     ##########################################################
     # DEFAULT RETURN
Esempio n. 5
0
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*
***** END LICENSE BLOCK *****/
if (isset($_POST['action'])) {
    switch (trim($_POST['action'])) {
        case 'page':
            $page = $_POST['page'];
            print render_page($page);
            break;
        case 'post':
            $post_id = $_POST['post_id'];
            $search_value = trim($POST['search_value']);
            $sql = generate_SQL(0, 10, array(), array(), '', null, false, $post_id, 1);
            $rs = $core->con->select($sql);
            $tpl = showSinglePost($rs, $core->tpl, $search_value, true, true);
            print $tpl->render('post.block');
            break;
            ##########################################################
            # DEFAULT RETURN
            ##########################################################
        ##########################################################
        # DEFAULT RETURN
        ##########################################################
        default:
            print '<div class="flash_error">' . T_('User bad call') . '</div>';
            break;
    }
} else {
Esempio n. 6
0
function generate_tribe_SQL($tribe_id, $num_start = 0, $nb_items = 10, $popular = false, $search = '')
{
    global $core;
    $sql_tribes = "SELECT\n\t\t\ttribe_id,\n\t\t\tuser_id,\n\t\t\ttribe_name,\n\t\t\ttribe_search,\n\t\t\ttribe_tags,\n\t\t\ttribe_notags,\n\t\t\ttribe_users,\n\t\t\ttribe_nousers\n\t\tFROM " . $core->prefix . "tribe\n\t\tWHERE tribe_id = '" . $tribe_id . "'\n\t\tAND visibility = 1";
    #	print $sql_tribes;
    #	exit;
    $rs = $core->con->select($sql_tribes);
    if ($rs->f('user_id') != "root") {
        if (!$core->hasPermission('administration')) {
            if (!$core->auth->sessionExists() || $core->auth->userID() != $rs->f('user_id')) {
                return "";
            }
        }
    }
    $tribe_name = $rs->f('tribe_name');
    $tribe_search = $rs->f('tribe_search');
    //getArrayFromList($rs->tribe_search);
    if ($search != '') {
        $tribe_search = $search;
    }
    $tribe_tags = getArrayFromList($rs->f('tribe_tags'));
    $tribe_notags = getArrayFromList($rs->f('tribe_notags'));
    $tribe_users = getArrayFromList($rs->f('tribe_users'));
    $tribe_nousers = getArrayFromList($rs->f('tribe_nousers'));
    $align = $align == 'right' ? 'left' : 'right';
    $count = true;
    if ($nb_items > 0) {
        $count = false;
        // we just need to count the number of posts
    }
    // Generating the SQL request
    return generate_SQL($num_start, $nb_items, $tribe_users, $tribe_tags, $tribe_search, null, $popular, null, 1, $count, $tribe_notags, $tribe_nousers);
}
Esempio n. 7
0
$rs = $core->con->select($sql_tribes);
$align = 'right';
while ($rs->fetch()) {
    $align = $align == 'right' ? 'left' : 'right';
    $tribe_icon = getTribeIcon($rs->tribe_id, $rs->tribe_name, $rs->tribe_icon);
    $tribe = array("title" => $rs->tribe_name, "id" => $rs->tribe_id, "icon" => $tribe_icon, "align" => $align, "page" => 0);
    $core->tpl->setVar('tribe', $tribe);
    // Generating the SQL request
    $sql_posts = generate_tribe_SQL($rs->tribe_id);
    $rs_posts = $core->con->select($sql_posts);
    if ($rs_posts->count() > 0) {
        $core->tpl = showTribe($core->tpl, $rs_posts);
        $core->tpl->render('portal.block');
    }
    // For each tribe I'll have to generate a list of 10 posts with their title and permalink
}
$align = $align == 'right' ? 'left' : 'right';
$tribe = array("title" => T_('Popular posts'), "id" => 'popular', "icon" => '', "align" => $align);
$core->tpl->setVar('tribe', $tribe);
$popular_sql = generate_SQL(0, 10, array(), array(), null, "week", true);
// popular
$rs_posts = $core->con->select($popular_sql);
if ($rs_posts->count() > 0) {
    $core->tpl = showTribe($core->tpl, $rs_posts, true);
    $core->tpl->render('portal.block');
}
$core->tpl->render("content.portal");
# Show result
$analytics_code = getAnalyticsCode();
$core->tpl->setVar('analytics_html', $analytics_code);
$core->renderTemplate();