source: extensions/AdditionalPages/admin/upgrade_from_21.php @ 9272

Last change on this file since 9272 was 9272, checked in by patdenice, 10 years ago

New functionalities

File size: 2.7 KB
Line 
1<?php
2
3if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
4
5global $prefixeTable, $conf;
6
7$query = 'ALTER TABLE ' . $prefixeTable . 'additionalpages
8CHANGE `id` `id` SMALLINT( 5 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
9CHANGE `pos` `pos` SMALLINT( 5 ) NULL DEFAULT NULL ,
10CHANGE `lang` `lang` VARCHAR( 255 ) NULL DEFAULT NULL ,
11CHANGE `text` `content` LONGTEXT NOT NULL ,
12ADD `users` VARCHAR( 255 ) NULL DEFAULT NULL ,
13ADD `groups` VARCHAR( 255 ) NULL DEFAULT NULL ,
14ADD `permalink` VARCHAR( 64 ) NULL DEFAULT NULL ,
15ADD `standalone` ENUM( "true", "false" ) NOT NULL DEFAULT "false";';
16pwg_query($query);
17
18$query = '
19SELECT id, pos, title, lang
20FROM '.$prefixeTable.'additionalpages
21ORDER BY pos ASC
22;';
23$result = pwg_query($query);
24while ($row = mysql_fetch_assoc($result))
25{
26  $title = $row['title'];
27  $authorized_users = 'NULL';
28  $authorized_groups = 'NULL';
29
30  if (strpos($title , '/user_id='))
31  {
32    $array = explode('/user_id=' , $title);
33    $title = $array[0];
34    $authorized_users = '"'.$array[1].'"';
35  }
36  if (strpos($title , '/group_id='))
37  {
38    $array = explode('/group_id=' , $title);
39    $title = $array[0];
40    $authorized_groups = '"'.$array[1].'"';
41  }
42
43  $position = $row['pos'];
44  if ($row['pos'] === '0')
45    $position = '-100';
46  elseif (empty($row['pos']))
47    $position = '0';
48
49  $language = $row['lang'] != 'ALL' ? '"'.$row['lang'].'"' : 'NULL';
50
51  $query = '
52UPDATE '.$prefixeTable.'additionalpages
53SET title = "'.addslashes($title).'",
54    pos = '.$position.',
55    lang = '.$language.',
56    users = '.$authorized_users.',
57    groups = '.$authorized_groups.'
58WHERE id = '.$row['id'].'
59;';
60  pwg_query($query);
61}
62
63load_conf_from_db('param = "additional_pages"');
64$old_conf = explode ("," , $conf['additional_pages']);
65
66if ($old_conf[1] == 'off')
67{
68  $mb_conf = @unserialize($conf['blk_menubar']);
69  if (!isset($mb_conf['mbAdditionalPages']))
70  {
71    $last = @abs(end($mb_conf));
72    $mb_conf['mbAdditionalPages'] = $last + 50;
73  }
74  $mb_conf['mbAdditionalPages'] = -1 * abs($mb_conf['mbAdditionalPages']);
75  conf_update_param('blk_menubar', pwg_db_real_escape_string(serialize($mb_conf)));
76}
77
78$new_conf = array(
79  'show_home' => @($old_conf[2] == 'on'),
80  'group_perm' => @($old_conf[6] == 'on'),
81  'user_perm' => @($old_conf[7] == 'on'),
82  'homepage' => null,
83  );
84
85$languages = explode('/', $old_conf[0]);
86$new_conf['languages'] = array();
87foreach($languages as $language)
88{
89  $array = explode(':', $language);
90  if (!isset($array[1])) $new_conf['languages']['default'] = $array[0];
91  else $new_conf['languages'][$array[0]] = $array[1];
92}
93
94$conf['additional_pages'] = $new_conf;
95
96conf_update_param('additional_pages', pwg_db_real_escape_string(serialize($new_conf)));
97
98?>
Note: See TracBrowser for help on using the repository browser.