Ignore:
Timestamp:
Mar 28, 2010, 5:57:37 PM (14 years ago)
Author:
grum
Message:

Update the plugin for compatibility with Piwigo 2.1 and fix some bugs
feature 1384, feature 1476, feature 1541

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/AMenuManager/amm_install.class.inc.php

    r4391 r5421  
    44  Author     : Grum
    55    email    : grum@grum.dnsalias.com
    6     website  : http://photos.grum.dnsalias.com
     6    website  : http://photos.grum.fr
    77    PWG user : http://forum.phpwebgallery.net/profile.php?id=3706
    88
     
    1414
    1515  --------------------------------------------------------------------------- */
    16   @include_once('amm_root.class.inc.php');
     16  include_once('amm_version.inc.php');
     17  include_once('amm_root.class.inc.php');
    1718  include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/tables.class.inc.php');
    1819
     
    3637    public function install()
    3738    {
     39      $this->init_config();
     40      $this->load_config();
     41      $this->my_config['installed']=AMM_VERSION2;
     42      $this->save_config();
    3843
    3944      $tables_def=array(
     
    5358  `id` int(11) NOT NULL default '0',
    5459  `lang` varchar(5) NOT NULL default '',
    55   `title` varchar(50) NOT NULL default '',
     60  `title` varchar(255) NOT NULL default '',
    5661  `content` text NOT NULL,
    5762  `visible` char(1) NOT NULL default 'y',
    58   `nfo` varchar(25) NOT NULL default '',
     63  `nfo` varchar(255) NOT NULL default '',
    5964  PRIMARY KEY  (`id`,`lang`)
    6065)"
     
    8388      $this->init_config();
    8489      $this->load_config();
     90
     91      $this->udpateTablesDef();
     92
     93      $this->my_config['installed']=AMM_VERSION2; //update the installed release number
     94      $this->save_config();
     95    }
     96
     97    public function deactivate()
     98    {
     99    }
     100
     101
     102    /**
     103     * update tables & config between releases
     104     *
     105     */
     106    protected function udpateTablesDef()
     107    {
    85108      /* AMM release earlier than the 2.1.3 uses two parameters to manage the display
    86109       * of the menu items ("amm_sections_modspecials" and "amm_sections_modmenu")
     
    108131      }
    109132
    110       $this->save_config();
    111     }
     133      if(!array_key_exists('installed', $this->my_config))
     134      {
     135        /*
     136         * if key does not exist, probably try to update a plugin older than the
     137         * 2.2.0 release
     138         */
     139        $this->my_config['installed']="02.01.06";
     140      }
    112141
    113     public function deactivate()
    114     {
     142      if($this->my_config['installed']<="02.01.06")
     143      {
     144        /*
     145         * 2.2.0 updates
     146         *
     147         * - update fields length for table 'personalised'
     148         * - update config for menu translation
     149         */
     150        $sql="ALTER TABLE `".$this->tables['personalised']."`
     151              MODIFY COLUMN `title` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
     152              MODIFY COLUMN `nfo` VARCHAR(255)  CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;";
     153        pwg_query($sql);
     154
     155        foreach($this->my_config['amm_sections_items'] as $key => $val)
     156        {
     157          $this->my_config['amm_sections_items'][$key]['translation'] = $this->defaultMenus[$key]['translation'];
     158        }
     159      }
    115160    }
    116161
Note: See TracChangeset for help on using the changeset viewer.