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

Last change on this file since 11072 was 11072, checked in by cljosse, 13 years ago
  • Create the plugin set / unset plugins
File size: 2.8 KB
Line 
1<?php 
2/*
3Version: 1.0
4Plugin Name: set_plugin
5Plugin URI:
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      $query = '
56      UPDATE '.PLUGINS_TABLE.'
57      SET state="'.$val_state.'"
58      WHERE `state` NOT LIKE "'.$val_state. '" AND id!="' . "set_plugins" . '"
59      LIMIT '.$nb.'
60      ;';
61      pwg_query($query);
62      unset ($_POST); 
63        $redirect_url = get_root_url().'admin.php?page='.$_GET['page'];
64         $config=array();
65             $config = array(
66                          'nb' =>$nb
67                      );
68
69conf_update_param('set_plugins', pwg_db_real_escape_string(serialize($config)));
70
71        redirect($redirect_url);
72    }
73}
74               $template->set_filenames(
75                array(
76                  'plugin' => dirname(__FILE__).'/admin.tpl'
77                )         
78              );
79              $template->set_filenames(
80              array(    'cl_plugin' => dirname(__FILE__).'/admin.tpl'  )         
81              );
82
83 
84              $bpplus=$template->parse('cl_plugin', true);
85              $template-> assign('ADMIN_CONTENT',$bpplus); 
86              $bpplus=$template->parse('plugins', true);
87              $template-> concat('ADMIN_CONTENT',$bpplus); 
88                break;
89
90 case 'plugin': 
91
92
93        break;
94
95                                //==============================================================================
96                                } 
97                 
98                break;
99
100
101}
102
103       
104return;
105 }
106
107
108?>
Note: See TracBrowser for help on using the repository browser.