News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Large numbers of Undefined errors in Log

Started by makv, May 09, 2015, 08:04:26 AM

Previous topic - Next topic

makv

I have purging on after 30 days, and currently have around 9000 Undefined errors in the logs. So roughly 300 a day. Many (but my no means all) are these:


http://xxxxxxx/smf/index.php?action=search2
8: Undefined index: title
File: /var/www/smf/Themes/default/index.template.php
Line: 425


http://xxxxxxx/smf/index.php?action=search2
8: Undefined index: href
File: /var/www/smf/Themes/default/index.template.php
Line: 424

We are on 2.0.10

Any thoughts or suggestions?

JBlaze

Attach your default theme's index.template.php here
Jason Clemons
Former Team Member 2009 - 2012

makv


JBlaze

Have you recently installed/uninstalled any mods?
Jason Clemons
Former Team Member 2009 - 2012

makv

Quote from: zilladotexe on May 09, 2015, 08:30:36 AM
Have you recently installed/uninstalled any mods?

Yes. The lovely tapatalk mod (uninstalled then re-installed as it doesn't handle upgrades). Subsequent to the 2.0.10 upgrade.

JBlaze

My guess is that something buggered up your Subs.php menu array, and is missing the 'href' and 'target' keys. I'm not on my home computer right now, so I can't provide any more help.

If you can, look through /Sources/Subs.php and find the setupMenuContext() function, and paste the entire function here
Jason Clemons
Former Team Member 2009 - 2012

Illori

do you have an entry in your main menu that is now showing correctly/completely? can you provide a link to your forum?

how did you upgrade to 2.0.10? large upgrade package? if so you need to remove your hooks and then reinstall your mods.

http://wiki.simplemachines.org/smf/Manually_setting_a_package_installed_or_uninstalled

Steve

If tapatalk is uninstalled, do the errors go away?
DO NOT pm me for support!

makv

Quote from: Steve on May 09, 2015, 09:08:45 AM
If tapatalk is uninstalled, do the errors go away?

I think that would seriously piss off my users, but I'll try as a last resort!

makv

Quote from: zilladotexe on May 09, 2015, 09:03:15 AM
My guess is that something buggered up your Subs.php menu array, and is missing the 'href' and 'target' keys. I'm not on my home computer right now, so I can't provide any more help.

If you can, look through /Sources/Subs.php and find the setupMenuContext() function, and paste the entire function here


// Setup the main menu items.
setupMenuContext();

if (empty($settings['theme_version']))
$context['show_vBlogin'] = $context['show_quick_login'];

// This is here because old index templates might still use it.
$context['show_news'] = !empty($settings['enable_news']);

// ILA in line attachment changes

$context['html_headers'] .=  '<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/ila.js"></script>';

// End ILA in line attachment changes


// This is done to allow theme authors to customize it as they want.
$context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm');

// Resize avatars the fancy, but non-GD requiring way.
if ($modSettings['avatar_action_too_large'] == 'option_js_resize' && (!empty($modSettings['avatar_max_width_external']) || !empty($modSettings['avatar_max_height_external'])))
{
$context['html_headers'] .= '
<script type="text/javascript"><!-- // --><![CDATA[
var smf_avatarMaxWidth = ' . (int) $modSettings['avatar_max_width_external'] . ';
var smf_avatarMaxHeight = ' . (int) $modSettings['avatar_max_height_external'] . ';';

if (!$context['browser']['is_ie'] && !$context['browser']['is_mac_ie'])
$context['html_headers'] .= '
window.addEventListener("load", smf_avatarResize, false);';
else
$context['html_headers'] .= '
var window_oldAvatarOnload = window.onload;
window.onload = smf_avatarResize;';

// !!! Move this over to script.js?
$context['html_headers'] .= '
// ]]></script>';
}

// This looks weird, but it's because BoardIndex.php references the variable.
$context['common_stats']['latest_member'] = array(
'id' => $modSettings['latestMember'],
'name' => $modSettings['latestRealName'],
'href' => $scripturl . '?action=profile;u=' . $modSettings['latestMember'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $modSettings['latestMember'] . '">' . $modSettings['latestRealName'] . '</a>',
);
$context['common_stats'] = array(
'total_posts' => comma_format($modSettings['totalMessages']),
'total_topics' => comma_format($modSettings['totalTopics']),
'total_members' => comma_format($modSettings['totalMembers']),
'latest_member' => $context['common_stats']['latest_member'],
);

if (empty($settings['theme_version']))
$context['html_headers'] .= '
<script type="text/javascript"><!-- // --><![CDATA[
var smf_scripturl = "' . $scripturl . '";
// ]]></script>';

if (!isset($context['page_title']))
$context['page_title'] = '';

// Set some specific vars.
$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title']));
$context['meta_keywords'] = !empty($modSettings['meta_keywords']) ? $smcFunc['htmlspecialchars']($modSettings['meta_keywords']) : '';
}


makv

Quote from: Illori on May 09, 2015, 09:03:56 AM
do you have an entry in your main menu that is now showing correctly/completely? can you provide a link to your forum?

how did you upgrade to 2.0.10? large upgrade package? if so you need to remove your hooks and then reinstall your mods.

http://wiki.simplemachines.org/smf/Manually_setting_a_package_installed_or_uninstalled

Yes, the forum itself works fine, and we aren't getting any actual issues from users. Can't post the URL unfortunately, as we are a private forum.

Just concerned by the number of log entries. I didn't use the large upgrade package, no.

JBlaze

Quote from: makv on May 09, 2015, 09:15:39 AM
Quote from: zilladotexe on May 09, 2015, 09:03:15 AM
My guess is that something buggered up your Subs.php menu array, and is missing the 'href' and 'target' keys. I'm not on my home computer right now, so I can't provide any more help.

If you can, look through /Sources/Subs.php and find the setupMenuContext() function, and paste the entire function here


// Setup the main menu items.
setupMenuContext();

if (empty($settings['theme_version']))
$context['show_vBlogin'] = $context['show_quick_login'];

// This is here because old index templates might still use it.
$context['show_news'] = !empty($settings['enable_news']);

// ILA in line attachment changes

$context['html_headers'] .=  '<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/ila.js"></script>';

// End ILA in line attachment changes


// This is done to allow theme authors to customize it as they want.
$context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm');

// Resize avatars the fancy, but non-GD requiring way.
if ($modSettings['avatar_action_too_large'] == 'option_js_resize' && (!empty($modSettings['avatar_max_width_external']) || !empty($modSettings['avatar_max_height_external'])))
{
$context['html_headers'] .= '
<script type="text/javascript"><!-- // --><![CDATA[
var smf_avatarMaxWidth = ' . (int) $modSettings['avatar_max_width_external'] . ';
var smf_avatarMaxHeight = ' . (int) $modSettings['avatar_max_height_external'] . ';';

if (!$context['browser']['is_ie'] && !$context['browser']['is_mac_ie'])
$context['html_headers'] .= '
window.addEventListener("load", smf_avatarResize, false);';
else
$context['html_headers'] .= '
var window_oldAvatarOnload = window.onload;
window.onload = smf_avatarResize;';

// !!! Move this over to script.js?
$context['html_headers'] .= '
// ]]></script>';
}

// This looks weird, but it's because BoardIndex.php references the variable.
$context['common_stats']['latest_member'] = array(
'id' => $modSettings['latestMember'],
'name' => $modSettings['latestRealName'],
'href' => $scripturl . '?action=profile;u=' . $modSettings['latestMember'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $modSettings['latestMember'] . '">' . $modSettings['latestRealName'] . '</a>',
);
$context['common_stats'] = array(
'total_posts' => comma_format($modSettings['totalMessages']),
'total_topics' => comma_format($modSettings['totalTopics']),
'total_members' => comma_format($modSettings['totalMembers']),
'latest_member' => $context['common_stats']['latest_member'],
);

if (empty($settings['theme_version']))
$context['html_headers'] .= '
<script type="text/javascript"><!-- // --><![CDATA[
var smf_scripturl = "' . $scripturl . '";
// ]]></script>';

if (!isset($context['page_title']))
$context['page_title'] = '';

// Set some specific vars.
$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title']));
$context['meta_keywords'] = !empty($modSettings['meta_keywords']) ? $smcFunc['htmlspecialchars']($modSettings['meta_keywords']) : '';
}



Correct function, wrong file :)

Find it in /Sources/Subs.php and paste the entire function. It should look like this:

function setupMenuContext()
{
global $context, $modSettings, $user_info, $txt, $scripturl;
// Set up the menu privileges.
$context['allow_search'] = 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');
$cacheTime = $modSettings['lastActive'] * 60;
// 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'])
{
$buttons = array(
'home' => array(
'title' => $txt['home'],
'href' => $scripturl,
'show' => true,
'sub_buttons' => array(
),
'is_last' => $context['right_to_left'],
),
'help' => array(
'title' => $txt['help'],
'href' => $scripturl . '?action=help',
'show' => true,
'sub_buttons' => array(
),
),
'search' => array(
'title' => $txt['search'],
'href' => $scripturl . '?action=search',
'show' => $context['allow_search'],
'sub_buttons' => array(
),
),
'admin' => array(
'title' => $txt['admin'],
'href' => $scripturl . '?action=admin',
'show' => $context['allow_admin'],
'sub_buttons' => array(
'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'),
),
'errorlog' => array(
'title' => $txt['errlog'],
'href' => $scripturl . '?action=admin;area=logs;sa=errorlog;desc',
'show' => allowedTo('admin_forum') && !empty($modSettings['enableErrorLogging']),
),
'permissions' => array(
'title' => $txt['edit_permissions'],
'href' => $scripturl . '?action=admin;area=permissions',
'show' => allowedTo('manage_permissions'),
'is_last' => true,
),
),
),
'moderate' => array(
'title' => $txt['moderate'],
'href' => $scripturl . '?action=moderate',
'show' => $context['allow_moderation_center'],
'sub_buttons' => array(
'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',
),
'poststopics' => array(
'title' => $txt['mc_unapproved_poststopics'],
'href' => $scripturl . '?action=moderate;area=postmod;sa=posts',
'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']),
),
'attachments' => array(
'title' => $txt['mc_unapproved_attachments'],
'href' => $scripturl . '?action=moderate;area=attachmod;sa=attachments',
'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']),
),
'reports' => array(
'title' => $txt['mc_reported_posts'],
'href' => $scripturl . '?action=moderate;area=reports',
'show' => !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1',
'is_last' => true,
),
),
),
'profile' => array(
'title' => $txt['profile'],
'href' => $scripturl . '?action=profile',
'show' => $context['allow_edit_profile'],
'sub_buttons' => array(
'summary' => array(
'title' => $txt['summary'],
'href' => $scripturl . '?action=profile',
'show' => true,
),
'account' => array(
'title' => $txt['account'],
'href' => $scripturl . '?action=profile;area=account',
'show' => allowedTo(array('profile_identity_any', 'profile_identity_own', 'manage_membergroups')),
),
'profile' => array(
'title' => $txt['forumprofile'],
'href' => $scripturl . '?action=profile;area=forumprofile',
'show' => allowedTo(array('profile_extra_any', 'profile_extra_own')),
'is_last' => true,
),
),
),
'pm' => array(
'title' => $txt['pm_short'],
'href' => $scripturl . '?action=pm',
'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'),
'is_last' => true,
),
),
),
'calendar' => array(
'title' => $txt['calendar'],
'href' => $scripturl . '?action=calendar',
'show' => $context['allow_calendar'],
'sub_buttons' => array(
'view' => array(
'title' => $txt['calendar_menu'],
'href' => $scripturl . '?action=calendar',
'show' => allowedTo('calendar_post'),
),
'post' => array(
'title' => $txt['calendar_post_event'],
'href' => $scripturl . '?action=calendar;sa=post',
'show' => allowedTo('calendar_post'),
'is_last' => true,
),
),
),
'mlist' => array(
'title' => $txt['members_title'],
'href' => $scripturl . '?action=mlist',
'show' => $context['allow_memberlist'],
'sub_buttons' => array(
'mlist_view' => array(
'title' => $txt['mlist_menu_view'],
'href' => $scripturl . '?action=mlist',
'show' => true,
),
'mlist_search' => array(
'title' => $txt['mlist_search'],
'href' => $scripturl . '?action=mlist;sa=search',
'show' => true,
'is_last' => true,
),
),
),
'login' => array(
'title' => $txt['login'],
'href' => $scripturl . '?action=login',
'show' => $user_info['is_guest'],
'sub_buttons' => array(
),
),
'register' => array(
'title' => $txt['register'],
'href' => $scripturl . '?action=register',
'show' => $user_info['is_guest'],
'sub_buttons' => array(
),
'is_last' => !$context['right_to_left'],
),
'logout' => array(
'title' => $txt['logout'],
'href' => $scripturl . '?action=logout;%1$s=%2$s',
'show' => !$user_info['is_guest'],
'sub_buttons' => array(
),
'is_last' => !$context['right_to_left'],
),
);
// Allow editing menu buttons easily.
call_integration_hook('integrate_menu_buttons', array(&$buttons));
// 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;
// Make sure the last button truely is the last button.
if (!empty($button['is_last']))
{
if (isset($last_button))
unset($menu_buttons[$last_button]['is_last']);
$last_button = $act;
}
// Go through the sub buttons if there are any.
if (!empty($button['sub_buttons']))
foreach ($button['sub_buttons'] as $key => $subbutton)
{
if (empty($subbutton['show']))
unset($button['sub_buttons'][$key]);
// 2nd level sub buttons next...
if (!empty($subbutton['sub_buttons']))
{
foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2)
{
if (empty($sub_button2['show']))
unset($button['sub_buttons'][$key]['sub_buttons'][$key2]);
}
}
}
$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);
}
$context['menu_buttons'] = $menu_buttons;
// Logging out requires the session id in the url.
if (isset($context['menu_buttons']['logout']))
$context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']);
// 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'] == 'search2')
$current_action = 'search';
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';
$context['menu_buttons'][$current_action]['active_button'] = true;
if (!$user_info['is_guest'] && $context['user']['unread_messages'] > 0 && isset($context['menu_buttons']['pm']))
{
$context['menu_buttons']['pm']['alttitle'] = $context['menu_buttons']['pm']['title'] . ' [' . $context['user']['unread_messages'] . ']';
$context['menu_buttons']['pm']['title'] .= ' [<strong>' . $context['user']['unread_messages'] . '</strong>]';
}
}
Jason Clemons
Former Team Member 2009 - 2012

makv

Quote from: zilladotexe on May 09, 2015, 09:24:56 AM

Correct function, wrong file :)

Find it in /Sources/Subs.php and paste the entire function. It should look like this:

function setupMenuContext()
{
global $context, $modSettings, $user_info, $txt, $scripturl;
// Set up the menu privileges.
$context['allow_search'] = 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');
$cacheTime = $modSettings['lastActive'] * 60;
// 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'])
{
$buttons = array(
'home' => array(
'title' => $txt['home'],
'href' => $scripturl,
'show' => true,
'sub_buttons' => array(
),
'is_last' => $context['right_to_left'],
),
'help' => array(
'title' => $txt['help'],
'href' => $scripturl . '?action=help',
'show' => true,
'sub_buttons' => array(
),
),
'search' => array(
'title' => $txt['search'],
'href' => $scripturl . '?action=search',
'show' => $context['allow_search'],
'sub_buttons' => array(
),
),
'admin' => array(
'title' => $txt['admin'],
'href' => $scripturl . '?action=admin',
'show' => $context['allow_admin'],
'sub_buttons' => array(
'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'),
),
'errorlog' => array(
'title' => $txt['errlog'],
'href' => $scripturl . '?action=admin;area=logs;sa=errorlog;desc',
'show' => allowedTo('admin_forum') && !empty($modSettings['enableErrorLogging']),
),
'permissions' => array(
'title' => $txt['edit_permissions'],
'href' => $scripturl . '?action=admin;area=permissions',
'show' => allowedTo('manage_permissions'),
'is_last' => true,
),
),
),
'moderate' => array(
'title' => $txt['moderate'],
'href' => $scripturl . '?action=moderate',
'show' => $context['allow_moderation_center'],
'sub_buttons' => array(
'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',
),
'poststopics' => array(
'title' => $txt['mc_unapproved_poststopics'],
'href' => $scripturl . '?action=moderate;area=postmod;sa=posts',
'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']),
),
'attachments' => array(
'title' => $txt['mc_unapproved_attachments'],
'href' => $scripturl . '?action=moderate;area=attachmod;sa=attachments',
'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']),
),
'reports' => array(
'title' => $txt['mc_reported_posts'],
'href' => $scripturl . '?action=moderate;area=reports',
'show' => !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1',
'is_last' => true,
),
),
),
'profile' => array(
'title' => $txt['profile'],
'href' => $scripturl . '?action=profile',
'show' => $context['allow_edit_profile'],
'sub_buttons' => array(
'summary' => array(
'title' => $txt['summary'],
'href' => $scripturl . '?action=profile',
'show' => true,
),
'account' => array(
'title' => $txt['account'],
'href' => $scripturl . '?action=profile;area=account',
'show' => allowedTo(array('profile_identity_any', 'profile_identity_own', 'manage_membergroups')),
),
'profile' => array(
'title' => $txt['forumprofile'],
'href' => $scripturl . '?action=profile;area=forumprofile',
'show' => allowedTo(array('profile_extra_any', 'profile_extra_own')),
'is_last' => true,
),
),
),
'pm' => array(
'title' => $txt['pm_short'],
'href' => $scripturl . '?action=pm',
'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'),
'is_last' => true,
),
),
),
'calendar' => array(
'title' => $txt['calendar'],
'href' => $scripturl . '?action=calendar',
'show' => $context['allow_calendar'],
'sub_buttons' => array(
'view' => array(
'title' => $txt['calendar_menu'],
'href' => $scripturl . '?action=calendar',
'show' => allowedTo('calendar_post'),
),
'post' => array(
'title' => $txt['calendar_post_event'],
'href' => $scripturl . '?action=calendar;sa=post',
'show' => allowedTo('calendar_post'),
'is_last' => true,
),
),
),
'mlist' => array(
'title' => $txt['members_title'],
'href' => $scripturl . '?action=mlist',
'show' => $context['allow_memberlist'],
'sub_buttons' => array(
'mlist_view' => array(
'title' => $txt['mlist_menu_view'],
'href' => $scripturl . '?action=mlist',
'show' => true,
),
'mlist_search' => array(
'title' => $txt['mlist_search'],
'href' => $scripturl . '?action=mlist;sa=search',
'show' => true,
'is_last' => true,
),
),
),
'login' => array(
'title' => $txt['login'],
'href' => $scripturl . '?action=login',
'show' => $user_info['is_guest'],
'sub_buttons' => array(
),
),
'register' => array(
'title' => $txt['register'],
'href' => $scripturl . '?action=register',
'show' => $user_info['is_guest'],
'sub_buttons' => array(
),
'is_last' => !$context['right_to_left'],
),
'logout' => array(
'title' => $txt['logout'],
'href' => $scripturl . '?action=logout;%1$s=%2$s',
'show' => !$user_info['is_guest'],
'sub_buttons' => array(
),
'is_last' => !$context['right_to_left'],
),
);
// Allow editing menu buttons easily.
call_integration_hook('integrate_menu_buttons', array(&$buttons));
// 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;
// Make sure the last button truely is the last button.
if (!empty($button['is_last']))
{
if (isset($last_button))
unset($menu_buttons[$last_button]['is_last']);
$last_button = $act;
}
// Go through the sub buttons if there are any.
if (!empty($button['sub_buttons']))
foreach ($button['sub_buttons'] as $key => $subbutton)
{
if (empty($subbutton['show']))
unset($button['sub_buttons'][$key]);
// 2nd level sub buttons next...
if (!empty($subbutton['sub_buttons']))
{
foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2)
{
if (empty($sub_button2['show']))
unset($button['sub_buttons'][$key]['sub_buttons'][$key2]);
}
}
}
$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);
}
$context['menu_buttons'] = $menu_buttons;
// Logging out requires the session id in the url.
if (isset($context['menu_buttons']['logout']))
$context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']);
// 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'] == 'search2')
$current_action = 'search';
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';
$context['menu_buttons'][$current_action]['active_button'] = true;
if (!$user_info['is_guest'] && $context['user']['unread_messages'] > 0 && isset($context['menu_buttons']['pm']))
{
$context['menu_buttons']['pm']['alttitle'] = $context['menu_buttons']['pm']['title'] . ' [' . $context['user']['unread_messages'] . ']';
$context['menu_buttons']['pm']['title'] .= ' [<strong>' . $context['user']['unread_messages'] . '</strong>]';
}
}


Oops. What I pasted was the call to it, and the following code :) Here is the actual function:


function setupMenuContext()
{
global $context, $modSettings, $user_info, $txt, $scripturl;

// Set up the menu privileges.
$context['allow_search'] = 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');

// Aeva Media changes - recalculate number of unseen items
if (!empty($user_info['aeva_unseen']) && $user_info['aeva_unseen'] == -1)
{
global $sourcedir;
require_once($sourcedir . '/Aeva-Subs.php');
aeva_loadSettings();
}
// End Aeva Media changes

$cacheTime = $modSettings['lastActive'] * 60;

// 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'])
{
$buttons = array(
'home' => array(
'title' => $txt['home'],
'href' => $scripturl,
'show' => true,
'sub_buttons' => array(
),
'is_last' => $context['right_to_left'],
),
'help' => array(
'title' => $txt['help'],
'href' => $scripturl . '?action=help',
'show' => true,
'sub_buttons' => array(
),
),
'search' => array(
'title' => $txt['search'],
'href' => $scripturl . '?action=search',
'show' => $context['allow_search'],
'sub_buttons' => array(
),
),
'admin' => array(
'title' => $txt['admin'],
'href' => $scripturl . '?action=admin',
'show' => $context['allow_admin'],
'sub_buttons' => array(
'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'),
),
'errorlog' => array(
'title' => $txt['errlog'],
'href' => $scripturl . '?action=admin;area=logs;sa=errorlog;desc',
'show' => allowedTo('admin_forum') && !empty($modSettings['enableErrorLogging']),
),

'permissions' => array(
'title' => $txt['edit_permissions'],
'href' => $scripturl . '?action=admin;area=permissions',
'show' => allowedTo('manage_permissions'),
'is_last' => true,
),
'tags_settings' => array(
'title' => $txt['smftags_admin'],
'href' => $scripturl . '?action=admin;area=tags;sa=admin',
'show' => allowedTo('admin_forum'),
),

),
),
'moderate' => array(
'title' => $txt['moderate'],
'href' => $scripturl . '?action=moderate',
'show' => $context['allow_moderation_center'],
'sub_buttons' => array(
'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',
),
'poststopics' => array(
'title' => $txt['mc_unapproved_poststopics'],
'href' => $scripturl . '?action=moderate;area=postmod;sa=posts',
'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']),
),
'attachments' => array(
'title' => $txt['mc_unapproved_attachments'],
'href' => $scripturl . '?action=moderate;area=attachmod;sa=attachments',
'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']),
),
'reports' => array(
'title' => $txt['mc_reported_posts'],
'href' => $scripturl . '?action=moderate;area=reports',
'show' => !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1',
'is_last' => true,
),
),
),
'profile' => array(
'title' => $txt['profile'],
'href' => $scripturl . '?action=profile',
'show' => $context['allow_edit_profile'],
'sub_buttons' => array(
'summary' => array(
'title' => $txt['summary'],
'href' => $scripturl . '?action=profile',
'show' => true,
),
'account' => array(
'title' => $txt['account'],
'href' => $scripturl . '?action=profile;area=account',
'show' => allowedTo(array('profile_identity_any', 'profile_identity_own', 'manage_membergroups')),
),
'profile' => array(
'title' => $txt['forumprofile'],
'href' => $scripturl . '?action=profile;area=forumprofile',
'show' => allowedTo(array('profile_extra_any', 'profile_extra_own')),
'is_last' => true,
),
),
),
'pm' => array(
'title' => $txt['pm_short'],
'href' => $scripturl . '?action=pm',
'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'),
'is_last' => true,
),
),
),
'bookmarks' => array(
'title' => $txt['bookmarks'],
'href' => $scripturl . '?action=bookmarks',
'show' => allowedTo('make_bookmarks'),
'sub_buttons' => array(
),
),

'tags' => array(
'title' => $txt['smftags_menu'],
'href' => $scripturl . '?action=tags',
'show' => true,
'sub_buttons' => array(
),
),
'calendar' => array(

'title' => $txt['calendar'],
'href' => $scripturl . '?action=calendar',
'show' => $context['allow_calendar'],
'sub_buttons' => array(
'view' => array(
'title' => $txt['calendar_menu'],
'href' => $scripturl . '?action=calendar',
'show' => allowedTo('calendar_post'),
),
'post' => array(
'title' => $txt['calendar_post_event'],
'href' => $scripturl . '?action=calendar;sa=post',
'show' => allowedTo('calendar_post'),
'is_last' => true,
),
),
),
// Aeva Media changes
'media' => array(
'title' => (isset($txt['aeva_gallery']) ? $txt['aeva_gallery'] : 'Media') . (!allowedTo('aeva_access_unseen') || empty($user_info['aeva_unseen']) || $user_info['aeva_unseen'] == -1 ? '' : ' [<b>' . $user_info['aeva_unseen'] . '</b>]'),
'href' => $scripturl . '?action=media',
'show' => allowedTo('aeva_access'),
'sub_buttons' => !allowedTo('aeva_access_unseen') || empty($user_info['aeva_unseen']) || $user_info['aeva_unseen'] == -1 ? array() : array(
'aeva_home' => array(
'title' => $txt['aeva_home'],
'href' => $scripturl . '?action=media',
'show' => true,
),
'aeva_unseen' => array(
'title' => $txt['aeva_unseen'],
'href' => $scripturl . '?action=media;sa=unseen',
'show' => true,
'is_last' => true,
),
),
),
// End Aeva Media changes
'mlist' => array(
'title' => $txt['members_title'],
'href' => $scripturl . '?action=mlist',
'show' => $context['allow_memberlist'],
'sub_buttons' => array(
'mlist_view' => array(
'title' => $txt['mlist_menu_view'],
'href' => $scripturl . '?action=mlist',
'show' => true,
),
'mlist_search' => array(
'title' => $txt['mlist_search'],
'href' => $scripturl . '?action=mlist;sa=search',
'show' => true,
'is_last' => true,
),
),
),
'login' => array(
'title' => $txt['login'],
'href' => $scripturl . '?action=login',
'show' => $user_info['is_guest'],
'sub_buttons' => array(
),
),
'register' => array(
'title' => $txt['register'],
'href' => $scripturl . '?action=register',
'show' => $user_info['is_guest'],
'sub_buttons' => array(
),
'is_last' => !$context['right_to_left'],
),
'logout' => array(
'title' => $txt['logout'],
'href' => $scripturl . '?action=logout;%1$s=%2$s',
'show' => !$user_info['is_guest'],
'sub_buttons' => array(
),
'is_last' => !$context['right_to_left'],
),
);

// Allow editing menu buttons easily.
call_integration_hook('integrate_menu_buttons', array(&$buttons));

// 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;

// Make sure the last button truely is the last button.
if (!empty($button['is_last']))
{
if (isset($last_button))
unset($menu_buttons[$last_button]['is_last']);
$last_button = $act;
}

// Go through the sub buttons if there are any.
if (!empty($button['sub_buttons']))
foreach ($button['sub_buttons'] as $key => $subbutton)
{
if (empty($subbutton['show']))
unset($button['sub_buttons'][$key]);

// 2nd level sub buttons next...
if (!empty($subbutton['sub_buttons']))
{
foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2)
{
if (empty($sub_button2['show']))
unset($button['sub_buttons'][$key]['sub_buttons'][$key2]);
}
}
}

$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);
}

$context['menu_buttons'] = $menu_buttons;

// Logging out requires the session id in the url.
if (isset($context['menu_buttons']['logout']))
$context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']);

// 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'] == 'search2')
$current_action = 'search';
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';

$context['menu_buttons'][$current_action]['active_button'] = true;

if (!$user_info['is_guest'] && $context['user']['unread_messages'] > 0 && isset($context['menu_buttons']['pm']))
{
$context['menu_buttons']['pm']['alttitle'] = $context['menu_buttons']['pm']['title'] . ' [' . $context['user']['unread_messages'] . ']';
$context['menu_buttons']['pm']['title'] .= ' [<strong>' . $context['user']['unread_messages'] . '</strong>]';
}
}


Advertisement: