| Conditions | 6 |
| Paths | 12 |
| Total Lines | 39 |
| Code Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | function smartpartner_notify_iteminfo($category, $item_id) |
||
| 14 | { |
||
| 15 | // This must contain the name of the folder in which reside SmartPartner |
||
| 16 | if (!defined('SMARTPARTNER_DIRNAME')) { |
||
| 17 | define('SMARTPARTNER_DIRNAME', 'smartpartner'); |
||
| 18 | } |
||
| 19 | |||
| 20 | global $xoopsModule, $xoopsModuleConfig, $xoopsConfig; |
||
|
|
|||
| 21 | |||
| 22 | if (empty($xoopsModule) || $xoopsModule->getVar('dirname') != SMARTPARTNER_DIRNAME) { |
||
| 23 | $moduleHandler = xoops_getHandler('module'); |
||
| 24 | $module = &$moduleHandler->getByDirname(SMARTPARTNER_DIRNAME); |
||
| 25 | $configHandler = xoops_getHandler('config'); |
||
| 26 | $config = &$configHandler->getConfigsByCat(0, $module->getVar('mid')); |
||
| 27 | } else { |
||
| 28 | $module = &$xoopsModule; |
||
| 29 | $config = &$xoopsModuleConfig; |
||
| 30 | } |
||
| 31 | |||
| 32 | if ($category === 'global') { |
||
| 33 | $item['name'] = ''; |
||
| 34 | $item['url'] = ''; |
||
| 35 | |||
| 36 | return $item; |
||
| 37 | } |
||
| 38 | |||
| 39 | global $xoopsDB; |
||
| 40 | |||
| 41 | if ($category === 'item') { |
||
| 42 | // Assume we have a valid partner id |
||
| 43 | $sql = 'SELECT question FROM ' . $xoopsDB->prefix('smartpartner_partner') . ' WHERE id = ' . $item_id; |
||
| 44 | $result = $xoopsDB->query($sql); // TODO: error check |
||
| 45 | $result_array = $xoopsDB->fetchArray($result); |
||
| 46 | $item['name'] = $result_array['title']; |
||
| 47 | $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/partner.php?id=' . $item_id; |
||
| 48 | |||
| 49 | return $item; |
||
| 50 | } |
||
| 51 | } |
||
| 52 |
Instead of relying on
globalstate, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state