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

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

remove a prefilter for a better integration, add an option to display a mark on thumbnails list

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