integrate_whos_online

Started by inter, September 04, 2012, 05:01:13 AM

Previous topic - Next topic

inter

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)
Sorry for my English

emanuele

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...


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

inter

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;
}
}
}
Sorry for my English

Advertisement: