source: extensions/MenuRandomPhoto/maintain.class.php @ 31882

Last change on this file since 31882 was 31882, checked in by plg, 7 years ago

rename maintain.inc.php into maintain.class.php

  • Property svn:executable set to *
File size: 1.5 KB
RevLine 
[30050]1<?php
2
3defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
4
5class MenuRandomPhoto_maintain extends PluginMaintain
6{
[31852]7        private $installed = false;
8       
9        private $default_conf = array(
10                'height' => 150,
11                'square' => true,
12                'randompicture_preload' => 25,     // number preloaded random pictures
13                'title' => 'A random photo',
14                'delay' => 4000,
15                'apply_to_albums' => 'all',
16        );
17       
18        function __construct($plugin_id)
19        {
20                parent::__construct($plugin_id);
21        }
22       
23        function install($plugin_version, &$errors=array())
24        {
25                global $conf;
26       
27                if (empty($conf['MRP']))
28                {
29                        $conf['MRP'] = serialize($this->default_conf);
30                        conf_update_param('MRP', $conf['MRP']);
31                }
32                else
33                {
34                        $new_conf = is_string($conf['MRP']) ? unserialize($conf['MRP']) : $conf['MRP'];
35               
36                        $conf['MRP'] = serialize($new_conf);
37                        conf_update_param('MRP', $conf['MRP']);
38                }
[30050]39
[31852]40                // add a new column to existing CATEGORIES table, if it doesn't already exist
41                $result = pwg_query('SHOW COLUMNS FROM `'.CATEGORIES_TABLE.'` LIKE "menurandomphoto_active";');
42                if (!pwg_db_num_rows($result))
43                {
44                        pwg_query('ALTER TABLE `'.CATEGORIES_TABLE.'` ADD `menurandomphoto_active` enum(\'true\', \'false\') default \'false\';');
45                }
46       
47                $this->installed = true;
48        }
49       
50        function activate($plugin_version, &$errors=array())
51        {
52                if (!$this->installed)
53                {
54                        $this->install($plugin_version, $errors);
55                }
56        }
57       
58        function deactivate()
59        {
60        }
61       
62        function uninstall()
63        {
64                conf_delete_param('MRP');
65            // delete field
66        pwg_query('ALTER TABLE `'. CATEGORIES_TABLE .'` DROP COLUMN `menurandomphoto_active`;');
67        }
[30050]68}
69
70?>
Note: See TracBrowser for help on using the repository browser.