Changeset 4711


Ignore:
Timestamp:
Jan 20, 2010, 6:03:37 PM (14 years ago)
Author:
patdenice
Message:

[Plugin][Piwigo Auto Upgrade]
If gallery and plugins are up to date, display note on admin homepage only one time for each session.
Allow to disable notification for plugins you don't want to update.

Location:
extensions/autoupdate
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • extensions/autoupdate/autoupdate.php

    r4700 r4711  
    102102}
    103103
    104 $template->set_filename('autoupdate_head', realpath(dirname(__FILE__).'/head.tpl'));
    105 array_push($header_notes, $template->parse('autoupdate_head', true));
     104if (!isset($_SESSION['need_update']) or !isset($_SESSION['plugins_need_update'])
     105  or $_SESSION['need_update'] !== false or $_SESSION['plugins_need_update'] !== array())
     106{
     107  $template->set_filename('autoupdate_head', realpath(dirname(__FILE__).'/head.tpl'));
     108  array_push($header_notes, $template->parse('autoupdate_head', true));
     109}
    106110
    107111?>
  • extensions/autoupdate/class.inc.php

    r4700 r4711  
    9999      include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php');
    100100      $plugins = new plugins();
     101      $plugin_list = array();
     102      $ignore_list = unserialize($conf['autoupdate_ignore_list']);
    101103
    102104      if (!isset($_SESSION['plugins_need_update']))
    103105      {
    104106        $_SESSION['plugins_need_update'] = null;
    105         $this->check_plugins_upgrade($plugins);
     107        $this->check_plugins_upgrade($plugins, $ignore_list);
    106108      }
    107109      elseif (!empty($_SESSION['plugins_need_update']))
     
    114116          {
    115117            // Plugin have been updated
    116             $this->check_plugins_upgrade($plugins);
     118            $this->check_plugins_upgrade($plugins, $ignore_list);
    117119          }
    118120        }
     
    121123      if (!empty($_SESSION['plugins_need_update']))
    122124      {
    123         return l10n('Some upgrades are available for you plugins').'<br>'
    124           . '<a href="admin.php?page=plugins_update">'.l10n('Click here see upgrade plugins page').'</a>';
     125        $plugin_list = $_SESSION['plugins_need_update'];
     126
     127        // Check ignore list
     128        foreach ($plugin_list as $plugin_id => $version)
     129        {
     130          if (in_array($plugins->fs_plugins[$plugin_id]['name'], $ignore_list))
     131          {
     132            unset($plugin_list[$plugin_id]);
     133          }
     134        }
     135
     136        if (!empty($plugin_list))
     137        {
     138          return l10n('Some upgrades are available for you plugins').'<br>'
     139            . '<a href="admin.php?page=plugins_update">'.l10n('Click here see upgrade plugins page').'</a>';
     140        }
    125141      }
    126142    }
    127143
    128     if ($_SESSION['need_update'] === false and $_SESSION['plugins_need_update'] === array())
     144    if ($_SESSION['need_update'] === false and $plugin_list === array())
    129145    {
    130146      return l10n('Gallery and plugins are up to date');
     
    138154  }
    139155
    140   function check_plugins_upgrade($plugins)
     156  function check_plugins_upgrade($plugins, $ignore_list)
    141157  {
    142158    if ($plugins->get_server_plugins())
    143159    {
     160      $new_ignore_list = array();
    144161      $_SESSION['plugins_need_update'] = array();
    145162
     
    154171            // Plugin need upgrade
    155172            $_SESSION['plugins_need_update'][$plugin_id] = $plugin_info['revision_name'];
     173
     174            if (in_array($fs_plugin['name'], $ignore_list))
     175            {
     176              array_push($new_ignore_list, $fs_plugin['name']);
     177            }
    156178          }
    157179        }
    158180      }
     181
     182      // Update ignore list in database
     183      $query = '
     184UPDATE '.CONFIG_TABLE.'
     185SET value = "'.addslashes(serialize($new_ignore_list)).'"
     186WHERE param = "autoupdate_ignore_list"
     187;';
     188      pwg_query($query);
    159189    }
    160190  }
  • extensions/autoupdate/language/en_UK/plugin.lang.php

    r4699 r4711  
    1717$lang['Click here to check upgrades now'] = 'Click here to check upgrades now';
    1818
     19$lang['Notify on admin homepage'] = 'Notify on admin homepage';
     20$lang['Don\'t notify on admin homepage'] = 'Don\'t notify on admin homepage';
     21
    1922?>
  • extensions/autoupdate/language/es_ES/plugin.lang.php

    r4699 r4711  
    1717/*TODO*/$lang['Click here to check upgrades now'] = 'Click here to check upgrades now';
    1818
     19/*TODO*/$lang['Notify on admin homepage'] = 'Notify on admin homepage';
     20/*TODO*/$lang['Don\'t notify on admin homepage'] = 'Don\'t notify on admin homepage';
     21
    1922?>
  • extensions/autoupdate/language/fr_FR/plugin.lang.php

    r4699 r4711  
    1515$lang['Unable to check upgrades...'] = 'Impossible de vérifier les mises à jour...';
    1616$lang['Click here to check upgrades now'] = 'Cliquez ici pour vérifier les mises à jour maintenant';
     17
     18$lang['Notify on admin homepage'] = 'Notifier sur l\'accueil de l\'administration';
     19$lang['Don\'t notify on admin homepage'] = 'Ne pas notifier sur l\'accueil de l\'administration';
     20
    1721?>
  • extensions/autoupdate/language/hu_HU/plugin.lang.php

    r4699 r4711  
    1717/*TODO*/$lang['Click here to check upgrades now'] = 'Click here to check upgrades now';
    1818
     19/*TODO*/$lang['Notify on admin homepage'] = 'Notify on admin homepage';
     20/*TODO*/$lang['Don\'t notify on admin homepage'] = 'Don\'t notify on admin homepage';
     21
    1922?>
  • extensions/autoupdate/language/it_IT/plugin.lang.php

    r4701 r4711  
    1616$lang['Piwigo will automaticaly try again later.'] = 'Piwigo riproverà automaticamente più tardi.';
    1717$lang['Click here to check upgrades now'] = 'Cliccare qui per verificare gli aggiornameti ora';
     18
     19/*TODO*/$lang['Notify on admin homepage'] = 'Notify on admin homepage';
     20/*TODO*/$lang['Don\'t notify on admin homepage'] = 'Don\'t notify on admin homepage';
     21
    1822?>
  • extensions/autoupdate/language/pl_PL/plugin.lang.php

    r4699 r4711  
    1717/*TODO*/$lang['Click here to check upgrades now'] = 'Click here to check upgrades now';
    1818
     19/*TODO*/$lang['Notify on admin homepage'] = 'Notify on admin homepage';
     20/*TODO*/$lang['Don\'t notify on admin homepage'] = 'Don\'t notify on admin homepage';
     21
    1922?>
  • extensions/autoupdate/main.inc.php

    r4699 r4711  
    2222  }
    2323
     24  if ($page['page'] == 'plugins_update')
     25  {
     26    include(dirname(__FILE__).'/plugins_update.php');
     27  }
     28
    2429  return $plugin_menu_links;
    2530}
  • extensions/autoupdate/remote.php

    r4699 r4711  
    88check_status(ACCESS_ADMINISTRATOR);
    99
    10 load_language('plugin.lang', dirname(__FILE__).'/');
     10if (isset($_POST['autoupdate_ignore'])
     11  and is_array($_POST['autoupdate_ignore'])
     12  and count($_POST['autoupdate_ignore']) == 2)
     13{
     14  $ignore = unserialize($conf['autoupdate_ignore_list']);
     15  $ignore = array_flip($ignore);
    1116
    12 include(dirname(__FILE__).'/class.inc.php');
    13 $autoupdate = new autoupdate();
     17  if ($_POST['autoupdate_ignore'][1] == "false" and isset($ignore[$_POST['autoupdate_ignore'][0]]))
     18  {
     19    unset($ignore[$_POST['autoupdate_ignore'][0]]);
     20    $ignore = array_flip($ignore);
     21  }
     22  elseif ($_POST['autoupdate_ignore'][1] == "true" and !isset($ignore[$_POST['autoupdate_ignore'][0]]))
     23  {
     24    $ignore = array_flip($ignore);
     25    array_push($ignore, $_POST['autoupdate_ignore'][0]);
     26  }
     27  else
     28  {
     29    die;
     30  }
     31  sort($ignore); 
    1432
    15 echo $autoupdate->check_version();
     33  $query = '
     34UPDATE '.CONFIG_TABLE.'
     35SET value = "'.addslashes(serialize($ignore)).'"
     36WHERE param = "autoupdate_ignore_list"
     37;';
     38  pwg_query($query);
     39
     40  echo 'ok';
     41}
     42else
     43{
     44  load_language('plugin.lang', dirname(__FILE__).'/');
     45
     46  include(dirname(__FILE__).'/class.inc.php');
     47  $autoupdate = new autoupdate();
     48
     49  echo $autoupdate->check_version();
     50}
    1651
    1752?>
Note: See TracChangeset for help on using the changeset viewer.