예제 #1
0
/**
 * Generate category line when it has children
 *
 * @param Chapter generic category we want to display
 * @param int level of the category in the recursive tree
 * @return string HTML
 */
function cat_line($Chapter, $level)
{
    global $line_class, $result_fadeout, $permission_to_edit, $current_User, $Settings;
    global $GenericCategoryCache;
    $line_class = $line_class == 'even' ? 'odd' : 'even';
    $r = '<tr id="tr-' . $Chapter->ID . '"class="' . $line_class . (isset($result_fadeout[$GenericCategoryCache->dbIDname]) && in_array($Chapter->ID, $result_fadeout[$GenericCategoryCache->dbIDname]) ? ' fadeout-ffff00' : '') . '">
					<td class="firstcol shrinkwrap">' . $Chapter->ID . '
				</td>';
    if ($permission_to_edit) {
        // We have permission permission to edit:
        $edit_url = regenerate_url('action,' . $Chapter->dbIDname, $Chapter->dbIDname . '=' . $Chapter->ID . '&amp;action=edit');
        $r .= '<td>
						<strong style="padding-left: ' . $level . 'em;"><a href="' . $edit_url . '" title="' . T_('Edit...') . '">' . $Chapter->dget('name') . '</a></strong>
					 </td>';
    } else {
        $r .= '<td>
						 <strong style="padding-left: ' . $level . 'em;">' . $Chapter->dget('name') . '</strong>
					 </td>';
    }
    $r .= '<td>' . $Chapter->dget('urlname') . '</td>';
    $r .= '<td class="lastcol shrinkwrap">';
    if ($permission_to_edit) {
        // We have permission permission to edit, so display action column:
        $r .= action_icon(T_('New...'), 'new', regenerate_url('action,cat_ID,cat_parent_ID', 'cat_parent_ID=' . $Chapter->ID . '&amp;action=new')) . action_icon(T_('Edit...'), 'edit', $edit_url);
        if ($Settings->get('allow_moving_chapters')) {
            // If moving cats between blogs is allowed:
            $r .= action_icon(T_('Move to a different blog...'), 'file_move', regenerate_url('action,cat_ID', 'cat_ID=' . $Chapter->ID . '&amp;action=move'), T_('Move'));
        }
        $r .= action_icon(T_('Delete...'), 'delete', regenerate_url('action,cat_ID', 'cat_ID=' . $Chapter->ID . '&amp;action=delete'));
    }
    $r .= '</td>';
    $r .= '</tr>';
    return $r;
}
예제 #2
0
 /**
  * Display list/table start preceeded by <form> opening.
  */
 function display_list_start()
 {
     global $item_ID_array, $current_User;
     if (!$current_User->check_perm('selections', 'view')) {
         // User is NOT allowed to view selections
         // Don't do any more then base class:
         parent::display_list_start();
         return;
     }
     $this->Form = new Form(regenerate_url('', '', '', '&'), $this->param_prefix . 'selections_checkchanges', 'post', 'none');
     // COPY!!
     $this->Form->begin_form('');
     if ($this->total_pages > 0) {
         // We have rows to display, we want the selection stuff:
         // Need it to check in the next page if the selection has to be updated
         $this->Form->hidden($this->param_prefix . 'previous_sel_ID', $this->current_selection_ID);
         // Sets the cols_check global variable to verify if checkboxes
         // have to be checked in the result set :
         cols_check($this->current_selection_ID, $this->table_objsel, $this->field_selected, $this->field_selection);
         // item_ID_array must be emptied to avoid conflicts with previous result sets :
         // TODO: put this into object
         $item_ID_array = array();
     }
     // list/table start:
     parent::display_list_start();
 }
 /**
  * Get actions links for IP range
  *
  * @param integer IP range ID
  * @param string Current tab value
  * @return string HTML links to edit and delete IP range
  */
 function antispam_ipranges_actions($aipr_ID, $tab_param)
 {
     global $admin_url;
     // A link to edit IP range
     $r = action_icon(T_('Edit this IP range...'), 'properties', $admin_url . '?ctrl=antispam' . $tab_param . '&amp;tab3=ipranges&amp;iprange_ID=' . $aipr_ID . '&amp;action=iprange_edit');
     // A link to delete IP range
     $r .= action_icon(T_('Delete this IP range!'), 'delete', regenerate_url('iprange_ID,action', 'iprange_ID=' . $aipr_ID . '&amp;action=iprange_delete&amp;' . url_crumb('iprange')));
     return $r;
 }
예제 #4
0
 function edit_actions($ID)
 {
     global $locked_IDs, $GenericElementCache;
     $r = action_icon(T_('Duplicate...'), 'copy', regenerate_url('action,' . $GenericElementCache->dbIDname, $GenericElementCache->dbIDname . '=' . $ID . '&amp;action=copy'));
     if (empty($locked_IDs) || !in_array($ID, $locked_IDs)) {
         // This element is NOT locked:
         $r = action_icon(T_('Edit...'), 'edit', regenerate_url('action,' . $GenericElementCache->dbIDname, $GenericElementCache->dbIDname . '=' . $ID . '&amp;action=edit')) . $r . action_icon(T_('Delete!'), 'delete', regenerate_url('action,' . $GenericElementCache->dbIDname, $GenericElementCache->dbIDname . '=' . $ID . '&amp;action=delete'));
     }
     return $r;
 }
예제 #5
0
function file_actions($link_ID)
{
    global $current_File, $edited_Item, $current_User;
    $title = T_('Locate this file!');
    $r = $current_File->get_linkedit_link('&amp;fm_mode=link_item&amp;item_ID=' . $edited_Item->ID, get_icon('locate', 'imgtag', array('title' => $title)), $title);
    if ($current_User->check_perm('item', 'edit', false, $edited_Item)) {
        // Check that we have permission to edit item:
        $r .= action_icon(T_('Delete this link!'), 'unlink', regenerate_url('action', 'link_ID=' . $link_ID . '&amp;action=unlink'));
    }
    return $r;
}
예제 #6
0
 function tagitem_edit_actions($Item)
 {
     global $current_User, $edited_ItemTag;
     // Display the edit icon if current user has the rights:
     $r = $Item->get_edit_link(array('before' => '', 'after' => ' ', 'text' => get_icon('edit'), 'title' => '#', 'class' => ''));
     if ($current_User->check_perm('item_post!CURSTATUS', 'edit', false, $Item)) {
         // Display the unlink icon if current user has the rights:
         $r .= action_icon(T_('Unlink this tag from post!'), 'unlink', regenerate_url('tag_ID,action,tag_filter', 'tag_ID=' . $edited_ItemTag->ID . '&amp;item_ID=' . $Item->ID . '&amp;action=unlink&amp;' . url_crumb('tag')), NULL, NULL, NULL, array('onclick' => 'return confirm(\'' . format_to_output(sprintf(TS_('Are you sure you want to remove the tag "%s" from "%s"?'), $edited_ItemTag->dget('name'), $Item->dget('title')) . '\');', 'htmlattr')));
     }
     return $r;
 }
예제 #7
0
/**
 * Callback to make item type name depending on item type id
 *
 */
function get_name_for_itemtype($id, $name)
{
    global $reserved_ids;
    if ($id < $reserved_ids[0] || $id > $reserved_ids[1]) {
        // not reserved id
        $ret_name = '<strong><a href="' . regenerate_url('action,ID', 'ptyp_ID=' . $id . '&amp;action=edit') . '">' . $name . '</a></strong>';
    } else {
        $ret_name = '<strong>' . $name . '</strong>';
    }
    return $ret_name;
}
예제 #8
0
/**
 * Callback to make post type name depending on post type id
 *
 */
function get_name_for_itemtype($id, $name)
{
    global $current_User;
    if (!ItemType::is_reserved($id) && $current_User->check_perm('options', 'edit')) {
        // Not reserved id AND current User has permission to edit the global settings
        $ret_name = '<a href="' . regenerate_url('action,ID', 'ityp_ID=' . $id . '&amp;action=edit') . '">' . $name . '</a>';
    } else {
        $ret_name = $name;
    }
    return '<strong>' . $ret_name . '</strong>';
}
예제 #9
0
function curr_td_actions($curr_enabled, $curr_ID)
{
    global $dispatcher;
    $r = '';
    if ($curr_enabled == true) {
        $r .= action_icon(T_('Disable the currency!'), 'deactivate', regenerate_url('action', 'action=disable_currency&amp;curr_ID=' . $curr_ID . '&amp;' . url_crumb('currency')));
    } else {
        $r .= action_icon(T_('Enable the currency!'), 'activate', regenerate_url('action', 'action=enable_currency&amp;curr_ID=' . $curr_ID . '&amp;' . url_crumb('currency')));
    }
    $r .= action_icon(T_('Edit this currency...'), 'edit', regenerate_url('action', 'curr_ID=' . $curr_ID . '&amp;action=edit'));
    $r .= action_icon(T_('Duplicate this currency...'), 'copy', regenerate_url('action', 'curr_ID=' . $curr_ID . '&amp;action=new'));
    $r .= action_icon(T_('Delete this currency!'), 'delete', regenerate_url('action', 'curr_ID=' . $curr_ID . '&amp;action=delete&amp;' . url_crumb('currency')));
    return $r;
}
예제 #10
0
function grp_actions(&$row)
{
    global $usedgroups, $Settings, $current_User;
    $r = '';
    if ($current_User->check_perm('users', 'edit', false)) {
        $r = action_icon(T_('Edit this group...'), 'edit', regenerate_url('ctrl,action', 'ctrl=groups&amp;action=edit&amp;grp_ID=' . $row->grp_ID));
        $r .= action_icon(T_('Duplicate this group...'), 'copy', regenerate_url('ctrl,action', 'ctrl=groups&amp;action=new&amp;grp_ID=' . $row->grp_ID));
        if ($row->grp_ID != 1 && $row->grp_ID != $Settings->get('newusers_grp_ID') && !in_array($row->grp_ID, $usedgroups)) {
            // delete
            $r .= action_icon(T_('Delete this group!'), 'delete', regenerate_url('ctrl,action', 'ctrl=groups&amp;action=delete&amp;grp_ID=' . $row->grp_ID . '&amp;' . url_crumb('group')));
        } else {
            $r .= get_icon('delete', 'noimg');
        }
    }
    return $r;
}
예제 #11
0
    /**
     * Event handler: SkinTag (widget)
     *
     * @param array Associative array of parameters.
     * @return boolean did we display?
     */
    function SkinTag($params)
    {
        /**
         * Default params:
         */
        $params = array_merge(array('block_start' => '<div class="bSideItem">', 'block_end' => "</div>\n", 'block_body_start' => '', 'block_body_end' => ''), $params);
        global $baseurlroot;
        //$test_url = url_absolute( regenerate_url( '', '', '', '&' ), 'http://127.0.0.1' );
        $current_url = url_absolute(regenerate_url('', '', '', '&'), $baseurlroot);
        echo $params['block_start'];
        echo $params['block_body_start'];
        echo '<iframe src="http://www.facebook.com/plugins/like.php?href=' . urlencode($current_url) . '&amp;layout=standard&amp;show_faces=true&amp;width=190&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=66" 
					scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:190px; height:66px;" 
					allowTransparency="true"></iframe>';
        echo $params['block_body_end'];
        echo $params['block_end'];
        return true;
    }
/**
 * Generate category line when it has children
 *
 * @param GenericCategory generic category we want to display
 * @param int level of the category in the recursive tree
 * @return string HTML
 */
function cat_line($GenericCategory, $level)
{
    global $line_class, $result_fadeout, $permission_to_edit, $current_User;
    $line_class = $line_class == 'even' ? 'odd' : 'even';
    $r = '<tr id="tr-' . $GenericCategory->ID . '"class="' . $line_class . (in_array($GenericCategory->ID, $result_fadeout) ? ' fadeout-ffff00' : '') . '">
					<td class="firstcol shrinkwrap">' . $GenericCategory->ID . '
					</td>';
    if ($permission_to_edit) {
        // We have permission permission to edit, so display action column:
        $edit_url = regenerate_url('action,' . $GenericCategory->dbIDname, $GenericCategory->dbIDname . '=' . $GenericCategory->ID . '&amp;action=edit');
        $r .= '<td>
						<label style="padding-left: ' . $level . 'em;"><a href="' . $edit_url . '" title="' . T_('Edit...') . '">' . $GenericCategory->name . '</a></label>
					 </td>
					 <td class="lastcol shrinkwrap">' . action_icon(T_('New...'), 'new', regenerate_url('action,' . $GenericCategory->dbIDname . ',' . $GenericCategory->dbprefix . 'parent_ID', $GenericCategory->dbprefix . 'parent_ID=' . $GenericCategory->ID . '&amp;action=new')) . action_icon(T_('Edit...'), 'edit', $edit_url) . action_icon(T_('Delete...'), 'delete', regenerate_url('action,' . $GenericCategory->dbIDname, $GenericCategory->dbIDname . '=' . $GenericCategory->ID . '&amp;action=delete&amp;' . url_crumb('element'))) . '
					 </td>';
    } else {
        $r .= '<td class="lastcol">
						 <label style="padding-left: ' . $level . 'em;">' . $GenericCategory->name . '</label>
					 </td>';
    }
    $r .= '</tr>';
    return $r;
}
예제 #13
0
/**
 * Get block/unblock icon
 *
 * @param block value
 * @param user ID
 * @return icon
 */
function contact_block($block, $user_ID, $user_status)
{
    if ($user_status == 'closed') {
        return '';
    }
    // set action url
    $action_url = regenerate_url();
    if (!is_admin_page()) {
        // in front office the action will be processed by messaging module handle_htsrv_action() through action.php
        $action_url = get_samedomain_htsrv_url() . 'action.php?mname=messaging&disp=contacts&redirect_to=' . rawurlencode($action_url);
    }
    if ($block == 0) {
        return action_icon(T_('Block contact'), 'file_allowed', $action_url . '&action=block&user_ID=' . $user_ID . '&amp;' . url_crumb('messaging_contacts'));
    } else {
        return action_icon(T_('Unblock contact'), 'file_not_allowed', $action_url . '&action=unblock&user_ID=' . $user_ID . '&amp;' . url_crumb('messaging_contacts'));
    }
}
예제 #14
0
// Create result set:
$Results = new Results($SQL->get(), 'goals_', '-A');
$Results->Cache =& get_GoalCache();
$Results->title = T_('Goals') . get_manual_link('goal-settings');
/**
 * Callback to add filters on top of the result set
 *
 * @param Form
 */
function filter_goals(&$Form)
{
    $Form->checkbox_basic_input('final', get_param('final'), T_('Final only') . ' &bull;');
    $Form->text('s', get_param('s'), 30, T_('Search'), '', 255);
    $GoalCategoryCache =& get_GoalCategoryCache(NT_('All'));
    $GoalCategoryCache->load_all();
    $Form->select_input_object('cat', get_param('cat'), $GoalCategoryCache, T_('Category'), array('allow_none' => true));
}
$Results->filter_area = array('callback' => 'filter_goals', 'url_ignore' => 'results_goals_page,final', 'presets' => array('all' => array(T_('All'), '?ctrl=goals&amp;blog=' . $blog . '&amp;final=0&amp;s=&amp;cat=0'), 'final' => array(T_('Final'), '?ctrl=goals&amp;blog=' . $blog . '&amp;final=1')));
$Results->cols[] = array('th' => T_('ID'), 'order' => 'goal_ID', 'td_class' => 'center', 'td' => '$goal_ID$');
$Results->cols[] = array('th' => T_('Name'), 'order' => 'goal_name', 'td' => $perm_options_edit ? '<a href="' . $admin_url . '?ctrl=goals&amp;action=edit&amp;blog=' . $blog . '&amp;goal_ID=$goal_ID$" style="color:$gcat_color$~conditional( #gcat_color# == "", "", ";font-weight:bold" )~">$goal_name$</a>' : '<span style="color:$gcat_color$~conditional( #gcat_color# == "", "", ";font-weight:bold" )~">$goal_name$</span>');
$Results->cols[] = array('th' => T_('Category'), 'order' => 'gcat_name', 'td' => $perm_options_edit ? '<a href="' . $admin_url . '?ctrl=goals&amp;tab3=cats&amp;action=cat_edit&amp;blog=' . $blog . '&amp;gcat_ID=$goal_gcat_ID$" style="color:$gcat_color$">$gcat_name$</a>' : '<span style="color:$gcat_color$">$gcat_name$</span>', 'extra' => array('style' => 'color:#gcat_color#'));
$Results->cols[] = array('th' => T_('Key'), 'order' => 'goal_key', 'td' => '@action_link( "edit", #goal_key# )@');
$Results->cols[] = array('th' => T_('Redirect to'), 'order' => 'goal_redir_url', 'td_class' => 'small', 'td' => '<a href="%{Obj}->get_active_url()%">%{Obj}->get_active_url( array( "before_temp" => "<b>", "after_temp" => "</b>" ) )%</a>');
$Results->cols[] = array('th' => T_('Def. val.'), 'order' => 'goal_default_value', 'td_class' => 'right', 'td' => '$goal_default_value$');
if ($perm_options_edit) {
    // We have permission to modify:
    $Results->cols[] = array('th' => T_('Actions'), 'th_class' => 'shrinkwrap', 'td_class' => 'shrinkwrap', 'td' => '@action_icon("edit")@@action_icon("copy")@@action_icon("delete")@');
    $Results->global_icon(T_('Create a new goal...'), 'new', regenerate_url('action', 'action=new'), T_('New goal') . ' &raquo;', 3, 4, array('class' => 'action_icon btn-primary'));
}
// Display results:
$Results->display();
예제 #15
0
    echo '<li><a href="' . regenerate_url('action', 'action=utf8check&amp;' . url_crumb('tools')) . '">' . T_('Check/Convert/Normalize the charsets/collations used by the DB (UTF-8 / ASCII)') . '</a></li>';
    // echo '<li><a href="'.regenerate_url('action', 'action=backup_db').'">'.T_('Backup database').'</a></li>';
    echo '</ul>';
    $block_item_Widget->disp_template_raw('block_end');
    $block_item_Widget->title = T_('Cleanup tools');
    $block_item_Widget->disp_template_replaced('block_start');
    echo '<ul>';
    echo '<li><a href="' . $admin_url . '?ctrl=itemtags&amp;action=cleanup&amp;' . url_crumb('tag') . '">' . T_('Find and delete all orphan Tag entries (not used anywhere) - DB only.') . '</a></li>';
    echo '<li><a href="' . regenerate_url('action', 'action=find_broken_posts&amp;' . url_crumb('tools')) . '">' . T_('Find all broken posts (with no matching Category) + Option to delete with related objects - DB only.') . '</a></li>';
    echo '<li><a href="' . regenerate_url('action', 'action=find_broken_slugs&amp;' . url_crumb('tools')) . '">' . T_('Find all broken slugs (with no matching Item) + Option to delete - DB only.') . '</a></li>';
    echo '<li><a href="' . regenerate_url('action', 'action=delete_orphan_comments&amp;' . url_crumb('tools')) . '">' . T_('Find and delete all orphan Comments (with no matching Item) - Disk &amp; DB.') . '</a></li>';
    echo '<li><a href="' . regenerate_url('action', 'action=delete_orphan_comment_uploads&amp;' . url_crumb('tools')) . '">' . T_('Find and delete all orphan comment Uploads - Disk &amp; DB.') . '</a></li>';
    echo '<li><a href="' . regenerate_url('action', 'action=delete_orphan_files&amp;' . url_crumb('tools')) . '">' . T_('Find and delete all orphan File objects (with no matching file on disk) - DB only.') . '</a></li>';
    echo '<li><a href="' . regenerate_url('action', 'action=delete_orphan_file_roots&amp;' . url_crumb('tools')) . '">' . T_('Find and delete all orphan file roots (with no matching Collection or User) and all of their content recursively - Disk &amp; DB.') . '</a></li>';
    echo '<li><a href="' . regenerate_url('action', 'action=prune_hits_sessions&amp;' . url_crumb('tools')) . '">' . T_('Prune old hits &amp; sessions (includes OPTIMIZE) - DB only.') . '</a></li>';
    echo '<li><a href="' . regenerate_url('action', 'action=recreate_itemslugs&amp;' . url_crumb('tools')) . '">' . T_('Recreate all item Slugs (change title-[0-9] canonical slugs to a slug generated from current title). Old slugs will still work, but will redirect to the new ones - DB only.') . '</a></li>';
    echo '<li><a href="' . regenerate_url('action', 'action=recreate_autogenerated_excerpts&amp;' . url_crumb('tools')) . '">' . T_('Recreate autogenerated excerpts - DB only.') . '</a></li>';
    echo '<li><a href="' . regenerate_url('action', 'action=convert_item_content_separators&amp;' . url_crumb('tools')) . '">' . T_('Convert item content separators to [teaserbreak] and [pagebreak] - DB only.') . '</a></li>';
    echo '</ul>';
    $block_item_Widget->disp_template_raw('block_end');
}
// We should load GeoIP plugin here even if it is disabled now, because action 'geoip_download' may be requested
$Plugins->load_plugin_by_classname('geoip_plugin');
// Event AdminToolPayload for each Plugin:
$tool_plugins = $Plugins->get_list_by_event('AdminToolPayload');
foreach ($tool_plugins as $loop_Plugin) {
    $block_item_Widget->title = format_to_output($loop_Plugin->name);
    $block_item_Widget->disp_template_replaced('block_start');
    $Plugins->call_method_if_active($loop_Plugin->ID, 'AdminToolPayload', $params = array());
    $block_item_Widget->disp_template_raw('block_end');
}
예제 #16
0
     }
     if ($action == 'disable_country_pref') {
         // Disable this country by setting flag to false.
         $edited_Country->set('preferred', 0);
         $Messages->add(sprintf(T_('Removed from preferred countries (%s, #%d).'), $edited_Country->name, $edited_Country->ID), 'success');
     } elseif ($action == 'enable_country_pref') {
         // Enable country by setting flag to true.
         $edited_Country->set('preferred', 1);
         $Messages->add(sprintf(T_('Added to preferred countries (%s, #%d).'), $edited_Country->name, $edited_Country->ID), 'success');
     }
     // Update db with new flag value.
     $edited_Country->dbupdate();
     param('results_ctry_page', 'integer', '', true);
     param('results_ctry_order', 'string', '', true);
     // Redirect so that a reload doesn't write to the DB twice:
     header_redirect(regenerate_url('', '', '', '&'), 303);
     // Will EXIT
     // We have EXITed already at this point!!
     break;
 case 'new':
     // Check permission:
     $current_User->check_perm('options', 'edit', true);
     if (!isset($edited_Country)) {
         // We don't have a model to use, start with blank object:
         $edited_Country = new Country();
     } else {
         // Duplicate object in order no to mess with the cache:
         $edited_Country = duplicate($edited_Country);
         // PHP4/5 abstraction
         $edited_Country->ID = 0;
     }
예제 #17
0
            // get the type of the removable sender customization
            $type = param('type', 'string', true);
            // Set remove custom settings query
            $remove_query = 'DELETE FROM T_users__usersettings WHERE uset_name = "%s" AND uset_value != %s';
            if ($type == 'sender_email') {
                // Remove custom sender emails
                $DB->query(sprintf($remove_query, 'notification_sender_email', $DB->quote($Settings->get('notification_sender_email'))));
            } elseif ($type == 'sender_name') {
                // Remove custom sender names
                $DB->query(sprintf($remove_query, 'notification_sender_name', $DB->quote($Settings->get('notification_sender_name'))));
            } else {
                // The customization param is not valid
                debug_die('Invalid remove sender customization action!');
            }
            $Messages->add(T_('Customizations have been removed!'), 'success');
            $redirect_to = param('redirect_to', 'url', regenerate_url('action'));
            // Redirect so that a reload doesn't write to the DB twice:
            header_redirect($redirect_to);
            /* EXITED */
            break;
        case 'remove_report':
            // Remove one report on user:
            // Check that this action request is not a CSRF hacked request:
            $Session->assert_received_crumb('users');
            $reporter_ID = param('reporter_ID', 'integer', true);
            // Remove the report from DB:
            $DB->query('DELETE FROM T_users__reports
					WHERE urep_target_user_ID = ' . $DB->quote($edited_User->ID) . '
					  AND urep_reporter_ID = ' . $DB->quote($reporter_ID));
            $Messages->add(T_('The report has been removed!'), 'success');
            // Redirect so that a reload doesn't write to the DB twice:
예제 #18
0
 /**
  * Return links to check and uncheck all check boxes of the form
  */
 function check_all()
 {
     // Need to add event click on links at the form end.
     $this->check_all = true;
     $r = '<span class="btn-group">';
     // fp> This is "name=" and I mean it!!! The JS is looking for all elements with this name!
     $r .= '<a name="check_all_nocheckchanges" href="' . regenerate_url() . '" class="btn btn-default">' . get_icon('check_all', 'imgtag', NULL, true) . '</a> <a name="uncheck_all_nocheckchanges" href="' . regenerate_url() . '" class="btn btn-default">' . get_icon('uncheck_all', 'imgtag', NULL, true) . '</a> ' . '&nbsp;';
     $r .= '</span>';
     return $r;
 }
예제 #19
0
/**
 * @param string Title of the container. This gets passed to T_()!
 * @param string Suffix of legend
 */
function display_container($container, $legend_suffix = '')
{
    global $Blog;
    global $Session;
    $Table = new Table();
    $Table->title = '<span class="container_name">' . T_($container) . '</span>' . $legend_suffix;
    // Table ID - fp> needs to be handled cleanly by Table object
    $table_id = str_replace(' ', '_', $container);
    // fp> Using the container name which has special chars is a bad idea. Counter would be better
    $Table->global_icon(T_('Add a widget...'), 'new', regenerate_url('', 'action=new&amp;container=' . rawurlencode($container)), T_('Add widget') . ' &raquo;', 3, 4, array('id' => 'add_new_' . $table_id));
    $Table->cols = array(array('th' => T_('En'), 'th_class' => 'shrinkwrap', 'td_class' => 'shrinkwrap'), array('th' => T_('Widget')), array('th' => T_('Type')), array('th' => T_('Move'), 'th_class' => 'shrinkwrap', 'td_class' => 'shrinkwrap'), array('th' => T_('Actions'), 'th_class' => 'shrinkwrap', 'td_class' => 'shrinkwrap'));
    //enable fadeouts here
    $Table->display_init(NULL, array('fadeouts' => true));
    // add ID for jQuery
    // TODO: fp> Awfully dirty. This should be handled by the Table object
    $Table->params['list_start'] = str_replace('<table', '<table id="' . $table_id . '"', $Table->params['list_start']);
    /*
    if( $legend_suffix )
    {	// add jQuery no-drop -- fp> what do we need this one for?
    	$Table->params['head_title'] = str_replace( 'class="grouped"', 'class="grouped no-drop"', $Table->params['head_title'] );
    }
    */
    $Table->display_list_start();
    // TITLE / COLUMN HEADERS:
    $Table->display_head();
    // BODY START:
    $Table->display_body_start();
    /**
     * @var WidgetCache
     */
    $WidgetCache =& get_WidgetCache();
    $Widget_array =& $WidgetCache->get_by_coll_container($Blog->ID, $container);
    if (empty($Widget_array)) {
        // TODO: cleanup
        $Table->display_line_start(true);
        $Table->display_col_start(array('colspan' => 5));
        echo '<span class="new_widget">' . T_('There is no widget in this container yet.') . '</span>';
        $Table->display_col_end();
        $Table->display_line_end();
    } else {
        $widget_count = 0;
        foreach ($Widget_array as $ComponentWidget) {
            $widget_count++;
            $enabled = $ComponentWidget->get('enabled');
            $fadeout_id = $Session->get('fadeout_id');
            if (isset($fadeout_id) && $ComponentWidget->ID == $fadeout_id) {
                $fadeout = true;
                $Session->delete('fadeout_id');
            } else {
                $fadeout = false;
            }
            $Table->display_line_start(false, $fadeout);
            $Table->display_col_start();
            if ($enabled) {
                // Indicator for the JS UI:
                echo '<span class="widget_is_enabled">';
                echo get_icon('enabled', 'imgtag', array('title' => T_('The widget is enabled.')));
                echo '</span>';
            } else {
                echo get_icon('disabled', 'imgtag', array('title' => T_('The widget is disabled.')));
            }
            $Table->display_col_end();
            $Table->display_col_start();
            $ComponentWidget->init_display(array());
            echo '<a href="' . regenerate_url('blog', 'action=edit&amp;wi_ID=' . $ComponentWidget->ID) . '" class="widget_name">' . $ComponentWidget->get_desc_for_list() . '</a>';
            $Table->display_col_end();
            // Note: this is totally useless, but we need more cols for the screen to feel "right":
            $Table->display_col_start();
            echo $ComponentWidget->type;
            $Table->display_col_end();
            // Move
            $Table->display_col_start();
            //echo $ComponentWidget->order.' ';
            if ($widget_count > 1) {
                echo action_icon(T_('Move up!'), 'move_up', regenerate_url('blog', 'action=move_up&amp;wi_ID=' . $ComponentWidget->ID . '&amp;' . url_crumb('widget')));
            } else {
                echo get_icon('nomove', 'imgtag', array('class' => 'action_icon'));
            }
            if ($widget_count < count($Widget_array)) {
                echo action_icon(T_('Move down!'), 'move_down', regenerate_url('blog', 'action=move_down&amp;wi_ID=' . $ComponentWidget->ID . '&amp;' . url_crumb('widget')));
            } else {
                echo get_icon('nomove', 'imgtag', array('class' => 'action_icon'));
            }
            $Table->display_col_end();
            // Actions
            $Table->display_col_start();
            if ($enabled) {
                echo action_icon(T_('Disable this widget!'), 'deactivate', regenerate_url('blog', 'action=toggle&amp;wi_ID=' . $ComponentWidget->ID . '&amp;' . url_crumb('widget')));
            } else {
                echo action_icon(T_('Enable this widget!'), 'activate', regenerate_url('blog', 'action=toggle&amp;wi_ID=' . $ComponentWidget->ID . '&amp;' . url_crumb('widget')));
            }
            echo '<span class="edit_icon_hook">' . action_icon(T_('Edit widget settings!'), 'edit', regenerate_url('blog', 'action=edit&amp;wi_ID=' . $ComponentWidget->ID)) . '</span>';
            echo '<span class="delete_icon_hook">' . action_icon(T_('Remove this widget!'), 'delete', regenerate_url('blog', 'action=delete&amp;wi_ID=' . $ComponentWidget->ID . '&amp;' . url_crumb('widget'))) . '</span>';
            $Table->display_col_end();
            $Table->display_line_end();
        }
    }
    // BODY END:
    $Table->display_body_end();
    $Table->display_list_end();
}
예제 #20
0
function ctry_td_actions($ctry_enabled, $ctry_ID)
{
    $r = '';
    $redirect_ctrl = param('ctrl', 'string', 'countries');
    if ($ctry_enabled == true) {
        $r .= action_icon(T_('Disable the country!'), 'deactivate', regenerate_url('ctrl,action', 'ctrl=countries&amp;action=disable_country&amp;ctry_ID=' . $ctry_ID . '&amp;redirect_ctrl=' . $redirect_ctrl . '&amp;' . url_crumb('country')));
    } else {
        $r .= action_icon(T_('Enable the country!'), 'activate', regenerate_url('ctrl,action', 'ctrl=countries&amp;action=enable_country&amp;ctry_ID=' . $ctry_ID . '&amp;redirect_ctrl=' . $redirect_ctrl . '&amp;' . url_crumb('country')));
    }
    $r .= action_icon(T_('Edit this country...'), 'edit', regenerate_url('ctrl,action', 'ctrl=countries&amp;ctry_ID=' . $ctry_ID . '&amp;action=edit'));
    $r .= action_icon(T_('Duplicate this country...'), 'copy', regenerate_url('ctrl,action', 'ctrl=countries&amp;ctry_ID=' . $ctry_ID . '&amp;action=new'));
    $r .= action_icon(T_('Delete this country!'), 'delete', regenerate_url('ctrl,action', 'ctrl=countries&amp;ctry_ID=' . $ctry_ID . '&amp;action=delete&amp;' . url_crumb('country')));
    return $r;
}
예제 #21
0
 /**
  * Build teh evobar menu
  */
 function build_evobar_menu()
 {
     /**
      * @var Menu
      */
     global $topleft_Menu, $topright_Menu;
     global $current_User;
     global $home_url, $admin_url, $dispatcher, $debug, $seo_page_type, $robots_index;
     global $Blog, $blog;
     global $Settings;
     $perm_admin_normal = $current_User->check_perm('admin', 'normal');
     $perm_admin_restricted = $current_User->check_perm('admin', 'restricted');
     $entries = NULL;
     if ($perm_admin_normal) {
         // Normal Access to Admin:
         $entries = array('b2evo' => array('text' => '<strong>b2evolution</strong>', 'href' => $home_url), 'dashboard' => array('text' => T_('Dashboard'), 'href' => $admin_url, 'title' => T_('Go to admin dashboard')), 'see' => array('text' => T_('See'), 'href' => $home_url, 'title' => T_('See the home page')), 'write' => array('text' => T_('Write'), 'title' => T_('No blog is currently selected'), 'disabled' => true), 'blog' => array('text' => T_('Blog'), 'title' => T_('No blog is currently selected'), 'disabled' => true), 'tools' => array('text' => T_('More'), 'disabled' => true));
     } elseif ($perm_admin_restricted) {
         // restricted Access to Admin:
         $entries = array('see' => array('text' => T_('Site'), 'href' => $home_url, 'title' => T_('See the home page')));
         if ($current_User->check_perm('blogs', 'create')) {
             $entries['blog'] = array('text' => T_('Blog'), 'title' => T_('No blog is currently selected'), 'disabled' => true);
         }
         $entries['tools'] = array('text' => T_('More'), 'disabled' => true);
     }
     if (!empty($Blog)) {
         // A blog is currently selected:
         if ($perm_admin_normal) {
             $entries['dashboard']['href'] = $admin_url . '?blog=' . $Blog->ID;
         }
         if ($perm_admin_restricted) {
             $entries['see']['href'] = $Blog->get('url');
             $entries['see']['title'] = T_('See the public view of this blog');
         }
         if ($current_User->check_perm('blog_post_statuses', 'edit', false, $Blog->ID)) {
             // We have permission to add a post with at least one status:
             $write_item_url = $Blog->get_write_item_url();
             if ($write_item_url) {
                 // write item URL is not empty, so it's sure that user can create new post
                 if (!$perm_admin_normal) {
                     $entries['write'] = array('text' => T_('Write'));
                 }
                 $entries['write']['href'] = $write_item_url;
                 $entries['write']['disabled'] = false;
                 $entries['write']['title'] = T_('Write a new post into this blog');
             }
         }
         if ($perm_admin_normal) {
             if (empty($write_item_url)) {
                 // Display restricted message on this blog
                 $entries['write']['title'] = T_('You don\'t have permission to post into this blog');
             }
             // BLOG MENU:
             $items_url = $admin_url . '?ctrl=items&amp;blog=' . $Blog->ID . '&amp;filter=restore';
             $entries['blog']['href'] = $items_url;
             $entries['blog']['disabled'] = false;
             $entries['blog']['title'] = T_('Manage this blog');
             if ($Blog->get('type') == 'manual') {
                 // Manual Pages
                 $entries['blog']['entries']['manual'] = array('text' => T_('Manual Pages') . '&hellip;', 'href' => $items_url . '&amp;tab=manual');
             }
             $entries['blog']['entries']['posts'] = array('text' => T_('Posts') . '&hellip;', 'href' => $items_url);
             // Check if user has permission for published, draft or depreceted comments (any of these)
             if ($current_User->check_perm('blog_comments', 'edit', false, $Blog->ID)) {
                 // Comments:
                 $entries['blog']['entries']['comments'] = array('text' => T_('Comments') . '&hellip;', 'href' => $admin_url . '?ctrl=comments&amp;blog=' . $Blog->ID . '&amp;filter=restore');
             }
             // Chapters / Categories:
             if ($current_User->check_perm('blog_cats', 'edit', false, $Blog->ID)) {
                 // Either permission for a specific blog or the global permission:
                 $entries['blog']['entries']['chapters'] = array('text' => T_('Categories') . '&hellip;', 'href' => $admin_url . '?ctrl=chapters&amp;blog=' . $Blog->ID);
             }
             // PLACE HOLDER FOR FILES MODULE:
             $entries['blog']['entries']['files'] = NULL;
             // BLOG SETTINGS:
             if ($current_User->check_perm('blog_properties', 'edit', false, $Blog->ID)) {
                 // We have permission to edit blog properties:
                 $blog_param = '&amp;blog=' . $Blog->ID;
                 if (!empty($entries['blog']['entries'])) {
                     // There are already entries aboce, insert a separator:
                     $entries['blog']['entries'][] = array('separator' => true);
                 }
                 $entries['blog']['entries']['general'] = array('text' => T_('Blog settings'), 'href' => $admin_url . '?ctrl=coll_settings' . $blog_param, 'entries' => array('general' => array('text' => T_('General') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=general' . $blog_param), 'features' => array('text' => T_('Features') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=features' . $blog_param), 'skin' => array('text' => T_('Skin') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=skin' . $blog_param), 'plugin_settings' => array('text' => T_('Plugins') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=plugin_settings' . $blog_param), 'widgets' => array('text' => T_('Widgets') . '&hellip;', 'href' => $admin_url . '?ctrl=widgets' . $blog_param), 'urls' => array('text' => T_('URLs') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=urls' . $blog_param), 'seo' => array('text' => T_('SEO') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=seo' . $blog_param), 'advanced' => array('text' => T_('Advanced') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=advanced' . $blog_param)));
                 if ($Blog && $Blog->advanced_perms) {
                     $entries['blog']['entries']['general']['entries']['userperms'] = array('text' => T_('User perms') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=perm' . $blog_param);
                     $entries['blog']['entries']['general']['entries']['groupperms'] = array('text' => T_('Group perms') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=permgroup' . $blog_param);
                 }
             }
         }
     }
     // SYSTEM MENU:
     if ($perm_admin_restricted) {
         if ($debug) {
             $debug_text = 'DEBUG: ';
             if (!empty($seo_page_type)) {
                 // Set in skin_init()
                 $debug_text = $seo_page_type . ': ';
             }
             if ($robots_index === false) {
                 $debug_text .= 'NO INDEX';
             } else {
                 $debug_text .= 'do index';
             }
             $entries['tools']['entries']['noindex'] = array('text' => $debug_text, 'disabled' => true);
             $entries['tools']['entries'][''] = array('separator' => true);
         }
         if ($current_User->check_perm('users', 'view')) {
             // Users:
             $entries['tools']['disabled'] = false;
             $entries['tools']['entries']['users'] = array('text' => T_('Users') . '&hellip;', 'href' => $admin_url . '?ctrl=users');
         }
         // PLACE HOLDER FOR MESSAGING MODULE:
         $entries['tools']['entries']['messaging'] = NULL;
         // PLACE HOLDER FOR FILES MODULE:
         $entries['tools']['entries']['files'] = NULL;
         $perm_spam = $current_User->check_perm('spamblacklist', 'view');
         $perm_options = $current_User->check_perm('options', 'view');
         $perm_emails = $current_User->check_perm('emails', 'view');
         $perm_slugs = $current_User->check_perm('slugs', 'view');
         $perm_maintenance = $current_User->check_perm('perm_maintenance', 'upgrade');
         if ($perm_spam || $perm_options || $perm_slugs || $perm_maintenance) {
             if ($perm_emails) {
                 $entries['tools']['entries']['email'] = array('text' => T_('Emails'), 'href' => $admin_url . '?ctrl=email', 'entries' => array('blocked' => array('text' => T_('Addresses') . '&hellip;', 'href' => $admin_url . '?ctrl=email'), 'sent' => array('text' => T_('Sent') . '&hellip;', 'href' => $admin_url . '?ctrl=email&amp;tab=sent'), 'return' => array('text' => T_('Returned') . '&hellip;', 'href' => $admin_url . '?ctrl=email&amp;tab=return'), 'settings' => array('text' => T_('Settings') . '&hellip;', 'href' => $admin_url . '?ctrl=email&amp;tab=settings')));
             }
             $entries['tools']['disabled'] = false;
             $entries['tools']['entries']['tools_sep'] = array('separator' => true);
             if ($perm_options) {
                 $entries['tools']['entries']['status'] = array('text' => T_('System status') . '&hellip;', 'href' => $admin_url . '?ctrl=system');
             }
             if ($perm_options) {
                 $entries['tools']['entries']['crontab'] = array('text' => T_('Scheduler') . '&hellip;', 'href' => $admin_url . '?ctrl=crontab');
             }
             if ($perm_spam) {
                 $entries['tools']['entries']['antispam'] = array('text' => T_('Antispam'), 'href' => $admin_url . '?ctrl=antispam', 'entries' => array('blacklist' => array('text' => T_('Blacklist') . '&hellip;', 'href' => $admin_url . '?ctrl=antispam')));
                 if ($perm_options) {
                     // If we have access to options, then we add a submenu:
                     $entries['tools']['entries']['antispam']['entries']['ipranges'] = array('text' => T_('IP Ranges') . '&hellip;', 'href' => $admin_url . '?ctrl=antispam&amp;tab3=ipranges');
                     $entries['tools']['entries']['antispam']['entries']['settings'] = array('text' => T_('Settings') . '&hellip;', 'href' => $admin_url . '?ctrl=antispam&amp;tab3=settings');
                     if ($current_User->check_perm('options', 'edit')) {
                         $entries['tools']['entries']['antispam']['entries']['tools'] = array('text' => T_('Tools') . '&hellip;', 'href' => $admin_url . '?ctrl=antispam&amp;tab3=tools');
                     }
                 }
             }
             if ($perm_slugs) {
                 $entries['tools']['entries']['slugs'] = array('text' => T_('Slugs') . '&hellip;', 'href' => $admin_url . '?ctrl=slugs');
             }
         }
         if ($perm_options) {
             // Global settings:
             $entries['tools']['entries']['general'] = array('text' => T_('General') . '&hellip;', 'href' => $admin_url . '?ctrl=gensettings');
             $entries['tools']['entries']['regional'] = array('text' => T_('Regional'), 'href' => $admin_url . '?ctrl=regional', 'entries' => array('locales' => array('text' => T_('Locales') . '&hellip;', 'href' => $admin_url . '?ctrl=locales'), 'time' => array('text' => T_('Time') . '&hellip;', 'href' => $admin_url . '?ctrl=time'), 'countries' => array('text' => T_('Countries') . '&hellip;', 'href' => $admin_url . '?ctrl=countries'), 'regions' => array('text' => T_('Regions') . '&hellip;', 'href' => $admin_url . '?ctrl=regions'), 'subregions' => array('text' => T_('Sub-regions') . '&hellip;', 'href' => $admin_url . '?ctrl=subregions'), 'cities' => array('text' => T_('Cities') . '&hellip;', 'href' => $admin_url . '?ctrl=cities'), 'currencies' => array('text' => T_('Currencies') . '&hellip;', 'href' => $admin_url . '?ctrl=currencies')));
             $entries['tools']['entries']['plugins'] = array('text' => T_('Plugins') . '&hellip;', 'href' => $admin_url . '?ctrl=plugins');
             $entries['tools']['entries']['remote'] = array('text' => T_('Remote publishing') . '&hellip;', 'href' => $admin_url . '?ctrl=remotepublish');
             $entries['tools']['entries']['maintenance'] = array('text' => T_('Maintenance'), 'href' => $admin_url . '?ctrl=tools', 'entries' => array('tools' => array('text' => T_('Tools') . '&hellip;', 'href' => $admin_url . '?ctrl=tools'), 'import' => array('text' => T_('Import') . '&hellip;', 'href' => $admin_url . '?ctrl=tools&amp;tab3=import'), 'test' => array('text' => T_('Testing') . '&hellip;', 'href' => $admin_url . '?ctrl=tools&amp;tab3=test'), 'backup' => array('text' => T_('Backup') . '&hellip;', 'href' => $admin_url . '?ctrl=backup'), 'upgrade' => array('text' => T_('Check for updates') . '&hellip;', 'href' => $admin_url . '?ctrl=upgrade')));
         }
     }
     global $debug, $debug_jslog;
     if ($debug || $debug_jslog) {
         // Show JS log menu if debug is enabled
         $entries['jslog'] = array('text' => T_('JS log'), 'title' => T_('JS log'), 'class' => 'jslog_switcher');
     }
     if ($entries !== NULL) {
         $topleft_Menu->add_menu_entries(NULL, $entries);
     }
     // ---------------------------------------------------------------------------
     /*
      * RIGHT MENU
      */
     global $localtimenow, $is_admin_page;
     $entries = array('userprefs' => array('text' => $current_User->get_avatar_imgtag('crop-top-15x15', '', 'top') . ' <strong>' . $current_User->get_colored_login() . '</strong>', 'href' => get_user_profile_url(), 'entries' => array('profile' => array('text' => T_('Edit your profile') . '&hellip;', 'href' => get_user_profile_url()), 'avatar' => array('text' => T_('Your profile picture') . '&hellip;', 'href' => get_user_avatar_url()), 'pwdchange' => array('text' => T_('Change password') . '&hellip;', 'href' => get_user_pwdchange_url()), 'userprefs' => array('text' => T_('Preferences') . '&hellip;', 'href' => get_user_preferences_url()), 'subs' => array('text' => T_('Notifications') . '&hellip;', 'href' => get_user_subs_url()))), 'time' => array('text' => date(locale_shorttimefmt(), $localtimenow), 'disabled' => true, 'class' => 'noborder'));
     // ADMIN SKINS:
     if ($is_admin_page) {
         $admin_skins = get_admin_skins();
         if (count($admin_skins) > 1) {
             // We have several admin skins available: display switcher:
             $entries['userprefs']['entries']['admskins_sep'] = array('separator' => true);
             $entries['userprefs']['entries']['admskins'] = array('text' => T_('Admin skin'));
             $redirect_to = rawurlencode(regenerate_url('', '', '', '&'));
             foreach ($admin_skins as $admin_skin) {
                 $entries['userprefs']['entries']['admskins']['entries'][$admin_skin] = array('text' => $admin_skin, 'href' => $dispatcher . '?ctrl=users&amp;action=change_admin_skin&amp;new_admin_skin=' . rawurlencode($admin_skin) . '&amp;redirect_to=' . $redirect_to);
             }
         }
     }
     $entries['userprefs']['entries']['logout_sep'] = array('separator' => true);
     $entries['userprefs']['entries']['logout'] = array('text' => T_('Logout'), 'href' => get_user_logout_url());
     // AB switch:
     if ($perm_admin_normal) {
         // User must have permission to access admin...
         if ($is_admin_page) {
             if (!empty($Blog)) {
                 $entries['abswitch'] = array('text' => T_('Blog') . ' ' . get_icon('switch-to-blog'), 'href' => $Blog->get('url'));
             } else {
                 $entries['abswitch'] = array('text' => T_('Home') . ' ' . get_icon('switch-to-blog'), 'href' => $home_url);
             }
         } else {
             $entries['abswitch'] = array('text' => T_('Admin') . ' ' . get_icon('switch-to-admin'), 'href' => $admin_url);
         }
     }
     $topright_Menu->add_menu_entries(NULL, $entries);
     $topright_Menu->add_menu_entries(NULL, array('logout' => array('text' => T_('Logout') . ' ' . get_icon('close'), 'class' => 'rollover_sprite', 'href' => get_user_logout_url())));
 }
예제 #22
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();
    }
}
예제 #23
0
 /**
  * Get the HTML for the menu entries of a specific path.
  *
  * @param NULL|string|array The path. See {@link get_node_by_path()}.
  * @param string Template name, see {@link get_template()}.
  * @param int Depth (recursion)
  * @return string The HTML for the menu.
  */
 function get_html_menu_entries($path, $template, $depth = 0)
 {
     global $current_User;
     $r = '';
     $templateForLevel = $this->get_template($template, $depth);
     if (!($menuEntries = $this->get_menu_entries($path))) {
         // No menu entries at this level
         if (isset($templateForLevel['empty'])) {
             $r .= $templateForLevel['empty'];
         }
     } else {
         // There are entries to display:
         $r .= $templateForLevel['before'];
         $selected = $this->get_selected($path);
         foreach ($menuEntries as $loop_key => $loop_details) {
             $anchor = '<a href="';
             if (isset($loop_details['href'])) {
                 $anchor .= $loop_details['href'];
             } elseif (!empty($loop_details['href_eval'])) {
                 // Useful for passing dynamic context vars (fp>> I AM using it)
                 $anchor .= eval($loop_details['href_eval']);
             } else {
                 $anchor .= regenerate_url('tab', 'tab=' . $loop_key);
             }
             $anchor .= '"';
             if (isset($loop_details['style'])) {
                 $anchor .= ' style="' . $loop_details['style'] . '"';
             }
             if (isset($loop_details['onclick'])) {
                 $anchor .= ' onclick="' . $loop_details['onclick'] . '"';
             }
             if (isset($loop_details['name'])) {
                 $anchor .= ' name="' . $loop_details['name'] . '"';
             }
             $anchor .= '>' . format_to_output($loop_details['text'], 'htmlbody') . "</a>";
             if ($loop_key == $selected) {
                 // Highlight selected entry
                 if (!empty($templateForLevel['_props']['recurseSelected']) && ($recursePath = array_merge($path, $loop_key)) && $this->get_menu_entries($recursePath)) {
                     $r .= isset($templateForLevel['beforeEachSelWithSub']) ? $templateForLevel['beforeEachSelWithSub'] : $templateForLevel['beforeEachSel'];
                     $r .= $anchor;
                     // Recurse:
                     $r .= $this->get_html_menu_entries($recursePath, $template, $depth + 1);
                     $r .= isset($templateForLevel['afterEachSelWithSub']) ? $templateForLevel['afterEachSelWithSub'] : $templateForLevel['afterEachSel'];
                 } else {
                     $r .= $templateForLevel['beforeEachSel'];
                     $r .= $anchor;
                     $r .= $templateForLevel['afterEachSel'];
                 }
             } else {
                 $r .= $templateForLevel['beforeEach'];
                 $r .= $anchor;
                 $r .= $templateForLevel['afterEach'];
             }
         }
         $r .= $templateForLevel['after'];
     }
     return $r;
 }
예제 #24
0
            $perm = 'sidebar';
            break;
        case 'ads':
            $label = T_('New advertisement');
            $title = T_('Add an advertisement...');
            $new_ptyp_ID = 4000;
            $perm = 'sidebar';
            break;
        default:
            $label = T_('New post');
            $title = T_('Write a new post...');
            $new_ptyp_ID = 1;
            $perm = '';
            // No need to check
            $ItemList->global_icon(T_('Create multiple posts...'), 'new', '?ctrl=items&amp;action=new_mass&amp;blog=' . $Blog->ID . '&amp;item_typ_ID=' . $new_ptyp_ID, T_('Mass create') . ' &raquo;', 3, 4);
            break;
    }
    if (empty($perm) || $current_User->check_perm('blog_' . $perm, 'edit', false, $Blog->ID)) {
        // We have the permission to create and edit posts with this post type:
        $ItemList->global_icon(T_('Mass edit the current post list...'), '', '?ctrl=items&amp;action=mass_edit&amp;filter=restore&amp;blog=' . $Blog->ID . '&amp;redirect_to=' . regenerate_url('action', '', '', '&'), T_('Mass edit') . ' &raquo;', 3, 4);
        $ItemList->global_icon($title, 'new', '?ctrl=items&amp;action=new&amp;blog=' . $Blog->ID . '&amp;item_typ_ID=' . $new_ptyp_ID, $label . ' &raquo;', 3, 4);
    }
}
// EXECUTE the query now:
$ItemList->restart();
// Initialize funky display vars now:
global $postIDlist, $postIDarray;
$postIDlist = $ItemList->get_page_ID_list();
$postIDarray = $ItemList->get_page_ID_array();
// DISPLAY table now:
$ItemList->display(NULL, $result_fadeout);
예제 #25
0
// Determine if we are creating or updating...
$creating = is_create_action($action);
$Form = new Form(NULL, 'form');
$close_url = get_chapter_redirect_url(get_param('redirect_page'), $edited_Chapter->parent_ID, $edited_Chapter->ID);
$Form->global_icon(T_('Cancel editing!'), 'close', $close_url);
$Form->begin_form('fform', $creating ? T_('New category') : T_('Category'));
$Form->add_crumb('element');
$Form->hidden('action', $creating ? 'create' : 'update');
$Form->hiddens_by_key(get_memorized('action'));
$Form->begin_fieldset(T_('Properties'));
// We're essentially double checking here...
$edited_Blog =& $edited_Chapter->get_Blog();
$move = '';
if ($Settings->get('allow_moving_chapters') && !$creating) {
    // If moving cats between blogs is allowed:
    $move = ' ' . action_icon(T_('Move to a different blog...'), 'file_move', regenerate_url('action,cat_ID', 'cat_ID=' . $edited_Chapter->ID . '&amp;action=move'), T_('Move'));
}
$Form->info(T_('Blog'), $edited_Blog->get_maxlen_name() . $move);
$Form->select_input_options('cat_parent_ID', $GenericCategoryCache->recurse_select($edited_Chapter->parent_ID, $subset_ID, true, NULL, 0, array($edited_Chapter->ID)), T_('Parent category'));
$Form->text_input('cat_name', $edited_Chapter->name, 40, T_('Name'), '', array('required' => true, 'maxlength' => 255));
$Form->text_input('cat_urlname', $edited_Chapter->urlname, 40, T_('URL "slug"'), T_('Used for clean URLs. Must be unique.'), array('maxlength' => 255));
$Form->text_input('cat_description', $edited_Chapter->description, 40, T_('Description'), T_('May be used as a title tag and/or meta description.'), array('maxlength' => 255));
if ($Settings->get('chapter_ordering') == 'manual') {
    $Form->text_input('cat_order', $edited_Chapter->order, 5, T_('Order'), T_('For manual ordering of the categories.'), array('maxlength' => 11));
}
$Form->checkbox_input('cat_meta', $edited_Chapter->meta, T_('Meta category'), array('note' => T_('If you check this box you will not be able to put any posts into this category.')));
$Form->checkbox_input('cat_lock', $edited_Chapter->lock, T_('Locked category'), array('note' => T_('Check this to lock all posts under this category. (Note: for posts with multiple categories, the post is only locked if *all* its categories are locked.)')));
$Form->end_fieldset();
if ($creating) {
    $Form->end_form(array(array('submit', 'submit', T_('Record'), 'SaveButton'), array('reset', '', T_('Reset'), 'ResetButton')));
} else {
예제 #26
0
        $block_item_Widget->title = T_('Choose a Mobile Phone skin');
        $display_same_as_normal = true;
        break;
    case 'tablet':
        $block_item_Widget->title = T_('Choose a Tablet skin');
        $display_same_as_normal = true;
        break;
    default:
        debug_die('Invalid skin type!');
}
// Get what is the current skin ID from this kind of skin type
$current_skin_ID = $edited_Blog->get_setting($skin_type . '_skin_ID', true);
if ($current_User->check_perm('options', 'edit', false)) {
    // We have permission to modify:
    $block_item_Widget->global_icon(T_('Install new skin...'), 'new', $dispatcher . '?ctrl=skins&amp;action=new&amp;redirect_to=' . rawurlencode(url_rel_to_same_host(regenerate_url('', 'skinpage=selection', '', '&'), $admin_url)), T_('Install new'), 3, 4);
    $block_item_Widget->global_icon(T_('Keep current skin!'), 'close', regenerate_url('skinpage'), ' ' . T_('Don\'t change'), 3, 4);
}
$block_item_Widget->disp_template_replaced('block_start');
$SkinCache =& get_SkinCache();
$SkinCache->load_all();
if ($display_same_as_normal) {
    $skinshot_title = T_('Same as normal skin');
    $select_url = '?ctrl=coll_settings&tab=skin&blog=' . $edited_Blog->ID . '&amp;action=update&amp;skinpage=selection&amp;' . $skin_type . '_skin_ID=0&amp;' . url_crumb('collection');
    $disp_params = array('function' => 'select', 'selected' => $current_skin_ID == '0', 'select_url' => $select_url);
    Skin::disp_skinshot($skinshot_title, $skinshot_title, $disp_params);
}
$SkinCache->rewind();
while (($iterator_Skin =& $SkinCache->get_next()) != NULL) {
    if ($iterator_Skin->type != $skin_type) {
        // This skin cannot be used here...
        continue;
예제 #27
0
 *
 * @license GNU GPL v2 - {@link http://b2evolution.net/about/gnu-gpl-license}
 *
 * @copyright (c)2003-2015 by Francois Planque - {@link http://fplanque.com/}
 *
 * @package admin
 */
if (!defined('EVO_MAIN_INIT')) {
    die('Please, do not access this page directly.');
}
global $localtimenow, $edited_Cronjob;
// Determine if we are creating or updating...
global $action;
$creating = is_create_action($action);
$Form = new Form(NULL, 'cronjob');
$Form->global_icon(T_('Cancel!'), 'close', regenerate_url('action'));
$Form->begin_form('fform', $creating ? T_('New scheduled job') : T_('Edit scheduled job'));
$Form->add_crumb('crontask');
$Form->hiddens_by_key(get_memorized('action'));
$Form->hidden('action', $creating ? 'create' : 'update');
$Form->begin_fieldset(T_('Job details') . get_manual_link('scheduled-job-form'));
if ($creating && $action != 'copy') {
    // New cronjob
    $cron_jobs_names = get_cron_jobs_config('name');
    // Exclude these cron jobs from manual creating
    unset($cron_jobs_names['send-post-notifications']);
    unset($cron_jobs_names['send-comment-notifications']);
    $Form->select_input_array('cjob_type', get_param('cjob_type'), $cron_jobs_names, T_('Job type'));
} else {
    // Edit cronjob
    if ($action == 'edit') {
예제 #28
0
 function file_actions($link_ID)
 {
     /**
      * @var File
      */
     global $current_File;
     global $edited_Item, $current_User;
     $r = '';
     if (isset($current_File)) {
         $title = T_('Locate this file!');
         $r = $current_File->get_linkedit_link($edited_Item->ID, get_icon('locate', 'imgtag', array('title' => $title)), $title) . ' ';
     }
     if ($current_User->check_perm('item', 'edit', false, $edited_Item)) {
         // Check that we have permission to edit item:
         $r .= action_icon(T_('Delete this link!'), 'unlink', regenerate_url('p,itm_ID,action', "link_ID={$link_ID}&amp;action=unlink"));
     }
     return $r;
 }
예제 #29
0
}
// Create result set:
$SQL = new SQL();
$SQL->SELECT('T_skins__skin.*, COUNT( DISTINCT( cset_coll_ID ) ) AS nb_blogs');
$SQL->FROM('T_skins__skin LEFT JOIN T_coll_settings ON skin_ID = cset_value AND
			( cset_name = "normal_skin_ID" OR cset_name = "mobile_skin_ID" OR cset_name = "tablet_skin_ID" )');
$SQL->GROUP_BY('skin_ID');
$CountSQL = new SQL();
$CountSQL->SELECT('COUNT( * )');
$CountSQL->FROM('T_skins__skin');
$Results = new Results($SQL->get(), 'skin_', '', NULL, $CountSQL->get());
$Results->Cache =& get_SkinCache();
$Results->title = T_('Installed skins') . get_manual_link('installed_skins');
if ($current_User->check_perm('options', 'edit', false)) {
    // We have permission to modify:
    $Results->cols[] = array('th' => T_('Name'), 'order' => 'skin_name', 'td' => '<strong><a href="' . regenerate_url('', 'skin_ID=$skin_ID$&amp;action=edit') . '" title="' . TS_('Edit skin properties...') . '">$skin_name$</a></strong>');
} else {
    // We have NO permission to modify:
    $Results->cols[] = array('th' => T_('Name'), 'order' => 'skin_name', 'td' => '<strong>$skin_name$</strong>');
}
$Results->cols[] = array('th' => T_('Skin type'), 'order' => 'skin_type', 'td_class' => 'center', 'td' => '$skin_type$');
$Results->cols[] = array('th' => T_('Blogs'), 'order' => 'nb_blogs', 'th_class' => 'shrinkwrap', 'td_class' => 'center', 'td' => '~conditional( (#nb_blogs# > 0), #nb_blogs#, \'&nbsp;\' )~');
$Results->cols[] = array('th' => T_('Skin Folder'), 'order' => 'skin_folder', 'td' => '$skin_folder$');
if ($current_User->check_perm('options', 'edit', false)) {
    // We have permission to modify:
    $Results->cols[] = array('th' => T_('Actions'), 'th_class' => 'shrinkwrap', 'td_class' => 'shrinkwrap', 'td' => action_icon(TS_('Edit skin properties...'), 'properties', '%regenerate_url( \'\', \'skin_ID=$skin_ID$&amp;action=edit\')%') . action_icon(TS_('Reload containers!'), 'reload', '%regenerate_url( \'\', \'skin_ID=$skin_ID$&amp;action=reload&amp;' . url_crumb('skin') . '\')%') . '~conditional( #nb_blogs# < 1, \'' . action_icon(TS_('Uninstall this skin!'), 'delete', '%regenerate_url( \'\', \'skin_ID=$skin_ID$&amp;action=delete&amp;' . url_crumb('skin') . '\')%') . '\', \'' . get_icon('delete', 'noimg') . '\' )~');
    $Results->global_icon(T_('Install new skin...'), 'new', regenerate_url('action,blog', 'action=new'), T_('Install new'), 3, 4);
}
// $fadeout_array = array( 'skin_ID' => array(6) );
$fadeout_array = NULL;
$Results->display(NULL, 'session');
예제 #30
0
$Form->hidden('user_tab', 'pwdchange');
$Form->hidden('password_form', '1');
$Form->hidden('reqID', $reqID);
$Form->hidden('user_ID', $edited_User->ID);
$Form->hidden('edited_user_login', $edited_User->login);
if (isset($Blog)) {
    $Form->hidden('blog', $Blog->ID);
}
/***************  Password  **************/
if ($action != 'view') {
    // We can edit the values:
    $Form->begin_fieldset($is_admin ? T_('Password') : '', array('class' => 'fieldset clear'));
    // current password is not required:
    //   - current user has full access and not editing his own pasword
    //   - password change requested by email
    if (!($has_full_access && $edited_User->ID != $current_User->ID || !empty($reqID) && $reqID == $Session->get('core.changepwd.request_id'))) {
        $Form->password_input('current_user_pass', '', 20, T_('Current password'), array('maxlength' => 50, 'required' => $edited_User->ID == 0, 'autocomplete' => 'off'));
    }
    $Form->password_input('edited_user_pass1', '', 20, T_('New password'), array('note' => sprintf(T_('Minimum length: %d characters.'), $Settings->get('user_minpwdlen')), 'maxlength' => 50, 'required' => $edited_User->ID == 0, 'autocomplete' => 'off'));
    $Form->password_input('edited_user_pass2', '', 20, T_('Confirm new password'), array('maxlength' => 50, 'required' => $edited_User->ID == 0, 'autocomplete' => 'off'));
    $Form->end_fieldset();
}
/***************  Buttons  **************/
if ($action != 'view') {
    // Edit buttons
    $Form->buttons(array(array('', 'actionArray[update]', T_('Change password!'), 'SaveButton')));
}
$Form->info('', '<div><a href="' . regenerate_url('disp', 'disp=profile') . '">' . T_('Abandon password change') . '</a></div>');
$Form->end_form();
// Display javascript password strength indicator bar
display_password_indicator(array('pass1-id' => 'edited_user_pass1', 'pass2-id' => 'edited_user_pass2', 'login-id' => 'edited_user_login', 'field-width' => 165));