/** * Check that we have received a valid blog param * * For use in admin */ function valid_blog_requested() { global $Blog, $Messages; if (empty($Blog)) { // The requested blog does not exist, Try to get other available blog for the current User $blog_ID = get_working_blog(); if ($blog_ID) { $BlogCache =& get_BlogCache(); $Blog =& $BlogCache->get_by_ID($blog_ID, false, false); } } if (empty($Blog)) { // The requested blog does not exist $Messages->add(T_('The requested blog does not exist (any more?)'), 'error'); return false; } return true; }
/** * Build the evobar menu */ function build_evobar_menu() { /** * @var Menu */ global $topleft_Menu, $topright_Menu; global $current_User; global $baseurl, $home_url, $admin_url, $debug, $debug_jslog, $dev_menu, $seo_page_type, $robots_index; global $Blog, $blog, $activate_collection_toolbar; global $Settings; $perm_admin_normal = $current_User->check_perm('admin', 'normal'); $perm_admin_restricted = $current_User->check_perm('admin', 'restricted'); $entries = NULL; $working_blog = get_working_blog(); if ($working_blog) { // Set collection url only when current user has an access to the working blog if (is_admin_page()) { // Front page of the working blog $BlogCache =& get_BlogCache(); $working_Blog =& $BlogCache->get_by_ID($working_blog); $collection_url = $working_Blog->get('url'); } else { // Dashboard of the working blog $collection_url = $admin_url . '?ctrl=dashboard&blog=' . $working_blog; } } if ($perm_admin_normal || $perm_admin_restricted) { // Normal OR Restricted Access to Admin: $entries = array(); if ($perm_admin_normal) { // Only for normal access $entries['b2evo'] = array('text' => '<strong>b2evolution</strong>', 'href' => $home_url, 'entry_class' => 'rwdhide'); } $entries['front'] = array('text' => T_('Front<u>-office</u>'), 'href' => $baseurl, 'title' => T_('Go to the site home page (Front-office)')); $entries['dashboard'] = array('text' => T_('Back<u>-office</u>'), 'href' => $admin_url, 'title' => T_('Go to the site dashboard (Back-office)')); if ($perm_admin_normal) { // Only for normal access $entries['write'] = array('text' => '<span class="fa fa-plus-square"></span> ' . T_('Post'), 'title' => T_('No blog is currently selected'), 'disabled' => true, 'entry_class' => 'rwdhide'); } if ($working_blog) { // Display a link to manage first available collection $entries['blog'] = array('text' => T_('Collection'), 'href' => $collection_url, 'disabled' => true); } $entries['tools'] = array('text' => T_('More'), 'href' => $admin_url . '#', 'disabled' => true); } if ((!is_admin_page() || !empty($activate_collection_toolbar)) && !empty($Blog)) { // A blog is currently selected AND we can activate toolbar items for selected collection: 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' => '<span class="fa fa-plus-square"></span> ' . T_('Post')); } $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 && $working_blog) { 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: $entries['blog'] = array('text' => T_('Collection'), 'title' => T_('Manage this blog'), 'href' => $collection_url); $display_separator = false; if ($current_User->check_perm('blog_ismember', 'view', false, $Blog->ID)) { // Check if current user has an access to post lists $items_url = $admin_url . '?ctrl=items&blog=' . $Blog->ID . '&filter=restore'; // Collection front page $entries['blog']['entries']['coll_front'] = array('text' => T_('Collection Front Page') . '…', 'href' => $Blog->get('url')); // Collection dashboard $entries['blog']['entries']['coll_dashboard'] = array('text' => T_('Collection Dashboard') . '…', 'href' => $admin_url . '?ctrl=dashboard&blog=' . $Blog->ID); $entries['blog']['entries'][] = array('separator' => true); if ($Blog->get('type') == 'manual') { // Manual view $entries['blog']['entries']['manual'] = array('text' => T_('Manual view') . '…', 'href' => $items_url . '&tab=manual'); } if ($Blog->get_setting('use_workflow')) { // Workflow view $entries['blog']['entries']['workflow'] = array('text' => T_('Workflow view') . '…', 'href' => $items_url . '&tab=tracker'); } $entries['blog']['entries']['posts'] = array('text' => T_('Posts') . '…', 'href' => $items_url); $display_separator = true; } // 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') . '…', 'href' => $admin_url . '?ctrl=comments&blog=' . $Blog->ID . '&filter=restore'); $display_separator = true; } // 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') . '…', 'href' => $admin_url . '?ctrl=chapters&blog=' . $Blog->ID); $display_separator = true; } if ($display_separator) { $entries['blog']['entries'][] = array('separator' => true); } // 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 = '&blog=' . $Blog->ID; $entries['blog']['entries']['features'] = array('text' => T_('Features'), 'href' => $admin_url . '?ctrl=coll_settings&tab=home' . $blog_param, 'entries' => array('front' => array('text' => T_('Front page') . '…', 'href' => $admin_url . '?ctrl=coll_settings&tab=home' . $blog_param), 'posts' => array('text' => T_('Posts') . '…', 'href' => $admin_url . '?ctrl=coll_settings&tab=features' . $blog_param), 'comments' => array('text' => T_('Comments') . '…', 'href' => $admin_url . '?ctrl=coll_settings&tab=comments' . $blog_param), 'other' => array('text' => T_('Other displays') . '…', 'href' => $admin_url . '?ctrl=coll_settings&tab=other' . $blog_param), 'more' => array('text' => T_('More') . '…', 'href' => $admin_url . '?ctrl=coll_settings&tab=more' . $blog_param))); $entries['blog']['entries']['skin'] = array('text' => T_('Skin') . '…', 'href' => $admin_url . '?ctrl=coll_settings&tab=skin' . $blog_param); $entries['blog']['entries']['plugin_settings'] = array('text' => T_('Plugins') . '…', 'href' => $admin_url . '?ctrl=coll_settings&tab=plugin_settings' . $blog_param); $entries['blog']['entries']['widgets'] = array('text' => T_('Widgets') . '…', 'href' => $admin_url . '?ctrl=widgets' . $blog_param); if (!is_admin_page()) { // Display a menu to turn on/off the debug containers global $ReqURI, $Session; if ($Session->get('display_containers_' . $Blog->ID) == 1) { // To hide the debug containers $entries['blog']['entries']['containers'] = array('text' => T_('Hide containers'), 'href' => url_add_param(regenerate_url('display_containers'), 'display_containers=hide')); } else { // To show the debug containers $entries['blog']['entries']['containers'] = array('text' => T_('Show containers'), 'href' => url_add_param(regenerate_url('display_containers'), 'display_containers=show')); } } $entries['blog']['entries']['general'] = array('text' => T_('Settings'), 'href' => $admin_url . '?ctrl=coll_settings' . $blog_param, 'entries' => array('general' => array('text' => T_('General') . '…', 'href' => $admin_url . '?ctrl=coll_settings&tab=general' . $blog_param), 'urls' => array('text' => T_('URLs') . '…', 'href' => $admin_url . '?ctrl=coll_settings&tab=urls' . $blog_param), 'seo' => array('text' => T_('SEO') . '…', 'href' => $admin_url . '?ctrl=coll_settings&tab=seo' . $blog_param))); if ($current_User->check_perm('options', 'view', false, $Blog->ID)) { // Post Types & Statuses $entries['blog']['entries']['general']['entries']['item_types'] = array('text' => T_('Post Types') . '…', 'href' => $admin_url . '?ctrl=itemtypes&tab=settings&tab3=types' . $blog_param); $entries['blog']['entries']['general']['entries']['item_statuses'] = array('text' => T_('Post Statuses') . '…', 'href' => $admin_url . '?ctrl=itemstatuses&tab=settings&tab3=statuses' . $blog_param); } $entries['blog']['entries']['general']['entries']['advanced'] = array('text' => T_('Advanced') . '…', 'href' => $admin_url . '?ctrl=coll_settings&tab=advanced' . $blog_param); if ($Blog && $Blog->advanced_perms) { $entries['blog']['entries']['general']['entries']['userperms'] = array('text' => T_('User perms') . '…', 'href' => $admin_url . '?ctrl=coll_settings&tab=perm' . $blog_param); $entries['blog']['entries']['general']['entries']['groupperms'] = array('text' => T_('Group perms') . '…', 'href' => $admin_url . '?ctrl=coll_settings&tab=permgroup' . $blog_param); } if ($current_User->check_perm('options', 'view')) { // Check if current user has a permission to view the common settings of the blogs $entries['blog']['entries']['general']['entries']['common_settings'] = array('text' => T_('Common Settings') . '…', 'href' => $admin_url . '?ctrl=collections&tab=blog_settings'); } } } } if ($perm_admin_restricted) { // DEV MENU: $dev_entries = array(); if ($dev_menu || $debug || $debug_jslog) { if (isset($Blog)) { $dev_entries['coll'] = array('text' => 'Collection = ' . $Blog->shortname, 'disabled' => true); } global $disp, $is_front; if (!empty($disp)) { $dev_entries['disp'] = array('text' => '$disp = ' . $disp, 'disabled' => true); } global $disp_detail; if (!empty($disp_detail)) { $dev_entries['disp_detail'] = array('text' => '$disp_detail = ' . $disp_detail, 'disabled' => true); } if (!empty($seo_page_type)) { // Set in skin_init() $dev_entries['seo_page_type'] = array('text' => '> ' . $seo_page_type, 'disabled' => true); } global $is_front; if (!empty($is_front)) { $dev_entries['front'] = array('text' => 'This is the FRONT page', 'disabled' => true); } if ($robots_index === false) { $debug_text = 'NO INDEX'; } else { $debug_text = 'do index'; } $dev_entries['noindex'] = array('text' => $debug_text, 'disabled' => true); } if (($dev_menu || $debug) && !is_admin_page() && !empty($Blog)) { // Display a menu to turn on/off the debug containers global $ReqURI, $Session; $dev_entries[] = array('separator' => true); if ($Session->get('display_containers_' . $Blog->ID) == 1) { // To hide the debug containers $dev_entries['containers'] = array('text' => T_('Hide containers'), 'href' => url_add_param(regenerate_url('display_containers'), 'display_containers=hide')); } else { // To show the debug containers $dev_entries['containers'] = array('text' => T_('Show containers'), 'href' => url_add_param(regenerate_url('display_containers'), 'display_containers=show')); } if ($Session->get('display_includes_' . $Blog->ID) == 1) { // To hide the debug includes $dev_entries['includes'] = array('text' => T_('Hide includes'), 'href' => url_add_param(regenerate_url('display_containers'), 'display_includes=hide')); } else { // To show the debug includes $dev_entries['includes'] = array('text' => T_('Show includes'), 'href' => url_add_param(regenerate_url('display_containers'), 'display_includes=show')); } } // MORE menu: if ($current_User->check_perm('users', 'view')) { // Users: $entries['tools']['disabled'] = false; $entries['tools']['entries']['users'] = array('text' => T_('Users') . '…', '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_options = $current_User->check_perm('options', 'view'); $perm_spam = $perm_options && $current_User->check_perm('spamblacklist', 'view'); $perm_emails = $current_User->check_perm('emails', 'view'); $perm_maintenance = $current_User->check_perm('perm_maintenance', 'upgrade'); if ($perm_spam || $perm_options || $perm_maintenance) { $entries['tools']['entries'][] = array('separator' => true); if ($perm_emails) { $entries['tools']['entries']['email'] = array('text' => T_('Emails'), 'href' => $admin_url . '?ctrl=campaigns', 'entries' => array('campaigns' => array('text' => T_('Campaigns') . '…', 'href' => $admin_url . '?ctrl=campaigns'), 'blocked' => array('text' => T_('Addresses') . '…', 'href' => $admin_url . '?ctrl=email'), 'sent' => array('text' => T_('Sent') . '…', 'href' => $admin_url . '?ctrl=email&tab=sent'), 'return' => array('text' => T_('Returned') . '…', 'href' => $admin_url . '?ctrl=email&tab=return'), 'settings' => array('text' => T_('Settings') . '…', 'href' => $admin_url . '?ctrl=email&tab=settings'))); } $entries['tools']['disabled'] = false; $entries['tools']['entries']['system'] = array('text' => T_('System'), 'href' => $admin_url . '?ctrl=system'); if ($perm_options) { $entries['tools']['entries']['system']['entries']['status'] = array('text' => T_('Status') . '…', 'href' => $admin_url . '?ctrl=system'); } if ($perm_options) { $entries['tools']['entries']['system']['entries']['crontab'] = array('text' => T_('Scheduler') . '…', 'href' => $admin_url . '?ctrl=crontab'); } if ($perm_spam) { $entries['tools']['entries']['system']['entries']['antispam'] = array('text' => T_('Antispam') . '…', 'href' => $admin_url . '?ctrl=antispam'); } } if ($perm_options) { // Global settings: $entries['tools']['entries']['system']['entries']['regional'] = array('text' => T_('Regional') . '…', 'href' => $admin_url . '?ctrl=regional'); $entries['tools']['entries']['system']['entries']['skins'] = array('text' => T_('Skins') . '…', 'href' => $admin_url . '?ctrl=skins&tab=system'); $entries['tools']['entries']['system']['entries']['plugins'] = array('text' => T_('Plugins') . '…', 'href' => $admin_url . '?ctrl=plugins'); $entries['tools']['entries']['system']['entries']['remote'] = array('text' => T_('Remote publishing') . '…', 'href' => $admin_url . '?ctrl=remotepublish'); $entries['tools']['entries']['system']['entries']['maintenance'] = array('text' => T_('Maintenance') . '…', 'href' => $admin_url . '?ctrl=tools'); $entries['tools']['entries']['system']['entries']['syslog'] = array('text' => T_('System log'), 'href' => '?ctrl=syslog'); } } if ($entries !== NULL) { $topleft_Menu->add_menu_entries(NULL, $entries); } // --------------------------------------------------------------------------- /* * RIGHT MENU */ global $localtimenow, $is_admin_page; $entries = array(); // Dev menu: global $debug_jslog; if ($debug || $debug_jslog) { // Show JS log menu if debug is enabled $dev_entries[] = array('separator' => true); $dev_entries['jslog'] = array('text' => T_('JS log'), 'title' => T_('JS log'), 'class' => 'jslog_switcher'); } if (!empty($dev_entries)) { // Add Dev menu if at least one entry is should be displayed $entries['dev'] = array('href' => $admin_url . '#', 'text' => '<span class="fa fa-wrench"></span> Dev', 'entries' => $dev_entries); } // User menu: $current_user_Group = $current_User->get_Group(); $userprefs_entries = array('name' => array('text' => $current_User->get_avatar_imgtag('crop-top-32x32', '', 'left') . ' ' . $current_User->get_preferred_name() . '<br /> <span class="note">' . $current_user_Group->get_name() . '</span>', 'href' => get_user_profile_url())); $userprefs_entries[] = array('separator' => true); $user_profile_url = get_user_profile_url(); if (!empty($user_profile_url)) { // Display this menu item only when url is available to current user $userprefs_entries['profile'] = array('text' => T_('Edit your profile') . '…', 'href' => $user_profile_url); } $user_avatar_url = get_user_avatar_url(); if (!empty($user_avatar_url)) { // Display this menu item only when url is available to current user $userprefs_entries['avatar'] = array('text' => T_('Your profile picture') . '…', 'href' => $user_avatar_url); } $user_pwdchange_url = get_user_pwdchange_url(); if (!empty($user_pwdchange_url)) { // Display this menu item only when url is available to current user $userprefs_entries['pwdchange'] = array('text' => T_('Change password') . '…', 'href' => $user_pwdchange_url); } $user_preferences_url = get_user_preferences_url(); if (!empty($user_preferences_url)) { // Display this menu item only when url is available to current user $userprefs_entries['userprefs'] = array('text' => T_('Preferences') . '…', 'href' => $user_preferences_url); } $user_subs_url = get_user_subs_url(); if (!empty($user_subs_url)) { // Display this menu item only when url is available to current user $userprefs_entries['subs'] = array('text' => T_('Notifications') . '…', 'href' => $user_subs_url); } $entries['userprefs'] = array('text' => '<strong>' . $current_User->get_colored_login(array('login_text' => 'name')) . '</strong>', 'href' => get_user_profile_url(), 'entries' => $userprefs_entries); $entries['time'] = array('text' => date(locale_shorttimefmt(), $localtimenow), 'disabled' => true, 'entry_class' => 'rwdhide'); if ($current_User->check_perm('admin', 'normal') && $current_User->check_perm('options', 'view')) { // Make time as link to Timezone settings if permission $entries['time']['disabled'] = false; $entries['time']['href'] = $admin_url . '?ctrl=time'; } // 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'] = 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' => $admin_url . '?ctrl=users&action=change_admin_skin&new_admin_skin=' . rawurlencode($admin_skin) . '&redirect_to=' . $redirect_to); } } } $entries['userprefs']['entries'][] = array('separator' => true); $entries['userprefs']['entries']['logout'] = array('text' => T_('Log out!'), 'href' => get_user_logout_url()); $topright_Menu->add_menu_entries(NULL, $entries); }
/** * Builds the 2nd half of the menu. This is the one with the configuration features * * At some point this might be displayed differently than the 1st half. */ function build_menu_2() { global $loc_transinfo, $ctrl, $admin_url; /** * @var User */ global $current_User; global $Blog; /** * @var AdminUI_general */ global $AdminUI; $blog = get_working_blog(); if (!$blog) { // No available blogs for current user return; } // Collection Dashboard $collection_menu_entries = array('dashboard' => array('text' => T_('Collection Dashboard'), 'href' => $admin_url . '?ctrl=dashboard&blog=' . $blog, 'order' => 'group_last')); $perm_comments = $current_User->check_perm('blog_comments', 'edit', false, $blog); $perm_cats = $current_User->check_perm('blog_cats', '', false, $blog); // Posts $collection_menu_entries['posts'] = array('text' => T_('Posts'), 'href' => $admin_url . '?ctrl=items&tab=full&filter=restore&blog=' . $blog); $last_group_menu_entry = 'posts'; if ($perm_comments) { // User has permission to edit published, draft or deprecated comments (at least one kind) $collection_menu_entries['comments'] = array('text' => T_('Comments'), 'href' => $admin_url . '?ctrl=comments&blog=' . $blog . '&filter=restore'); $last_group_menu_entry = 'comments'; } if ($perm_cats) { // Categories $collection_menu_entries['categories'] = array('text' => T_('Categories'), 'href' => $admin_url . '?ctrl=chapters&blog=' . $blog); $last_group_menu_entry = 'categories'; } // Mark last menu entry in group $collection_menu_entries[$last_group_menu_entry]['order'] = 'group_last'; $AdminUI->add_menu_entries('collections', $collection_menu_entries); if ($current_User->check_perm('blog_properties', 'edit', false, $blog)) { // Display these menus only when some blog is selected and current user has an access to edit the blog properties // BLOG SETTINGS: // We're on any other page, we may have a direct destination // + we have subtabs (fp > maybe the subtabs should go into the controller as for _items ?) $AdminUI->add_menu_entries('collections', array('features' => array('text' => T_('Features'), 'href' => $admin_url . '?ctrl=coll_settings&tab=home&blog=' . $blog, 'entries' => array('home' => array('text' => T_('Front page'), 'href' => $admin_url . '?ctrl=coll_settings&tab=home&blog=' . $blog), 'features' => array('text' => T_('Posts'), 'href' => $admin_url . '?ctrl=coll_settings&tab=features&blog=' . $blog), 'comments' => array('text' => T_('Comments'), 'href' => $admin_url . '?ctrl=coll_settings&tab=comments&blog=' . $blog), 'other' => array('text' => T_('Other displays'), 'href' => $admin_url . '?ctrl=coll_settings&tab=other&blog=' . $blog), 'more' => array('text' => T_('More'), 'href' => $admin_url . '?ctrl=coll_settings&tab=more&blog=' . $blog))), 'skin' => array('text' => T_('Skins'), 'href' => $admin_url . '?ctrl=coll_settings&tab=skin&blog=' . $blog, 'entries' => array('current_skin' => array('text' => T_('Skins for this blog'), 'href' => $admin_url . '?ctrl=coll_settings&tab=skin&blog=' . $blog))), 'plugin_settings' => array('text' => T_('Plugins'), 'href' => $admin_url . '?ctrl=coll_settings&tab=plugin_settings&blog=' . $blog), 'widgets' => array('text' => T_('Widgets'), 'href' => $admin_url . '?ctrl=widgets&blog=' . $blog, 'order' => 'group_last'), 'settings' => array('text' => T_('Settings'), 'href' => $admin_url . '?ctrl=coll_settings&tab=general&blog=' . $blog, 'entries' => array('general' => array('text' => T_('General'), 'href' => $admin_url . '?ctrl=coll_settings&tab=general&blog=' . $blog), 'urls' => array('text' => T_('URLs'), 'href' => $admin_url . '?ctrl=coll_settings&tab=urls&blog=' . $blog), 'seo' => array('text' => T_('SEO'), 'href' => $admin_url . '?ctrl=coll_settings&tab=seo&blog=' . $blog))))); if ($current_User->check_perm('options', 'view')) { // Manage skins $AdminUI->add_menu_entries(array('collections', 'skin'), array('manage_skins' => array('text' => T_('Manage skins'), 'href' => $admin_url . '?ctrl=skins&blog=' . $blog))); } if ($current_User->check_perm('options', 'view', false, $blog)) { // Post Types & Statuses $AdminUI->add_menu_entries(array('collections', 'settings'), array('types' => array('text' => T_('Post Types'), 'title' => T_('Post Types Management'), 'href' => $admin_url . '?ctrl=itemtypes&tab=settings&tab3=types&blog=' . $blog), 'statuses' => array('text' => T_('Post Statuses'), 'title' => T_('Post Statuses Management'), 'href' => $admin_url . '?ctrl=itemstatuses&tab=settings&tab3=statuses&blog=' . $blog))); } $AdminUI->add_menu_entries(array('collections', 'settings'), array('advanced' => array('text' => T_('Advanced'), 'href' => $admin_url . '?ctrl=coll_settings&tab=advanced&blog=' . $blog))); if ($Blog && $Blog->advanced_perms) { // Permissions $AdminUI->add_menu_entries(array('collections', 'settings'), array('perm' => array('text' => T_('User perms'), 'href' => $admin_url . '?ctrl=coll_settings&tab=perm&blog=' . $blog), 'permgroup' => array('text' => T_('Group perms'), 'href' => $admin_url . '?ctrl=coll_settings&tab=permgroup&blog=' . $blog))); } if ($current_User->check_perm('options', 'view')) { // Check if current user has a permission to view the common settings of the blogs $AdminUI->add_menu_entries(array('collections', 'settings'), array('blog_settings' => array('text' => T_('Common Settings'), 'href' => $admin_url . '?ctrl=collections&tab=blog_settings&blog=' . $blog))); } } }