p_master::is_active PHP Method

is_active() public method

Check if a module is active
public is_active ( $id, $mode = false )
    function is_active($id, $mode = false)
    {
        // If we find a name by this id and being enabled we have our active one...
        foreach ($this->module_ary as $row_id => $item_ary) {
            if (($item_ary['name'] === $id || $item_ary['id'] === (int) $id) && $item_ary['display'] || $item_ary['name'] === $this->p_class . '_' . $id) {
                if ($mode === false || $mode === $item_ary['mode']) {
                    return true;
                }
            }
        }
        return false;
    }

Usage Example

Beispiel #1
0
}
// We use this approach because it does not impose large code changes
if (!$default) {
    return true;
}
// Only registered users can go beyond this point
if (!$user->data['is_registered']) {
    if ($user->data['is_bot']) {
        redirect(append_sid("{$phpbb_root_path}index.{$phpEx}"));
    }
    login_box('', $user->lang['LOGIN_EXPLAIN_UCP']);
}
// Instantiate module system and generate list of available modules
$module->list_modules('ucp');
// Check if the zebra module is set
if ($module->is_active('zebra', 'friends')) {
    // Output listing of friends online
    $update_time = $config['load_online_time'] * 60;
    $sql = $db->sql_build_query('SELECT_DISTINCT', array('SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline', 'FROM' => array(USERS_TABLE => 'u', ZEBRA_TABLE => 'z'), 'LEFT_JOIN' => array(array('FROM' => array(SESSIONS_TABLE => 's'), 'ON' => 's.session_user_id = z.zebra_id')), 'WHERE' => 'z.user_id = ' . $user->data['user_id'] . '
			AND z.friend = 1
			AND u.user_id = z.zebra_id', 'GROUP_BY' => 'z.zebra_id, u.user_id, u.username_clean, u.user_colour, u.username', 'ORDER_BY' => 'u.username_clean ASC'));
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
        $which = time() - $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline')) ? 'online' : 'offline';
        $template->assign_block_vars("friends_{$which}", array('USER_ID' => $row['user_id'], 'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'USER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'])));
    }
    $db->sql_freeresult($result);
}
// Do not display subscribed topics/forums if not allowed
if (!$config['allow_topic_notify'] && !$config['allow_forum_notify']) {
    $module->set_display('main', 'subscribed', false);
All Usage Examples Of p_master::is_active