1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* **************************************************************************** |
4
|
|
|
* references - MODULE FOR XOOPS |
5
|
|
|
* Copyright (c) Hervé Thouzard of Instant Zero (http://www.instant-zero.com) |
6
|
|
|
* |
7
|
|
|
* You may not change or alter any portion of this comment or credits |
8
|
|
|
* of supporting developers from this source code or any supporting source code |
9
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
10
|
|
|
* This program is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13
|
|
|
* |
14
|
|
|
* @copyright Hervé Thouzard of Instant Zero (http://www.instant-zero.com) |
15
|
|
|
* @license http://www.fsf.org/copyleft/gpl.html GNU public license |
16
|
|
|
* @package references |
17
|
|
|
* @author Hervé Thouzard of Instant Zero (http://www.instant-zero.com) |
18
|
|
|
* |
19
|
|
|
* **************************************************************************** |
20
|
|
|
* @param $items |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
function references_tag_iteminfo(&$items) |
24
|
|
|
{ |
25
|
|
|
$items_id = array(); |
26
|
|
|
foreach (array_keys($items) as $cat_id) { |
27
|
|
|
foreach (array_keys($items[$cat_id]) as $item_id) { |
28
|
|
|
$items_id[] = (int)$item_id; |
29
|
|
|
} |
30
|
|
|
} |
31
|
|
|
include XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
32
|
|
|
$items_obj = $h_references_articles->getItemsFromIds($items_id); |
|
|
|
|
33
|
|
|
|
34
|
|
|
foreach (array_keys($items) as $cat_id) { |
35
|
|
|
foreach (array_keys($items[$cat_id]) as $item_id) { |
36
|
|
|
$item_obj =& $items_obj[$item_id]; |
37
|
|
|
/** @noinspection SenselessCommaInArrayDefinitionInspection */ |
38
|
|
|
$items[$cat_id][$item_id] = array( |
39
|
|
|
'title' => $item_obj->getVar('article_title'), |
40
|
|
|
'uid' => $item_obj->getVar('article_author'), |
41
|
|
|
'link' => 'index.php', |
42
|
|
|
'time' => $item_obj->getVar('article_timestamp'), |
43
|
|
|
'tags' => '', |
44
|
|
|
'content' => '', |
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
unset($items_obj); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** Remove orphan tag-item links * |
52
|
|
|
* @param $mid |
53
|
|
|
*/ |
54
|
|
|
function references_tag_synchronization($mid) |
55
|
|
|
{ |
56
|
|
|
global $xoopsDB; |
|
|
|
|
57
|
|
|
$item_handler_keyName = 'article_id'; |
58
|
|
|
$item_handler_table = $xoopsDB->prefix('references_articles'); |
59
|
|
|
$link_handler = xoops_getModuleHandler('link', 'tag'); |
60
|
|
|
$where = "($item_handler_table.article_online = 1)"; |
61
|
|
|
$where1 = "($item_handler_table.article_online = 0)"; |
62
|
|
|
|
63
|
|
|
/* clear tag-item links */ |
64
|
|
|
if ($link_handler->mysql_major_version() >= 4): |
65
|
|
|
$sql = " DELETE FROM {$link_handler->table}" . ' WHERE ' . " tag_modid = {$mid}" . ' AND ' . ' ( tag_itemid NOT IN ' . " ( SELECT DISTINCT {$item_handler_keyName} " . " FROM {$item_handler_table} " . " WHERE $where" . ' ) ' |
66
|
|
|
. ' )'; |
67
|
|
|
else: |
68
|
|
|
$sql = " DELETE {$link_handler->table} FROM {$link_handler->table}" . " LEFT JOIN {$item_handler_table} AS aa ON {$link_handler->table}.tag_itemid = aa.{$item_handler_keyName} " . ' WHERE ' . " tag_modid = {$mid}" . ' AND ' . " ( aa.{$item_handler_keyName} IS NULL" |
69
|
|
|
. " OR $where1" . ' )'; |
70
|
|
|
endif; |
71
|
|
|
if (!$link_handler->db->queryF($sql)) { |
72
|
|
|
trigger_error($link_handler->db->error()); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.