<li><a href="<?php echo get_user_preferences_url(); ?> "><?php echo T_('Preferences'); ?> </a></li> <li><a href="<?php echo get_user_subs_url(); ?> "><?php echo T_('Notifications'); ?> </a></li> <li><a href="<?php echo get_user_logout_url(); ?> "><?php echo T_('Log out'); ?> </a></li> </ul> </div> <?php } ?> </div> <div id="headerbar"> <div id="headerbar-title"> <a href="<?php
/** * 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&blog=' . $Blog->ID . '&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') . '…', 'href' => $items_url . '&tab=manual'); } $entries['blog']['entries']['posts'] = array('text' => T_('Posts') . '…', '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') . '…', 'href' => $admin_url . '?ctrl=comments&blog=' . $Blog->ID . '&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') . '…', 'href' => $admin_url . '?ctrl=chapters&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 = '&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') . '…', 'href' => $admin_url . '?ctrl=coll_settings&tab=general' . $blog_param), 'features' => array('text' => T_('Features') . '…', 'href' => $admin_url . '?ctrl=coll_settings&tab=features' . $blog_param), 'skin' => array('text' => T_('Skin') . '…', 'href' => $admin_url . '?ctrl=coll_settings&tab=skin' . $blog_param), 'plugin_settings' => array('text' => T_('Plugins') . '…', 'href' => $admin_url . '?ctrl=coll_settings&tab=plugin_settings' . $blog_param), 'widgets' => array('text' => T_('Widgets') . '…', 'href' => $admin_url . '?ctrl=widgets' . $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), '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); } } } } // 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') . '…', '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') . '…', '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']['tools_sep'] = array('separator' => true); if ($perm_options) { $entries['tools']['entries']['status'] = array('text' => T_('System status') . '…', 'href' => $admin_url . '?ctrl=system'); } if ($perm_options) { $entries['tools']['entries']['crontab'] = array('text' => T_('Scheduler') . '…', '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') . '…', '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') . '…', 'href' => $admin_url . '?ctrl=antispam&tab3=ipranges'); $entries['tools']['entries']['antispam']['entries']['settings'] = array('text' => T_('Settings') . '…', 'href' => $admin_url . '?ctrl=antispam&tab3=settings'); if ($current_User->check_perm('options', 'edit')) { $entries['tools']['entries']['antispam']['entries']['tools'] = array('text' => T_('Tools') . '…', 'href' => $admin_url . '?ctrl=antispam&tab3=tools'); } } } if ($perm_slugs) { $entries['tools']['entries']['slugs'] = array('text' => T_('Slugs') . '…', 'href' => $admin_url . '?ctrl=slugs'); } } if ($perm_options) { // Global settings: $entries['tools']['entries']['general'] = array('text' => T_('General') . '…', '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') . '…', 'href' => $admin_url . '?ctrl=locales'), 'time' => array('text' => T_('Time') . '…', 'href' => $admin_url . '?ctrl=time'), 'countries' => array('text' => T_('Countries') . '…', 'href' => $admin_url . '?ctrl=countries'), 'regions' => array('text' => T_('Regions') . '…', 'href' => $admin_url . '?ctrl=regions'), 'subregions' => array('text' => T_('Sub-regions') . '…', 'href' => $admin_url . '?ctrl=subregions'), 'cities' => array('text' => T_('Cities') . '…', 'href' => $admin_url . '?ctrl=cities'), 'currencies' => array('text' => T_('Currencies') . '…', 'href' => $admin_url . '?ctrl=currencies'))); $entries['tools']['entries']['plugins'] = array('text' => T_('Plugins') . '…', 'href' => $admin_url . '?ctrl=plugins'); $entries['tools']['entries']['remote'] = array('text' => T_('Remote publishing') . '…', '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') . '…', 'href' => $admin_url . '?ctrl=tools'), 'import' => array('text' => T_('Import') . '…', 'href' => $admin_url . '?ctrl=tools&tab3=import'), 'test' => array('text' => T_('Testing') . '…', 'href' => $admin_url . '?ctrl=tools&tab3=test'), 'backup' => array('text' => T_('Backup') . '…', 'href' => $admin_url . '?ctrl=backup'), 'upgrade' => array('text' => T_('Check for updates') . '…', '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') . '…', 'href' => get_user_profile_url()), 'avatar' => array('text' => T_('Your profile picture') . '…', 'href' => get_user_avatar_url()), 'pwdchange' => array('text' => T_('Change password') . '…', 'href' => get_user_pwdchange_url()), 'userprefs' => array('text' => T_('Preferences') . '…', 'href' => get_user_preferences_url()), 'subs' => array('text' => T_('Notifications') . '…', '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&action=change_admin_skin&new_admin_skin=' . rawurlencode($admin_skin) . '&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()))); }
/** * Display the widget! * * @param array MUST contain at least the basic display params */ function display($params) { /** * @var Blog */ global $Blog; global $disp; $this->init_display($params); // Default link class $link_class = $this->disp_params['link_default_class']; $blog_ID = intval($this->disp_params['blog_ID']); if ($blog_ID > 0) { // Try to use blog from widget setting $BlogCache =& get_BlogCache(); $current_Blog =& $BlogCache->get_by_ID($blog_ID, false, false); } if (empty($current_Blog)) { // Blog is not defined in setting or it doesn't exist in DB // Use current blog $current_Blog =& $Blog; } if (empty($current_Blog)) { // We cannot use this widget without a current collection: return false; } switch ($this->disp_params['link_type']) { case 'recentposts': $url = $current_Blog->get('recentpostsurl'); if (is_same_url($url, $Blog->get('url'))) { // This menu item has the same url as front page of blog $EnabledWidgetCache =& get_EnabledWidgetCache(); $Widget_array =& $EnabledWidgetCache->get_by_coll_container($current_Blog->ID, NT_('Menu')); if (!empty($Widget_array)) { foreach ($Widget_array as $Widget) { $Widget->init_display($params); if (isset($Widget->param_array, $Widget->param_array['link_type']) && $Widget->param_array['link_type'] == 'home') { // Don't display this menu if 'Blog home' menu item exists with the same url return false; } } } } $text = T_('Recently'); if ($disp == 'posts') { // Let's display the link as selected $link_class = $this->disp_params['link_selected_class']; } break; case 'search': $url = $current_Blog->get('searchurl'); $text = T_('Search'); // Is this the current display? if ($disp == 'search') { // Let's display the link as selected $link_class = $this->disp_params['link_selected_class']; } break; case 'arcdir': $url = $current_Blog->get('arcdirurl'); $text = T_('Archives'); if ($disp == 'arcdir') { // Let's display the link as selected $link_class = $this->disp_params['link_selected_class']; } break; case 'catdir': $url = $current_Blog->get('catdirurl'); $text = T_('Categories'); if ($disp == 'catdir') { // Let's display the link as selected $link_class = $this->disp_params['link_selected_class']; } break; case 'tags': $url = $current_Blog->get('tagsurl'); $text = T_('Tags'); if ($disp == 'tags') { // Let's display the link as selected: $link_class = $this->disp_params['link_selected_class']; } break; case 'postidx': $url = $current_Blog->get('postidxurl'); $text = T_('Post index'); if ($disp == 'postidx') { // Let's display the link as selected $link_class = $this->disp_params['link_selected_class']; } break; case 'mediaidx': $url = $current_Blog->get('mediaidxurl'); $text = T_('Photo index'); if ($disp == 'mediaidx') { // Let's display the link as selected $link_class = $this->disp_params['link_selected_class']; } break; case 'sitemap': $url = $current_Blog->get('sitemapurl'); $text = T_('Site map'); if ($disp == 'sitemap') { // Let's display the link as selected $link_class = $this->disp_params['link_selected_class']; } break; case 'latestcomments': if (!$current_Blog->get_setting('comments_latest')) { // This page is disabled return false; } $url = $current_Blog->get('lastcommentsurl'); $text = T_('Latest comments'); if ($disp == 'comments') { // Let's display the link as selected $link_class = $this->disp_params['link_selected_class']; } break; case 'owneruserinfo': $url = url_add_param($current_Blog->get('userurl'), 'user_ID=' . $current_Blog->owner_user_ID); $text = T_('Owner details'); // Is this the current display? global $User; if ($disp == 'user' && !empty($User) && $User->ID == $current_Blog->owner_user_ID) { // Let's display the link as selected $link_class = $this->disp_params['link_selected_class']; } break; case 'ownercontact': if (!($url = $current_Blog->get_contact_url(true))) { // user does not allow contact form: return; } $text = T_('Contact'); // Is this the current display? if ($disp == 'msgform' || isset($_GET['disp']) && $_GET['disp'] == 'msgform') { // Let's display the link as selected // fp> I think it's interesting to select this link , even if the recipient ID is different from the owner // odds are there is no other link to highlight in this case $link_class = $this->disp_params['link_selected_class']; } break; case 'login': if (is_logged_in()) { // Don't display this link for already logged in users return false; } global $Settings; $url = get_login_url('menu link', $Settings->get('redirect_to_after_login'), false, $current_Blog->ID); if (isset($this->BlockCache)) { // Do NOT cache because some of these links are using a redirect_to param, which makes it page dependent. // so this will be cached by the PageCache; there is no added benefit to cache it in the BlockCache // (which could have been shared between several pages): $this->BlockCache->abort_collect(); } $text = T_('Log in'); // Is this the current display? if ($disp == 'login') { // Let's display the link as selected $link_class = $this->disp_params['link_selected_class']; } break; case 'logout': if (!is_logged_in()) { return false; } $url = get_user_logout_url($current_Blog->ID); $text = T_('Log out'); break; case 'register': if (!($url = get_user_register_url(NULL, 'menu link', false, '&', $current_Blog->ID))) { return false; } if (isset($this->BlockCache)) { // Do NOT cache because some of these links are using a redirect_to param, which makes it page dependent. // Note: also beware of the source param. // so this will be cached by the PageCache; there is no added benefit to cache it in the BlockCache // (which could have been shared between several pages): $this->BlockCache->abort_collect(); } $text = T_('Register'); // Is this the current display? if ($disp == 'register') { // Let's display the link as selected $link_class = $this->disp_params['link_selected_class']; } break; case 'profile': if (!is_logged_in()) { return false; } $url = get_user_profile_url($current_Blog->ID); $text = T_('Edit profile'); // Is this the current display? (Edit my Profile) if (in_array($disp, array('profile', 'avatar', 'pwdchange', 'userprefs', 'subs'))) { // Let's display the link as selected $link_class = $this->disp_params['link_selected_class']; } break; case 'avatar': if (!is_logged_in()) { return false; } $url = get_user_avatar_url($current_Blog->ID); $text = T_('Profile picture'); // Note: we never highlight this, it will always highlight 'profile' instead break; case 'users': global $Settings; if (!is_logged_in() && !$Settings->get('allow_anonymous_user_list')) { // Don't allow anonymous users to see users list return false; } $url = $current_Blog->get('usersurl'); $text = T_('User directory'); // Is this the current display? // Note: If $user_ID is not set, it means we are viewing "My Profile" instead global $user_ID; if ($disp == 'users' || $disp == 'user' && !empty($user_ID)) { // Let's display the link as selected // Note: we also highlight this for any user profile that is displayed $link_class = $this->disp_params['link_selected_class']; } break; case 'item': $ItemCache =& get_ItemCache(); /** * @var Item */ $item_ID = intval($this->disp_params['item_ID']); $disp_Item =& $ItemCache->get_by_ID($item_ID, false, false); if (empty($disp_Item)) { // Item not found return false; } $url = $disp_Item->get_permanent_url(); $text = $disp_Item->title; // Is this the current item? global $Item; if (!empty($Item) && $disp_Item->ID == $Item->ID) { // The current page is currently displaying the Item this link is pointing to // Let's display it as selected $link_class = $this->disp_params['link_selected_class']; } break; case 'url': if (empty($this->disp_params['link_href'])) { // Don't display a link if url is empty return false; } $url = $this->disp_params['link_href']; $text = '[URL]'; // should normally be overriden below... // Note: we never highlight this link break; case 'postnew': if (!check_item_perm_create()) { // Don't allow users to create a new post return false; } $url = url_add_param($current_Blog->get('url'), 'disp=edit'); $text = T_('Write a new post'); // Is this the current display? if ($disp == 'edit') { // Let's display the link as selected $link_class = $this->disp_params['link_selected_class']; } break; case 'myprofile': if (!is_logged_in()) { // Don't show this link for not logged in users return false; } $url = $current_Blog->get('userurl'); $text = T_('My profile'); // Is this the current display? (Edit my Profile) global $user_ID, $current_User; // If $user_ID is not set, it means we will fall back to the current user, so it's ok // If $user_ID is set, it means we are browsing the directory instead if ($disp == 'user' && empty($user_ID)) { // Let's display the link as selected $link_class = $this->disp_params['link_selected_class']; } break; case 'admin': global $current_User; if (!(is_logged_in() && $current_User->check_perm('admin', 'restricted') && $current_User->check_status('can_access_admin'))) { // Don't allow admin url for users who have no access to backoffice return false; } global $admin_url; $url = $admin_url; $text = T_('Admin') . ' »'; break; case 'home': default: $url = $current_Blog->get('url'); $text = T_('Front Page'); global $is_front; if ($disp == 'front' || !empty($is_front)) { // Let's display the link as selected on front page $link_class = $this->disp_params['link_selected_class']; } } // Override default link text? if (!empty($this->param_array['link_text'])) { // We have a custom link text: $text = $this->param_array['link_text']; } echo $this->disp_params['block_start']; echo $this->disp_params['block_body_start']; echo $this->disp_params['list_start']; if ($link_class == $this->disp_params['link_selected_class']) { echo $this->disp_params['item_selected_start']; } else { echo $this->disp_params['item_start']; } echo '<a href="' . $url . '" class="' . $link_class . '">' . $text . '</a>'; if ($link_class == $this->disp_params['link_selected_class']) { echo $this->disp_params['item_selected_end']; } else { echo $this->disp_params['item_end']; } echo $this->disp_params['list_end']; echo $this->disp_params['block_body_end']; echo $this->disp_params['block_end']; 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); }
/** * Template tag: Get a link to logout * * @param string * @param string * @param string link text can include %s for current user login * @return string */ function get_user_logout_link($before = '', $after = '', $link_text = '', $link_title = '#', $params = array()) { global $current_User; if (!is_logged_in()) { return false; } if ($link_text == '') { $link_text = T_('Logout'); } if ($link_title == '#') { $link_title = T_('Logout from your account'); } $r = $before; $r .= '<a href="' . get_user_logout_url() . '"'; $r .= get_field_attribs_as_string($params, false); $r .= ' title="' . $link_title . '">'; $r .= sprintf($link_text, $current_User->login); $r .= '</a>'; $r .= $after; return $r; }