SMF Development > Bug Reports
integrate_whos_online
(1/1)
Inter:
to do inquiries in a cycle it is impossible :-\
I think that it is necessary to alter this code
Who.php
--- Code: --- $data = array();
foreach ($url_list as $k => $url)
{
...
// Maybe the action is integrated into another system?
if (count($integrate_actions = call_integration_hook('integrate_whos_online', array($actions))) > 0)
{
foreach ($integrate_actions as $integrate_action)
{
if (!empty($integrate_action))
{
$data[$k] = $integrate_action;
break;
}
}
}
}
--- End code ---
if I in this cycle each time extend from a database the material name that I instead of one inquiry I can pull 10-30-50-... inquiries
For Example:
Hook -> My Function:
--- Code: ---function torrent_whos_online($actions)
{
global $scripturl, $txt, $smcFunc;
if ($actions['action'] === 'torrent')
$action = $txt['st_who_torrents'];
if (!empty($actions['sa']))
{
switch ($actions['sa'])
{
...
case 'comments':
$action = $txt['st_who_comments'];
break;
case 'display':
if (isset($actions['id']) and is_numeric($actions['id']))
{
$q = $smcFunc['db_query']('', '
SELECT tor.id_torrent, tor.name,
FROM {db_prefix}st_torrents AS tor
WHERE tor.banned = {string:ban} AND tor.id_torrent = {int:id_torrent}
LIMIT 1',
array(
'ban' => 'no',
'id_torrent' => (int) $actions['id'],
)
);
if ($smcFunc['db_num_rows']($q) == 0)
$action = $txt['st_who_torrents'];
else
$action = sprintf($txt['st_who_display'], $row['id_torrent'], censorText($row['name']));
$smcFunc['db_free_result']($result);
}
break;
default:
$action = $txt['st_who_torrents'];
}
}
if (!empty($action))
return $action; // !important
}
--- End code ---
-> every time when I call this function may be challenged in the database (though to get past all the identifiers in the loop and make only one request)
emanuele:
mmm...I see.
It's equivalent to the query in the block:
--- Code: ---elseif (isset($txt['whopost_' . $actions['action']]))
--- End code ---
yes, it's not very efficient, it could be hacked somehow, it would require another hook...
Inter:
Update! 8)
File: Who.php
Find:
--- Code: --- // Maybe the action is integrated into another system?
if (count($integrate_actions = call_integration_hook('integrate_whos_online', array($actions))) > 0)
{
foreach ($integrate_actions as $integrate_action)
{
if (!empty($integrate_action))
{
$data[$k] = $integrate_action;
break;
}
}
}
--- End code ---
Replace:
--- Code: --- $all_actions[$k] = $actions;
--- End code ---
Find:
--- Code: --- $all_actions[$k] = $actions;
}
--- End code ---
Add After:
--- Code: --- // Maybe the action is integrated into another system?
if (count($integrate_actions = call_integration_hook('integrate_whos_online', array($all_actions))) > 0)
{
//iPre($integrate_actions);
foreach ($integrate_actions as $ind)
{
foreach ($ind as $k => $integrate_action)
{
if (empty($integrate_action))
continue;
$data[$k] = $integrate_action;
}
}
}
--- End code ---
Navigation
[0] Message Index
Go to full version