1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Module: WF-links |
4
|
|
|
* Version: v1.0.3 |
5
|
|
|
* Release Date: 21 June 2005 |
6
|
|
|
* Developer: John N |
7
|
|
|
* Team: WF-Projects |
8
|
|
|
* Licence: GNU |
9
|
|
|
* @param mixed $cid |
10
|
|
|
* @param mixed $permType |
11
|
|
|
* @param mixed $redirect |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
// checkBlockgroups() |
15
|
|
|
// |
16
|
|
|
// @param integer $cid |
17
|
|
|
// @param string $permType |
18
|
|
|
// @param boolean $redirect |
19
|
|
|
// @return |
20
|
|
|
/** |
21
|
|
|
* @param int $cid |
22
|
|
|
* @param string $permType |
23
|
|
|
* @param bool $redirect |
24
|
|
|
* |
25
|
|
|
* @return bool |
26
|
|
|
*/ |
27
|
|
|
function checkBlockgroups($cid = 0, $permType = 'WFLinkCatPerm', $redirect = false) |
28
|
|
|
{ |
29
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
30
|
|
|
global $xoopsUser; |
31
|
|
|
|
32
|
|
|
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
33
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
34
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
35
|
|
|
|
36
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
37
|
|
|
$moduleHandler = xoops_getHandler('module'); |
38
|
|
|
$module = $moduleHandler->getByDirname($moduleDirName); |
39
|
|
|
|
40
|
|
|
if (!$grouppermHandler->checkRight($permType, $cid, $groups, $module->getVar('mid'))) { |
41
|
|
|
if (false === $redirect) { |
42
|
|
|
return false; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
redirect_header('index.php', 3, _NOPERM); |
46
|
|
|
} |
47
|
|
|
unset($module); |
48
|
|
|
|
49
|
|
|
return true; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
// Function: b_mylinks_top_show |
53
|
|
|
// Input : $options[0] = date for the most recent links |
54
|
|
|
// hits for the most popular links |
55
|
|
|
// $options[1] = How many links are displayes |
56
|
|
|
// $options[2] = Length of title |
57
|
|
|
// $options[3] = Date format |
58
|
|
|
// $block['content'] = The optional above content |
59
|
|
|
// Output : Returns the most recent or most popular links |
60
|
|
|
/** |
61
|
|
|
* @param $options |
62
|
|
|
* |
63
|
|
|
* @return array |
64
|
|
|
*/ |
65
|
|
|
function b_wflinks_top_show($options) |
66
|
|
|
{ |
67
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
68
|
|
|
global $xoopsDB; |
69
|
|
|
|
70
|
|
|
$block = []; |
71
|
|
|
$time = time(); |
72
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
73
|
|
|
$moduleHandler = xoops_getHandler('module'); |
74
|
|
|
$wflModule = $moduleHandler->getByDirname($moduleDirName); |
75
|
|
|
/* @var \XoopsConfigHandler $configHandler */ |
76
|
|
|
/** @var \XoopsConfigHandler $configHandler */ |
77
|
|
|
$configHandler = xoops_getHandler('config'); |
78
|
|
|
$wflModuleConfig = $configHandler->getConfigsByCat(0, $wflModule->getVar('mid')); |
|
|
|
|
79
|
|
|
$myts = MyTextSanitizer:: getInstance(); |
|
|
|
|
80
|
|
|
|
81
|
|
|
$result = $xoopsDB->query('SELECT lid, cid, title, published, hits FROM ' . $xoopsDB->prefix('wflinks_links') . ' WHERE published > 0 AND published <= ' . $time . ' AND (expired = 0 OR expired > ' . $time . ') AND offline = 0 ORDER BY ' . $options[0] . ' DESC', $options[1], 0); |
82
|
|
|
while (false !== ($myrow = $xoopsDB->fetchArray($result))) { |
83
|
|
|
if (0 == $myrow['cid'] || false === checkBlockgroups($myrow['cid'])) { |
84
|
|
|
continue; |
85
|
|
|
} |
86
|
|
|
$linkload = []; |
87
|
|
|
$title = htmlspecialchars($myrow['title'], ENT_QUOTES | ENT_HTML5); |
88
|
|
|
if (!XOOPS_USE_MULTIBYTES) { |
89
|
|
|
if (mb_strlen($myrow['title']) >= $options[2]) { |
90
|
|
|
$title = mb_substr($myrow['title'], 0, $options[2] - 1) . '...'; |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
$linkload['id'] = (int)$myrow['lid']; |
94
|
|
|
$linkload['cid'] = (int)$myrow['cid']; |
95
|
|
|
$linkload['title'] = $title; |
96
|
|
|
if ('published' === $options[0]) { |
97
|
|
|
$linkload['date'] = formatTimestamp($myrow['published'], $options[3]); |
98
|
|
|
} elseif ('hits' === $options[0]) { |
99
|
|
|
$linkload['hits'] = $myrow['hits']; |
100
|
|
|
} |
101
|
|
|
$linkload['dirname'] = $wflModule->getVar('dirname'); |
102
|
|
|
$block['links'][] = $linkload; |
103
|
|
|
} |
104
|
|
|
unset($_block_check_array); |
|
|
|
|
105
|
|
|
|
106
|
|
|
return $block; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
// b_wflinks_top_edit() |
110
|
|
|
// |
111
|
|
|
// @param $options |
112
|
|
|
// @return |
113
|
|
|
/** |
114
|
|
|
* @param $options |
115
|
|
|
* |
116
|
|
|
* @return string |
117
|
|
|
*/ |
118
|
|
|
function b_wflinks_top_edit($options) |
119
|
|
|
{ |
120
|
|
|
$form = '' . _MB_WFL_DISP . ' '; |
121
|
|
|
$form .= "<input type='hidden' name='options[]' value='"; |
122
|
|
|
if ('published' === $options[0]) { |
123
|
|
|
$form .= "published'"; |
124
|
|
|
} else { |
125
|
|
|
$form .= "hits'"; |
126
|
|
|
} |
127
|
|
|
$form .= '>'; |
128
|
|
|
$form .= "<input type='text' name='options[]' value='" . $options[1] . "'> " . _MB_WFL_FILES . ''; |
129
|
|
|
$form .= ' <br>' . _MB_WFL_CHARS . " <input type='text' name='options[]' value='" . $options[2] . "'> " . _MB_WFL_LENGTH . ''; |
130
|
|
|
$form .= ' <br>' . _MB_WFL_DATEFORMAT . " <input type='text' name='options[]' value='" . $options[3] . "'> " . _MB_WFL_DATEFORMATMANUAL; |
131
|
|
|
|
132
|
|
|
return $form; |
133
|
|
|
} |
134
|
|
|
|