source: extensions/piclens/maintain.inc.php @ 3649

Last change on this file since 3649 was 3649, checked in by tiico, 15 years ago

Personnalize the icon in the cooliris feed (on the wall)
Unstall the plugin will suppress the configuration on the database

File size: 1.9 KB
Line 
1<?php
2/*
3 * Plugin Name: CoolIris-Piclens
4 * File :  maintain.inc.php 
5 */
6
7if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
8
9
10function plugin_install()
11{
12}
13
14function plugin_activate()
15{
16
17
18  // Check if upgrade is needed
19        $query = '
20          SELECT value
21          FROM '.CONFIG_TABLE.'
22          WHERE param = \''.basename(dirname(__FILE__)).'\'
23        ;';
24        $result = pwg_query($query);
25
26        if($result) 
27        {
28                 $row = mysql_fetch_row($result);
29                 if(is_string($row[0])) 
30                 {
31                        $row = unserialize($row[0]);
32                        if (!isset($row['piclens_rss_name']))   // name and desc format changed from 0.3.x --> 0.4.x
33                                upgrade_piclens_from_03x($row);                 
34                 }
35        }
36
37}
38
39function plugin_uninstall()
40{
41
42        $query = '
43      DELETE FROM '.CONFIG_TABLE.'
44          WHERE param = \''.basename(dirname(__FILE__)).'\'
45        ;';
46
47        pwg_query($query);
48
49}
50
51function upgrade_piclens_from_03x($row)
52{
53        $piclens_rss_name = '';
54        $piclens_rss_desc = '';
55
56        if (isset($row['piclens_name_image']) and $row['piclens_name_image'] != 4)      // old name format
57        {
58                if ($row['piclens_cat_view'])           // View cat active
59                        $piclens_rss_name .= "%C2 - ";
60                switch($row['piclens_name_image'])
61                {
62                        case 2 : $piclens_rss_name .= "%IC";
63                                break;
64                        case 3 : $piclens_rss_name .= "%I2";
65                                break;
66                        default : $piclens_rss_name .= "%IC";
67                                break;
68                }
69               
70        }
71        if (isset($row['piclens_name_desc']))   // old description format
72        {
73                switch($row['piclens_name_desc'])
74                {
75                        case 2 : $piclens_rss_desc .= "%C2";
76                                break;
77                        case 3 : $piclens_rss_desc .= "%C3";
78                                break;
79                        default :
80                                break;
81                }
82        }
83        // New format for name and desc in database
84        $row['piclens_rss_name'] = $piclens_rss_name;
85        $row['piclens_rss_desc'] = $piclens_rss_desc;
86       
87        $query = '
88          REPLACE INTO '.CONFIG_TABLE.'
89          VALUES(
90                \''.basename(dirname(__FILE__)).'\',
91                \''.serialize($row).'\',
92                \'Configuration de Piclens\')
93        ;';
94
95        pwg_query($query);
96
97}
98
99
100?>
Note: See TracBrowser for help on using the repository browser.