Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
git-svn-id: file:///svn/phpbb/trunk@7229 89ea8834-ac86-4346-8a33-228a782c2dd0
  • Loading branch information
David M committed Mar 24, 2007
1 parent f269de0 commit 6bc4b14
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 35 deletions.
38 changes: 38 additions & 0 deletions phpBB/includes/functions_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,44 @@ function load_active($mode = false, $module_url = false, $execute_module = true)
}
}

/**
* Check if a module is active
*/
function is_active($id = false)
{
$icat = false;

$category = false;
foreach ($this->module_ary as $row_id => $item_ary)
{
// If this is a module and it's selected, active
// If this is a category and the module is the first within it, active
// If this is a module and no mode selected, select first mode
// If no category or module selected, go active for first module in first category
if (
(($item_ary['name'] === $id || $item_ary['id'] === (int) $id) && (($item_ary['mode'] == false && !$item_ary['cat']) || ($icat && $item_ary['cat']))) ||
($item_ary['parent'] === $category && !$item_ary['cat'] && !$icat && $item_ary['display']) ||
(($item_ary['name'] === $id || $item_ary['id'] === (int) $id) && !$item_ary['cat']) ||
(!$id && !$item_ary['cat'] && $item_ary['display'])
)
{
if ($item_ary['cat'])
{
$id = $icat;
$icat = false;

continue;
}

return $item_ary['id'];
}
else if (($item_ary['cat'] && $item_ary['id'] === (int) $id) || ($item_ary['parent'] === $category && $item_ary['cat']))
{
$category = $item_ary['id'];
}
}
}

/**
* Get parents
*/
Expand Down
75 changes: 40 additions & 35 deletions phpBB/ucp.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,53 +241,58 @@
login_box('', $user->lang['LOGIN_EXPLAIN_UCP']);
}

// Instantiate module system and generate list of available modules
$module->list_modules('ucp');

// Output listing of friends online
$update_time = $config['load_online_time'] * 60;
// Check if the zebra module is set
$zebra_enabled = $module->is_active('zebra') ? true : false;

$sql = $db->sql_build_query('SELECT_DISTINCT', array(
'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, u.user_allow_viewonline, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline',
if ($zebra_enabled)
{
// Output listing of friends online
$update_time = $config['load_online_time'] * 60;

'FROM' => array(
USERS_TABLE => 'u',
ZEBRA_TABLE => 'z'
),
$sql = $db->sql_build_query('SELECT_DISTINCT', array(
'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, u.user_allow_viewonline, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline',

'LEFT_JOIN' => array(
array(
'FROM' => array(SESSIONS_TABLE => 's'),
'ON' => 's.session_user_id = z.zebra_id'
)
),
'FROM' => array(
USERS_TABLE => 'u',
ZEBRA_TABLE => 'z'
),

'WHERE' => 'z.user_id = ' . $user->data['user_id'] . '
AND z.friend = 1
AND u.user_id = z.zebra_id',
'LEFT_JOIN' => array(
array(
'FROM' => array(SESSIONS_TABLE => 's'),
'ON' => 's.session_user_id = z.zebra_id'
)
),

'GROUP_BY' => 'z.zebra_id, u.user_id, u.username_clean, u.user_allow_viewonline, u.user_colour, u.username',
'WHERE' => 'z.user_id = ' . $user->data['user_id'] . '
AND z.friend = 1
AND u.user_id = z.zebra_id',

'ORDER_BY' => 'u.username_clean ASC',
));
'GROUP_BY' => 'z.zebra_id, u.user_id, u.username_clean, u.user_allow_viewonline, u.user_colour, u.username',

$result = $db->sql_query($sql);
'ORDER_BY' => 'u.username_clean ASC',
));

while ($row = $db->sql_fetchrow($result))
{
$which = (time() - $update_time < $row['online_time'] && $row['viewonline'] && $row['user_allow_viewonline']) ? 'online' : 'offline';
$result = $db->sql_query($sql);

$template->assign_block_vars("friends_{$which}", array(
'USER_ID' => $row['user_id'],
while ($row = $db->sql_fetchrow($result))
{
$which = (time() - $update_time < $row['online_time'] && $row['viewonline'] && $row['user_allow_viewonline']) ? 'online' : 'offline';

'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);
$template->assign_block_vars("friends_{$which}", array(
'USER_ID' => $row['user_id'],

// Instantiate module system and generate list of available modules
$module->list_modules('ucp');
'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);
}

// Select the active module
$module->set_active($id, $mode);
Expand Down

0 comments on commit 6bc4b14

Please sign in to comment.