Advertisement:

Author Topic: integrate_whos_online  (Read 9401 times)

Offline inter

  • Jr. Member
  • **
  • Posts: 290
  • Gender: Male
    • interlab on GitHub
integrate_whos_online
« 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
Code: [Select]
$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:

Code: [Select]
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

Offline emanuele

  • SMF Super Hero
  • *******
  • Posts: 14,156
  • Gender: Male
  • THERE'S JUST ME
Re: integrate_whos_online
« Reply #1 on: September 04, 2012, 05:59:01 AM »
mmm...I see.

It's equivalent to the query in the block:
Code: [Select]
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.

Offline inter

  • Jr. Member
  • **
  • Posts: 290
  • Gender: Male
    • interlab on GitHub
Re: integrate_whos_online
« Reply #2 on: October 14, 2012, 08:04:09 AM »
Update!  8)

File: Who.php



Find:
Code: [Select]
// 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:
Code: [Select]
$all_actions[$k] = $actions;


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

Add After:
Code: [Select]
// 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