/** * Profile Menu Hook, integrate_profile_areas, called from Profile.controller.php * * Used to add menu items to the profile area * Adds Connected Accounts to profile menu * * @param mixed[] $profile_areas */ function ipa_extauth(&$profile_areas) { global $user_info; // No need to show these profile option to guests, perhaps a view_awards permissions should be added? if ($user_info['is_guest']) { return; } $profile_areas = elk_array_insert($profile_areas, 'exit_profile', array('extauth' => array('label' => 'Connected Accounts', 'file' => 'Extauth.controller.php', 'controller' => 'Extauth_Controller', 'function' => 'action_profile', 'sc' => 'post', 'token' => 'profile-ea%u', 'password' => true, 'permission' => array('own' => array('profile_identity_any', 'profile_identity_own'), 'any' => array('profile_identity_any')))), 'after'); }
/** * ibb_fa_button * * - Editor hook, integrate_bbc_buttons hook, Called from Editor.subs.php * - Used to add buttons to the editor menu bar * * @param mixed[] $bbc_tags */ function ibb_fa_button(&$bbc_tags) { // This is the group we intend to modify $where = $bbc_tags['row1'][2]; // And here we insert the new value after font $bbc_tags['row1'][2] = elk_array_insert($where, 'font', array('fontawesome'), 'after', false); // Add the javascript, this tells the editor what to do with the new button loadJavascriptFile('faButton.plugin.js', array(), 'faButton'); // CSS specific to this button presentation in the editor toolbar loadCSSFile('faButton.css', array(), 'fa44'); }
/** * ibb_gist_button * * - Editor hook, integrate_bbc_buttons hook, Called from Editor.subs.php * - Used to add buttons to the editor menu bar * * @param mixed[] $bbc_tags */ function ibb_gist_button(&$bbc_tags) { global $context; // This is the group we intend to modify $where = $bbc_tags['row2'][0]; // And here we insert the new value after code $bbc_tags['row2'][0] = elk_array_insert($where, 'code', array('gist'), 'after', false); // Add the javascript, this tells the editor what to do with the new button loadJavascriptFile('GistButton.js', array(), 'GistButton'); // We need to supply the css for the button image, here we use a data-url to save an image call $context['html_headers'] .= '<style>.sceditor-button-gist div {background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAVpJREFUeNqM0s0rRGEUx/F7x0RKxob4A6bZKBYWFkLZqIkkC7FUsrCwoCxsZcN/IFmIP4E9ZWnyurBR3krZeH8b1/dMv5vTpDue+szzzL33nJ5znieIoihIGCGmMIt0+ctSbIUETbhHEbm/EqSD5PGOC2TwgHo04xaPv9tIHhbUoPUMXjAcx4aln9BKDcYxgRR20IJNDKEO69hCFie2JnYx3sGYJcQ5jrU2PTjEDbpwpeeXWPZN3NOLnLb8hm1UoaBAG3P6btR26pt4rblDDarRs6KOMh7fmr/idZxgAW3Y0H/r/IqCfYKU5o/yB1b7kY5tGp04Uwmh++5Vcx59PoGNWtV3pznQXK2SbLf76s8kVv09yLpGRro0SwoawIgrt1fNzPtT2FVd/WjVCdiL9qQb5k8ho3Ia8eTKea50TeMd2LZOXQmfmP9PrL/K3RjURTrAmk4lMcGPAAMAEvmJGW+ZZPAAAAAASUVORK5CYII=)}</style>'; }
/** * Menu Button hook, integrate_menu_buttons, called from subs.php * used to add top menu buttons * * @param mixed[] $buttons */ function sp_integrate_menu_buttons(&$buttons) { global $txt, $scripturl, $modSettings, $context; require_once SUBSDIR . '/Portal.subs.php'; loadLanguage('SPortal', sp_languageSelect('SPortal')); // Set the right portalurl based on what integration mode the portal is using if ($modSettings['sp_portal_mode'] == 1 && empty($context['disable_sp'])) { $sportalurl = $scripturl . '?action=forum'; } elseif ($modSettings['sp_portal_mode'] == 3 && empty($context['disable_sp'])) { $sportalurl = $modSettings['sp_standalone_url']; } else { $sportalurl = ''; } // Define the new menu item(s), show it for modes 1 and 3 only $buttons = elk_array_insert($buttons, 'home', array('forum' => array('title' => empty($txt['sp-forum']) ? 'Forum' : $txt['sp-forum'], 'data-icon' => '', 'href' => $sportalurl, 'show' => in_array($modSettings['sp_portal_mode'], array(1, 3)) && empty($context['disable_sp']), 'sub_buttons' => array())), 'after'); }
/** * Sets up all of the top menu buttons * * What it does: * - defines every master item in the menu, as well as any sub-items * - ensures the chosen action is set so the menu is highlighted * - Saves them in the cache if it is available and on * - Places the results in $context */ function setupMenuContext() { global $context, $modSettings, $user_info, $txt, $scripturl, $settings; // Set up the menu privileges. $context['allow_search'] = !empty($modSettings['allow_guestAccess']) ? allowedTo('search_posts') : !$user_info['is_guest'] && allowedTo('search_posts'); $context['allow_admin'] = allowedTo(array('admin_forum', 'manage_boards', 'manage_permissions', 'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_attachments', 'manage_smileys')); $context['allow_edit_profile'] = !$user_info['is_guest'] && allowedTo(array('profile_view_own', 'profile_view_any', 'profile_identity_own', 'profile_identity_any', 'profile_extra_own', 'profile_extra_any', 'profile_remove_own', 'profile_remove_any', 'moderate_forum', 'manage_membergroups', 'profile_title_own', 'profile_title_any')); $context['allow_memberlist'] = allowedTo('view_mlist'); $context['allow_calendar'] = allowedTo('calendar_view') && !empty($modSettings['cal_enabled']); $context['allow_moderation_center'] = $context['user']['can_mod']; $context['allow_pm'] = allowedTo('pm_read'); if ($context['allow_search']) { $context['theme_header_callbacks'] = elk_array_insert($context['theme_header_callbacks'], 'login_bar', array('search_bar'), 'after'); } $cacheTime = $modSettings['lastActive'] * 60; // Update the Moderation menu items with action item totals if ($context['allow_moderation_center']) { // Get the numbers for the menu ... require_once SUBSDIR . '/Moderation.subs.php'; $menu_count = loadModeratorMenuCounts(); } $menu_count['unread_messages'] = $context['user']['unread_messages']; $menu_count['mentions'] = $context['user']['mentions']; // All the buttons we can possible want and then some, try pulling the final list of buttons from cache first. if (($menu_buttons = cache_get_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $cacheTime)) === null || time() - $cacheTime <= $modSettings['settings_updated']) { // Start things up: this is what we know by default require_once SUBSDIR . '/Menu.subs.php'; $buttons = array('home' => array('title' => $txt['community'], 'href' => $scripturl, 'data-icon' => '', 'show' => true, 'sub_buttons' => array('help' => array('title' => $txt['help'], 'href' => $scripturl . '?action=help', 'show' => true), 'search' => array('title' => $txt['search'], 'href' => $scripturl . '?action=search', 'show' => $context['allow_search']), 'calendar' => array('title' => $txt['calendar'], 'href' => $scripturl . '?action=calendar', 'show' => $context['allow_calendar']), 'memberlist' => array('title' => $txt['members_title'], 'href' => $scripturl . '?action=memberlist', 'show' => $context['allow_memberlist']), 'recent' => array('title' => $txt['recent_posts'], 'href' => $scripturl . '?action=recent', 'show' => true)))); // Will change title correctly if user is either a mod or an admin. // Button highlighting works properly too (see current action stuffz). if ($context['allow_admin']) { $buttons['admin'] = array('title' => $context['current_action'] !== 'moderate' ? $txt['admin'] : $txt['moderate'], 'counter' => 'grand_total', 'href' => $scripturl . '?action=admin', 'data-icon' => '', 'show' => true, 'sub_buttons' => array('admin_center' => array('title' => $txt['admin_center'], 'href' => $scripturl . '?action=admin', 'show' => $context['allow_admin']), 'featuresettings' => array('title' => $txt['modSettings_title'], 'href' => $scripturl . '?action=admin;area=featuresettings', 'show' => allowedTo('admin_forum')), 'packages' => array('title' => $txt['package'], 'href' => $scripturl . '?action=admin;area=packages', 'show' => allowedTo('admin_forum')), 'permissions' => array('title' => $txt['edit_permissions'], 'href' => $scripturl . '?action=admin;area=permissions', 'show' => allowedTo('manage_permissions')), 'errorlog' => array('title' => $txt['errlog'], 'href' => $scripturl . '?action=admin;area=logs;sa=errorlog;desc', 'show' => allowedTo('admin_forum') && !empty($modSettings['enableErrorLogging'])), 'moderate_sub' => array('title' => $txt['moderate'], 'counter' => 'grand_total', 'href' => $scripturl . '?action=moderate', 'show' => $context['allow_moderation_center'], 'sub_buttons' => array('reports' => array('title' => $txt['mc_reported_posts'], 'counter' => 'reports', 'href' => $scripturl . '?action=moderate;area=reports', 'show' => !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1'), 'modlog' => array('title' => $txt['modlog_view'], 'href' => $scripturl . '?action=moderate;area=modlog', 'show' => !empty($modSettings['modlog_enabled']) && !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1'), 'attachments' => array('title' => $txt['mc_unapproved_attachments'], 'counter' => 'attachments', 'href' => $scripturl . '?action=moderate;area=attachmod;sa=attachments', 'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap'])), 'poststopics' => array('title' => $txt['mc_unapproved_poststopics'], 'counter' => 'postmod', 'href' => $scripturl . '?action=moderate;area=postmod;sa=posts', 'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap'])), 'postbyemail' => array('title' => $txt['mc_emailerror'], 'counter' => 'emailmod', 'href' => $scripturl . '?action=admin;area=maillist;sa=emaillist', 'show' => !empty($modSettings['maillist_enabled']) && allowedTo('approve_emails')))))); } else { $buttons['admin'] = array('title' => $txt['moderate'], 'counter' => 'grand_total', 'href' => $scripturl . '?action=moderate', 'data-icon' => '', 'show' => $context['allow_moderation_center'], 'sub_buttons' => array('reports' => array('title' => $txt['mc_reported_posts'], 'counter' => 'reports', 'href' => $scripturl . '?action=moderate;area=reports', 'show' => !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1'), 'modlog' => array('title' => $txt['modlog_view'], 'href' => $scripturl . '?action=moderate;area=modlog', 'show' => !empty($modSettings['modlog_enabled']) && !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1'), 'attachments' => array('title' => $txt['mc_unapproved_attachments'], 'counter' => 'attachments', 'href' => $scripturl . '?action=moderate;area=attachmod;sa=attachments', 'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap'])), 'poststopics' => array('title' => $txt['mc_unapproved_poststopics'], 'counter' => 'postmod', 'href' => $scripturl . '?action=moderate;area=postmod;sa=posts', 'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap'])), 'postbyemail' => array('title' => $txt['mc_emailerror'], 'counter' => 'emailmod', 'href' => $scripturl . '?action=admin;area=maillist;sa=emaillist', 'show' => !empty($modSettings['maillist_enabled']) && allowedTo('approve_emails')))); } $buttons += array('profile' => array('title' => (!empty($user_info['avatar']['href']) ? '<img class="avatar" src="' . $user_info['avatar']['href'] . '" alt="" /> ' : '') . (!empty($modSettings['displayMemberNames']) ? $user_info['name'] : $txt['account_short']), 'href' => $scripturl . '?action=profile', 'data-icon' => '', 'show' => $context['allow_edit_profile'], 'sub_buttons' => array('account' => array('title' => $txt['account'], 'href' => $scripturl . '?action=profile;area=account', 'show' => allowedTo(array('profile_identity_any', 'profile_identity_own', 'manage_membergroups'))), 'forumprofile' => array('title' => $txt['forumprofile'], 'href' => $scripturl . '?action=profile;area=forumprofile', 'show' => allowedTo(array('profile_extra_any', 'profile_extra_own'))), 'theme' => array('title' => $txt['theme'], 'href' => $scripturl . '?action=profile;area=theme', 'show' => allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_extra_any'))), 'logout' => array('title' => $txt['logout'], 'href' => $scripturl . '?action=logout', 'show' => !$user_info['is_guest']))), 'pm' => array('title' => $txt['pm_short'], 'counter' => 'unread_messages', 'href' => $scripturl . '?action=pm', 'data-icon' => '', 'show' => $context['allow_pm'], 'sub_buttons' => array('pm_read' => array('title' => $txt['pm_menu_read'], 'href' => $scripturl . '?action=pm', 'show' => allowedTo('pm_read')), 'pm_send' => array('title' => $txt['pm_menu_send'], 'href' => $scripturl . '?action=pm;sa=send', 'show' => allowedTo('pm_send')))), 'mentions' => array('title' => $txt['mention'], 'counter' => 'mentions', 'href' => $scripturl . '?action=mentions', 'data-icon' => '', 'show' => !$user_info['is_guest'] && !empty($modSettings['mentions_enabled'])), 'unread' => array('title' => $txt['view_unread_category'], 'href' => $scripturl . '?action=unread', 'data-icon' => '', 'show' => !$user_info['is_guest']), 'unreadreplies' => array('title' => $txt['view_replies_category'], 'href' => $scripturl . '?action=unreadreplies', 'data-icon' => '', 'show' => !$user_info['is_guest']), 'login' => array('title' => $txt['login'], 'href' => $scripturl . '?action=login', 'data-icon' => '', 'show' => $user_info['is_guest']), 'register' => array('title' => $txt['register'], 'href' => $scripturl . '?action=register', 'data-icon' => '', 'show' => $user_info['is_guest'] && $context['can_register']), 'contact' => array('title' => $txt['contact'], 'href' => $scripturl . '?action=contact', 'data-icon' => '', 'show' => $user_info['is_guest'] && !empty($modSettings['enable_contactform']) && $modSettings['enable_contactform'] == 'menu')); // Allow editing menu buttons easily. call_integration_hook('integrate_menu_buttons', array(&$buttons, &$menu_count)); // Now we put the buttons in the context so the theme can use them. $menu_buttons = array(); foreach ($buttons as $act => $button) { if (!empty($button['show'])) { $button['active_button'] = false; // This button needs some action. if (isset($button['action_hook'])) { $needs_action_hook = true; } if (isset($button['counter']) && !empty($menu_count[$button['counter']])) { $button['alttitle'] = $button['title'] . ' [' . $menu_count[$button['counter']] . ']'; if (!empty($settings['menu_numeric_notice'][0])) { $button['title'] .= sprintf($settings['menu_numeric_notice'][0], $menu_count[$button['counter']]); $button['indicator'] = true; } } // Go through the sub buttons if there are any. if (isset($button['sub_buttons'])) { foreach ($button['sub_buttons'] as $key => $subbutton) { if (empty($subbutton['show'])) { unset($button['sub_buttons'][$key]); } elseif (isset($subbutton['counter']) && !empty($menu_count[$subbutton['counter']])) { $button['sub_buttons'][$key]['alttitle'] = $subbutton['title'] . ' [' . $menu_count[$subbutton['counter']] . ']'; if (!empty($settings['menu_numeric_notice'][1])) { $button['sub_buttons'][$key]['title'] .= sprintf($settings['menu_numeric_notice'][1], $menu_count[$subbutton['counter']]); } // 2nd level sub buttons next... if (isset($subbutton['sub_buttons'])) { foreach ($subbutton['sub_buttons'] as $key2 => $subbutton2) { $button['sub_buttons'][$key]['sub_buttons'][$key2] = $subbutton2; if (empty($subbutton2['show'])) { unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); } elseif (isset($subbutton2['counter']) && !empty($menu_count[$subbutton2['counter']])) { $button['sub_buttons'][$key]['sub_buttons'][$key2]['alttitle'] = $subbutton2['title'] . ' [' . $menu_count[$subbutton2['counter']] . ']'; if (!empty($settings['menu_numeric_notice'][2])) { $button['sub_buttons'][$key]['sub_buttons'][$key2]['title'] .= sprintf($settings['menu_numeric_notice'][2], $menu_count[$subbutton2['counter']]); } unset($menu_count[$subbutton2['counter']]); } } } } } } $menu_buttons[$act] = $button; } } if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); } } if (!empty($menu_buttons['profile']['sub_buttons']['logout'])) { $menu_buttons['profile']['sub_buttons']['logout']['href'] .= ';' . $context['session_var'] . '=' . $context['session_id']; } $context['menu_buttons'] = $menu_buttons; // Figure out which action we are doing so we can set the active tab. // Default to home. $current_action = 'home'; if (isset($context['menu_buttons'][$context['current_action']])) { $current_action = $context['current_action']; } elseif ($context['current_action'] == 'profile') { $current_action = 'pm'; } elseif ($context['current_action'] == 'theme') { $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; } elseif ($context['current_action'] == 'register2') { $current_action = 'register'; } elseif ($context['current_action'] == 'login2' || $user_info['is_guest'] && $context['current_action'] == 'reminder') { $current_action = 'login'; } elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) { $current_action = 'moderate'; } elseif ($context['current_action'] == 'moderate' && $context['allow_admin']) { $current_action = 'admin'; } // Not all actions are simple. if (!empty($needs_action_hook)) { call_integration_hook('integrate_current_action', array(&$current_action)); } if (isset($context['menu_buttons'][$current_action])) { $context['menu_buttons'][$current_action]['active_button'] = true; } }