source: extensions/Back2Front/maintain.inc.php @ 11132

Last change on this file since 11132 was 10852, checked in by mistic100, 13 years ago

improve process, add options for link effect

File size: 2.1 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4include_once(PHPWG_PLUGINS_PATH.'back2front/functions.inc.php');
5
6function plugin_install() {
7        global $prefixeTable;
8
9  /* create table for recto/veros pairs | stores original verso categories */
10        pwg_query("CREATE TABLE IF NOT EXISTS `" . $prefixeTable . "image_verso` (
11    `image_id` mediumint(8) unsigned NOT NULL DEFAULT '0',
12    `verso_id` mediumint(8) unsigned NOT NULL DEFAULT '0',
13    `categories` varchar(128) NULL,
14    PRIMARY KEY (`image_id`),
15    UNIQUE KEY (`verso_id`)
16        ) DEFAULT CHARSET=utf8;");
17 
18  /* create a virtual category to store versos */
19  $versos_cat = create_virtual_category('Back2Front private album');
20  $versos_cat = array(
21    'id' => $versos_cat['id'],
22    'comment' => 'Used by Back2Front to store backsides.',
23    'status'  => 'private',
24    'visible' => 'false',
25    'commentable' => 'false',
26    );
27  mass_updates(
28    CATEGORIES_TABLE,
29    array(
30      'primary' => array('id'),
31      'update' => array_diff(array_keys($versos_cat), array('id'))
32      ),
33    array($versos_cat)
34    );
35   
36  /* config parameter */
37  pwg_query("INSERT INTO `" . CONFIG_TABLE . "`
38    VALUES ('back2front', '".$versos_cat['id'].",click,none', 'Configuration for Back2Front plugin');");
39}
40
41function plugin_uninstall() {
42        global $conf, $prefixeTable;
43 
44  $conf['back2front'] = explode(',',$conf['back2front']);
45 
46  /* versos must be restored to their original categories
47   criterias :
48    - verso € 'versos' cat only => restore verso to original categories
49    - otherwise nothing is changed
50  */
51
52  $query = "SELECT * FROM `" . $prefixeTable . "image_verso`;";
53  $images_versos = pwg_query($query);
54 
55  while ($item = pwg_db_fetch_assoc($images_versos))
56  {
57    back2front_restaure_categories($item);
58  }
59
60  pwg_query("DROP TABLE `" . $prefixeTable . "image_verso`;");
61  pwg_query("DELETE FROM `" . CONFIG_TABLE . "` WHERE param = 'back2front';");
62  pwg_query("DELETE FROM `" . CATEGORIES_TABLE ."`WHERE id = ".$conf['back2front'][0].";");
63 
64  /* rebuild categories cache */
65  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
66  invalidate_user_cache(true);
67}
68?>
Note: See TracBrowser for help on using the repository browser.