source: extensions/autoupdate/trunk/main.inc.php @ 9712

Last change on this file since 9712 was 9712, checked in by patdenice, 13 years ago

Clean code.
Rename files.

File size: 1.8 KB
Line 
1<?php
2/*
3Plugin Name: Piwigo AutoUpgrade
4Version: auto
5Description: Upgrade your gallery automatically.
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=302
7Author: P@t
8Author URI: http://www.gauchon.com
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
13define('AUTOUPDATE_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
14
15global $conf;
16$conf['AU_ignore'] = unserialize($conf['autoupdate_ignore_list']);
17
18// Upgrade?
19if (!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
25if (script_basename() == 'admin')
26 add_event_handler('get_admin_plugin_menu_links', 'check_for_auto_upgrade');
27
28function 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?>
Note: See TracBrowser for help on using the repository browser.