-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.inc
More file actions
244 lines (209 loc) · 7.88 KB
/
Copy pathfunctions.inc
File metadata and controls
244 lines (209 loc) · 7.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<?php
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
// | Test Plugin 1.0 |
// +---------------------------------------------------------------------------+
// | functions.inc |
// | |
// | This file does two things: 1) it implements the necessary Geeklog Plugin |
// | API methods and 2) implements all the common code needed by this plugin. |
// +---------------------------------------------------------------------------+
// | Copyright (C) 2016 by the following authors: |
// | |
// | Authors: Ben - hostellerie DOT org AT gmail DOT com |
// +---------------------------------------------------------------------------+
// | Created with the Geeklog Plugin Toolkit. |
// +---------------------------------------------------------------------------+
// | |
// | This program is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU General Public License |
// | as published by the Free Software Foundation; either version 2 |
// | of the License, or (at your option) any later version. |
// | |
// | This program is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the Free Software Foundation, |
// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// | |
// +---------------------------------------------------------------------------+
/**
* @package Test
*/
if (strpos(strtolower($_SERVER['PHP_SELF']), 'functions.inc') !== false) {
die ('This file can not be used on its own.');
}
/**
* Language file include
*/
$plugin_path = $_CONF['path'] . 'plugins/test/';
$langfile = $plugin_path . 'language/' . $_CONF['language'] . '.php';
if (file_exists($langfile)) {
require_once $langfile;
} else {
require_once $plugin_path . 'language/english.php';
}
// +---------------------------------------------------------------------------+
// | Geeklog Plugin API Implementation |
// +---------------------------------------------------------------------------+
/**
* Returns the item(s) for this plugin that should appear on the main menu
*
* NOTE: this MUST return the url/value pairs in the following format
* $<arrayname>[<label>] = <url>
*
* @return mixed menu entry, or boolean false if disabled / hidden
*
*/
function plugin_getmenuitems_test()
{
global $_CONF, $LANG_TEST_1;
$url = $_CONF['site_url'] . '/test/index.php';
$menuitems[$LANG_TEST_1['plugin_name']] = $url;
return $menuitems;
}
/**
* Implements a [test:] autotag.
*
* @param string $op operation to perform
* @param string $content item (e.g. story text), including the autotag
* @param array $autotag parameters used in the autotag
* @param mixed tag names (for $op='tagname') or formatted content
*
*/
/*
function plugin_autotags_test($op, $content = '', $autotag = '')
{
global $_CONF, $_TABLES, $LANG_TEST_1;
if ($op == 'tagname') {
return 'test';
} elseif ($op == 'parse') {
$tid = COM_applyFilter($autotag['parm1']);
if (! empty($tid)) {
$url = $_CONF['site_url'] . '/test/index.php?item=' . $tid;
if (empty($autotag['parm2'])) {
$linktext = 'Test'; // or get title from db
} else {
$linktext = $autotag['parm2'];
}
$link = COM_createLink($linktext, $url);
$content = str_replace($autotag['tagstr'], $link, $content);
}
return $content;
}
}
*/
/**
* Return plugin entry for "Command and Control" (moderation.php)
*
* @return array Array containing (plugin name, admin url, url of plugin icon)
*
*/
function plugin_cclabel_test()
{
global $_CONF, $LANG_TEST_1;
$retval = array();
if (SEC_hasRights('test.admin')) {
$retval = array($LANG_TEST_1['plugin_name'],
$_CONF['site_admin_url'] . '/plugins/test/index.php',
plugin_geticon_test());
}
return $retval;
}
/**
* Return plugin entry for the Admins Only block
*
* @return array Array containing (plugin name, plugin admin url, # of plugin items or '')
*/
function plugin_getadminoption_test()
{
global $_CONF, $LANG_TEST_1;
if (SEC_hasRights('test.admin')) {
return array($LANG_TEST_1['plugin_name'],
$_CONF['site_admin_url'] . '/plugins/test/index.php', 0);
}
}
/**
* Returns the URL of the plugin's icon
*
* @return string URL of the icon
*
*/
function plugin_geticon_test()
{
global $_CONF;
// popular alternative location:
// return $_CONF['site_url'] . '/test/images/test.png';
return $_CONF['site_admin_url'] . '/plugins/test/images/test.png';
}
/**
* Returns the current plugin code version
*
* @return string plugin version
*/
function plugin_chkVersion_test()
{
global $_CONF;
require_once $_CONF['path'] . 'plugins/test/autoinstall.php';
$inst_parms = plugin_autoinstall_test('test');
return $inst_parms['info']['pi_version'];
}
/**
* Update the plugin
*
* @return int Number of message to display or true for success
*
*/
function plugin_upgrade_test()
{
global $_CONF, $_TABLES;
$installed_version = DB_getItem($_TABLES['plugins'], 'pi_version',
"pi_name = 'test'");
$code_version = plugin_chkVersion_test();
if ($installed_version == $code_version) {
// nothing to do
return true;
}
require_once $_CONF['path'] . 'plugins/test/autoinstall.php';
if (! plugin_compatible_with_this_version_test('test')) {
return 3002;
}
// other update code goes here
// update plugin version number
$inst_parms = plugin_autoinstall_test('test');
$pi_gl_version = $inst_parms['info']['pi_gl_version'];
DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = '$code_version', pi_gl_version = '$pi_gl_version' WHERE pi_name = 'test'");
return true;
}
/**
* Automatic uninstall function for plugins
*
* This code is automatically uninstalling the plugin.
* It passes an array to the core code function that removes
* tables, groups, features and php blocks from the tables.
* Additionally, this code can perform special actions that cannot be
* foreseen by the core code (interactions with other plugins for example)
*
* @return array Plugin information
*
*/
function plugin_autouninstall_test()
{
$out = array (
/* give the name of the tables, without $_TABLES[] */
'tables' => array(/* e.g. 'test' */),
/* give the full name of the group, as in the db */
'groups' => array('Test Admin'),
/* give the full name of the feature, as in the db */
'features' => array('test.admin'),
/* give the full name of the block, including 'phpblock_', etc */
'php_blocks' => array(),
/* give all vars with their name */
'vars' => array()
);
return $out;
}
?>