-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmaintain.class.php
92 lines (75 loc) · 2.39 KB
/
maintain.class.php
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
<?php
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
class Back2Front_maintain extends PluginMaintain
{
private $table;
private $default_conf = array(
'versos_cat' => 0,
'switch_mode' => 'click',
'transition' => 'none',
'position' => 'top',
'link_name' => array('default'=>null),
'show_thumbnail' => true,
);
function __construct($id)
{
global $prefixeTable;
parent::__construct($id);
$this->table = $prefixeTable . 'image_verso';
}
function install($plugin_version, &$errors=array())
{
global $conf;
if (empty($conf['back2front']))
{
// create virtual private cat for storage
include_once(PHPWG_ROOT_PATH . 'admin/include/functions.php');
$cat = create_virtual_category('Back2Front private album');
$info = array(
'comment' => 'Used by Back2Front to store backsides.',
'status' => 'private',
'visible' => 'false',
'commentable' => 'false',
);
single_update(
CATEGORIES_TABLE,
$info,
array('id' => $cat['id'])
);
$this->default_conf['versos_cat'] = $cat['id'];
conf_update_param('back2front', $this->default_conf, true);
}
// create tables
$query = '
CREATE TABLE IF NOT EXISTS `' . $this->table . '` (
`image_id` mediumint(8) unsigned NOT NULL DEFAULT 0,
`verso_id` mediumint(8) unsigned NOT NULL DEFAULT 0,
`categories` varchar(128) NULL,
PRIMARY KEY (`image_id`),
UNIQUE KEY (`verso_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
;';
pwg_query($query);
}
function update($old_version, $new_version, &$errors=array())
{
$this->install($new_version, $errors);
}
function uninstall()
{
global $conf;
include_once(PHPWG_PLUGINS_PATH . 'Back2Front/include/functions.inc.php');
$conf['back2front'] = safe_unserialize($conf['back2front']);
$images_versos = pwg_query("SELECT * FROM `" . $this->table . "`;");
while ($item = pwg_db_fetch_assoc($images_versos))
{
back2front_restaure_categories($item);
}
pwg_query("DROP TABLE `" . $this->table . "`;");
pwg_query("DELETE FROM `" . CATEGORIES_TABLE ."`WHERE id = ".$conf['back2front']['versos_cat'].";");
// rebuild categories cache
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
invalidate_user_cache(true);
conf_delete_param('back2front');
}
}