Skip to content

Commit 3b8a462

Browse files
committed
seperating oninstall
1 parent bf5d042 commit 3b8a462

17 files changed

Lines changed: 365 additions & 38 deletions

admin/admin_header.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@
3535
$pathIcon32 = $GLOBALS['xoops']->url('www/' . $GLOBALS['xoopsModule']->getInfo('icons32'));
3636
$pathModuleAdmin = $GLOBALS['xoops']->path('www/' . $GLOBALS['xoopsModule']->getInfo('dirmoduleadmin'));
3737

38-
if (file_exists("{$pathModuleAdmin}/moduleadmin/moduleadmin.php")) {
39-
include_once "{$pathModuleAdmin}/moduleadmin/moduleadmin.php";
40-
} else {
41-
redirect_header("{$path}/admin.php", TagConstants::REDIRECT_DELAY_LONG, _AM_MODULEADMIN_MISSING, false);
42-
}
38+
include_once "{$pathModuleAdmin}/moduleadmin/moduleadmin.php";
4339

4440
include_once $GLOBALS['xoops']->path('/Frameworks/art/functions.admin.php');

blocks/block.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ function tag_block_top_show($options, $dirname = '', $catid = 0)
241241
$criteria->setLimit((int)$options[0]);
242242
$criteria->add(new Criteria('o.tag_status', TagConstants::STATUS_ACTIVE));
243243
if (!empty($options[1])) {
244-
$criteria->add(new Criteria('l.tag_time', time() - floatval($options[1]) * 24 * 3600, '>'));
244+
$criteria->add(new Criteria('l.tag_time', time() - (float)$options[1] * 24 * 3600, '>'));
245245
}
246246
if (!empty($modid)) {
247247
$criteria->add(new Criteria('l.tag_modid', $modid));
@@ -326,7 +326,7 @@ function tag_block_top_edit($options)
326326
return $form;
327327
}
328328

329-
/*
329+
/**
330330
* $options for cumulus:
331331
* $options[0] - number of tags to display
332332
* $options[1] - time duration

class/tag.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function updateByItem($tags, $itemid, $modid = '', $catid = 0)
139139

140140
if (!empty($tags_delete)) {
141141
$tags_delete = array_map(array($this->db, 'quoteString'), $tags_delete);
142-
if ($tags_id = $this->getIds(new Criteria('tag_term', '(' . implode(', ', $tags_delete) . ')', 'IN'))) {
142+
if ($tags_id =& $this->getIds(new Criteria('tag_term', '(' . implode(', ', $tags_delete) . ')', 'IN'))) {
143143
$sql = "DELETE FROM {$this->table_link}"
144144
. ' WHERE '
145145
. " {$this->keyName} IN ("
@@ -166,7 +166,7 @@ public function updateByItem($tags, $itemid, $modid = '', $catid = 0)
166166
$tag_link = array();
167167
$tag_count = array();
168168
foreach ($tags_add as $tag) {
169-
if ($tags_id = $this->getIds(new Criteria('tag_term', $tag))) {
169+
if ($tags_id =& $this->getIds(new Criteria('tag_term', $tag))) {
170170
$tag_id = $tags_id[0];
171171
$tag_count[] = $tag_id;
172172
} else {
@@ -265,11 +265,11 @@ public function update_stats($tag_id, $modid = 0, $catid = 0)
265265
* Get tags with item count
266266
*
267267
* @access public
268-
* @param int $limit
269-
* @param int $start
270-
* @param CriteriaElement|object $criteria {@link Criteria}
271-
* @param null $fields
272-
* @param boolean $fromStats fetch from tag-stats table
268+
* @param int $limit
269+
* @param int $start
270+
* @param CriteriaElement $criteria {@link Criteria}
271+
* @param null $fields
272+
* @param boolean $fromStats fetch from tag-stats table
273273
* @return array associative array of tags (id, term, count)
274274
*/
275275
public function &getByLimit($limit = 0, $start = 0, CriteriaElement $criteria = null, $fields = null, $fromStats = true)//&getByLimit($criteria = null, $fromStats = true)
@@ -490,7 +490,7 @@ public function delete(XoopsObject $object, $force = true)
490490
if (!is_object($object) || !$object->getVar($this->keyName)) {
491491
return false;
492492
}
493-
*/
493+
*/
494494
$queryFunc = empty($force) ? 'query' : 'queryF';
495495

496496
/*
@@ -539,7 +539,7 @@ public function cleanOrphan($table_link = '', $field_link = '', $field_object =
539539
* @param CriteriaElement $ids
540540
* @return array|bool object IDs or false on failure
541541
*/
542-
public function &getIds(CriteriaElement $ids = null) //getIds(CriteriaElement $ids = null)
542+
public function &getIds(CriteriaElement $ids = null)
543543
{
544544
return parent::getIds($ids);
545545
}

class/utilities.php

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?php
2+
/*
3+
You may not change or alter any portion of this comment or credits
4+
of supporting developers from this source code or any supporting source code
5+
which is considered copyrighted (c) material of the original comment or credit authors.
6+
7+
This program is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10+
*/
11+
/**
12+
* Module: Tag
13+
*
14+
* @category Module
15+
* @package Tag
16+
* @author XOOPS Module Development Team
17+
* @author Mamba
18+
* @copyright {@link http://xoops.org The XOOPS Project}
19+
* @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
20+
* @link http://xoops.org XOOPS
21+
* @since 2.00
22+
*/
23+
24+
/**
25+
* TagUtilities
26+
*
27+
* Static utilities class to provide common functionality
28+
*
29+
*/
30+
class TagUtilities
31+
{
32+
/**
33+
*
34+
* Verifies XOOPS version meets minimum requirements for this module
35+
* @static
36+
* @param XoopsModule
37+
*
38+
* @return bool true if meets requirements, false if not
39+
*/
40+
public static function checkXoopsVer(&$module)
41+
{
42+
xoops_loadLanguage('admin', $module->dirname());
43+
//check for minimum XOOPS version
44+
$currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string
45+
$currArray = explode('.', $currentVer);
46+
$requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string
47+
$reqArray = explode('.', $requiredVer);
48+
$success = true;
49+
foreach ($reqArray as $k => $v) {
50+
if (isset($currArray[$k])) {
51+
if ($currArray[$k] > $v) {
52+
break;
53+
} elseif ($currArray[$k] == $v) {
54+
continue;
55+
} else {
56+
$success = false;
57+
break;
58+
}
59+
} else {
60+
if ((int)$v > 0) { // handles things like x.x.x.0_RC2
61+
$success = false;
62+
break;
63+
}
64+
}
65+
}
66+
67+
if (!$success) {
68+
$module->setErrors(sprintf(_AM_TAG_ERROR_BAD_XOOPS, $requiredVer, $currentVer));
69+
}
70+
71+
return $success;
72+
}
73+
74+
/**
75+
*
76+
* Verifies PHP version meets minimum requirements for this module
77+
* @static
78+
* @param XoopsModule
79+
*
80+
* @return bool true if meets requirements, false if not
81+
*/
82+
public static function checkPHPVer(&$module)
83+
{
84+
xoops_loadLanguage('admin', $module->dirname());
85+
// check for minimum PHP version
86+
$success = true;
87+
$verNum = phpversion();
88+
$reqVer = $module->getInfo('min_php');
89+
if (isset($reqVer)) {
90+
if (version_compare($verNum, $reqVer, '<')) {
91+
$module->setErrors(sprintf(_AM_TAG_ERROR_BAD_PHP, $reqVer, $verNum));
92+
$success = false;
93+
}
94+
}
95+
return $success;
96+
}
97+
}

docs/changelog.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
2.33 RC 1 2016-06-01
22
=================================
33
- added check for plugins in /class/plugins (in preparation for next version of XOOPS (mamba)
4+
- fixed XOOPS version check on install (zyspec)
5+
- fixed call to XoopsFormText in TagFormTag class (zyspec)
46
- removed @version (mamba)
57
- code cosmetics (mamba)
68
- replaced <b /> with <b> (mamba)

docs/lang_diff.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,19 @@ Legend :
1010

1111
2.32
1212
==============
13-
1413
main.php:
1514

1615
+ define('_AM_TAG_DB_UPDATED', 'Database Updated Successfully');
16+
17+
18+
2.33
19+
=============
20+
admin.php:
21+
22+
define('_AM_TAG_UPGRADEFAILED0', "Update failed - couldn't rename field '%s'");
23+
define('_AM_TAG_UPGRADEFAILED1', "Update failed - couldn't add new fields");
24+
define('_AM_TAG_UPGRADEFAILED2', "Update failed - couldn't rename table '%s'");
25+
define('_AM_TAG_ERROR_COLUMN', 'Could not create column in database : %s');
26+
define('_AM_TAG_ERROR_BAD_XOOPS', 'This module requires XOOPS %s+ (%s installed)');
27+
define('_AM_TAG_ERROR_BAD_PHP', 'This module requires PHP version %s+ (%s installed)');
28+
define('_AM_TAG_ERROR_TAG_REMOVAL', 'Could not remove tags from Tag Module');

header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @since 1.00
2020
*/
2121

22-
include_once '../../mainfile.php';
22+
include_once dirname(dirname(__DIR__)) . '/mainfile.php';
2323
include __DIR__ . '/include/vars.php';
2424
include_once __DIR__ . '/include/functions.php';
2525
xoops_load('constants', 'tag');

include/action.module.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ function xoops_module_install_tag(&$module)
3131
}
3232

3333
/**
34-
* @param $module
34+
* @param XoopsModule $module
3535
* @return bool
3636
*/
37-
function xoops_module_pre_install_tag(&$module)
37+
function xoops_module_pre_install_tag(XoopsModule $module)
3838
{
3939
//check for minimum XOOPS version
4040
$currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string
@@ -57,7 +57,7 @@ function xoops_module_pre_install_tag(&$module)
5757
$phpLen = strlen(PHP_VERSION);
5858
$extraLen = strlen(PHP_EXTRA_VERSION);
5959
$verNum = substr(PHP_VERSION, 0, $phpLen - $extraLen);
60-
$reqVer = $module->getInfo('min_php');
60+
$reqVer =& $module->getInfo('min_php');
6161
if ($verNum < $reqVer) {
6262
$module->setErrors("The module requires PHP {$reqVer}+ ({$verNum} installed)");
6363

@@ -72,7 +72,7 @@ function xoops_module_pre_install_tag(&$module)
7272
}
7373
*/
7474

75-
$mod_tables = $module->getInfo('tables');
75+
$mod_tables =& $module->getInfo('tables');
7676
foreach ($mod_tables as $table) {
7777
$GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';');
7878
}
@@ -81,29 +81,29 @@ function xoops_module_pre_install_tag(&$module)
8181
}
8282

8383
/**
84-
* @param $module
84+
* @param XoopsModule $module
8585
* @return bool
8686
*/
87-
function xoops_module_pre_update_tag(&$module)
87+
function xoops_module_pre_update_tag(XoopsModule $module)
8888
{
8989
return true;
9090
}
9191

9292
/**
93-
* @param $module
93+
* @param XoopsModule $module
9494
* @return bool
9595
*/
96-
function xoops_module_pre_uninstall_tag(&$module)
96+
function xoops_module_pre_uninstall_tag(XoopsModule $module)
9797
{
9898
return true;
9999
}
100100

101101
/**
102-
* @param $module
103-
* @param null $prev_version
102+
* @param XoopsModule $module
103+
* @param null $prev_version
104104
* @return bool
105105
*/
106-
function xoops_module_update_tag(&$module, $prev_version = null)
106+
function xoops_module_update_tag(XoopsModule $module, $prev_version = null)
107107
{
108108
//load_functions("config");
109109
//mod_clearConfg($module->getVar("dirname", "n"));

include/functions.ini.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
/**
3434
* @return array|mixed|null
3535
*/
36-
function &tag_load_config()
36+
function tag_load_config()
3737
{
3838
static $moduleConfig;
3939

include/functions.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,14 @@ function tag_getTagHandler()
6060
* @return bool true on args parsed
6161
*/
6262

63-
/* known issues:
63+
/** known issues:
6464
* - "/" in a string
6565
* - "&" in a string
66-
*/
66+
* @param $args_numeric
67+
* @param $args
68+
* @param $args_string
69+
* @return bool|null
70+
*/
6771
function tag_parse_args(&$args_numeric, &$args, &$args_string)
6872
{
6973
$args_abb = array(

0 commit comments

Comments
 (0)