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

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

Add index.php file into directory
Add CHANGELOG and clean header files
Add 'last comments' option for name and descriptions (%ID option)
Add maintain.inc.php for migration to 0.4.x (name and description translation)
Complete Chinese translation (thanks winson)

  • Correct the latests commit (3636 & 3637 were not complete)
File size: 1.8 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
43function upgrade_piclens_from_03x($row)
44{
45        $piclens_rss_name = '';
46        $piclens_rss_desc = '';
47
48        if (isset($row['piclens_name_image']) and $row['piclens_name_image'] != 4)      // old name format
49        {
50                if ($row['piclens_cat_view'])           // View cat active
51                        $piclens_rss_name .= "%C2 - ";
52                switch($row['piclens_name_image'])
53                {
54                        case 2 : $piclens_rss_name .= "%IC";
55                                break;
56                        case 3 : $piclens_rss_name .= "%I2";
57                                break;
58                        default : $piclens_rss_name .= "%IC";
59                                break;
60                }
61               
62        }
63        if (isset($row['piclens_name_desc']))   // old description format
64        {
65                switch($row['piclens_name_desc'])
66                {
67                        case 2 : $piclens_rss_desc .= "%C2";
68                                break;
69                        case 3 : $piclens_rss_desc .= "%C3";
70                                break;
71                        default :
72                                break;
73                }
74        }
75        // New format for name and desc in database
76        $row['piclens_rss_name'] = $piclens_rss_name;
77        $row['piclens_rss_desc'] = $piclens_rss_desc;
78       
79        $query = '
80          REPLACE INTO '.CONFIG_TABLE.'
81          VALUES(
82                \''.basename(dirname(__FILE__)).'\',
83                \''.serialize($row).'\',
84                \'Configuration de Piclens\')
85        ;';
86
87        pwg_query($query);
88
89}
90
91
92?>
Note: See TracBrowser for help on using the repository browser.