Exemple #1
0
/**
 * Prepare the MainList object for displaying skins.
 *
 * @param integer max # of posts on the page
 */
function init_MainList($items_nb_limit)
{
    global $MainList;
    global $Blog;
    global $timestamp_min, $timestamp_max;
    global $preview;
    global $disp;
    global $postIDlist, $postIDarray;
    $MainList = new ItemList2($Blog, $timestamp_min, $timestamp_max, $items_nb_limit);
    // COPY (FUNC)
    if (!$preview) {
        if ($disp == 'page') {
            // Get  pages:
            $MainList->set_default_filters(array('types' => '1000'));
        }
        // else: we are either in single or in page mode
        // pre_dump( $MainList->default_filters );
        $MainList->load_from_Request(false);
        // pre_dump( $MainList->filters );
        // echo '<br/>'.( $MainList->is_filtered() ? 'filtered' : 'NOT filtered' );
        // $MainList->dump_active_filters();
        // Run the query:
        $MainList->query();
        // Old style globals for category.funcs:
        $postIDlist = $MainList->get_page_ID_list();
        $postIDarray = $MainList->get_page_ID_array();
    } else {
        // We want to preview a single post, we are going to fake a lot of things...
        $MainList->preview_from_request();
        // Legacy for the category display
        $cat_array = array();
    }
    param('more', 'integer', 0, true);
    param('page', 'integer', 1, true);
    // Post page to show
    param('c', 'integer', 0, true);
    // Display comments?
    param('tb', 'integer', 0, true);
    // Display trackbacks?
    param('pb', 'integer', 0, true);
    // Display pingbacks?
}
Exemple #2
0
/**
 * blogger.getRecentPosts retieves X most recent posts.
 *
 * This API call is not documented on
 * {@link http://www.blogger.com/developers/api/1_docs/}
 * @see http://www.sixapart.com/developers/xmlrpc/blogger_api/bloggergetrecentposts.html
 *
 * @param xmlrpcmsg XML-RPC Message
 *					0 appkey (string): Unique identifier/passcode of the application sending the post.
 *						(See access info {@link http://www.blogger.com/developers/api/1_docs/#access} .)
 *					1 blogid (string): Unique identifier of the blog the post will be added to.
 *						Currently ignored in b2evo, in favor of the category.
 *					2 username (string): Login for a Blogger user who has permission to edit the given
 *						post (either the user who originally created it or an admin of the blog).
 *					3 password (string): Password for said username.
 *					4 numposts (integer): number of posts to retrieve.
 * @return xmlrpcresp XML-RPC Response
 */
function blogger_getrecentposts($m)
{
    global $xmlrpcerruser, $DB;
    // CHECK LOGIN:
    /**
     * @var User
     */
    if (!($current_User =& xmlrpcs_login($m, 2, 3))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    // GET BLOG:
    /**
     * @var Blog
     */
    if (!($Blog =& xmlrpcs_get_Blog($m, 1))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    $numposts = $m->getParam(4);
    $numposts = $numposts->scalarval();
    // Get the posts to display:
    load_class('items/model/_itemlist.class.php', 'ItemList');
    $MainList = new ItemList2($Blog, NULL, NULL, $numposts);
    // Protected and private get checked by statuses_where_clause().
    $statuses = array('published', 'redirected', 'protected', 'private');
    if ($current_User->check_perm('blog_ismember', 'view', false, $Blog->ID)) {
        // These statuses require member status:
        $statuses = array_merge($statuses, array('draft', 'deprecated'));
    }
    logIO('Statuses: ' . implode(', ', $statuses));
    $MainList->set_filters(array('visibility_array' => $statuses, 'order' => 'DESC', 'unit' => 'posts'));
    // Run the query:
    $MainList->query();
    logIO('Items:' . $MainList->result_num_rows);
    $data = array();
    while ($Item =& $MainList->get_item()) {
        logIO('Item:' . $Item->title . ' - Issued: ' . $Item->issue_date . ' - Modified: ' . $Item->datemodified);
        $post_date = mysql2date('U', $Item->issue_date);
        $post_date = gmdate('Ymd', $post_date) . 'T' . gmdate('H:i:s', $post_date);
        $content = '<title>' . $Item->title . '</title>';
        $content .= '<category>' . $Item->main_cat_ID . '</category>';
        $content .= $Item->content;
        // Load Item's creator User:
        $Item->get_creator_User();
        $authorname = $Item->creator_User->get('preferredname');
        $data[] = new xmlrpcval(array('authorName' => new xmlrpcval($authorname), 'userid' => new xmlrpcval($Item->creator_user_ID), 'dateCreated' => new xmlrpcval($post_date, 'dateTime.iso8601'), 'content' => new xmlrpcval($content), 'postid' => new xmlrpcval($Item->ID)), 'struct');
    }
    $resp = new xmlrpcval($data, 'array');
    logIO('OK.');
    return new xmlrpcresp($resp);
}
 * For example: /blogs/index.php?disp=posts
 *
 * b2evolution - {@link http://b2evolution.net/}
 * Released under GNU GPL License - {@link http://b2evolution.net/about/gnu-gpl-license}
 * @copyright (c)2003-2015 by Francois Planque - {@link http://fplanque.com/}
 *
 * @package evoskins
 */
if (!defined('EVO_MAIN_INIT')) {
    die('Please, do not access this page directly.');
}
global $number_of_posts_in_cat, $cat;
if ($cat > 0) {
    // Init MainList
    $page = param('paged', 'integer', 1);
    $MainList = new ItemList2($Blog, $Blog->get_timestamp_min(), $Blog->get_timestamp_max(), $Blog->get_setting('posts_per_page'));
    $MainList->load_from_Request();
    $MainList->set_filters(array('cat_array' => array($cat), 'cat_modifier' => NULL, 'page' => $page));
    $MainList->query();
    $MainList->nav_target = $cat;
    // set navigation target, we are always navigating through category in this skin
    // Load read statuses if required
    $MainList->load_content_read_statuses();
    // Breadcrumbs
    $Skin->display_breadcrumbs($cat);
    ?>
<div class="post_panel">
<?php 
    // Buttons to post/reply
    $Skin->display_post_button($cat);
    // Page title
Exemple #4
0
/**
 * Template tag. Initializes internal states for the most common skin displays.
 *
 * For more specific skins, this function should not be called and
 * equivalent code should be customized within the skin.
 *
 * @param string What are we going to display. Most of the time the global $disp should be passed.
 */
function skin_init($disp)
{
    /**
     * @var Blog
     */
    global $Blog;
    /**
     * @var Item
     */
    global $Item;
    /**
     * @var Skin
     */
    global $Skin;
    global $robots_index;
    global $seo_page_type;
    global $redir, $ReqURL, $ReqURI, $m, $w, $preview;
    global $Chapter;
    global $Debuglog;
    /**
     * @var ItemList2
     */
    global $MainList;
    /**
     * This will give more detail when $disp == 'posts'; otherwise it will have the same content as $disp
     * @var string
     */
    global $disp_detail, $Settings;
    global $Timer;
    global $Messages, $PageCache;
    $Timer->resume('skin_init');
    if (empty($disp_detail)) {
        $disp_detail = $disp;
    }
    $Debuglog->add('skin_init: ' . $disp, 'skins');
    // This is the main template; it may be used to display very different things.
    // Do inits depending on current $disp:
    switch ($disp) {
        case 'posts':
        case 'single':
        case 'page':
        case 'feedback-popup':
        case 'search':
            // We need to load posts for this display:
            // Note: even if we request the same post as $Item above, the following will do more restrictions (dates, etc.)
            // Init the MainList object:
            init_MainList($Blog->get_setting('posts_per_page'));
            // Init post navigation
            $post_navigation = $Skin->get_post_navigation();
            if (empty($post_navigation)) {
                $post_navigation = $Blog->get_setting('post_navigation');
            }
            break;
    }
    // SEO stuff & redirects if necessary:
    $seo_page_type = NULL;
    switch ($disp) {
        // CONTENT PAGES:
        case 'single':
        case 'page':
            init_ajax_forms();
            // auto requires jQuery
            init_ratings_js();
            init_voting_comment_js();
            init_scrollwide_js();
            // Add jQuery Wide Scroll plugin
            if ($disp == 'single') {
                $seo_page_type = 'Single post page';
            } else {
                $seo_page_type = '"Page" page';
            }
            // Check if the post has 'redirected' status:
            if (!$preview && $Item->status == 'redirected' && $redir == 'yes') {
                // $redir=no here allows to force a 'single post' URL for commenting
                // Redirect to the URL specified in the post:
                $Debuglog->add('Redirecting to post URL [' . $Item->url . '].');
                header_redirect($Item->url, true);
            }
            // Check if we want to redirect to a canonical URL for the post
            // Please document encountered problems.
            if (!$preview && ($Blog->get_setting('canonical_item_urls') && $redir == 'yes' || $Blog->get_setting('relcanonical_item_urls'))) {
                // We want to redirect to the Item's canonical URL:
                $canonical_url = $Item->get_permanent_url('', '', '&');
                if (preg_match('|[&?](page=\\d+)|', $ReqURI, $page_param)) {
                    // A certain post page has been requested, keep only this param and discard all others:
                    $canonical_url = url_add_param($canonical_url, $page_param[1], '&');
                }
                if (preg_match('|[&?](mode=quote&[qcp]+=\\d+)|', $ReqURI, $page_param)) {
                    // A quote of comment/post, keep only these params and discard all others:
                    $canonical_url = url_add_param($canonical_url, $page_param[1], '&');
                }
                if (!is_same_url($ReqURL, $canonical_url)) {
                    // The requested URL does not look like the canonical URL for this post...
                    // url difference was resolved
                    $url_resolved = false;
                    // Check if the difference is because of an allowed post navigation param
                    if (preg_match('|[&?]cat=(\\d+)|', $ReqURI, $cat_param)) {
                        // A category post navigation param is set
                        $extended_url = '';
                        if ($post_navigation == 'same_category' && isset($cat_param[1])) {
                            // navigatie through posts from the same category
                            $category_ids = postcats_get_byID($Item->ID);
                            if (in_array($cat_param[1], $category_ids)) {
                                // cat param is one of this Item categories
                                $extended_url = $Item->add_navigation_param($canonical_url, $post_navigation, $cat_param[1], '&');
                                // Set MainList navigation target to the requested category
                                $MainList->nav_target = $cat_param[1];
                            }
                        }
                        $url_resolved = is_same_url($ReqURL, $extended_url);
                    }
                    if (!$url_resolved && $Blog->get_setting('canonical_item_urls') && $redir == 'yes' && !$Item->check_cross_post_nav('auto', $Blog->ID)) {
                        // REDIRECT TO THE CANONICAL URL:
                        $Debuglog->add('Redirecting to canonical URL [' . $canonical_url . '].');
                        header_redirect($canonical_url, true);
                    } else {
                        // Use rel="canoncial":
                        add_headline('<link rel="canonical" href="' . $canonical_url . '" />');
                    }
                    // EXITED.
                }
            }
            if (!$MainList->result_num_rows) {
                // There is nothing to display for this page, don't index it!
                $robots_index = false;
            }
            break;
        case 'posts':
            init_ajax_forms('blog');
            // auto requires jQuery
            init_scrollwide_js('blog');
            // Add jQuery Wide Scroll plugin
            // fp> if we add this here, we have to exetnd the inner if()
            // init_ratings_js( 'blog' );
            // Get list of active filters:
            $active_filters = $MainList->get_active_filters();
            if (!empty($active_filters)) {
                // The current page is being filtered...
                if (array_diff($active_filters, array('page')) == array()) {
                    // This is just a follow "paged" page
                    $disp_detail = 'posts-next';
                    $seo_page_type = 'Next page';
                    if ($Blog->get_setting('paged_noindex')) {
                        // We prefer robots not to index category pages:
                        $robots_index = false;
                    }
                } elseif (array_diff($active_filters, array('cat_array', 'cat_modifier', 'cat_focus', 'posts', 'page')) == array()) {
                    // This is a category page
                    $disp_detail = 'posts-cat';
                    $seo_page_type = 'Category page';
                    if ($Blog->get_setting('chapter_noindex')) {
                        // We prefer robots not to index category pages:
                        $robots_index = false;
                    }
                    global $cat, $catsel;
                    if (empty($catsel) && preg_match('~[0-9]+~', $cat)) {
                        // We are on a single cat page:
                        // NOTE: we must have selected EXACTLY ONE CATEGORY through the cat parameter
                        // BUT: - this can resolve to including children
                        //      - selecting exactly one cat through catsel[] is NOT OK since not equivalent (will exclude children)
                        // echo 'SINGLE CAT PAGE';
                        if ($Blog->get_setting('canonical_cat_urls') && $redir == 'yes' || $Blog->get_setting('relcanonical_cat_urls')) {
                            // Check if the URL was canonical:
                            if (!isset($Chapter)) {
                                $ChapterCache =& get_ChapterCache();
                                /**
                                 * @var Chapter
                                 */
                                $Chapter =& $ChapterCache->get_by_ID($MainList->filters['cat_array'][0], false);
                            }
                            if ($Chapter) {
                                if ($Chapter->parent_ID) {
                                    // This is a sub-category page (i-e: not a level 1 category)
                                    $disp_detail = 'posts-subcat';
                                }
                                $canonical_url = $Chapter->get_permanent_url(NULL, NULL, $MainList->get_active_filter('page'), NULL, '&');
                                if (!is_same_url($ReqURL, $canonical_url)) {
                                    // fp> TODO: we're going to lose the additional params, it would be better to keep them...
                                    // fp> what additional params actually?
                                    if ($Blog->get_setting('canonical_cat_urls') && $redir == 'yes') {
                                        // REDIRECT TO THE CANONICAL URL:
                                        header_redirect($canonical_url, true);
                                    } else {
                                        // Use rel="canonical":
                                        add_headline('<link rel="canonical" href="' . $canonical_url . '" />');
                                    }
                                }
                            }
                        }
                        if ($post_navigation == 'same_category') {
                            // Category is set and post navigation should go through the same category, set navigation target param
                            $MainList->nav_target = $cat;
                        }
                    }
                } elseif (array_diff($active_filters, array('tags', 'posts', 'page')) == array()) {
                    // This is a tag page
                    $disp_detail = 'posts-tag';
                    $seo_page_type = 'Tag page';
                    if ($Blog->get_setting('tag_noindex')) {
                        // We prefer robots not to index tag pages:
                        $robots_index = false;
                    }
                    if ($Blog->get_setting('canonical_tag_urls') && $redir == 'yes' || $Blog->get_setting('relcanonical_tag_urls')) {
                        // Check if the URL was canonical:
                        $canonical_url = $Blog->gen_tag_url($MainList->get_active_filter('tags'), $MainList->get_active_filter('page'), '&');
                        if (!is_same_url($ReqURL, $canonical_url)) {
                            if ($Blog->get_setting('canonical_tag_urls') && $redir == 'yes') {
                                // REDIRECT TO THE CANONICAL URL:
                                header_redirect($canonical_url, true);
                            } else {
                                // Use rel="canoncial":
                                add_headline('<link rel="canonical" href="' . $canonical_url . '" />');
                            }
                        }
                    }
                } elseif (array_diff($active_filters, array('ymdhms', 'week', 'posts', 'page')) == array()) {
                    // This is an archive page
                    // echo 'archive page';
                    $disp_detail = 'posts-date';
                    $seo_page_type = 'Date archive page';
                    if ($Blog->get_setting('canonical_archive_urls') && $redir == 'yes' || $Blog->get_setting('relcanonical_archive_urls')) {
                        // Check if the URL was canonical:
                        $canonical_url = $Blog->gen_archive_url(substr($m, 0, 4), substr($m, 4, 2), substr($m, 6, 2), $w, '&', $MainList->get_active_filter('page'));
                        if (!is_same_url($ReqURL, $canonical_url)) {
                            if ($Blog->get_setting('canonical_archive_urls') && $redir == 'yes') {
                                // REDIRECT TO THE CANONICAL URL:
                                header_redirect($canonical_url, true);
                            } else {
                                // Use rel="canoncial":
                                add_headline('<link rel="canonical" href="' . $canonical_url . '" />');
                            }
                        }
                    }
                    if ($Blog->get_setting('archive_noindex')) {
                        // We prefer robots not to index archive pages:
                        $robots_index = false;
                    }
                } else {
                    // Other filtered pages:
                    // pre_dump( $active_filters );
                    $disp_detail = 'posts-filtered';
                    $seo_page_type = 'Other filtered page';
                    if ($Blog->get_setting('filtered_noindex')) {
                        // We prefer robots not to index other filtered pages:
                        $robots_index = false;
                    }
                }
            } else {
                // This is the default blog page
                $disp_detail = 'posts-default';
                $seo_page_type = 'Default page';
                if ($Blog->get_setting('canonical_homepage') && $redir == 'yes' || $Blog->get_setting('relcanonical_homepage')) {
                    // Check if the URL was canonical:
                    $canonical_url = $Blog->gen_blogurl();
                    if (!is_same_url($ReqURL, $canonical_url)) {
                        if ($Blog->get_setting('canonical_homepage') && $redir == 'yes') {
                            // REDIRECT TO THE CANONICAL URL:
                            header_redirect($canonical_url, true);
                        } else {
                            // Use rel="canoncial":
                            add_headline('<link rel="canonical" href="' . $canonical_url . '" />');
                        }
                    }
                }
                if ($Blog->get_setting('default_noindex')) {
                    // We prefer robots not to index archive pages:
                    $robots_index = false;
                }
            }
            break;
        case 'search':
            $seo_page_type = 'Search page';
            if ($Blog->get_setting('filtered_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
            // SPECIAL FEATURE PAGES:
        // SPECIAL FEATURE PAGES:
        case 'feedback-popup':
            $seo_page_type = 'Comment popup';
            if ($Blog->get_setting($disp . '_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
        case 'arcdir':
            $seo_page_type = 'Date archive directory';
            if ($Blog->get_setting($disp . '_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
        case 'catdir':
            $seo_page_type = 'Category directory';
            if ($Blog->get_setting($disp . '_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
        case 'msgform':
            init_ajax_forms('blog');
            // auto requires jQuery
            $seo_page_type = 'Contact form';
            if ($Blog->get_setting($disp . '_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
        case 'messages':
        case 'contacts':
        case 'threads':
            init_results_js('blog');
            // Add functions to work with Results tables
            // just in case some robot would be logged in:
            $seo_page_type = 'Messaging module';
            $robots_index = false;
            break;
        case 'login':
            global $Plugins, $transmit_hashed_password;
            $seo_page_type = 'Login form';
            $robots_index = false;
            require_js('functions.js', 'blog');
            $transmit_hashed_password = (bool) $Settings->get('js_passwd_hashing') && !(bool) $Plugins->trigger_event_first_true('LoginAttemptNeedsRawPassword');
            if ($transmit_hashed_password) {
                // Include JS for client-side password hashing:
                require_js('sha1_md5.js', 'blog');
            }
            break;
        case 'register':
            if (is_logged_in()) {
                // If user is logged in the register form should not be displayed. In this case redirect to the blog home page.
                $Messages->add(T_('You are already logged in.'), 'note');
                header_redirect($Blog->gen_blogurl(), false);
            }
            $seo_page_type = 'Register form';
            $robots_index = false;
            break;
        case 'lostpassword':
            if (is_logged_in()) {
                // If user is logged in the lost password form should not be displayed. In this case redirect to the blog home page.
                $Messages->add(T_('You are already logged in.'), 'note');
                header_redirect($Blog->gen_blogurl(), false);
            }
            $seo_page_type = 'Lost password form';
            $robots_index = false;
            break;
        case 'profile':
            global $rsc_url;
            require_css($rsc_url . 'css/jquery/smoothness/jquery-ui.css');
            init_userfields_js('blog');
        case 'avatar':
        case 'pwdchange':
        case 'userprefs':
        case 'subs':
            $seo_page_type = 'Special feature page';
            if ($Blog->get_setting('special_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
        case 'users':
            $seo_page_type = 'Users list';
            $robots_index = false;
            global $rsc_url;
            require_css($rsc_url . 'css/jquery/smoothness/jquery-ui.css');
            init_results_js('blog');
            // Add functions to work with Results tables
            break;
        case 'user':
            $seo_page_type = 'User display';
            if (is_logged_in()) {
                // Used for combo_box contacts groups
                require_js('form_extensions.js', 'blog');
            }
            break;
        case 'edit':
            init_datepicker_js('blog');
            require_js('admin.js', 'blog');
            init_inskin_editing('blog');
            init_plugins_js('blog');
            break;
        case 'edit_comment':
            init_plugins_js('blog');
            break;
        case 'useritems':
        case 'usercomments':
            global $inc_path, $display_params, $viewed_User;
            // get user_ID because we want it in redirect_to in case we need to ask for login.
            $user_ID = param('user_ID', 'integer', true, true);
            if (empty($user_ID)) {
                bad_request_die(sprintf(T_('Parameter &laquo;%s&raquo; is required!'), 'user_ID'));
            }
            // set where to redirect in case of error
            $error_redirect_to = empty($Blog) ? $baseurl : $Blog->gen_blogurl();
            if (!is_logged_in()) {
                // Redirect to the login page if not logged in and allow anonymous user setting is OFF
                $Messages->add(T_('You must log in to view this user profile.'));
                header_redirect(get_login_url('cannot see user'), 302);
                // will have exited
            }
            if (is_logged_in() && !check_user_status('can_view_user', $user_ID)) {
                // user is logged in, but his/her status doesn't permit to view user profile
                if (check_user_status('can_be_validated')) {
                    // user is logged in but his/her account is not active yet
                    // Redirect to the account activation page
                    $Messages->add(T_('You must activate your account before you can view this user profile. <b>See below:</b>'));
                    header_redirect(get_activate_info_url(), 302);
                    // will have exited
                }
                $Messages->add(T_('Your account status currently does not permit to view this user profile.'));
                header_redirect($error_redirect_to, 302);
                // will have exited
            }
            if (!empty($user_ID)) {
                $UserCache =& get_UserCache();
                $viewed_User = $UserCache->get_by_ID($user_ID, false);
                if (empty($viewed_User)) {
                    $Messages->add(T_('The requested user does not exist!'));
                    header_redirect($error_redirect_to);
                    // will have exited
                }
                if ($viewed_User->check_status('is_closed')) {
                    $Messages->add(T_('The requested user account is closed!'));
                    header_redirect($error_redirect_to);
                    // will have exited
                }
            }
            // Require results.css to display thread query results in a table
            require_css('results.css');
            // Results/tables styles
            // Require functions.js to show/hide a panel with filters
            require_js('functions.js', 'blog');
            // Include this file to expand/collapse the filters panel when JavaScript is disabled
            require_once $inc_path . '_filters.inc.php';
            $display_params = !empty($Skin) ? $Skin->get_template('Results') : NULL;
            if ($disp == 'useritems') {
                // Init items list
                global $user_ItemList;
                $param_prefix = 'useritems_';
                $page = param($param_prefix . 'paged', 'integer', 1);
                $orderby = param($param_prefix . 'orderby', 'string', $Blog->get_setting('orderby'));
                $order = param($param_prefix . 'order', 'string', $Blog->get_setting('orderdir'));
                $useritems_Blog = NULL;
                $user_ItemList = new ItemList2($useritems_Blog, NULL, NULL, NULL, 'ItemCache', $param_prefix);
                $user_ItemList->load_from_Request();
                $user_ItemList->set_filters(array('page' => $page, 'authors' => $user_ID, 'orderby' => str_replace($param_prefix, '', $orderby), 'order' => str_replace($param_prefix, '', $order)));
                $user_ItemList->query();
            } else {
                // Init comments list
                global $user_CommentList;
                $param_prefix = 'usercmts_';
                $page = param($param_prefix . 'paged', 'integer', 1);
                $orderby = param($param_prefix . 'orderby', 'string', 'date');
                $order = param($param_prefix . 'order', 'string', $Blog->get_setting('orderdir'));
                $user_CommentList = new CommentList2(NULL, NULL, 'CommentCache', $param_prefix);
                $user_CommentList->load_from_Request();
                $user_CommentList->set_filters(array('page' => $page, 'author_IDs' => $user_ID, 'orderby' => str_replace($param_prefix, '', $orderby), 'order' => str_replace($param_prefix, '', $order)));
                $user_CommentList->query();
            }
            break;
        case 'comments':
            if (!$Blog->get_setting('comments_latest')) {
                // If latest comments page is disabled - Display 404 page with error message
                $Messages->add(T_('This feature is disabled.'), 'error');
                global $disp;
                $disp = '404';
            } else {
                break;
            }
        case '404':
            // We have a 404 unresolved content error
            // How do we want do deal with it?
            skin_404_header();
            // This MAY or MAY not have exited -- will exit on 30x redirect, otherwise will return here.
            // Just in case some dumb robot needs extra directives on this:
            $robots_index = false;
            break;
    }
    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
        // Detect IE browser version
        preg_match('/msie (\\d+)/i', $_SERVER['HTTP_USER_AGENT'], $browser_ie);
        if (count($browser_ie) == 2 && $browser_ie[1] < 7) {
            // IE < 7
            require_css('ie6.css', 'relative');
            $Messages->add(T_('Your web browser is too old. For this site to work correctly, we recommend you use a more recent browser.'), 'note');
        }
    }
    // dummy var for backward compatibility with versions < 2.4.1 -- prevents "Undefined variable"
    global $global_Cache, $credit_links;
    $credit_links = $global_Cache->get('creds');
    $Timer->pause('skin_init');
    // Check if user is logged in with a not active account, and display an error message if required
    check_allow_disp($disp);
    // initialize Blog enabled widgets, before displaying anything
    init_blog_widgets($Blog->ID);
    // Initialize displaying....
    $Timer->start('Skin:display_init');
    $Skin->display_init();
    $Timer->pause('Skin:display_init');
    // Send default headers:
    // See comments inside of this function:
    headers_content_mightcache('text/html');
    // In most situations, you do NOT want to cache dynamic content!
    // Never allow Messages to be cached!
    if ($Messages->count() && !empty($PageCache)) {
        // Abort PageCache collect
        $PageCache->abort_collect();
    }
}
Exemple #5
0
        }
    }
    ?>
</ul>
<?php 
    // -------------------- PREV/NEXT PAGE LINKS (POST LIST MODE) --------------------
    mainlist_page_links(array('block_start' => '<div class="navigation">' . T_('Page') . ': ', 'block_end' => '</div>', 'prev_text' => T_('Previous'), 'next_text' => T_('Next')));
    // ------------------------- END OF PREV/NEXT PAGE LINKS -------------------------
    // Button to create a new page
    $write_new_post_url = $Blog->get_write_item_url($cat);
    if (!empty($write_new_post_url)) {
        // Display button to write a new post
        echo '<a href="' . $write_new_post_url . '" class="roundbutton roundbutton_text_noicon" style="margin-top:15px">' . T_('Add a page here') . '</a>';
    }
    // Init MainList for posts ONLY from EXTRA categories
    $MainList = new ItemList2($Blog, $Blog->get_timestamp_min(), $Blog->get_timestamp_max(), $Blog->get_setting('posts_per_page'), 'ItemCache', 'extra_');
    $MainList->load_from_Request();
    $MainList->set_filters(array('cat_array' => array($cat), 'cat_focus' => 'extra', 'page' => param('extra_paged', 'integer', 1, true, true)));
    $MainList->query();
    $MainList->nav_target = $cat;
    // set navigation target, we are always navigating through category in this skin
    if (isset($MainList) && $MainList->result_num_rows > 0) {
        ?>
<h4 style="margin-top:20px"><?php 
        echo T_('See also');
        ?>
:</h4>
<?php 
        // -------------------- PREV/NEXT PAGE LINKS (POST LIST MODE) --------------------
        mainlist_page_links(array('block_start' => '<div class="navigation_top"><div class="navigation">' . T_('Page') . ': ', 'block_end' => '</div></div>', 'prev_text' => T_('Previous'), 'next_text' => T_('Next')));
        // ------------------------- END OF PREV/NEXT PAGE LINKS -------------------------
/**
 * Dispaly posts awaiting moderation with the given status
 *
 * @param string visibility status
 * @param object block_item_Widget
 * @return boolean true if items were displayed, false otherwise
 */
function display_posts_awaiting_moderation($status, &$block_item_Widget)
{
    global $Blog, $current_User;
    // Create empty List:
    $ItemList = new ItemList2($Blog, NULL, NULL);
    // Filter list:
    $ItemList->set_filters(array('visibility_array' => array($status), 'orderby' => 'datemodified', 'order' => 'DESC', 'posts' => 5));
    // Get ready for display (runs the query):
    $ItemList->display_init();
    if (!$ItemList->result_num_rows) {
        // We don't have posts awaiting moderation with the given status
        return false;
    }
    switch ($status) {
        case 'draft':
            $block_title = T_('Recent drafts');
            break;
        case 'review':
            $block_title = T_('Recent posts to review');
            break;
        case 'protected':
            $block_title = T_('Recent member posts awaiting moderation');
            break;
        case 'community':
            $block_title = T_('Recent community posts awaiting moderation');
            break;
        default:
            $block_title = T_('Recent posts awaiting moderation');
            break;
    }
    $block_item_Widget->title = $block_title;
    $block_item_Widget->disp_template_replaced('block_start');
    while ($Item =& $ItemList->get_item()) {
        echo '<div class="dashboard_post dashboard_post_' . ($ItemList->current_idx % 2 ? 'even' : 'odd') . '" lang="' . $Item->get('locale') . '">';
        // We don't switch locales in the backoffice, since we use the user pref anyway
        // Load item's creator user:
        $Item->get_creator_User();
        $Item->status(array('before' => '<div class="floatright"><span class="note status_' . $Item->status . '"><span>', 'after' => '</span></span></div>'));
        echo '<div class="dashboard_float_actions">';
        $Item->edit_link(array('before' => ' ', 'after' => ' ', 'class' => 'ActionButton btn'));
        $Item->publish_link('', '', '#', '#', 'PublishButton');
        echo get_icon('pixel');
        echo '</div>';
        if ($Item->status !== 'draft' || $Item->creator_user_ID == $current_User->ID) {
            // Display Item permalink icon
            echo '<span style="float: left; padding-right: 5px; margin-top: 4px">' . $Item->get_permanent_link('#icon#') . '</span>';
        }
        echo '<h3 class="dashboard_post_title">';
        $item_title = $Item->dget('title');
        if (!strlen($item_title)) {
            $item_title = '[' . format_to_output(T_('No title')) . ']';
        }
        echo '<a href="?ctrl=items&amp;blog=' . $Blog->ID . '&amp;p=' . $Item->ID . '">' . $item_title . '</a>';
        echo ' <span class="dashboard_post_details">';
        echo '</span>';
        echo '</h3>';
        echo '</div>';
    }
    $block_item_Widget->disp_template_raw('block_end');
    return true;
}
Exemple #7
0
/**
 * Initialize internal states for the most common skin displays.
 *
 * For more specific skins, this function may not be called and
 * equivalent code may be customized within the skin.
 *
 * @param string What are we going to display. Most of the time the global $disp should be passed.
 */
function skin_init($disp)
{
    /**
     * @var Blog
     */
    global $Blog;
    /**
     * @var Item
     */
    global $Item;
    /**
     * @var Skin
     */
    global $Skin;
    global $robots_index;
    global $seo_page_type;
    global $redir, $ReqURL, $ReqURI, $m, $w, $preview;
    global $Chapter;
    global $Debuglog;
    /**
     * @var ItemList2
     */
    global $MainList;
    /**
     * This will give more detail when $disp == 'posts'; otherwise it will have the same content as $disp
     * @var string
     */
    global $disp_detail, $Settings;
    global $Timer;
    global $Messages, $PageCache;
    global $Session, $current_User;
    $Timer->resume('skin_init');
    if (empty($disp_detail)) {
        $disp_detail = $disp;
    }
    $Debuglog->add('skin_init: $disp=' . $disp, 'skins');
    // This is the main template; it may be used to display very different things.
    // Do inits depending on current $disp:
    switch ($disp) {
        case 'front':
        case 'posts':
        case 'single':
        case 'page':
        case 'terms':
        case 'download':
        case 'feedback-popup':
            // We need to load posts for this display:
            if ($disp == 'terms') {
                // Initialize the redirect param to know what page redirect after accepting of terms:
                param('redirect_to', 'url', '');
            }
            // Note: even if we request the same post as $Item above, the following will do more restrictions (dates, etc.)
            // Init the MainList object:
            init_MainList($Blog->get_setting('posts_per_page'));
            // Init post navigation
            $post_navigation = $Skin->get_post_navigation();
            if (empty($post_navigation)) {
                $post_navigation = $Blog->get_setting('post_navigation');
            }
            if (!empty($MainList) && $MainList->single_post && ($single_Item =& mainlist_get_item())) {
                // If we are currently viewing a single post
                // We assume the current user will have read the entire post and all its current comments:
                $single_Item->update_read_timestamps(true, true);
                // Restart the items list:
                $MainList->restart();
            }
            break;
        case 'search':
            // Searching post, comments and categories
            load_funcs('collections/_search.funcs.php');
            // Check previous search keywords so it can be displayed in the search input box
            param('s', 'string', '', true);
            break;
    }
    // SEO stuff & redirects if necessary:
    $seo_page_type = NULL;
    switch ($disp) {
        // CONTENT PAGES:
        case 'single':
        case 'page':
        case 'terms':
            if ($disp == 'terms' && !$Item) {
                // Wrong post ID for terms page:
                global $disp;
                $disp = '404';
                $Messages->add(sprintf(T_('Terms not found. (post ID #%s)'), get_param('p')), 'error');
                break;
            }
            if (!$preview && empty($Item)) {
                // No Item, incorrect request and incorrect state of the application, a 404 redirect should have already happened
                //debug_die( 'Invalid page URL!' );
            }
            if ($disp == 'single') {
                $seo_page_type = 'Single post page';
            } else {
                $seo_page_type = '"Page" page';
            }
            if (!$preview) {
                // Check if item has a goal to insert a hit into DB
                $Item->check_goal();
            }
            // Check if the post has 'redirected' status:
            if (!$preview && $Item->status == 'redirected' && $redir == 'yes') {
                // $redir=no here allows to force a 'single post' URL for commenting
                // Redirect to the URL specified in the post:
                $Debuglog->add('Redirecting to post URL [' . $Item->url . '].');
                header_redirect($Item->url, true, true);
            }
            // Check if we want to redirect to a canonical URL for the post
            // Please document encountered problems.
            if (!$preview && ($Blog->get_setting('canonical_item_urls') && $redir == 'yes' || $Blog->get_setting('relcanonical_item_urls'))) {
                // We want to redirect to the Item's canonical URL:
                $canonical_url = $Item->get_permanent_url('', '', '&');
                if (preg_match('|[&?](page=\\d+)|', $ReqURI, $page_param)) {
                    // A certain post page has been requested, keep only this param and discard all others:
                    $canonical_url = url_add_param($canonical_url, $page_param[1], '&');
                }
                if (preg_match('|[&?](mode=quote&[qcp]+=\\d+)|', $ReqURI, $page_param)) {
                    // A quote of comment/post, keep only these params and discard all others:
                    $canonical_url = url_add_param($canonical_url, $page_param[1], '&');
                }
                if (!is_same_url($ReqURL, $canonical_url)) {
                    // The requested URL does not look like the canonical URL for this post...
                    // url difference was resolved
                    $url_resolved = false;
                    // Check if the difference is because of an allowed post navigation param
                    if (preg_match('|[&?]cat=(\\d+)|', $ReqURI, $cat_param)) {
                        // A category post navigation param is set
                        $extended_url = '';
                        if ($post_navigation == 'same_category' && isset($cat_param[1])) {
                            // navigatie through posts from the same category
                            $category_ids = postcats_get_byID($Item->ID);
                            if (in_array($cat_param[1], $category_ids)) {
                                // cat param is one of this Item categories
                                $extended_url = $Item->add_navigation_param($canonical_url, $post_navigation, $cat_param[1], '&');
                                // Set MainList navigation target to the requested category
                                $MainList->nav_target = $cat_param[1];
                            }
                        }
                        $url_resolved = is_same_url($ReqURL, $extended_url);
                    }
                    if (preg_match('|[&?]tag=([^&A-Z]+)|', $ReqURI, $tag_param)) {
                        // A tag post navigation param is set
                        $extended_url = '';
                        if ($post_navigation == 'same_tag' && isset($tag_param[1])) {
                            // navigatie through posts from the same tag
                            $tag_names = $Item->get_tags();
                            if (in_array($tag_param[1], $tag_names)) {
                                // tag param is one of this Item tags
                                $extended_url = $Item->add_navigation_param($canonical_url, $post_navigation, $tag_param[1], '&');
                                // Set MainList navigation target to the requested tag
                                $MainList->nav_target = $tag_param[1];
                            }
                        }
                        $url_resolved = is_same_url($ReqURL, $extended_url);
                    }
                    if (!$url_resolved && $Blog->get_setting('canonical_item_urls') && $redir == 'yes' && !$Item->check_cross_post_nav('auto', $Blog->ID)) {
                        // REDIRECT TO THE CANONICAL URL:
                        $Debuglog->add('Redirecting to canonical URL [' . $canonical_url . '].');
                        header_redirect($canonical_url, true);
                    } else {
                        // Use rel="canoncial":
                        add_headline('<link rel="canonical" href="' . $canonical_url . '" />');
                    }
                    // EXITED.
                }
            }
            if (!$MainList->result_num_rows) {
                // There is nothing to display for this page, don't index it!
                $robots_index = false;
            }
            break;
        case 'download':
            if (empty($Item)) {
                // No Item, incorrect request and incorrect state of the application, a 404 redirect should have already happened
                debug_die('Invalid page URL!');
            }
            $download_link_ID = param('download', 'integer', 0);
            // Check if we can allow to download the selected file
            $LinkCache =& get_LinkCache();
            if (!(($download_Link =& $LinkCache->get_by_ID($download_link_ID, false, false)) && ($LinkItem =& $download_Link->get_LinkOwner()) && ($LinkItem->Item && $LinkItem->Item->ID == $Item->ID) && ($download_File =& $download_Link->get_File()) && $download_File->exists())) {
                // Bad request, Redirect to Item permanent url
                $Messages->add(T_('The requested file is not available for download.'), 'error');
                $canonical_url = $Item->get_permanent_url('', '', '&');
                $Debuglog->add('Redirecting to canonical URL [' . $canonical_url . '].');
                header_redirect($canonical_url, true);
            }
            // Save the downloading Link to the global vars
            $GLOBALS['download_Link'] =& $download_Link;
            // Save global $Item to $download_Item, because $Item can be rewritten by function get_featured_Item() in some skins
            $GLOBALS['download_Item'] =& $Item;
            init_ajax_forms('blog');
            // auto requires jQuery
            // Initialize JavaScript to download file after X seconds
            add_js_headline('
jQuery( document ).ready( function ()
{
	jQuery( "#download_timer_js" ).show();
} );

var b2evo_download_timer = ' . intval($Blog->get_setting('download_delay')) . ';
var downloadInterval = setInterval( function()
{
	jQuery( "#download_timer" ).html( b2evo_download_timer );
	if( b2evo_download_timer == 0 )
	{ // Stop timer and download a file
		clearInterval( downloadInterval );
		jQuery( "#download_help_url" ).show();
	}
	b2evo_download_timer--;
}, 1000 );');
            // Use meta tag to download file when JavaScript is NOT enabled
            add_headline('<meta http-equiv="refresh" content="' . intval($Blog->get_setting('download_delay')) . '; url=' . $download_Link->get_download_url(array('type' => 'action')) . '" />');
            $seo_page_type = 'Download page';
            if ($Blog->get_setting($disp . '_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
        case 'posts':
            init_ajax_forms('blog');
            // auto requires jQuery
            // fp> if we add this here, we have to exetnd the inner if()
            // init_ratings_js( 'blog' );
            // Get list of active filters:
            $active_filters = $MainList->get_active_filters();
            if (!empty($active_filters)) {
                // The current page is being filtered...
                if (array_diff($active_filters, array('page')) == array()) {
                    // This is just a follow "paged" page
                    $disp_detail = 'posts-next';
                    $seo_page_type = 'Next page';
                    if ($Blog->get_setting('paged_noindex')) {
                        // We prefer robots not to index category pages:
                        $robots_index = false;
                    }
                } elseif (array_diff($active_filters, array('cat_array', 'cat_modifier', 'cat_focus', 'posts', 'page')) == array()) {
                    // This is a category page
                    $disp_detail = 'posts-cat';
                    $seo_page_type = 'Category page';
                    if ($Blog->get_setting('chapter_noindex')) {
                        // We prefer robots not to index category pages:
                        $robots_index = false;
                    }
                    global $cat, $catsel;
                    if (empty($catsel) && preg_match('~^[0-9]+$~', $cat)) {
                        // We are on a single cat page:
                        // NOTE: we must have selected EXACTLY ONE CATEGORY through the cat parameter
                        // BUT: - this can resolve to including children
                        //      - selecting exactly one cat through catsel[] is NOT OK since not equivalent (will exclude children)
                        // echo 'SINGLE CAT PAGE';
                        if ($Blog->get_setting('canonical_cat_urls') && $redir == 'yes' || $Blog->get_setting('relcanonical_cat_urls')) {
                            // Check if the URL was canonical:
                            if (!isset($Chapter)) {
                                $ChapterCache =& get_ChapterCache();
                                /**
                                 * @var Chapter
                                 */
                                $Chapter =& $ChapterCache->get_by_ID($MainList->filters['cat_array'][0], false);
                            }
                            if ($Chapter) {
                                if ($Chapter->parent_ID) {
                                    // This is a sub-category page (i-e: not a level 1 category)
                                    $disp_detail = 'posts-subcat';
                                }
                                $canonical_url = $Chapter->get_permanent_url(NULL, NULL, $MainList->get_active_filter('page'), NULL, '&');
                                if (!is_same_url($ReqURL, $canonical_url)) {
                                    // fp> TODO: we're going to lose the additional params, it would be better to keep them...
                                    // fp> what additional params actually?
                                    if ($Blog->get_setting('canonical_cat_urls') && $redir == 'yes') {
                                        // REDIRECT TO THE CANONICAL URL:
                                        header_redirect($canonical_url, true);
                                    } else {
                                        // Use rel="canonical":
                                        add_headline('<link rel="canonical" href="' . $canonical_url . '" />');
                                    }
                                }
                            } else {
                                // If the requested chapter was not found display 404 page
                                $Messages->add(T_('The requested chapter was not found'));
                                global $disp;
                                $disp = '404';
                                break;
                            }
                        }
                        if ($post_navigation == 'same_category') {
                            // Category is set and post navigation should go through the same category, set navigation target param
                            $MainList->nav_target = $cat;
                        }
                    }
                } elseif (array_diff($active_filters, array('tags', 'posts', 'page')) == array()) {
                    // This is a tag page
                    $disp_detail = 'posts-tag';
                    $seo_page_type = 'Tag page';
                    if ($Blog->get_setting('tag_noindex')) {
                        // We prefer robots not to index tag pages:
                        $robots_index = false;
                    }
                    if ($Blog->get_setting('canonical_tag_urls') && $redir == 'yes' || $Blog->get_setting('relcanonical_tag_urls')) {
                        // Check if the URL was canonical:
                        $canonical_url = $Blog->gen_tag_url($MainList->get_active_filter('tags'), $MainList->get_active_filter('page'), '&');
                        if (!is_same_url($ReqURL, $canonical_url)) {
                            if ($Blog->get_setting('canonical_tag_urls') && $redir == 'yes') {
                                // REDIRECT TO THE CANONICAL URL:
                                header_redirect($canonical_url, true);
                            } else {
                                // Use rel="canoncial":
                                add_headline('<link rel="canonical" href="' . $canonical_url . '" />');
                            }
                        }
                    }
                    $tag = $MainList->get_active_filter('tags');
                    if ($post_navigation == 'same_tag' && !empty($tag)) {
                        // Tag is set and post navigation should go through the same tag, set navigation target param
                        $MainList->nav_target = $tag;
                    }
                } elseif (array_diff($active_filters, array('ymdhms', 'week', 'posts', 'page')) == array()) {
                    // This is an archive page
                    // echo 'archive page';
                    $disp_detail = 'posts-date';
                    $seo_page_type = 'Date archive page';
                    if ($Blog->get_setting('canonical_archive_urls') && $redir == 'yes' || $Blog->get_setting('relcanonical_archive_urls')) {
                        // Check if the URL was canonical:
                        $canonical_url = $Blog->gen_archive_url(substr($m, 0, 4), substr($m, 4, 2), substr($m, 6, 2), $w, '&', $MainList->get_active_filter('page'));
                        if (!is_same_url($ReqURL, $canonical_url)) {
                            if ($Blog->get_setting('canonical_archive_urls') && $redir == 'yes') {
                                // REDIRECT TO THE CANONICAL URL:
                                header_redirect($canonical_url, true);
                            } else {
                                // Use rel="canoncial":
                                add_headline('<link rel="canonical" href="' . $canonical_url . '" />');
                            }
                        }
                    }
                    if ($Blog->get_setting('archive_noindex')) {
                        // We prefer robots not to index archive pages:
                        $robots_index = false;
                    }
                } else {
                    // Other filtered pages:
                    // pre_dump( $active_filters );
                    $disp_detail = 'posts-filtered';
                    $seo_page_type = 'Other filtered page';
                    if ($Blog->get_setting('filtered_noindex')) {
                        // We prefer robots not to index other filtered pages:
                        $robots_index = false;
                    }
                }
            } elseif ($Blog->get_setting('front_disp') == 'posts') {
                // This is the default blog page only if the 'front_disp' is set to 'posts'
                $disp_detail = 'posts-default';
                $seo_page_type = 'Default page';
                if ($Blog->get_setting('default_noindex')) {
                    // We prefer robots not to index archive pages:
                    $robots_index = false;
                }
            }
            break;
        case 'search':
            $seo_page_type = 'Search page';
            if ($Blog->get_setting('filtered_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
            // SPECIAL FEATURE PAGES:
        // SPECIAL FEATURE PAGES:
        case 'feedback-popup':
            $seo_page_type = 'Comment popup';
            if ($Blog->get_setting($disp . '_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
        case 'arcdir':
            $seo_page_type = 'Date archive directory';
            if ($Blog->get_setting($disp . '_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
        case 'catdir':
            $seo_page_type = 'Category directory';
            if ($Blog->get_setting($disp . '_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
        case 'msgform':
            global $disp;
            // get expected message form type
            $msg_type = param('msg_type', 'string', '');
            // initialize
            $recipient_User = NULL;
            $Comment = NULL;
            $allow_msgform = NULL;
            // get possible params
            $recipient_id = param('recipient_id', 'integer', 0, true);
            $comment_id = param('comment_id', 'integer', 0, true);
            $post_id = param('post_id', 'integer', 0, true);
            $subject = param('subject', 'string', '');
            // try to init recipient_User
            if (!empty($recipient_id)) {
                $UserCache =& get_UserCache();
                $recipient_User =& $UserCache->get_by_ID($recipient_id);
            } elseif (!empty($comment_id)) {
                // comment id is set, try to get comment author user
                $CommentCache =& get_CommentCache();
                $Comment = $CommentCache->get_by_ID($comment_id, false);
                if ($Comment = $CommentCache->get_by_ID($comment_id, false)) {
                    $recipient_User =& $Comment->get_author_User();
                    if (empty($recipient_User) && $Comment->allow_msgform && is_email($Comment->get_author_email())) {
                        // set allow message form to email because comment author (not registered) accepts email
                        $allow_msgform = 'email';
                        param('recipient_address', 'string', $Comment->get_author_email());
                        param('recipient_name', 'string', $Comment->get_author_name());
                    }
                }
            } else {
                // Recipient was not defined, try set the blog owner as recipient
                global $Blog;
                if (empty($Blog)) {
                    // Blog is not set, this is an invalid request
                    debug_die('Invalid send message request!');
                }
                $recipient_User = $Blog->get_owner_User();
            }
            if ($recipient_User) {
                // recipient User is set
                // get_msgform_possibility returns NULL (false), only if there is no messaging option between current_User and recipient user
                $allow_msgform = $recipient_User->get_msgform_possibility();
                if ($msg_type == 'email' && $recipient_User->get_msgform_possibility(NULL, 'email') != 'email') {
                    // User doesn't want to receive email messages, Restrict if this was requested by wrong url:
                    $msg_type = '';
                }
                if ($allow_msgform == 'login') {
                    // user must login first to be able to send a message to this User
                    $disp = 'login';
                    param('action', 'string', 'req_login');
                    // override redirect to param
                    param('redirect_to', 'url', regenerate_url(), true, true);
                    if (($msg_Blog =& get_setting_Blog('msg_blog_ID')) && $Blog->ID != $msg_Blog->ID) {
                        // Redirect to special blog for messaging actions if it is defined in general settings
                        header_redirect(url_add_param($msg_Blog->get('msgformurl', array('glue' => '&')), 'redirect_to=' . rawurlencode($redirect_to), '&'));
                    }
                    $Messages->add(T_('You must log in before you can contact this user'));
                } elseif ($allow_msgform == 'PM' && check_user_status('can_be_validated')) {
                    // user is not activated
                    if ($recipient_User->accepts_email()) {
                        // recipient User accepts email allow to send email
                        $allow_msgform = 'email';
                        $msg_type = 'email';
                        $activateinfo_link = 'href="' . get_activate_info_url(NULL, '&amp;') . '"';
                        $Messages->add(sprintf(T_('You must activate your account before you can send a private message to %s. However you can send them an email if you\'d like. <a %s>More info &raquo;</a>'), $recipient_User->get('login'), $activateinfo_link), 'warning');
                    } else {
                        // Redirect to the activate info page for not activated users
                        $Messages->add(T_('You must activate your account before you can contact a user. <b>See below:</b>'));
                        header_redirect(get_activate_info_url(), 302);
                        // will have exited
                    }
                } elseif ($msg_type == 'PM' && $allow_msgform == 'email') {
                    // only email is allowed but user expect private message form
                    if (!empty($current_User) && $recipient_id == $current_User->ID) {
                        $Messages->add(T_('You cannot send a private message to yourself. However you can send yourself an email if you\'d like.'), 'warning');
                    } else {
                        $Messages->add(sprintf(T_('You cannot send a private message to %s. However you can send them an email if you\'d like.'), $recipient_User->get('login')), 'warning');
                    }
                } elseif ($msg_type != 'email' && $allow_msgform == 'PM') {
                    // private message form should be displayed, change display to create new individual thread with the given recipient user
                    // check if creating new PM is allowed
                    if (check_create_thread_limit(true)) {
                        // thread limit reached
                        header_redirect();
                        // exited here
                    }
                    global $edited_Thread, $edited_Message, $recipients_selected;
                    // Load classes
                    load_class('messaging/model/_thread.class.php', 'Thread');
                    load_class('messaging/model/_message.class.php', 'Message');
                    // Set global variable to auto define the FB autocomplete plugin field
                    $recipients_selected = array(array('id' => $recipient_User->ID, 'title' => $recipient_User->login));
                    init_tokeninput_js('blog');
                    $disp = 'threads';
                    $edited_Thread = new Thread();
                    $edited_Message = new Message();
                    $edited_Message->Thread =& $edited_Thread;
                    $edited_Thread->recipients = $recipient_User->login;
                    param('action', 'string', 'new', true);
                    param('thrdtype', 'string', 'individual', true);
                }
                if ($allow_msgform == 'email') {
                    // set recippient user param
                    set_param('recipient_id', $recipient_User->ID);
                }
            }
            if ($allow_msgform == NULL) {
                // should be Prevented by UI
                if (!empty($recipient_User)) {
                    $Messages->add(sprintf(T_('The user "%s" does not want to be contacted through the message form.'), $recipient_User->get('login')), 'error');
                } elseif (!empty($Comment)) {
                    $Messages->add(T_('This commentator does not want to get contacted through the message form.'), 'error');
                }
                $blogurl = $Blog->gen_blogurl();
                // If it was a front page request or the front page is set to 'msgform' then we must not redirect to the front page because it is forbidden for the current User
                $redirect_to = is_front_page() || $Blog->get_setting('front_disp') == 'msgform' ? url_add_param($blogurl, 'disp=403', '&') : $blogurl;
                header_redirect($redirect_to, 302);
                // exited here
            }
            if ($allow_msgform == 'PM' || $allow_msgform == 'email') {
                // Some message form is available
                // Get the suggested subject for the email:
                if (empty($subject)) {
                    // no subject provided by param:
                    global $DB;
                    if (!empty($comment_id)) {
                        // fp>TODO there should be NO SQL in this file. Make a $ItemCache->get_by_comment_ID().
                        $row = $DB->get_row('
							SELECT post_title
								FROM T_items__item, T_comments
							 WHERE comment_ID = ' . $DB->quote($comment_id) . '
								 AND post_ID = comment_item_ID');
                        if ($row) {
                            $subject = T_('Re:') . ' ' . sprintf(T_('Comment on %s'), $row->post_title);
                        }
                    }
                    if (empty($subject) && !empty($post_id)) {
                        // fp>TODO there should be NO SQL in this file. Use $ItemCache->get_by_ID.
                        $row = $DB->get_row('
								SELECT post_title
									FROM T_items__item
								 WHERE post_ID = ' . $post_id);
                        if ($row) {
                            $subject = T_('Re:') . ' ' . $row->post_title;
                        }
                    }
                }
                if ($allow_msgform == 'PM' && isset($edited_Thread)) {
                    $edited_Thread->title = $subject;
                } else {
                    param('subject', 'string', $subject, true);
                }
            }
            if (($msg_Blog =& get_setting_Blog('msg_blog_ID')) && $Blog->ID != $msg_Blog->ID) {
                // Redirect to special blog for messaging actions if it is defined in general settings
                header_redirect($msg_Blog->get('msgformurl', array('glue' => '&')));
            }
            $seo_page_type = 'Contact form';
            if ($Blog->get_setting($disp . '_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
        case 'messages':
        case 'contacts':
        case 'threads':
            switch ($disp) {
                case 'messages':
                    // Actions ONLY for disp=messages
                    // fp> The correct place to get thrd_ID is here, because we want it in redirect_to in case we need to ask for login.
                    $thrd_ID = param('thrd_ID', 'integer', '', true);
                    if (!is_logged_in()) {
                        // Redirect to the login page for anonymous users
                        $Messages->add(T_('You must log in to read your messages.'));
                        header_redirect(get_login_url('cannot see messages'), 302);
                        // will have exited
                    }
                    // check if user status allow to view messages
                    if (!$current_User->check_status('can_view_messages')) {
                        // user status does not allow to view messages
                        if ($current_User->check_status('can_be_validated')) {
                            // user is logged in but his/her account is not activate yet
                            $Messages->add(T_('You must activate your account before you can read & send messages. <b>See below:</b>'));
                            header_redirect(get_activate_info_url(), 302);
                            // will have exited
                        }
                        $Messages->add('You are not allowed to view Messages!');
                        header_redirect($Blog->gen_blogurl(), 302);
                        // will have exited
                    }
                    // check if user permissions allow to view messages
                    if (!$current_User->check_perm('perm_messaging', 'reply')) {
                        // Redirect to the blog url for users without messaging permission
                        $Messages->add('You are not allowed to view Messages!');
                        header_redirect($Blog->gen_blogurl(), 302);
                        // will have exited
                    }
                    if (!empty($thrd_ID)) {
                        // if this thread exists and current user is part of this thread update status because won't be any unread messages on this conversation
                        // we need to mark this early to make sure the unread message count will be correct in the evobar
                        mark_as_read_by_user($thrd_ID, $current_User->ID);
                    }
                    if (($unsaved_message_params = get_message_params_from_session()) !== NULL) {
                        // set Message and Thread saved params from Session
                        global $edited_Message, $action;
                        load_class('messaging/model/_message.class.php', 'Message');
                        $edited_Message = new Message();
                        $edited_Message->text = $unsaved_message_params['message'];
                        $edited_Message->original_text = $unsaved_message_params['message_original'];
                        $edited_Message->set_renderers($unsaved_message_params['renderers']);
                        $edited_Message->thread_ID = $thrd_ID;
                        $action = $unsaved_message_params['action'];
                    }
                    break;
                case 'contacts':
                    // Actions ONLY for disp=contacts
                    if (!is_logged_in()) {
                        // Redirect to the login page for anonymous users
                        $Messages->add(T_('You must log in to manage your contacts.'));
                        header_redirect(get_login_url('cannot see contacts'), 302);
                        // will have exited
                    }
                    if (!$current_User->check_status('can_view_contacts')) {
                        // user is logged in, but his status doesn't allow to view contacts
                        if ($current_User->check_status('can_be_validated')) {
                            // user is logged in but his/her account was not activated yet
                            // Redirect to the account activation page
                            $Messages->add(T_('You must activate your account before you can manage your contacts. <b>See below:</b>'));
                            header_redirect(get_activate_info_url(), 302);
                            // will have exited
                        }
                        // Redirect to the blog url for users without messaging permission
                        $Messages->add('You are not allowed to view Contacts!');
                        $blogurl = $Blog->gen_blogurl();
                        // If it was a front page request or the front page is set to display 'contacts' then we must not redirect to the front page because it is forbidden for the current User
                        $redirect_to = is_front_page() || $Blog->get_setting('front_disp') == 'contacts' ? url_add_param($blogurl, 'disp=403', '&') : $blogurl;
                        header_redirect($redirect_to, 302);
                    }
                    if (has_cross_country_restriction('any') && empty($current_User->ctry_ID)) {
                        // User may browse/contact other users only from the same country
                        $Messages->add(T_('Please specify your country before attempting to contact other users.'));
                        header_redirect(get_user_profile_url());
                    }
                    // Get action parameter from request:
                    $action = param_action();
                    if (!$current_User->check_perm('perm_messaging', 'reply')) {
                        // Redirect to the blog url for users without messaging permission
                        $Messages->add('You are not allowed to view Contacts!');
                        $blogurl = $Blog->gen_blogurl();
                        // If it was a front page request or the front page is set to display 'contacts' then we must not redirect to the front page because it is forbidden for the current User
                        $redirect_to = is_front_page() || $Blog->get_setting('front_disp') == 'contacts' ? url_add_param($blogurl, 'disp=403', '&') : $blogurl;
                        header_redirect($redirect_to, 302);
                        // will have exited
                    }
                    switch ($action) {
                        case 'add_user':
                            // Add user to contacts list
                            // Check that this action request is not a CSRF hacked request:
                            $Session->assert_received_crumb('messaging_contacts');
                            $user_ID = param('user_ID', 'integer', 0);
                            if ($user_ID > 0) {
                                // Add user to contacts
                                if (create_contacts_user($user_ID)) {
                                    // Add user to the group
                                    $group_ID = param('group_ID', 'string', '');
                                    if ($result = create_contacts_group_users($group_ID, $user_ID, 'group_ID_combo')) {
                                        // User has been added to the group
                                        $Messages->add(sprintf(T_('User has been added to the &laquo;%s&raquo; group.'), $result['group_name']), 'success');
                                    } else {
                                        // User has been added ONLY to the contacts list
                                        $Messages->add('User has been added to your contacts.', 'success');
                                    }
                                }
                                header_redirect($Blog->get('userurl', array('url_suffix' => 'user_ID=' . $user_ID, 'glue' => '&')));
                            }
                            break;
                        case 'unblock':
                            // Unblock user
                            // Check that this action request is not a CSRF hacked request:
                            $Session->assert_received_crumb('messaging_contacts');
                            $user_ID = param('user_ID', 'integer', 0);
                            if ($user_ID > 0) {
                                set_contact_blocked($user_ID, 0);
                                $Messages->add(T_('Contact was unblocked.'), 'success');
                            }
                            break;
                        case 'remove_user':
                            // Remove user from contacts group
                            // Check that this action request is not a CSRF hacked request:
                            $Session->assert_received_crumb('messaging_contacts');
                            $view = param('view', 'string', 'profile');
                            $user_ID = param('user_ID', 'integer', 0);
                            $group_ID = param('group_ID', 'integer', 0);
                            if ($user_ID > 0 && $group_ID > 0) {
                                // Remove user from selected group
                                if (remove_contacts_group_user($group_ID, $user_ID)) {
                                    // User has been removed from the group
                                    if ($view == 'contacts') {
                                        // Redirect to the contacts list
                                        header_redirect($Blog->get('contactsurl', array('glue' => '&')));
                                    } else {
                                        // Redirect to the user profile page
                                        header_redirect($Blog->get('userurl', array('url_suffix' => 'user_ID=' . $user_ID, 'glue' => '&')));
                                    }
                                }
                            }
                            break;
                        case 'add_group':
                            // Add users to the group
                            // Check that this action request is not a CSRF hacked request:
                            $Session->assert_received_crumb('messaging_contacts');
                            $group = param('group', 'string', '');
                            $users = param('users', 'string', '');
                            if ($result = create_contacts_group_users($group, $users)) {
                                // Users have been added to the group
                                $Messages->add(sprintf(T_('%d contacts have been added to the &laquo;%s&raquo; group.'), $result['count_users'], $result['group_name']), 'success');
                                $redirect_to = $Blog->get('contactsurl', array('glue' => '&'));
                                $item_ID = param('item_ID', 'integer', 0);
                                if ($item_ID > 0) {
                                    $redirect_to = url_add_param($redirect_to, 'item_ID=' . $item_ID, '&');
                                }
                                header_redirect($redirect_to);
                            }
                            break;
                        case 'rename_group':
                            // Rename the group
                            // Check that this action request is not a CSRF hacked request:
                            $Session->assert_received_crumb('messaging_contacts');
                            $group_ID = param('group_ID', 'integer', true);
                            if (rename_contacts_group($group_ID)) {
                                $item_ID = param('item_ID', 'integer', 0);
                                $redirect_to = url_add_param($Blog->get('contactsurl', array('glue' => '&')), 'g=' . $group_ID, '&');
                                if ($item_ID > 0) {
                                    $redirect_to = url_add_param($redirect_to, 'item_ID=' . $item_ID, '&');
                                }
                                $Messages->add(T_('The group has been renamed.'), 'success');
                                header_redirect($redirect_to);
                            }
                            break;
                        case 'delete_group':
                            // Delete the group
                            // Check that this action request is not a CSRF hacked request:
                            $Session->assert_received_crumb('messaging_contacts');
                            $group_ID = param('group_ID', 'integer', true);
                            if (delete_contacts_group($group_ID)) {
                                $item_ID = param('item_ID', 'integer', 0);
                                $redirect_to = $Blog->get('contactsurl', array('glue' => '&'));
                                if ($item_ID > 0) {
                                    $redirect_to = url_add_param($redirect_to, 'item_ID=' . $item_ID, '&');
                                }
                                $Messages->add(T_('The group has been deleted.'), 'success');
                                header_redirect($redirect_to);
                            }
                            break;
                    }
                    modules_call_method('switch_contacts_actions', array('action' => $action));
                    break;
                case 'threads':
                    // Actions ONLY for disp=threads
                    if (!is_logged_in()) {
                        // Redirect to the login page for anonymous users
                        $Messages->add(T_('You must log in to read your messages.'));
                        header_redirect(get_login_url('cannot see messages'), 302);
                        // will have exited
                    }
                    if (!$current_User->check_status('can_view_threads')) {
                        // user status does not allow to view threads
                        if ($current_User->check_status('can_be_validated')) {
                            // user is logged in but his/her account is not activate yet
                            $Messages->add(T_('You must activate your account before you can read & send messages. <b>See below:</b>'));
                            header_redirect(get_activate_info_url(), 302);
                            // will have exited
                        }
                        $Messages->add('You are not allowed to view Messages!');
                        $blogurl = $Blog->gen_blogurl();
                        // If it was a front page request or the front page is set to display 'threads' then we must not redirect to the front page because it is forbidden for the current User
                        $redirect_to = is_front_page() || $Blog->get_setting('front_disp') == 'threads' ? url_add_param($blogurl, 'disp=404', '&') : $blogurl;
                        header_redirect($redirect_to, 302);
                        // will have exited
                    }
                    if (!$current_User->check_perm('perm_messaging', 'reply')) {
                        // Redirect to the blog url for users without messaging permission
                        $Messages->add('You are not allowed to view Messages!');
                        $blogurl = $Blog->gen_blogurl();
                        // If it was a front page request or the front page is set to display 'threads' then we must not redirect to the front page because it is forbidden for the current User
                        $redirect_to = is_front_page() || $Blog->get_setting('front_disp') == 'threads' ? url_add_param($blogurl, 'disp=403', '&') : $blogurl;
                        header_redirect($redirect_to, 302);
                        // will have exited
                    }
                    $action = param('action', 'string', 'view');
                    if ($action == 'new') {
                        // Before new message form is displayed ...
                        if (has_cross_country_restriction('contact') && empty($current_User->ctry_ID)) {
                            // Cross country contact restriction is enabled, but user country is not set yet
                            $Messages->add(T_('Please specify your country before attempting to contact other users.'));
                            header_redirect(get_user_profile_url());
                        } elseif (check_create_thread_limit(true)) {
                            // don't allow to create new thread, because the new thread limit was already reached
                            set_param('action', 'view');
                        }
                    }
                    // Load classes
                    load_class('messaging/model/_thread.class.php', 'Thread');
                    load_class('messaging/model/_message.class.php', 'Message');
                    // Get action parameter from request:
                    $action = param_action('view');
                    switch ($action) {
                        case 'new':
                            // Check permission:
                            $current_User->check_perm('perm_messaging', 'reply', true);
                            global $edited_Thread, $edited_Message;
                            $edited_Thread = new Thread();
                            $edited_Message = new Message();
                            $edited_Message->Thread =& $edited_Thread;
                            modules_call_method('update_new_thread', array('Thread' => &$edited_Thread));
                            if (($unsaved_message_params = get_message_params_from_session()) !== NULL) {
                                // set Message and Thread saved params from Session
                                $edited_Message->text = $unsaved_message_params['message'];
                                $edited_Message->original_text = $unsaved_message_params['message_original'];
                                $edited_Message->set_renderers($unsaved_message_params['renderers']);
                                $edited_Thread->title = $unsaved_message_params['subject'];
                                $edited_Thread->recipients = $unsaved_message_params['thrd_recipients'];
                                $edited_Message->Thread = $edited_Thread;
                                global $thrd_recipients_array, $thrdtype, $action, $creating_success;
                                $thrd_recipients_array = $unsaved_message_params['thrd_recipients_array'];
                                $thrdtype = $unsaved_message_params['thrdtype'];
                                $action = $unsaved_message_params['action'];
                                $creating_success = !empty($unsaved_message_params['creating_success']) ? $unsaved_message_params['creating_success'] : false;
                            } else {
                                if (empty($edited_Thread->recipients)) {
                                    $edited_Thread->recipients = param('thrd_recipients', 'string', '');
                                }
                                if (empty($edited_Thread->title)) {
                                    $edited_Thread->title = param('subject', 'string', '');
                                }
                            }
                            break;
                        default:
                            // Check permission:
                            $current_User->check_perm('perm_messaging', 'reply', true);
                            break;
                    }
                    break;
            }
            // Actions for disp = messages, contacts, threads:
            if (($msg_Blog =& get_setting_Blog('msg_blog_ID')) && $Blog->ID != $msg_Blog->ID) {
                // Redirect to special blog for messaging actions if it is defined in general settings
                $blog_url_params = array('glue' => '&');
                if (!empty($thrd_ID)) {
                    // Don't forget the important param on redirect
                    $blog_url_params['url_suffix'] = 'thrd_ID=' . $thrd_ID;
                }
                header_redirect($msg_Blog->get($disp . 'url', $blog_url_params));
            }
            // just in case some robot would be logged in:
            $seo_page_type = 'Messaging module';
            $robots_index = false;
            // Display messages depending on user email status
            display_user_email_status_message();
            break;
        case 'login':
            global $Plugins, $transmit_hashed_password;
            if (is_logged_in()) {
                // User is already logged in
                if ($current_User->check_status('can_be_validated')) {
                    // account is not active yet, redirect to the account activation page
                    $Messages->add(T_('You are logged in but your account is not activated. You will find instructions about activating your account below:'));
                    header_redirect(get_activate_info_url(), 302);
                    // will have exited
                }
                // User is already logged in, redirect to "redirect_to" page
                $Messages->add(T_('You are already logged in.'), 'note');
                $redirect_to = param('redirect_to', 'url', NULL);
                if (empty($redirect_to)) {
                    // If empty redirect to referer page
                    $redirect_to = '';
                }
                header_redirect($redirect_to, 302);
                // will have exited
            }
            if (($login_Blog =& get_setting_Blog('login_blog_ID')) && $Blog->ID != $login_Blog->ID) {
                // Redirect to special blog for login/register actions if it is defined in general settings
                header_redirect($login_Blog->get('loginurl', array('glue' => '&')));
            }
            $seo_page_type = 'Login form';
            $robots_index = false;
            break;
        case 'register':
            if (is_logged_in()) {
                // If user is logged in the register form should not be displayed. In this case redirect to the blog home page.
                $Messages->add(T_('You are already logged in.'), 'note');
                header_redirect($Blog->gen_blogurl(), false);
            }
            if (($login_Blog =& get_setting_Blog('login_blog_ID')) && $Blog->ID != $login_Blog->ID) {
                // Redirect to special blog for login/register actions if it is defined in general settings
                header_redirect($login_Blog->get('registerurl', array('glue' => '&')));
            }
            $seo_page_type = 'Register form';
            $robots_index = false;
            // Check invitation code if it exists and registration is enabled
            global $display_invitation;
            $display_invitation = check_invitation_code();
            break;
        case 'lostpassword':
            if (is_logged_in()) {
                // If user is logged in the lost password form should not be displayed. In this case redirect to the blog home page.
                $Messages->add(T_('You are already logged in.'), 'note');
                header_redirect($Blog->gen_blogurl(), false);
            }
            if (($login_Blog =& get_setting_Blog('login_blog_ID')) && $Blog->ID != $login_Blog->ID) {
                // Redirect to special blog for login/register actions if it is defined in general settings
                header_redirect($login_Blog->get('lostpasswordurl', array('glue' => '&')));
            }
            $seo_page_type = 'Lost password form';
            $robots_index = false;
            break;
        case 'activateinfo':
            if (!is_logged_in()) {
                // Redirect to the login page for anonymous users
                $Messages->add(T_('You must log in before you can activate your account.'));
                header_redirect(get_login_url('cannot see messages'), 302);
                // will have exited
            }
            if (!$current_User->check_status('can_be_validated')) {
                // don't display activateinfo screen
                $after_email_validation = $Settings->get('after_email_validation');
                if ($after_email_validation == 'return_to_original') {
                    // we want to return to original page after account activation
                    // check if Session 'validatemail.redirect_to' param is still set
                    $redirect_to = $Session->get('core.validatemail.redirect_to');
                    if (empty($redirect_to)) {
                        // Session param is empty try to get general redirect_to param
                        $redirect_to = param('redirect_to', 'url', '');
                    } else {
                        // cleanup validateemail.redirect_to param from session
                        $Session->delete('core.validatemail.redirect_to');
                    }
                } else {
                    // go to after email validation url which is set in the user general settings form
                    $redirect_to = $after_email_validation;
                }
                if (empty($redirect_to) || preg_match('#disp=activateinfo#', $redirect_to)) {
                    // redirect_to is pointing to the activate info display or is empty
                    // redirect to referer page
                    $redirect_to = '';
                }
                if ($current_User->check_status('is_validated')) {
                    $Messages->add(T_('Your account has already been activated.'));
                }
                header_redirect($redirect_to, 302);
                // will have exited
            }
            if (($login_Blog =& get_setting_Blog('login_blog_ID')) && $Blog->ID != $login_Blog->ID) {
                // Redirect to special blog for login/register actions if it is defined in general settings
                header_redirect($login_Blog->get('activateinfourl', array('glue' => '&')));
            }
            break;
        case 'profile':
        case 'avatar':
            $action = param_action();
            if ($action == 'crop' && is_logged_in()) {
                // Check data for crop action:
                global $current_User, $cropped_File;
                $file_ID = param('file_ID', 'integer');
                if (!($cropped_File = $current_User->get_File_by_ID($file_ID, $error_code))) {
                    // Current user cannot crop this file
                    set_param('action', '');
                }
            }
        case 'pwdchange':
        case 'userprefs':
        case 'subs':
            $seo_page_type = 'Special feature page';
            if ($Blog->get_setting('special_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            // Display messages depending on user email status
            display_user_email_status_message();
            break;
        case 'users':
            if (!is_logged_in() && !$Settings->get('allow_anonymous_user_list')) {
                // Redirect to the login page if not logged in and allow anonymous user setting is OFF
                $Messages->add(T_('You must log in to view the user directory.'));
                header_redirect(get_login_url('cannot see user'), 302);
                // will have exited
            }
            if (is_logged_in() && !check_user_status('can_view_users')) {
                // user status doesn't permit to view users list
                if (check_user_status('can_be_validated')) {
                    // user is logged in but his/her account is not active yet
                    // Redirect to the account activation page
                    $Messages->add(T_('You must activate your account before you can view the user directory. <b>See below:</b>'));
                    header_redirect(get_activate_info_url(), 302);
                    // will have exited
                }
                // set where to redirect
                $error_redirect_to = empty($Blog) ? $baseurl : $Blog->gen_blogurl();
                $Messages->add(T_('Your account status currently does not permit to view the user directory.'));
                header_redirect($error_redirect_to, 302);
                // will have exited
            }
            if (has_cross_country_restriction('users', 'list') && empty($current_User->ctry_ID)) {
                // User may browse other users only from the same country
                $Messages->add(T_('Please specify your country before attempting to contact other users.'));
                header_redirect(get_user_profile_url());
            }
            $seo_page_type = 'Users list';
            $robots_index = false;
            break;
        case 'user':
            // get user_ID because we want it in redirect_to in case we need to ask for login.
            $user_ID = param('user_ID', 'integer', '', true);
            // set where to redirect in case of error
            $error_redirect_to = empty($Blog) ? $baseurl : $Blog->gen_blogurl();
            if (!is_logged_in()) {
                // Redirect to the login page if not logged in and allow anonymous user setting is OFF
                $user_available_by_group_level = true;
                if (!empty($user_ID)) {
                    $UserCache =& get_UserCache();
                    if ($User =& $UserCache->get_by_ID($user_ID, false)) {
                        // If user exists we can check if the anonymous users have an access to view the user by group level limitation
                        $User->get_Group();
                        $user_available_by_group_level = $User->Group->level >= $Settings->get('allow_anonymous_user_level_min') && $User->Group->level <= $Settings->get('allow_anonymous_user_level_max');
                    }
                }
                if (!$Settings->get('allow_anonymous_user_profiles') || !$user_available_by_group_level || empty($user_ID)) {
                    // If this user is not available for anonymous users
                    $Messages->add(T_('You must log in to view this user profile.'));
                    header_redirect(get_login_url('cannot see user'), 302);
                    // will have exited
                }
            }
            if (is_logged_in() && !check_user_status('can_view_user', $user_ID)) {
                // user is logged in, but his/her status doesn't permit to view user profile
                if (check_user_status('can_be_validated')) {
                    // user is logged in but his/her account is not active yet
                    // Redirect to the account activation page
                    $Messages->add(T_('You must activate your account before you can view this user profile. <b>See below:</b>'));
                    header_redirect(get_activate_info_url(), 302);
                    // will have exited
                }
                $Messages->add(T_('Your account status currently does not permit to view this user profile.'));
                header_redirect($error_redirect_to, 302);
                // will have exited
            }
            if (!empty($user_ID)) {
                $UserCache =& get_UserCache();
                $User =& $UserCache->get_by_ID($user_ID, false);
                if (empty($User)) {
                    $Messages->add(T_('The requested user does not exist!'));
                    header_redirect($error_redirect_to);
                    // will have exited
                }
                if ($User->check_status('is_closed')) {
                    $Messages->add(T_('The requested user account is closed!'));
                    header_redirect($error_redirect_to);
                    // will have exited
                }
                if (has_cross_country_restriction('any')) {
                    if (empty($current_User->ctry_ID)) {
                        // Current User country is not set
                        $Messages->add(T_('Please specify your country before attempting to contact other users.'));
                        header_redirect(get_user_profile_url());
                        // will have exited
                    }
                    if (has_cross_country_restriction('users', 'profile') && $current_User->ctry_ID !== $User->ctry_ID) {
                        // Current user country is different then edited user country and cross country user browsing is not enabled.
                        $Messages->add(T_('You don\'t have permission to view this user profile.'));
                        header_redirect(url_add_param($error_redirect_to, 'disp=403', '&'));
                        // will have exited
                    }
                }
            }
            // Initialize users list from session cache in order to display prev/next links:
            // It is used to navigate between users
            load_class('users/model/_userlist.class.php', 'UserList');
            global $UserList;
            $UserList = new UserList();
            $UserList->memorize = false;
            $UserList->load_from_Request();
            $seo_page_type = 'User display';
            break;
        case 'edit':
            global $current_User, $post_ID;
            // Post ID, go from $_GET when we edit a post from Front-office
            //          or from $_POST when we switch from Back-office
            $post_ID = param('p', 'integer', empty($post_ID) ? 0 : $post_ID, true);
            if (!is_logged_in()) {
                // Redirect to the login page if not logged in and allow anonymous user setting is OFF
                $redirect_to = url_add_param($Blog->gen_blogurl(), 'disp=edit');
                $Messages->add(T_('You must log in to create & edit posts.'));
                header_redirect(get_login_url('cannot edit posts', $redirect_to), 302);
                // will have exited
            }
            if (!$current_User->check_status('can_edit_post')) {
                if ($current_User->check_status('can_be_validated')) {
                    // user is logged in but his/her account was not activated yet
                    // Redirect to the account activation page
                    $Messages->add(T_('You must activate your account before you can create & edit posts. <b>See below:</b>'));
                    header_redirect(get_activate_info_url(), 302);
                    // will have exited
                }
                // Redirect to the blog url for users without messaging permission
                $Messages->add(T_('You are not allowed to create & edit posts!'));
                header_redirect($Blog->gen_blogurl(), 302);
            }
            // user logged in and the account was activated
            check_item_perm_edit($post_ID);
            if (!blog_has_cats($Blog->ID)) {
                // No categories are in this blog
                $error_message = T_('Since this blog has no categories, you cannot post into it.');
                if ($current_User->check_perm('blog_cats', 'edit', false, $Blog->ID)) {
                    // If current user has a permission to create a category
                    global $admin_url;
                    $error_message .= ' ' . sprintf(T_('You must <a %s>create categories</a> first.'), 'href="' . $admin_url . '?ctrl=chapters&amp;blog=' . $Blog->ID . '"');
                }
                $Messages->add($error_message, 'error');
                header_redirect($Blog->gen_blogurl(), 302);
            }
            // Prepare the 'In-skin editing':
            init_inskin_editing();
            break;
        case 'edit_comment':
            global $current_User, $edited_Comment, $comment_Item, $Item, $comment_title, $comment_content, $display_params;
            // comment ID
            $comment_ID = param('c', 'integer', 0, true);
            if (!is_logged_in()) {
                // Redirect to the login page if not logged in and allow anonymous user setting is OFF
                $redirect_to = url_add_param($Blog->gen_blogurl(), 'disp=edit_comment');
                $Messages->add(T_('You must log in to edit comments.'));
                header_redirect(get_login_url('cannot edit comments', $redirect_to), 302);
                // will have exited
            }
            if (!$current_User->check_status('can_edit_comment')) {
                if ($current_User->check_status('can_be_validated')) {
                    // user is logged in but his/her account was not activated yet
                    // Redirect to the account activation page
                    $Messages->add(T_('You must activate your account before you can edit comments. <b>See below:</b>'));
                    header_redirect(get_activate_info_url(), 302);
                    // will have exited
                }
                // Redirect to the blog url for users without messaging permission
                $Messages->add('You are not allowed to edit comments!');
                header_redirect($Blog->gen_blogurl(), 302);
            }
            if (empty($comment_ID)) {
                // Can't edit a not exisiting comment
                $Messages->add('Invalid comment edit URL!');
                global $disp;
                $disp = 404;
                break;
            }
            $CommentCache =& get_CommentCache();
            $edited_Comment = $CommentCache->get_by_ID($comment_ID);
            $comment_Item = $edited_Comment->get_Item();
            if (!$current_User->check_perm('comment!CURSTATUS', 'edit', false, $edited_Comment)) {
                // If User has no permission to edit comments with this comment status:
                $Messages->add('You are not allowed to edit the previously selected comment!');
                header_redirect($Blog->gen_blogurl(), 302);
            }
            $comment_title = '';
            $comment_content = htmlspecialchars_decode($edited_Comment->content);
            // Format content for editing, if we were not already in editing...
            $Plugins_admin =& get_Plugins_admin();
            $comment_Item->load_Blog();
            $params = array('object_type' => 'Comment', 'object_Blog' => &$comment_Item->Blog);
            $Plugins_admin->unfilter_contents($comment_title, $comment_content, $edited_Comment->get_renderers_validated(), $params);
            $Item = $comment_Item;
            $display_params = array();
            break;
        case 'useritems':
        case 'usercomments':
            global $display_params, $viewed_User;
            // get user_ID because we want it in redirect_to in case we need to ask for login.
            $user_ID = param('user_ID', 'integer', true, true);
            if (empty($user_ID)) {
                bad_request_die(sprintf(T_('Parameter &laquo;%s&raquo; is required!'), 'user_ID'));
            }
            // set where to redirect in case of error
            $error_redirect_to = empty($Blog) ? $baseurl : $Blog->gen_blogurl();
            if (!is_logged_in()) {
                // Redirect to the login page if not logged in and allow anonymous user setting is OFF
                $Messages->add(T_('You must log in to view this user profile.'));
                header_redirect(get_login_url('cannot see user'), 302);
                // will have exited
            }
            if (is_logged_in() && !check_user_status('can_view_user', $user_ID)) {
                // user is logged in, but his/her status doesn't permit to view user profile
                if (check_user_status('can_be_validated')) {
                    // user is logged in but his/her account is not active yet
                    // Redirect to the account activation page
                    $Messages->add(T_('You must activate your account before you can view this user profile. <b>See below:</b>'));
                    header_redirect(get_activate_info_url(), 302);
                    // will have exited
                }
                $Messages->add(T_('Your account status currently does not permit to view this user profile.'));
                header_redirect($error_redirect_to, 302);
                // will have exited
            }
            if (!empty($user_ID)) {
                $UserCache =& get_UserCache();
                $viewed_User = $UserCache->get_by_ID($user_ID, false);
                if (empty($viewed_User)) {
                    $Messages->add(T_('The requested user does not exist!'));
                    header_redirect($error_redirect_to);
                    // will have exited
                }
                if ($viewed_User->check_status('is_closed')) {
                    $Messages->add(T_('The requested user account is closed!'));
                    header_redirect($error_redirect_to);
                    // will have exited
                }
            }
            $display_params = !empty($Skin) ? $Skin->get_template('Results') : NULL;
            if ($disp == 'useritems') {
                // Init items list
                global $user_ItemList;
                $useritems_Blog = NULL;
                $user_ItemList = new ItemList2($useritems_Blog, NULL, NULL, NULL, 'ItemCache', 'useritems_');
                $user_ItemList->load_from_Request();
                $user_ItemList->set_filters(array('authors' => $user_ID), true, true);
                $user_ItemList->query();
            } else {
                // Init comments list
                global $user_CommentList;
                $user_CommentList = new CommentList2(NULL, NULL, 'CommentCache', 'usercmts_');
                $user_CommentList->load_from_Request();
                $user_CommentList->set_filters(array('author_IDs' => $user_ID), true, true);
                $user_CommentList->query();
            }
            break;
        case 'comments':
            if (!$Blog->get_setting('comments_latest')) {
                // If latest comments page is disabled - Display 404 page with error message
                $Messages->add(T_('This feature is disabled.'), 'error');
                global $disp;
                $disp = '404';
            }
            break;
        case 'closeaccount':
            global $current_User;
            if (!$Settings->get('account_close_enabled') || is_logged_in() && $current_User->check_perm('users', 'edit', false) || !is_logged_in() && !$Session->get('account_closing_success')) {
                // If an account closing page is disabled - Display 404 page with error message
                // Don't allow admins close own accounts from front office
                // Don't display this message for not logged in users, except of one case to display a bye message after account closing
                global $disp;
                $disp = '404';
            } elseif ($Session->get('account_closing_success')) {
                // User has closed the account
                global $account_closing_success;
                $account_closing_success = $Session->get('account_closing_success');
                // Unset this temp session var to don't display the message twice
                $Session->delete('account_closing_success');
                if (is_logged_in()) {
                    // log out current User
                    logout();
                }
            }
            break;
        case 'tags':
            $seo_page_type = 'Tags';
            if ($Blog->get_setting($disp . '_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
    }
    $Debuglog->add('skin_init: $disp=' . $disp . ' / $disp_detail=' . $disp_detail . ' / $seo_page_type=' . $seo_page_type, 'skins');
    // Make this switch block special only for 404 page
    switch ($disp) {
        case '404':
            // We have a 404 unresolved content error
            // How do we want do deal with it?
            skin_404_header();
            // This MAY or MAY not have exited -- will exit on 30x redirect, otherwise will return here.
            // Just in case some dumb robot needs extra directives on this:
            $robots_index = false;
            break;
    }
    global $Hit, $check_browser_version;
    if ($check_browser_version && $Hit->get_browser_version() > 0 && $Hit->is_IE(9, '<')) {
        // Display info message if browser IE < 9 version and it is allowed by config var:
        global $debug;
        $Messages->add(T_('Your web browser is too old. For this site to work correctly, we recommend you use a more recent browser.'), 'note');
        if ($debug) {
            $Messages->add('User Agent: ' . $Hit->get_user_agent(), 'note');
        }
    }
    // dummy var for backward compatibility with versions < 2.4.1 -- prevents "Undefined variable"
    global $global_Cache, $credit_links;
    $credit_links = $global_Cache->get('creds');
    $Timer->pause('skin_init');
    // Check if user is logged in with a not active account, and display an error message if required
    check_allow_disp($disp);
    // initialize Blog enabled widgets, before displaying anything
    init_blog_widgets($Blog->ID);
    // Initialize displaying....
    $Timer->start('Skin:display_init');
    $Skin->display_init();
    $Timer->pause('Skin:display_init');
    // Send default headers:
    // See comments inside of this function:
    headers_content_mightcache('text/html');
    // In most situations, you do NOT want to cache dynamic content!
    // Never allow Messages to be cached!
    if ($Messages->count() && !empty($PageCache)) {
        // Abort PageCache collect
        $PageCache->abort_collect();
    }
}
/**
 * Get array of latest items
 *
 * @param array of params
 *			- limit (int) the number of items to return
 *			- post_ID (int) return specified item or NULL to return all available
 * @return xmlrpcmsg
 */
function xmlrpc_get_items($params, &$Blog)
{
    global $current_User;
    $params = array_merge(array('limit' => 0, 'item_ID' => 0, 'types' => ''), $params);
    // Protected and private get checked by statuses_where_clause().
    $statuses = array('published', 'redirected', 'protected', 'private');
    if ($current_User->check_perm('blog_ismember', 'view', false, $Blog->ID)) {
        // These statuses require member status:
        $statuses = array_merge($statuses, array('draft', 'deprecated'));
    }
    logIO('Statuses: ' . implode(', ', $statuses));
    if (!empty($params['item_ID'])) {
        logIO('Getting item #' . $params['item_ID']);
        $filters = array('visibility_array' => $statuses, 'types' => NULL, 'post_ID' => $params['item_ID']);
    } else {
        logIO(sprintf('Trying to get latest items (%s)', $params['limit'] ? $params['limit'] : 'all'));
        $filters = array('visibility_array' => $statuses, 'types' => $params['types'], 'order' => 'DESC', 'unit' => 'posts');
    }
    // Get the pages to display:
    load_class('items/model/_itemlist.class.php', 'ItemList2');
    $ItemList = new ItemList2($Blog, NULL, NULL, $params['limit']);
    $ItemList->set_filters($filters, false);
    // Run the query:
    $ItemList->query();
    logIO('Items found: ' . $ItemList->result_num_rows);
    $data = array();
    while ($Item =& $ItemList->get_item()) {
        $data[] = _wp_mw_get_item_struct($Item);
    }
    return $data;
}
Exemple #9
0
 /**
  * Display a button to view the Recent/New Topics
  */
 function display_button_recent_topics()
 {
     global $Blog;
     if (!is_logged_in() || !$Blog->get_setting('track_unread_content')) {
         // For not logged in users AND if the tracking of unread content is turned off for the collection
         $btn_class = 'btn-info';
         $btn_title = T_('Recent Topics');
     } else {
         // For logged in users:
         global $current_User, $DB, $localtimenow;
         // Initialize SQL query to get only the posts which are displayed by global $MainList on disp=posts:
         $ItemList2 = new ItemList2($Blog, $Blog->get_timestamp_min(), $Blog->get_timestamp_max(), NULL, 'ItemCache', 'recent_topics');
         $ItemList2->set_default_filters(array('unit' => 'all'));
         $ItemList2->query_init();
         // Get a count of the unread topics for current user:
         $unread_posts_SQL = new SQL();
         $unread_posts_SQL->SELECT('COUNT( post_ID )');
         $unread_posts_SQL->FROM('T_items__item');
         $unread_posts_SQL->FROM_add('LEFT JOIN T_users__postreadstatus ON post_ID = uprs_post_ID AND uprs_user_ID = ' . $DB->quote($current_User->ID));
         $unread_posts_SQL->FROM_add('INNER JOIN T_categories ON post_main_cat_ID = cat_ID');
         $unread_posts_SQL->WHERE($ItemList2->ItemQuery->get_where(''));
         $unread_posts_SQL->WHERE_and('post_last_touched_ts > ' . $DB->quote(date2mysql($localtimenow - 30 * 86400)));
         // In theory, it would be more safe to use this comparison:
         // $unread_posts_SQL->WHERE_and( 'uprs_post_ID IS NULL OR uprs_read_post_ts <= post_last_touched_ts' );
         // But until we have milli- or micro-second precision on timestamps, we decided it was a better trade-off to never see our own edits as unread. So we use:
         $unread_posts_SQL->WHERE_and('uprs_post_ID IS NULL OR uprs_read_post_ts < post_last_touched_ts');
         // Execute a query with to know if current user has new data to view:
         $unread_posts_count = $DB->get_var($unread_posts_SQL->get(), 0, NULL, 'Get a count of the unread topics for current user');
         if ($unread_posts_count > 0) {
             // If at least one new unread topic exists
             $btn_class = 'btn-warning';
             $btn_title = T_('New Topics') . ' <span class="badge">' . $unread_posts_count . '</span>';
         } else {
             // Current user already have read all topics
             $btn_class = 'btn-info';
             $btn_title = T_('Recent Topics');
         }
     }
     // Print out the button:
     echo '<a href="' . $Blog->get('recentpostsurl') . '" class="btn ' . $btn_class . ' pull-right btn_recent_topics">' . $btn_title . '</a>';
 }
Exemple #10
0
 * For example: /blogs/index.php?disp=comments
 *
 * b2evolution - {@link http://b2evolution.net/}
 * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
 * @copyright (c)2003-2013 by Francois Planque - {@link http://fplanque.com/}
 *
 * @package evoskins
 */
if (!defined('EVO_MAIN_INIT')) {
    die('Please, do not access this page directly.');
}
global $number_of_posts_in_cat, $cat;
if ($cat > 0) {
    // Init MainList
    $page = param('paged', 'integer', 1);
    $MainList = new ItemList2($Blog, $Blog->get_timestamp_min(), $Blog->get_timestamp_max(), $Blog->get_setting('posts_per_page'));
    $MainList->load_from_Request();
    $MainList->set_filters(array('cat_array' => array($cat), 'page' => $page));
    $MainList->query();
    $MainList->nav_target = $cat;
    // set navigation target, we are always navigating through category in this skin
    $ChapterCache =& get_ChapterCache();
    if ($category =& $ChapterCache->get_by_ID($cat)) {
        // Display category title
        $category_name = $category->get('name');
        // $category_name is also used below
        echo '<h2 class="page_title">' . $category_name . '</h2>';
    }
    // -------------------- PREV/NEXT PAGE LINKS (POST LIST MODE) --------------------
    mainlist_page_links(array('block_start' => '<div class="navigation_top"><div class="navigation">' . T_('Page') . ': ', 'block_end' => '</div></div>', 'prev_text' => T_('Previous'), 'next_text' => T_('Next')));
    // ------------------------- END OF PREV/NEXT PAGE LINKS -------------------------
Exemple #11
0
/**
 * If an Intro Post is available, return it. If not, see if a Featured Post is available and return it.
 *
 * Note: this will set the global $FeaturedList which may be used to obtain several featured Items.
 *
 * @param string Name of $disp where we should display it
 * @param string Collection IDs:
 *                 NULL: depend on blog setting "Collections to aggregate"
 *                 empty: current blog only
 *                 "*": all blogs
 *                 "1,2,3":blog IDs separated by comma
 *                 "-": current blog only and exclude the aggregated blogs
 * @return Item
 */
function &get_featured_Item($restrict_disp = 'posts', $coll_IDs = NULL)
{
    global $Blog, $cat;
    global $disp, $disp_detail, $MainList, $FeaturedList;
    global $featured_displayed_item_IDs;
    if ($disp != $restrict_disp || !isset($MainList)) {
        // If we're not currently displaying posts, no need to try & display a featured/intro post on top!
        $Item = NULL;
        return $Item;
    }
    if (!isset($FeaturedList)) {
        // Don't repeat if we've done this already -- Initialize the featured list only first time this function is called in a skin:
        // Get ready to obtain 1 post only:
        $FeaturedList = new ItemList2($Blog, $Blog->get_timestamp_min(), $Blog->get_timestamp_max(), 1);
        $featured_list_filters = $MainList->filters;
        if (!empty($cat)) {
            // Get a featured post only of the selected category and don't touch the posts of the child categories:
            $featured_list_filters['cat_array'] = array($cat);
        }
        // Set default filters for the current page:
        $FeaturedList->set_default_filters($featured_list_filters);
        // FIRST: Try to find an Intro post:
        if (!$MainList->is_filtered()) {
            // This is not a filtered page, so we are on the home page.
            if ($restrict_disp == 'front') {
                // Special Front page:
                // Use Intro-Front posts
                $restrict_to_types = '1400';
            } else {
                // Default front page displaying posts:
                // The competing intro-* types are: 'main' and 'all':
                // fplanque> IMPORTANT> nobody changes this without consulting the manual and talking to me first!
                $restrict_to_types = '1500,1600';
            }
        } else {
            // We are on a filtered... it means a category page or sth like this...
            // echo $disp_detail;
            switch ($disp_detail) {
                case 'posts-cat':
                case 'posts-subcat':
                    // The competing intro-* types are: 'cat' and 'all':
                    // fplanque> IMPORTANT> nobody changes this without consulting the manual and talking to me first!
                    $restrict_to_types = '1520,1600';
                    break;
                case 'posts-tag':
                    // The competing intro-* types are: 'tag' and 'all':
                    // fplanque> IMPORTANT> nobody changes this without consulting the manual and talking to me first!
                    $restrict_to_types = '1530,1600';
                    break;
                default:
                    // The competing intro-* types are: 'sub' and 'all':
                    // fplanque> IMPORTANT> nobody changes this without consulting the manual and talking to me first!
                    $restrict_to_types = '1570,1600';
            }
        }
        $FeaturedList->set_filters(array('coll_IDs' => $coll_IDs, 'types' => $restrict_to_types), false);
        // pre_dump( $FeaturedList->filters );
        // Run the query:
        $FeaturedList->query();
        // SECOND: If no Intro, try to find an Featured post:
        if ($FeaturedList->result_num_rows == 0 && $restrict_disp != 'front') {
            // No Intro page was found, try to find a featured post instead:
            $FeaturedList->reset();
            $FeaturedList->set_filters(array('coll_IDs' => $coll_IDs, 'featured' => 1), false);
            // Run the query:
            $FeaturedList->query();
        }
    }
    // Get first Item in the result set.
    $Item = $FeaturedList->get_item();
    if ($Item) {
        // Memorize that ID so that it can later be filtered out of normal display:
        $featured_displayed_item_IDs[] = $Item->ID;
    }
    return $Item;
}
Exemple #12
0
        $l_Blog =& $BlogCache->get_by_ID($blog);
        ?>
		<h3><a href="<?php 
        echo $l_Blog->gen_blogurl();
        ?>
" title="<?php 
        $l_Blog->disp('shortdesc', 'htmlattr');
        ?>
"><?php 
        $l_Blog->disp('name', 'htmlattr');
        ?>
</a></h3>
		<ul>
		<?php 
        // Get the 3 last posts for each blog:
        $BlogBList = new ItemList2($l_Blog, $l_Blog->get_timestamp_min(), $l_Blog->get_timestamp_max(), 3);
        $BlogBList->set_filters(array('order' => 'DESC', 'unit' => 'posts'));
        // Run the query:
        $BlogBList->query();
        while ($Item =& $BlogBList->get_item()) {
            ?>
				<li lang="<?php 
            $Item->lang();
            ?>
">
					<?php 
            $Item->issue_date(array('before' => ' ', 'after' => ' ', 'date_format' => '#'));
            $Item->title(array('link_type' => 'permalink'));
            ?>
					<span class="small">[<?php 
            $Item->lang();
Exemple #13
0
/**
 * Initialize list mode; Several actions need this.
 */
function init_list_mode()
{
    global $tab, $tab_type, $Blog, $UserSettings, $ItemList, $AdminUI;
    // set default itemslist param prefix
    $items_list_param_prefix = 'items_';
    if (param('p', 'integer', NULL) || param('title', 'string', NULL)) {
        // Single post requested, do not filter any post types. If the user
        // has clicked a post link on the dashboard and previously has selected
        // a tab which would filter this post, it wouldn't be displayed now.
        $tab = 'full';
        // in case of single item view params prefix must be empty
        $items_list_param_prefix = NULL;
    } else {
        // Store/retrieve preferred tab from UserSettings:
        $UserSettings->param_Request('tab', 'pref_browse_tab', 'string', NULL, true, true);
        $UserSettings->param_Request('tab_type', 'pref_browse_tab_type', 'string', NULL, true, true);
    }
    if ($tab == 'tracker' && !$Blog->get_setting('use_workflow')) {
        // Display workflow view only if it is enabled
        global $Messages;
        $Messages->add(T_('Workflow feature has not been enabled for this collection.'), 'note');
        $tab = 'full';
    }
    /*
     * Init list of posts to display:
     */
    load_class('items/model/_itemlist.class.php', 'ItemList2');
    if (!empty($tab) && !empty($items_list_param_prefix)) {
        // Use different param prefix for each tab
        $items_list_param_prefix .= substr($tab, 0, 7) . '_';
        //.utf8_strtolower( $tab_type ).'_';
    }
    // Set different filterset name for each different tab and tab_type
    $filterset_name = $tab == 'type' ? $tab . '_' . utf8_strtolower($tab_type) : $tab;
    // Create empty List:
    $ItemList = new ItemList2($Blog, NULL, NULL, $UserSettings->get('results_per_page'), 'ItemCache', $items_list_param_prefix, $filterset_name);
    // COPY (func)
    $ItemList->set_default_filters(array('visibility_array' => get_visibility_statuses('keys')));
    if ($Blog->get_setting('orderby') == 'RAND') {
        // Do not display random posts in backoffice for easy management
        $ItemList->set_default_filters(array('orderby' => 'datemodified'));
    }
    switch ($tab) {
        case 'full':
            $ItemList->set_default_filters(array('types' => NULL));
            // $AdminUI->breadcrumbpath_add( T_('All items'), '?ctrl=items&amp;blog=$blog$&amp;tab='.$tab.'&amp;filter=restore' );
            // require colorbox js
            require_js_helper('colorbox');
            $AdminUI->breadcrumbpath_add(T_('All'), '?ctrl=items&amp;blog=$blog$&amp;tab=full&amp;filter=restore');
            break;
        case 'manual':
            if ($Blog->get('type') != 'manual') {
                // Display this tab only for manual blogs
                global $admin_url;
                header_redirect($admin_url . '?ctrl=items&blog=' . $Blog->ID . '&tab=type&tab_type=posts&filter=restore');
            }
            global $ReqURI, $blog;
            init_field_editor_js(array('action_url' => $ReqURI . '&blog=' . $blog . '&order_action=update&order_data='));
            $AdminUI->breadcrumbpath_add(T_('Manual view'), '?ctrl=items&amp;blog=$blog$&amp;tab=' . $tab . '&amp;filter=restore');
            break;
        case 'type':
            // Filter a posts list by type
            $ItemList->set_default_filters(array('types' => get_item_types_by_tab($tab_type)));
            $AdminUI->breadcrumbpath_add(T_($tab_type), '?ctrl=items&amp;blog=$blog$&amp;tab=' . $tab . '&amp;tab_type=' . urlencode($tab_type) . '&amp;filter=restore');
            break;
        case 'tracker':
            // In tracker mode, we want a different default sort:
            $ItemList->set_default_filters(array('orderby' => 'priority', 'order' => 'ASC'));
            $AdminUI->breadcrumbpath_add(T_('Workflow view'), '?ctrl=items&amp;blog=$blog$&amp;tab=tracker&amp;filter=restore');
            $AdminUI->set_page_manual_link('workflow-features');
            // JS to edit priority of items from list view
            require_js('jquery/jquery.jeditable.js', 'rsc_url');
            break;
        default:
            // Delete the pref_browse_tab setting so that the default
            // (full) gets used the next time the user wants to browse
            // a blog and we don't run into the same error again.
            $UserSettings->delete('pref_browse_tab');
            $UserSettings->dbupdate();
            debug_die('Unknown filterset [' . $tab . ']');
    }
    // Init filter params:
    if (!$ItemList->load_from_Request()) {
        // If we could not init a filterset from request
        // typically happens when we could no fall back to previously saved filterset...
        // echo ' no filterset!';
    }
}
         // a block was dispalyed for this status
         $nb_blocks_displayed++;
     }
 }
 $posts_awaiting_moderation_content = ob_get_contents();
 ob_clean();
 if (!empty($posts_awaiting_moderation_content)) {
     echo '<div class="items_container evo_content_block">';
     echo $posts_awaiting_moderation_content;
     echo '</div>';
 }
 /*
  * RECENTLY EDITED
  */
 // Create empty List:
 $ItemList = new ItemList2($Blog, NULL, NULL);
 // Filter list:
 $ItemList->set_filters(array('visibility_array' => get_visibility_statuses('keys', array('trash')), 'orderby' => 'datemodified', 'order' => 'DESC', 'posts' => 5));
 // Get ready for display (runs the query):
 $ItemList->display_init();
 if ($ItemList->result_num_rows) {
     // We have recent edits
     $nb_blocks_displayed++;
     if ($current_User->check_perm('blog_post_statuses', 'edit', false, $Blog->ID)) {
         // We have permission to add a post with at least one status:
         $block_item_Widget->global_icon(T_('Write a new post...'), 'new', '?ctrl=items&amp;action=new&amp;blog=' . $Blog->ID, T_('New post') . ' &raquo;', 3, 4, array('class' => 'action_icon btn-primary'));
     }
     echo '<div class="items_container evo_content_block">';
     $block_item_Widget->title = T_('Recently edited');
     $block_item_Widget->disp_template_replaced('block_start');
     while ($Item =& $ItemList->get_item()) {
Exemple #15
0
/**
 * Search and score items
 *
 * @param string original search term
 * @param array all separated words from the search term
 * @param array all quoted parts from the search term
 * @param number max possible score
 */
function search_and_score_items($search_term, $keywords, $quoted_parts)
{
    global $DB, $Blog, $posttypes_perms;
    // Exclude from search: 'sidebar' type posts and from reserved type with ID 5000
    $filter_post_types = isset($posttypes_perms['sidebar']) ? $posttypes_perms['sidebar'] : array();
    $filter_post_types = array_merge($filter_post_types, array(5000));
    // Prepare filters:
    $search_ItemList = new ItemList2($Blog, $Blog->get_timestamp_min(), $Blog->get_timestamp_max(), '', 'ItemCache', 'search_item');
    $search_ItemList->set_filters(array('keywords' => $search_term, 'keyword_scope' => 'title,content,tags', 'phrase' => 'OR', 'types' => '-' . implode(',', $filter_post_types), 'orderby' => 'datemodified', 'order' => 'DESC', 'posts' => 1000));
    // Generate query from filters above and count results:
    $search_ItemList->query_init();
    // Make a custom search query:
    $search_query = 'SELECT DISTINCT post_ID, post_datemodified, post_title, post_content, user_login as creator_login, tag_name' . $search_ItemList->ItemQuery->get_from() . ' LEFT JOIN T_users ON post_creator_user_ID = user_ID' . $search_ItemList->ItemQuery->get_where() . $search_ItemList->ItemQuery->get_group_by() . $search_ItemList->ItemQuery->get_order_by() . $search_ItemList->ItemQuery->get_limit();
    // Run query:
    $query_result = $DB->get_results($search_query, OBJECT, 'Search items query');
    // Compute scores:
    $search_result = array();
    foreach ($query_result as $row) {
        $scores_map = array();
        $scores_map['title'] = score_text($row->post_title, $search_term, $keywords, $quoted_parts, 5);
        $scores_map['content'] = score_text($row->post_content, $search_term, $keywords, $quoted_parts);
        $scores_map['tags'] = score_tags($row->tag_name, $search_term, 4);
        if (!empty($search_term) && !empty($row->creator_login) && strpos($row->creator_login, $search_term) !== false) {
            $scores_map['creator_login'] = 5;
        }
        $scores_map['last_mod_date'] = score_date($row->post_datemodified);
        $final_score = $scores_map['title']['score'] + $scores_map['content']['score'] + $scores_map['tags']['score'] + (isset($scores_map['creator_login']) ? $scores_map['creator_login'] : 0) + $scores_map['last_mod_date'];
        $search_result[] = array('type' => 'item', 'score' => $final_score, 'ID' => $row->post_ID, 'scores_map' => $scores_map);
    }
    return $search_result;
}
Exemple #16
0
/**
 * Initialize list mode; Several actions need this.
 */
function init_list_mode()
{
    global $tab, $Blog, $UserSettings, $ItemList, $AdminUI, $posttypes_perms;
    // set default itemslist param prefix
    $items_list_param_prefix = 'items_';
    if (param('p', 'integer', NULL) || param('title', 'string', NULL)) {
        // Single post requested, do not filter any post types. If the user
        // has clicked a post link on the dashboard and previously has selected
        // a tab which would filter this post, it wouldn't be displayed now.
        $tab = 'full';
        // in case of single item view params prefix must be empty
        $items_list_param_prefix = NULL;
    } else {
        // Store/retrieve preferred tab from UserSettings:
        $UserSettings->param_Request('tab', 'pref_browse_tab', 'string', NULL, true, true);
    }
    /*
     * Init list of posts to display:
     */
    load_class('items/model/_itemlist.class.php', 'ItemList2');
    if (!empty($tab) && !empty($items_list_param_prefix)) {
        // Use different param prefix for each tab
        $items_list_param_prefix .= substr($tab, 0, 7) . '_';
    }
    // Create empty List:
    $ItemList = new ItemList2($Blog, NULL, NULL, $UserSettings->get('results_per_page'), 'ItemCache', $items_list_param_prefix, $tab);
    // COPY (func)
    $ItemList->set_default_filters(array('visibility_array' => get_visibility_statuses('keys')));
    if ($Blog->get_setting('orderby') == 'RAND') {
        // Do not display random posts in backoffice for easy management
        $ItemList->set_default_filters(array('orderby' => 'datemodified'));
    }
    switch ($tab) {
        case 'full':
            $ItemList->set_default_filters(array('types' => NULL));
            // $AdminUI->breadcrumbpath_add( T_('All items'), '?ctrl=items&amp;blog=$blog$&amp;tab='.$tab.'&amp;filter=restore' );
            // require colorbox js
            require_js_helper('colorbox');
            break;
        case 'manual':
            if ($Blog->get('type') != 'manual') {
                // Display this tab only for manual blogs
                global $admin_url;
                header_redirect($admin_url . '?ctrl=items&blog=' . $Blog->ID . '&tab=list&filter=restore');
            }
            $AdminUI->breadcrumbpath_add(T_('Manual Pages'), '?ctrl=items&amp;blog=$blog$&amp;tab=' . $tab . '&amp;filter=restore');
            break;
        case 'list':
            // Nothing special
            $AdminUI->breadcrumbpath_add(T_('Regular posts'), '?ctrl=items&amp;blog=$blog$&amp;tab=' . $tab . '&amp;filter=restore');
            break;
        case 'pages':
            $ItemList->set_default_filters(array('types' => implode(',', $posttypes_perms['page'])));
            $AdminUI->breadcrumbpath_add(T_('Pages'), '?ctrl=items&amp;blog=$blog$&amp;tab=' . $tab . '&amp;filter=restore');
            break;
        case 'intros':
            $ItemList->set_default_filters(array('types' => implode(',', $posttypes_perms['intro'])));
            $AdminUI->breadcrumbpath_add(T_('Intro posts'), '?ctrl=items&amp;blog=$blog$&amp;tab=' . $tab . '&amp;filter=restore');
            break;
        case 'podcasts':
            $ItemList->set_default_filters(array('types' => implode(',', $posttypes_perms['podcast'])));
            $AdminUI->breadcrumbpath_add(T_('Podcasts'), '?ctrl=items&amp;blog=$blog$&amp;tab=' . $tab . '&amp;filter=restore');
            break;
        case 'links':
            $ItemList->set_default_filters(array('types' => '3000'));
            $AdminUI->breadcrumbpath_add(T_('Links'), '?ctrl=items&amp;blog=$blog$&amp;tab=' . $tab . '&amp;filter=restore');
            break;
        case 'ads':
            $ItemList->set_default_filters(array('types' => '4000'));
            $AdminUI->breadcrumbpath_add(T_('Advertisements'), '?ctrl=items&amp;blog=$blog$&amp;tab=' . $tab . '&amp;filter=restore');
            break;
        case 'tracker':
            // In tracker mode, we want a different default sort:
            $ItemList->set_default_filters(array('orderby' => 'priority', 'order' => 'ASC'));
            break;
        default:
            // Delete the pref_browse_tab setting so that the default
            // (full) gets used the next time the user wants to browse
            // a blog and we don't run into the same error again.
            $UserSettings->delete('pref_browse_tab');
            $UserSettings->dbupdate();
            debug_die('Unknown filterset [' . $tab . ']');
    }
    // Init filter params:
    if (!$ItemList->load_from_Request()) {
        // If we could not init a filterset from request
        // typically happens when we could no fall back to previously saved filterset...
        // echo ' no filterset!';
    }
}
Exemple #17
0
 /**
  * Display a list of the posts for current chapter
  *
  * @param array params
  * @return string List with posts
  */
 function display_chapter_posts($params = array())
 {
     $params = array_merge(array('chapter_ID' => 0, 'item_start' => '<li>', 'item_end' => '</li>', 'class_selected' => 'selected', 'class_post' => 'post', 'chapters_items_mode' => 'std', 'display_children' => false, 'display_posts' => false), $params);
     global $DB, $Item, $Blog, $blog;
     if (empty($Blog) && !empty($blog)) {
         // Set Blog if it still doesn't exist
         $BlogCache =& get_BlogCache();
         $Blog =& $BlogCache->get_by_ID($blog, false);
     }
     if (empty($params['chapter_ID']) || empty($Blog)) {
         // No chapter ID, Exit here
         return;
     }
     if ($params['chapters_items_mode'] == 'order') {
         // Get all subchapters in this mode to following insertion into posts list below
         $sub_chapters = $this->get_chapters($params['chapter_ID']);
     }
     // Get the posts of current category
     $ItemList = new ItemList2($Blog, $Blog->get_timestamp_min(), $Blog->get_timestamp_max(), $Blog->get_setting('posts_per_page'));
     $ItemList->load_from_Request();
     $ItemList->set_filters(array('cat_array' => array($params['chapter_ID']), 'unit' => 'all'));
     $ItemList->query();
     $selected_item_ID = !empty($Item) && !empty($Item->ID) ? $Item->ID : 0;
     // Split items in two arrays to know what items are from main category and what items are from extra category
     $items_main = array();
     $items_extra = array();
     while ($cur_Item = $ItemList->get_item()) {
         if ($cur_Item->main_cat_ID == $params['chapter_ID']) {
             // Item is from main category
             $items_main[] = $cur_Item;
         } else {
             // Item is from extra catogry
             $items_extra[] = $cur_Item;
         }
     }
     // ---- Display Items from MAIN category ---- //
     $prev_item_order = 0;
     foreach ($items_main as $cur_Item) {
         if ($params['chapters_items_mode'] == 'order') {
             // In this mode we display the chapters inside a posts list
             foreach ($sub_chapters as $s => $sub_Chapter) {
                 // Loop through categories to find for current order
                 if ($sub_Chapter->get('order') <= $cur_Item->get('order') && $sub_Chapter->get('order') > $prev_item_order || $cur_Item->get('order') == 0 && $sub_Chapter->get('order') >= $cur_Item->get('order')) {
                     // Display chapter
                     $this->display_chapter_item(array_merge($params, array('Chapter' => $sub_Chapter)));
                     // Remove this chapter from array to avoid the duplicates
                     unset($sub_chapters[$s]);
                 }
             }
             // Save current post order for next iteration
             $prev_item_order = $cur_Item->get('order');
         }
         $classes = array('post');
         if ($selected_item_ID == $cur_Item->ID) {
             // This post is selected
             $classes[] = $params['class_selected'];
         }
         // Display a post
         if (empty($classes)) {
             echo $params['item_start'];
         } else {
             // Add attr "class" for item start tag
             echo str_replace('>', ' class="' . implode(' ', $classes) . '">', $params['item_start']);
         }
         // Display a permanent link to post
         $cur_Item->title(array('post_navigation' => 'same_category', 'nav_target' => $params['chapter_ID'], 'link_type' => 'permalink', 'link_class' => 'link'));
         //echo ' <span class="red">'.( $cur_Item->get('order') > 0 ? $cur_Item->get('order') : 'NULL').'</span>'.$params['item_end'];
         echo $params['item_end'];
     }
     if ($params['chapters_items_mode'] == 'order') {
         foreach ($sub_chapters as $s => $sub_Chapter) {
             // Loop through rest categories that have order more than last item
             $this->display_chapter_item(array_merge($params, array('Chapter' => $sub_Chapter)));
             // Remove this chapter from array to avoid the duplicates
             unset($sub_chapters[$s]);
         }
     }
     // ---- Display Items from EXTRA category ---- //
     foreach ($items_extra as $cur_Item) {
         $classes = array('post');
         if ($selected_item_ID == $cur_Item->ID) {
             // This post is selected
             $classes[] = $params['class_selected'];
         }
         // Display a post
         if (empty($classes)) {
             echo $params['item_start'];
         } else {
             // Add attr "class" for item start tag
             echo str_replace('>', ' class="' . implode(' ', $classes) . '">', $params['item_start']);
         }
         // Display a permanent link to post
         $cur_Item->title(array('post_navigation' => 'same_category', 'nav_target' => $params['chapter_ID'], 'link_type' => 'permalink', 'link_class' => 'link', 'before' => '<i>', 'after' => '</i>'));
         //echo ' <span class="red">'.( $cur_Item->get('order') > 0 ? $cur_Item->get('order') : 'NULL').'</span>'.$params['item_end'];
         echo $params['item_end'];
     }
 }
Exemple #18
0
<?php 
    // ------------------------------- END OF INTRO-FRONT POST -------------------------------
}
// --------------------------------- START OF POSTS -------------------------------------
// Display message if no post:
$params_no_content = array('before' => '<div class="msg_nothing">', 'after' => '</div>', 'msg_empty_logged_in' => T_('Sorry, there is nothing to display...'), 'msg_empty_not_logged_in' => T_('This site has no public contents.'));
// Get only root categories of this blog
$ChapterCache =& get_ChapterCache();
$chapters = $ChapterCache->get_chapters($Blog->ID, 0, true);
// Boolean var to know when at least one post is displayed
$no_content_to_display = true;
if (!empty($chapters)) {
    // Display the posts with chapters
    foreach ($chapters as $Chapter) {
        // Get the posts of current category
        $ItemList = new ItemList2($Blog, $Blog->get_timestamp_min(), $Blog->get_timestamp_max());
        $ItemList->set_filters(array('cat_array' => array($Chapter->ID), 'cat_modifier' => NULL, 'unit' => 'all'));
        $ItemList->query();
        if ($ItemList->result_num_rows > 0) {
            $no_content_to_display = false;
            ?>
<div class="posts_list">
	<div class="category_title clear"><h2><a href="<?php 
            echo $Chapter->get_permanent_url();
            ?>
"><?php 
            echo $Chapter->get('name');
            ?>
</a></h2></div>
<?php 
            while ($Item =& $ItemList->get_item()) {
Exemple #19
0
/**
 * Display a list of the posts for current chapter
 *
 * @param array params
 * @return string List with posts
 */
function manual_display_posts($params = array(), $level = 0)
{
    $params = array_merge(array('chapter_ID' => 0, 'chapters_items_mode' => 'std'), $params);
    global $DB, $Blog, $blog;
    if (empty($Blog) && !empty($blog)) {
        // Set Blog if it still doesn't exist
        $BlogCache =& get_BlogCache();
        $Blog =& $BlogCache->get_by_ID($blog, false);
    }
    if (empty($params['chapter_ID']) || empty($Blog)) {
        // No chapter ID, Exit here
        return;
    }
    if ($params['chapters_items_mode'] == 'order') {
        // Get all subchapters in this mode to following insertion into posts list below
        $sub_chapters = manual_get_chapters($params['chapter_ID']);
    }
    // Get the posts of current category
    $ItemList = new ItemList2($Blog, $Blog->get_timestamp_min(), $Blog->get_timestamp_max(), $Blog->get_setting('posts_per_page'));
    $ItemList->load_from_Request();
    $ItemList->set_filters(array('cat_array' => array($params['chapter_ID']), 'unit' => 'all'));
    $ItemList->query();
    // Split items in two arrays to know what items are from main category and what items are from extra category
    $items_main = array();
    $items_extra = array();
    while ($cur_Item = $ItemList->get_item()) {
        if ($cur_Item->main_cat_ID == $params['chapter_ID']) {
            // Item is from main category
            $items_main[] = $cur_Item;
        } else {
            // Item is from extra catogry
            $items_extra[] = $cur_Item;
        }
    }
    // ---- Display Items from MAIN category ---- //
    $prev_item_order = 0;
    foreach ($items_main as $cur_Item) {
        if ($params['chapters_items_mode'] == 'order') {
            // In this mode we display the chapters inside a posts list
            foreach ($sub_chapters as $s => $sub_Chapter) {
                // Loop through categories to find for current order
                if ($sub_Chapter->get('order') <= $cur_Item->get('order') && $sub_Chapter->get('order') > $prev_item_order || $cur_Item->get('order') == 0 && $sub_Chapter->get('order') >= $cur_Item->get('order')) {
                    // Display chapter
                    manual_display_chapter(array_merge($params, array('Chapter' => $sub_Chapter)), $level);
                    // Remove this chapter from array to avoid the duplicates
                    unset($sub_chapters[$s]);
                }
            }
            // Save current post order for next iteration
            $prev_item_order = $cur_Item->get('order');
        }
        manual_display_post_row($cur_Item, $level, array('post_navigation' => 'same_category', 'nav_target' => $params['chapter_ID'], 'link_type' => 'permalink', 'title_field' => 'urltitle'));
    }
    if ($params['chapters_items_mode'] == 'order') {
        foreach ($sub_chapters as $s => $sub_Chapter) {
            // Loop through rest categories that have order more than last item
            manual_display_chapter(array_merge($params, array('Chapter' => $sub_Chapter)), $level);
            // Remove this chapter from array to avoid the duplicates
            unset($sub_chapters[$s]);
        }
    }
    // ---- Display Items from EXTRA category ---- //
    foreach ($items_extra as $cur_Item) {
        manual_display_post_row($cur_Item, $level, array('post_navigation' => 'same_category', 'nav_target' => $params['chapter_ID'], 'link_type' => 'permalink', 'title_field' => 'urltitle', 'title_before' => '<i>', 'title_after' => '</i>'));
    }
}
Exemple #20
0
	<div class="bSideItem">
		<?php 
    $Blog_roll =& $BlogCache->get_by_ID(3, false);
    if (empty($Blog_roll)) {
        echo sprintf(T_('Blog #%d doesn\'t seem to exist.'), 3);
    } else {
        ?>
		<h3>#3: <a href="<?php 
        $Blog_roll->disp('blogurl', 'raw');
        ?>
"><?php 
        echo $Blog_roll->disp('name', 'htmlbody');
        ?>
</a></h3>
		<?php 
        $LinkblogList = new ItemList2($Blog_roll, $Blog_roll->get_timestamp_min(), $Blog_roll->get_timestamp_max(), $posts);
        $LinkblogList->set_filters(array('authors' => $author, 'ymdhms' => $m, 'week' => $w, 'order' => $order, 'orderby' => $orderby, 'unit' => $unit));
        // Run the query:
        $LinkblogList->query();
        while ($Item =& $LinkblogList->get_item()) {
            ?>
			<div id="<?php 
            $Item->anchor_id();
            ?>
" class="bPostSide bPostSide<?php 
            $Item->status_raw();
            ?>
" lang="<?php 
            $Item->lang();
            ?>
">
Exemple #21
0
/**
 * Initialize list mode; Several actions need this.
 */
function init_list_mode()
{
    global $tab, $Blog, $UserSettings, $ItemList;
    // Store/retrieve preferred tab from UserSettings:
    $UserSettings->param_Request('tab', 'pref_browse_tab', 'string', NULL, true);
    /*
     * Init list of posts to display:
     */
    load_class('items/model/_itemlist.class.php');
    // Create empty List:
    $ItemList = new ItemList2($Blog, NULL, NULL, $UserSettings->get('results_per_page'));
    // COPY (func)
    $ItemList->set_default_filters(array('visibility_array' => array('published', 'protected', 'private', 'draft', 'deprecated', 'redirected'), 'types' => NULL));
    if ($tab == 'tracker') {
        // In tracker mode, we want a different default sort:
        $ItemList->set_default_filters(array('orderby' => 'priority', 'order' => 'ASC'));
    }
    // Init filter params:
    if (!$ItemList->load_from_Request()) {
        // If we could not init a filterset from request
        // typically happens when we could no fall back to previously saved filterset...
        // echo ' no filterset!';
    }
}