function getOutput($sql, $num_page = 0, $nb_items = 30)
{
    global $blog_settings, $core;
    $next_page = $num_page + 1;
    $prev_page = $num_page - 1;
    $rs = $core->con->select($sql);
    $output = showPagination($rs->count(), $num_page, $nb_items, 'updateTribeList');
    $output .= '
<br />
<div id="tribelist" class="tribe-list">';
    if ($rs->count() > 0) {
        while ($rs->fetch()) {
            $sql_post = generate_tribe_SQL($rs->tribe_id, 0, 0);
            //			print $sql_post;
            $rs_post = $core->con->select($sql_post);
            $tribe_state = "private";
            $tribe_state_img = "lock_locked";
            if ($rs->visibility == 1) {
                $tribe_state = "public";
                $tribe_state_img = "lock_unlock";
            }
            $tribe_owner = T_('Admin');
            if ($rs->user_id != "root") {
                $tribe_owner = $rs->user_id;
            }
            $tribe_name = html_entity_decode($rs->tribe_name, ENT_QUOTES, 'UTF-8');
            $tribe_tags = preg_split('/,/', $rs->tribe_tags, -1, PREG_SPLIT_NO_EMPTY);
            $tag_list = "";
            foreach ($tribe_tags as $tag_item) {
                $tag_list .= '<span class="tag">' . $tag_item . ' <a href="javascript:rm_tag(' . $num_page . ',' . $nb_items . ',\'' . $rs->tribe_id . '\',\'' . $tag_item . '\')">x</a>';
                $tag_list .= '</a></span>';
            }
            $tribe_notags = preg_split('/,/', $rs->tribe_notags, -1, PREG_SPLIT_NO_EMPTY);
            $notag_list = "";
            foreach ($tribe_notags as $tag_item) {
                $notag_list .= '<span class="tag">' . $tag_item . ' <a href="javascript:rm_notag(' . $num_page . ',' . $nb_items . ',\'' . $rs->tribe_id . '\',\'' . $tag_item . '\')">x</a>';
                $notag_list .= '</a></span>';
            }
            $tribe_users = preg_split('/,/', $rs->tribe_users, -1, PREG_SPLIT_NO_EMPTY);
            $user_list = "";
            foreach ($tribe_users as $user_item) {
                $user_list .= '<span class="user">' . $user_item . ' <a href="javascript:rm_user(' . $num_page . ',' . $nb_items . ',\'' . $rs->tribe_id . '\',\'' . $user_item . '\')">x</a>';
                $user_list .= '</a></span>';
            }
            $rm_search_action = '(' . T_('empty') . ')';
            if ($rs->tribe_search) {
                $rm_search_action = '(<a href="javascript:rm_search(' . $num_page . ', ' . $nb_items . ',\'' . $rs->tribe_id . '\')">' . T_('clear') . '</a>)';
            }
            $tribe_icon = '';
            $icon_action = '<a href="javascript:add_icon(' . $num_page . ',' . $nb_items . ',\'' . $rs->tribe_id . '\',\'' . addslashes($tribe_name) . '\')">
				<img src="meta/icons/add_icon.png" title="' . T_('Add icon to tribe') . '" /></a>';
            if ($rs->tribe_icon) {
                $tribe_icon = '<p class="tribe-icon"><img class="tribe-icon" src="../' . $rs->tribe_icon . '" /></p>';
                $icon_action = '<a href="javascript:rm_icon(' . $num_page . ',' . $nb_items . ',\'' . $rs->tribe_id . '\')">
				<img src="meta/icons/rm_icon.png" title="' . T_('Remove icon from tribe') . '" /></a>';
            }
            $output .= '<div class="tribesbox tribe-' . $tribe_state . '" id="tribe-' . $rs->tribe_id . '">
				<h3><a href="' . BP_PLANET_URL . '/index.php?list=1&tribe_id=' . $rs->tribe_id . '">' . $tribe_name . '</a></h3>
				' . $tribe_icon . '
				<p class="nickname">
					Tribe owner : ' . $tribe_owner . '<br/>
					Tags : <div class="tag-line">' . $tag_list . '</div><br/>
					No-tags : <div class="notag-line">' . $notag_list . '</div><br/>
					Users : <div class="user-line">' . $user_list . '</div><br/>
					search : ' . $rs->tribe_search . ' ' . $rm_search_action . '<br/>
					Last post : ' . mysqldatetime_to_date("d/m/Y", $rs_post->last) . '<br/>
					Post count : ' . $rs_post->count . '<br/>
					Ordering : ' . $rs->ordering . '
				</p>
				<ul class="actions">
					<li><a href="javascript:toggleTribeVisibility(\'' . $rs->tribe_id . '\',' . $num_page . ',' . $nb_items . ')"><img src="meta/icons/' . $tribe_state_img . '.png" title="' . T_('Toggle tribe visibility') . '"/></a></li>
					<li><a href="javascript:edit(\'' . $rs->tribe_id . '\', ' . $num_page . ', ' . $nb_items . ')"><img src="meta/icons/action-edit.png" title="' . T_('Edit tribe') . '" /></a></li>
					<li><a href="javascript:removeTribe(\'' . $rs->tribe_id . '\',' . $num_page . ',' . $nb_items . ')"><img src="meta/icons/cross.png" title="' . T_('Remove tribe') . '" /></a></li>
					<li><a href="javascript:add_tags(' . $num_page . ',' . $nb_items . ',\'' . $rs->tribe_id . '\',\'' . addslashes($tribe_name) . '\')"><img src="meta/icons/add_tag.png" title="' . T_('Add tags to tribe') . '"/></a></li>
					<li><a href="javascript:add_notags(' . $num_page . ',' . $nb_items . ',\'' . $rs->tribe_id . '\',\'' . addslashes($tribe_name) . '\')"><img src="meta/icons/add_notag.png" title="' . T_('Add unwanted tags to tribe') . '"/></a></li>
					<li><a href="javascript:add_users(' . $num_page . ',' . $nb_items . ',\'' . $rs->tribe_id . '\',\'' . addslashes($tribe_name) . '\')"><img src="meta/icons/add_user.png" title="' . T_('Add users to tribe') . '" /></a></li>
					<li><a href="javascript:add_search(' . $num_page . ',' . $nb_items . ',\'' . $rs->tribe_id . '\',\'' . addslashes($tribe_name) . '\')"><img src="meta/icons/add_search.png" title="' . T_('Add search to tribe') . '" /></a></li>
					<li>' . $icon_action . '</li>
				</ul>
				<div class="feedlink"><a href="' . BP_PLANET_URL . '/index.php?list=1&tribe_id=' . $rs->tribe_id . '">
						<img alt="RSS" src="' . BP_PLANET_URL . '/themes/' . $blog_settings->get('planet_theme') . '/images/rss_24.png" /></a></div>
				</div>';
        }
    } else {
        $output .= '<div class="tribebox">
				' . T_('No tribes found') . '
			</div>';
    }
    $output .= '</div>';
    $output .= showPagination($rs->count(), $num_page, $nb_items, 'updateFeedList');
    return $output;
}
Пример #2
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();
}
Пример #3
0
         $tribe_id = $_GET['tribe_id'];
     }
 }
 # On active le cache
 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("&", "&amp;", $params);
 }
 # Execute SQL request
 $post_list = $core->con->select($sql);
Пример #4
0
     ##########################################################
     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
         ##########################################################
     ##########################################################
     # DEFAULT RETURN
     ##########################################################
     default:
         print '<div class="flash_error">' . T_('User bad call') . '</div>';
         break;
 }
Пример #5
0
$scripts[] = "javascript/main.js";
$current_page = "tags";
include dirname(__FILE__) . '/tpl.php';
#
header('Content-type: text/html; charset=utf-8');
# Valeurs par defaut
$params = array('title' => $blog_settings->get('planet_title') . " - " . T_('Users'));
$core->tpl->setVar('params', $params);
$user_id = '';
if ($core->auth->sessionExists()) {
    $user_id = $core->auth->userID();
}
$sql_tribes = "SELECT\n\t\tuser_id,\n\t\ttribe_name,\n\t\ttribe_tags,\n\t\ttribe_users,\n\t\ttribe_search,\n\t\ttribe_icon,\n\t\ttribe_id\n\tFROM " . $core->prefix . "tribe\n\tWHERE (user_id = 'root' OR user_id = '" . $user_id . "')\n\t\tAND visibility = 1\n\tORDER BY ordering\n\t\t";
$rs = $core->con->select($sql_tribes);
while ($rs->fetch()) {
    $sql_post = generate_tribe_SQL($rs->tribe_id, 0, 0);
    $rs_post = $core->con->select($sql_post);
    $tribe_icon = getTribeIcon($rs->tribe_id, $rs->tribe_name, $rs->tribe_icon);
    $tribe = array("id" => $rs->tribe_id, "user_id" => $rs->user_id, "name" => $rs->tribe_name, "tags" => implode(', ', getArrayFromList($rs->tribe_tags)), "users" => implode(', ', getArrayFromList($rs->tribe_users)), "search" => $rs->tribe_search, "icon" => $tribe_icon, "last" => mysqldatetime_to_date("d/m/Y", $rs_post->last), "nb_post" => $rs_post->count);
    $core->tpl->setVar('tribe', $tribe);
    $core->tpl->render("tribe.block");
}
$sql_tags = "SELECT\n\t\t" . $core->prefix . "post_tag.tag_id,\n\t\tCOUNT(" . $core->prefix . "post_tag.tag_id) as weigth\n\tFROM " . $core->prefix . "post_tag\n\tGROUP BY " . $core->prefix . "post_tag.tag_id\n\tORDER BY weigth DESC\n\tLIMIT 100";
$rs = $core->con->select($sql_tags);
$max = $rs->f('weight');
while ($rs->fetch()) {
    if ($rs->weigth > $max) {
        $max = $rs->weigth;
    }
    $weigth = intval($rs->weigth * 10 / $max);
    $tag = array("id" => $rs->tag_id, "weigth" => $weigth);
Пример #6
0
$core->tpl->setVar('params', $params);
if ($core->auth->sessionExists()) {
    $user_condition = "OR user_id = '" . $core->auth->userID() . "'";
}
$sql_tribes = "SELECT\n\t\ttribe_id,\n\t\tuser_id,\n\t\ttribe_icon,\n\t\ttribe_name\n\tFROM " . $core->prefix . "tribe\n\tWHERE visibility = 1\n\tAND (user_id = 'root' " . $user_condition . ")\n\tORDER BY ordering DESC";
//print $sql_tribes;
//exit;
$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);