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 | |
---|
13 | define('AUTOUPDATE_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); |
---|
14 | |
---|
15 | global $conf; |
---|
16 | $conf['AU_ignore'] = unserialize($conf['autoupdate_ignore_list']); |
---|
17 | |
---|
18 | // Upgrade? |
---|
19 | if (!isset($conf['AU_ignore']['plugins'])) |
---|
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 | |
---|
25 | add_event_handler('get_admin_plugin_menu_links', 'check_for_auto_upgrade'); |
---|
26 | add_event_handler('ws_add_methods', 'add_ws_autoupdate_methods'); |
---|
27 | |
---|
28 | function check_for_auto_upgrade($plugin_menu_links) |
---|
29 | { |
---|
30 | global $template, $page, $header_notes; |
---|
31 | |
---|
32 | if ($page['page'] == 'intro') |
---|
33 | { |
---|
34 | if (isset($_GET['action']) and |
---|
35 | ($_GET['action'] == 'check_autoupdate' or $_GET['action'] == 'check_upgrade' )) |
---|
36 | { |
---|
37 | unset($_SESSION['need_update']); |
---|
38 | unset($_SESSION['extensions_need_update']); |
---|
39 | } |
---|
40 | |
---|
41 | if (!isset($_SESSION['need_update']) or !isset($_SESSION['extensions_need_update']) |
---|
42 | or $_SESSION['need_update'] !== false or $_SESSION['extensions_need_update'] !== array()) |
---|
43 | { |
---|
44 | load_language('plugin.lang', dirname(__FILE__).'/'); |
---|
45 | $template->set_filename('autoupdate_head', realpath(AUTOUPDATE_PATH.'template/head.tpl')); |
---|
46 | array_push($header_notes, $template->parse('autoupdate_head', true)); |
---|
47 | } |
---|
48 | } |
---|
49 | |
---|
50 | array_push($plugin_menu_links, array( |
---|
51 | 'NAME' => 'Piwigo AutoUpgrade', |
---|
52 | 'URL' => get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__)) |
---|
53 | ) |
---|
54 | ); |
---|
55 | |
---|
56 | return $plugin_menu_links; |
---|
57 | } |
---|
58 | |
---|
59 | function add_ws_autoupdate_methods($arr) |
---|
60 | { |
---|
61 | include_once(AUTOUPDATE_PATH.'ws_functions.inc.php'); |
---|
62 | } |
---|
63 | ?> |
---|