Simple Machines Community Forum

SMF Development => Bug Reports => Fixed or Bogus Bugs => Topic started by: inter on September 04, 2012, 05:01:13 AM

Title: integrate_whos_online
Post by: inter on September 04, 2012, 05:01:13 AM
to do inquiries in a cycle it is impossible  :-\
I think that it is necessary to alter this code

Who.php
$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;
}
}
}
}


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:


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
}


-> 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)
Title: Re: integrate_whos_online
Post by: emanuele on September 04, 2012, 05:59:01 AM
mmm...I see.

It's equivalent to the query in the block:
elseif (isset($txt['whopost_' . $actions['action']]))
yes, it's not very efficient, it could be hacked somehow, it would require another hook...
Title: Re: integrate_whos_online
Post by: inter on October 14, 2012, 08:04:09 AM
Update!  8)

File: Who.php




Find:
// 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;
}
}
}


Replace:
$all_actions[$k] = $actions;




Find:
$all_actions[$k] = $actions;
}


Add After:
// 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;
}
}
}