Changeset 9707 for extensions/autoupdate/trunk/include
- Timestamp:
- Mar 15, 2011, 6:07:03 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/autoupdate/trunk/include/functions_remote.inc.php
r6767 r9707 23 23 { 24 24 return l10n('A new version of Piwigo is available.').'<br>' 25 . '<a href="admin.php?page=plugin &section=autoupdate%2Fautoupdate.php">'.l10n('Click here to upgrade automatically').'</a>';25 . '<a href="admin.php?page=plugin-autoupdate">'.l10n('Click here to upgrade automatically').'</a>'; 26 26 } 27 27 else … … 30 30 // Check plugins upgrade 31 31 include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php'); 32 include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php'); 33 include_once(PHPWG_ROOT_PATH.'admin/include/languages.class.php'); 32 34 $plugins = new plugins(); 35 $themes = new themes(); 36 $languages = new languages(); 33 37 $ignore_list = unserialize($conf['autoupdate_ignore_list']); 34 38 35 if (!isset($_SESSION['plugins_need_update'])) 36 { 37 $_SESSION['plugins_need_update'] = null; 39 // Upgrade? 40 if (!isset($ignore_list['plugins']) or !isset($ignore_list['themes']) or !isset($ignore_list['languages'])) 41 { 42 $ignore_list = array('plugins'=>array(),'themes'=>array(),'languages'=>array()); 43 $conf['autoupdate_ignore_list'] = serialize($ignore_list); 44 conf_update_param('autoupdate_ignore_list', pwg_db_real_escape_string($conf['autoupdate_ignore_list'])); 45 } 46 47 if (!isset($_SESSION['extensions_need_update'])) 48 { 49 $_SESSION['extensions_need_update'] = null; 38 50 autoupdate_check_plugins_upgrade($plugins, $ignore_list); 39 } 40 elseif (!empty($_SESSION['plugins_need_update'])) 41 { 42 // Check if plugins have been upgraded since last check 43 foreach($plugins->fs_plugins as $plugin_id => $fs_plugin) 44 { 45 if (isset($_SESSION['plugins_need_update'][$plugin_id]) 46 and $plugins->plugin_version_compare($fs_plugin['version'], $_SESSION['plugins_need_update'][$plugin_id])) 47 { 48 // Plugin have been updated 49 autoupdate_check_plugins_upgrade($plugins, $ignore_list); 50 } 51 } 52 } 53 54 if (!empty($_SESSION['plugins_need_update'])) 51 autoupdate_check_themes_upgrade($themes, $ignore_list); 52 autoupdate_check_languages_upgrade($languages, $ignore_list); 53 } 54 else 55 { 56 if (!empty($_SESSION['extensions_need_update']['plugins'])) 57 { 58 // Check if plugins have been upgraded since last check 59 foreach($plugins->fs_plugins as $plugin_id => $fs_plugin) 60 { 61 if (isset($_SESSION['extensions_need_update']['plugins'][$plugin_id]) 62 and $plugins->plugin_version_compare($fs_plugin['version'], $_SESSION['extensions_need_update']['plugins'][$plugin_id])) 63 { 64 // Plugin have been updated 65 autoupdate_check_extensions_upgrade($plugins, $themes, $languages, $ignore_list); 66 } 67 } 68 } 69 if (!empty($_SESSION['extensions_need_update']['themes'])) 70 { 71 // Check if themes have been upgraded since last check 72 foreach($themes->fs_themes as $theme_id => $fs_theme) 73 { 74 if (isset($_SESSION['extensions_need_update']['themes'][$theme_id]) 75 and $themes->theme_version_compare($fs_theme['version'], $_SESSION['extensions_need_update']['themes'][$theme_id])) 76 { 77 // theme have been updated 78 autoupdate_check_extensions_upgrade($themes, $themes, $languages, $ignore_list); 79 } 80 } 81 } 82 if (!empty($_SESSION['extensions_need_update']['languages'])) 83 { 84 // Check if languages have been upgraded since last check 85 foreach($languages->fs_languages as $language_id => $fs_language) 86 { 87 if (isset($_SESSION['extensions_need_update']['languages'][$language_id]) 88 and $languages->language_version_compare($fs_language['version'], $_SESSION['extensions_need_update']['languages'][$language_id])) 89 { 90 // language have been updated 91 autoupdate_check_extensions_upgrade($languages, $themes, $languages, $ignore_list); 92 } 93 } 94 } 95 } 96 97 if (!empty($_SESSION['extensions_need_update'])) 55 98 { 56 99 return l10n('Some upgrades are available for you plugins').'<br>' 57 . '<a href="admin.php?page=plugin s_update">'.l10n('Click here see upgrade plugins page').'</a>';58 } 59 } 60 61 if ($_SESSION['need_update'] === false and $_SESSION[' plugins_need_update'] === array())100 . '<a href="admin.php?page=plugin-autoupdate">'.l10n('Click here see upgrade plugins page').'</a>'; 101 } 102 } 103 104 if ($_SESSION['need_update'] === false and $_SESSION['extensions_need_update'] === array()) 62 105 { 63 106 return l10n('Gallery and plugins are up to date'); … … 73 116 function autoupdate_check_plugins_upgrade($plugins, $ignore_list) 74 117 { 118 global $conf; 119 75 120 if ($plugins->get_server_plugins()) 76 121 { 77 $new_ignore_list = array(); 78 $_SESSION['plugins_need_update'] = array(); 122 $plugins_ignore_list = array(); 123 $need_upgrade = array(); 124 if (is_null($_SESSION['extensions_need_update'])) 125 $_SESSION['extensions_need_update'] = array(); 79 126 80 127 foreach($plugins->fs_plugins as $plugin_id => $fs_plugin) … … 88 135 $fs_plugin_name = htmlspecialchars_decode($fs_plugin['name']); 89 136 90 if (in_array($fs_plugin_name, $ignore_list ))91 { 92 array_push($ new_ignore_list, $fs_plugin_name);137 if (in_array($fs_plugin_name, $ignore_list['plugins'])) 138 { 139 array_push($plugins_ignore_list, $fs_plugin_name); 93 140 } 94 141 else 95 142 { 96 $_SESSION['plugins_need_update'][$plugin_id] = $plugin_info['revision_name']; 97 } 98 } 99 } 100 } 101 143 $need_upgrade[$plugin_id] = $plugin_info['revision_name']; 144 } 145 } 146 } 147 } 148 if (!empty($need_upgrade)) 149 { 150 $_SESSION['extensions_need_update']['plugins'] = $need_upgrade; 151 } 102 152 // Update ignore list in database 103 $query = ' 104 UPDATE '.CONFIG_TABLE.' 105 SET value = "'.addslashes(serialize($new_ignore_list)).'" 106 WHERE param = "autoupdate_ignore_list" 107 ;'; 108 pwg_query($query); 153 $conf['autoupdate_ignore_list']['plugins'] = $plugins_ignore_list; 154 conf_update_param('autoupdate_ignore_list', pwg_db_real_escape_string(serialize($conf['autoupdate_ignore_list']))); 155 } 156 } 157 158 function autoupdate_check_themes_upgrade($themes, $ignore_list) 159 { 160 global $conf; 161 162 if ($themes->get_server_themes()) 163 { 164 $themes_ignore_list = array(); 165 $need_upgrade = array(); 166 if (is_null($_SESSION['extensions_need_update'])) 167 $_SESSION['extensions_need_update'] = array(); 168 169 foreach($themes->fs_themes as $theme_id => $fs_theme) 170 { 171 if (isset($fs_theme['extension']) and isset($themes->server_themes[$fs_theme['extension']])) 172 { 173 $theme_info = $themes->server_themes[$fs_theme['extension']]; 174 175 if (!$themes->theme_version_compare($fs_theme['version'], $theme_info['revision_name'])) 176 { 177 $fs_theme_name = htmlspecialchars_decode($fs_theme['name']); 178 179 if (in_array($fs_theme_name, $ignore_list['theme'])) 180 { 181 array_push($themes_ignore_list, $fs_theme_name); 182 } 183 else 184 { 185 $need_upgrade[$theme_id] = $theme_info['revision_name']; 186 } 187 } 188 } 189 } 190 if (!empty($need_upgrade)) 191 { 192 $_SESSION['extensions_need_update']['themes'] = $need_upgrade; 193 } 194 // Update ignore list in database 195 $conf['autoupdate_ignore_list']['themes'] = $themes_ignore_list; 196 conf_update_param('autoupdate_ignore_list', pwg_db_real_escape_string(serialize($conf['autoupdate_ignore_list']))); 197 } 198 } 199 200 function autoupdate_check_languages_upgrade($plugins, $ignore_list) 201 { 202 global $conf; 203 204 if ($languages->get_server_languages()) 205 { 206 $languages_ignore_list = array(); 207 $need_upgrade = array(); 208 if (is_null($_SESSION['extensions_need_update'])) 209 $_SESSION['extensions_need_update'] = array(); 210 211 foreach($languages->fs_languages as $language_id => $fs_language) 212 { 213 if (isset($fs_language['extension']) and isset($languages->server_languages[$fs_language['extension']])) 214 { 215 $language_info = $languages->server_languages[$fs_language['extension']]; 216 217 if (!$languages->language_version_compare($fs_language['version'], $language_info['revision_name'])) 218 { 219 $fs_language_name = htmlspecialchars_decode($fs_language['name']); 220 221 if (in_array($fs_language_name, $ignore_list['languages'])) 222 { 223 array_push($languages_ignore_list, $fs_language_name); 224 } 225 else 226 { 227 $need_upgrade[$language_id] = $language_info['revision_name']; 228 } 229 } 230 } 231 } 232 if (!empty($need_upgrade)) 233 { 234 $_SESSION['extensions_need_update']['languages'] = $need_upgrade; 235 } 236 // Update ignore list in database 237 $conf['autoupdate_ignore_list']['languages'] = $languages_ignore_list; 238 conf_update_param('autoupdate_ignore_list', pwg_db_real_escape_string(serialize($conf['autoupdate_ignore_list']))); 109 239 } 110 240 }
Note: See TracChangeset
for help on using the changeset viewer.