[3604] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: Piwigo AutoUpgrade |
---|
| 4 | Version: auto |
---|
| 5 | Description: Upgrade your gallery automatically. |
---|
| 6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=302 |
---|
| 7 | Author: P@t |
---|
| 8 | Author URI: http://www.gauchon.com |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 12 | |
---|
[6167] | 13 | define('AUTOUPDATE_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); |
---|
[3604] | 14 | |
---|
[9707] | 15 | global $conf; |
---|
| 16 | $conf['AU_ignore'] = unserialize($conf['autoupdate_ignore_list']); |
---|
| 17 | |
---|
| 18 | // Upgrade? |
---|
[9710] | 19 | if (!isset($conf['AU_ignore']['plugins'])) |
---|
[9707] | 20 | { |
---|
| 21 | $conf['AU_ignore'] = array('plugins'=>array(),'themes'=>array(),'languages'=>array()); |
---|
| 22 | conf_update_param('autoupdate_ignore_list', pwg_db_real_escape_string(serialize($conf['AU_ignore']))); |
---|
| 23 | } |
---|
| 24 | |
---|
[9935] | 25 | add_event_handler('get_admin_plugin_menu_links', 'check_for_auto_upgrade'); |
---|
| 26 | add_event_handler('ws_add_methods', 'add_ws_autoupdate_methods'); |
---|
[6167] | 27 | |
---|
[3604] | 28 | function check_for_auto_upgrade($plugin_menu_links) |
---|
| 29 | { |
---|
[9712] | 30 | global $template, $page, $header_notes; |
---|
[4699] | 31 | |
---|
| 32 | if ($page['page'] == 'intro') |
---|
| 33 | { |
---|
[6167] | 34 | if (isset($_GET['action']) and |
---|
| 35 | ($_GET['action'] == 'check_autoupdate' or $_GET['action'] == 'check_upgrade' )) |
---|
| 36 | { |
---|
| 37 | unset($_SESSION['need_update']); |
---|
[9710] | 38 | unset($_SESSION['extensions_need_update']); |
---|
[6167] | 39 | } |
---|
| 40 | |
---|
[9710] | 41 | if (!isset($_SESSION['need_update']) or !isset($_SESSION['extensions_need_update']) |
---|
| 42 | or $_SESSION['need_update'] !== false or $_SESSION['extensions_need_update'] !== array()) |
---|
[6167] | 43 | { |
---|
[9712] | 44 | load_language('plugin.lang', dirname(__FILE__).'/'); |
---|
[6167] | 45 | $template->set_filename('autoupdate_head', realpath(AUTOUPDATE_PATH.'template/head.tpl')); |
---|
| 46 | array_push($header_notes, $template->parse('autoupdate_head', true)); |
---|
| 47 | } |
---|
[4699] | 48 | } |
---|
| 49 | |
---|
[6167] | 50 | array_push($plugin_menu_links, array( |
---|
[9707] | 51 | 'NAME' => 'Piwigo AutoUpgrade', |
---|
| 52 | 'URL' => get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__)) |
---|
| 53 | ) |
---|
| 54 | ); |
---|
[6167] | 55 | |
---|
[3604] | 56 | return $plugin_menu_links; |
---|
| 57 | } |
---|
[9935] | 58 | |
---|
| 59 | function add_ws_autoupdate_methods($arr) |
---|
| 60 | { |
---|
| 61 | include_once(AUTOUPDATE_PATH.'ws_functions.inc.php'); |
---|
| 62 | } |
---|
[3575] | 63 | ?> |
---|