source: extensions/AMenuManager/amm_install.class.inc.php @ 4391

Last change on this file since 4391 was 4391, checked in by grum, 14 years ago

[AMM] import config from releases earlier than 2.1.3

  • Property svn:executable set to *
File size: 3.6 KB
Line 
1<?php
2/* -----------------------------------------------------------------------------
3  Plugin     : Advanced Menu Manager
4  Author     : Grum
5    email    : grum@grum.dnsalias.com
6    website  : http://photos.grum.dnsalias.com
7    PWG user : http://forum.phpwebgallery.net/profile.php?id=3706
8
9    << May the Little SpaceFrog be with you ! >>
10  ------------------------------------------------------------------------------
11  See main.inc.php for release information
12
13  MyPolls_Install : classe to manage plugin install
14
15  --------------------------------------------------------------------------- */
16  @include_once('amm_root.class.inc.php');
17  include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/tables.class.inc.php');
18
19
20  class AMM_install extends AMM_root
21  {
22    private $tablef;
23    private $exportfile;
24
25    public function AMM_install($prefixeTable, $filelocation)
26    {
27      parent::__construct($prefixeTable, $filelocation);
28      $this->tablef= new manage_tables($this->tables);
29      $this->exportfile=dirname($this->filelocation).'/'.$this->plugin_name_files.'.sql';
30    }
31
32    /*
33        function for installation process
34        return true if install process is ok, otherwise false
35    */
36    public function install()
37    {
38
39      $tables_def=array(
40"CREATE TABLE  `".$this->tables['urls']."` (
41  `id` int(11) NOT NULL auto_increment,
42  `label` varchar(50) NOT NULL default '',
43  `url` varchar(255) NOT NULL default '',
44  `mode` int(11) NOT NULL default '0',
45  `icon` varchar(50) NOT NULL default '',
46  `position` int(11) NOT NULL default '0',
47  `visible` char(1) NOT NULL default 'y',
48  PRIMARY KEY  (`id`),
49  KEY `order_key` (`position`)
50)",
51
52"CREATE TABLE  `".$this->tables['personalised']."` (
53  `id` int(11) NOT NULL default '0',
54  `lang` varchar(5) NOT NULL default '',
55  `title` varchar(50) NOT NULL default '',
56  `content` text NOT NULL,
57  `visible` char(1) NOT NULL default 'y',
58  `nfo` varchar(25) NOT NULL default '',
59  PRIMARY KEY  (`id`,`lang`)
60)"
61);
62      //$table_def array
63      $tables_def = create_table_add_character_set($tables_def);
64      $result=$this->tablef->create_tables($tables_def);
65      return($result);
66    }
67
68
69    /*
70        function for uninstall process
71    */
72    public function uninstall()
73    {
74      $this->tablef->export($this->exportfile);
75      $this->delete_config();
76      $this->tablef->drop_tables();
77    }
78
79    public function activate()
80    {
81      global $template;
82
83      $this->init_config();
84      $this->load_config();
85      /* AMM release earlier than the 2.1.3 uses two parameters to manage the display
86       * of the menu items ("amm_sections_modspecials" and "amm_sections_modmenu")
87       *
88       * These two parameters are replaced by a single parameter "amm_sections_items"
89       *
90       * This function aim to import the old conf into the new conf property
91      */
92      if(isset($this->my_config['amm_sections_modspecials']))
93      {
94        foreach($this->my_config['amm_sections_modspecials'] as $key=>$val)
95        {
96          $this->my_config['amm_sections_items'][$key]['visibility']=($val=="y")?"guest,generic,normal,admin/":"admin/";
97        }
98        unset($this->my_config['amm_sections_modspecials']);
99      }
100
101      if(isset($this->my_config['amm_sections_modmenu']))
102      {
103        foreach($this->my_config['amm_sections_modmenu'] as $key=>$val)
104        {
105          $this->my_config['amm_sections_items'][$key]['visibility']=($val=="y")?"guest,generic,normal,admin/":"admin/";
106        }
107        unset($this->my_config['amm_sections_modmenu']);
108      }
109
110      $this->save_config();
111    }
112
113    public function deactivate()
114    {
115    }
116
117  } //class
118
119?>
Note: See TracBrowser for help on using the repository browser.