[11072] | 1 | <?php |
---|
| 2 | /* |
---|
[11074] | 3 | Version: auto |
---|
[11073] | 4 | Plugin Name: set_plugins |
---|
| 5 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=550 |
---|
[11072] | 6 | Author: cljosse |
---|
| 7 | Description: Active/déactive tous les plugins installés. |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | // Chech whether we are indeed included by Piwigo. |
---|
| 11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 12 | |
---|
| 13 | // Define the path to our plugin. |
---|
| 14 | define('SET_PLUGINS_PATH', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
| 15 | load_language('plugin.lang', SET_PLUGINS_PATH); |
---|
| 16 | // Hook on to an event to show the administration page. |
---|
| 17 | add_event_handler('get_admin_plugin_menu_links', 'set_plugins_admin_menu'); |
---|
| 18 | |
---|
| 19 | // Add an entry to the 'Plugins' menu. |
---|
| 20 | function 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 | |
---|
| 31 | add_event_handler('loc_after_page_header','set_plugins_add'); |
---|
| 32 | function 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 | |
---|
| 42 | include_once(SET_PLUGINS_PATH."include/constants.php"); |
---|
| 43 | include_once(SET_PLUGINS_PATH.'include/affiche.php'); |
---|
| 44 | |
---|
| 45 | $val_state=""; |
---|
| 46 | |
---|
| 47 | if( 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 | |
---|
[11074] | 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 | |
---|
[11072] | 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 | ;'; |
---|
[11074] | 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 | |
---|
[11072] | 80 | unset ($_POST); |
---|
| 81 | $redirect_url = get_root_url().'admin.php?page='.$_GET['page']; |
---|
| 82 | $config=array(); |
---|
| 83 | $config = array( |
---|
[11074] | 84 | 'state' => $val_state, |
---|
| 85 | 'list'=>$data, |
---|
[11072] | 86 | 'nb' =>$nb |
---|
| 87 | ); |
---|
| 88 | |
---|
| 89 | conf_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 | |
---|
| 124 | return; |
---|
| 125 | } |
---|
| 126 | |
---|
| 127 | |
---|
| 128 | ?> |
---|