- Timestamp:
- Aug 14, 2013, 11:30:28 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_plugins.inc.php
r19703 r24160 253 253 } 254 254 } 255 256 /* 257 * test if a plugin needs to be updated and call a update function 258 * @param: string $plugin_id, id of the plugin as seen in PLUGINS_TABLE and $pwg_loaded_plugins 259 * @param: string $version, version exposed by the plugin 260 * @param: callable $on_update, function to call when and update is needed 261 * it receives the previous version as first parameter 262 */ 263 function request_plugin_update($plugin_id, $version, $on_update) 264 { 265 global $pwg_loaded_plugins; 266 267 if ( 268 $version == 'auto' or 269 $pwg_loaded_plugins[$plugin_id]['version'] == 'auto' or 270 version_compare($pwg_loaded_plugins[$plugin_id]['version'], $version, '<') 271 ) 272 { 273 // call update function 274 if (!empty($on_update)) 275 { 276 call_user_func($on_update, $pwg_loaded_plugins[$plugin_id]['version']); 277 } 278 279 // update plugin version in database 280 if ($version != 'auto') 281 { 282 $query = ' 283 UPDATE '. PLUGINS_TABLE .' 284 SET version = "'. $version .'" 285 WHERE id = "'. $plugin_id .'"'; 286 pwg_query($query); 287 288 $pwg_loaded_plugins[$plugin_id]['version'] = $version; 289 } 290 } 291 } 292 255 293 ?>
Note: See TracChangeset
for help on using the changeset viewer.