source: extensions/set_plugins/main.inc.php @ 11074

Last change on this file since 11074 was 11074, checked in by cljosse, 13 years ago
  • add list of last set/unset plugin
File size: 3.4 KB
Line 
1<?php 
2/*
3Version: auto
4Plugin Name: set_plugins
5Plugin URI: http://piwigo.org/ext/extension_view.php?eid=550
6Author: cljosse
7Description: Active/déactive tous les plugins installés.
8*/
9
10// Chech whether we are indeed included by Piwigo.
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
13// Define the path to our plugin.
14define('SET_PLUGINS_PATH', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
15load_language('plugin.lang', SET_PLUGINS_PATH);
16// Hook on to an event to show the administration page.
17add_event_handler('get_admin_plugin_menu_links', 'set_plugins_admin_menu');
18
19// Add an entry to the 'Plugins' menu.
20function set_plugins_admin_menu($menu) {
21  array_push(
22    $menu,
23    array(
24      'NAME'  => 'Set_plugins',
25      'URL'   => get_admin_plugin_menu_link(dirname(__FILE__)).'/admin.php'
26    )
27  );
28  return $menu;
29}
30
31add_event_handler('loc_after_page_header','set_plugins_add'); 
32function set_plugins_add() {
33  global $user, $template, $val,$page;
34  if (!isset($page['body_id'])) return;
35
36  switch($page['body_id']){
37          case  'theAdminPage': 
38   
39      switch($page['page']){
40                    case 'plugins_list':               
41
42include_once(SET_PLUGINS_PATH."include/constants.php");           
43include_once(SET_PLUGINS_PATH.'include/affiche.php');
44
45$val_state="";
46
47if(  isset($_POST['unset_plugins']) || isset($_POST['set_plugins'])  ){
48 if(isset($_POST['unset_plugins'])  ) 
49                    $val_state='inactive';
50      elseif(isset($_POST['set_plugins'])  ) 
51        $val_state='active';
52      $nb=isset($_POST['nb'])?$_POST['nb']:$nb ;
53   
54    if($val_state!=""){ 
55   
56      $query = 'SELECT *
57                FROM ' . PLUGINS_TABLE . '
58           WHERE `state` NOT LIKE "'.$val_state. '" AND id!="' . "set_plugins" . '"
59           LIMIT '.$nb.'
60      ';
61          $result = pwg_query($query);
62             
63      $query = '
64      UPDATE '.PLUGINS_TABLE.'
65      SET state="'.$val_state.'"
66      WHERE `state` NOT LIKE "'.$val_state. '" AND id!="' . "set_plugins" . '"
67      LIMIT '.$nb.'
68      ;';
69
70       pwg_query($query);
71
72    $data = array();
73    if($result)
74    while ($row = pwg_db_fetch_assoc($result))
75    {
76      $url =  $row['id'] ;$vers= $row['version'];
77      array_push($data, array('plugin' => $url,'version'=>$vers) );
78    }
79
80      unset ($_POST); 
81        $redirect_url = get_root_url().'admin.php?page='.$_GET['page'];
82         $config=array();
83             $config = array(
84                          'state' => $val_state,
85                          'list'=>$data,
86                          'nb' =>$nb
87                      );
88
89conf_update_param('set_plugins', pwg_db_real_escape_string(serialize($config)));
90
91        redirect($redirect_url);
92    }
93}
94               $template->set_filenames(
95                array(
96                  'plugin' => dirname(__FILE__).'/admin.tpl'
97                )         
98              );
99              $template->set_filenames(
100              array(    'cl_plugin' => dirname(__FILE__).'/admin.tpl'  )         
101              );
102
103 
104              $bpplus=$template->parse('cl_plugin', true);
105              $template-> assign('ADMIN_CONTENT',$bpplus); 
106              $bpplus=$template->parse('plugins', true);
107              $template-> concat('ADMIN_CONTENT',$bpplus); 
108                break;
109
110 case 'plugin': 
111
112
113        break;
114
115                                //==============================================================================
116                                } 
117                 
118                break;
119
120
121}
122
123       
124return;
125 }
126
127
128?>
Note: See TracBrowser for help on using the repository browser.