source: extensions/reset_level/initadmin.php @ 32293

Last change on this file since 32293 was 31521, checked in by ddtddt, 9 years ago

[extensions] - reset_level - 2.8 - add action on maintenance page

File size: 2.7 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | reset level plugin for piwigo                                         |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2011-2016 ddtddt               http://temmii.com/piwigo/ |
6// +-----------------------------------------------------------------------+
7// | This program is free software; you can redistribute it and/or modify  |
8// | it under the terms of the GNU General Public License as published by  |
9// | the Free Software Foundation                                          |
10// |                                                                       |
11// | This program is distributed in the hope that it will be useful, but   |
12// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
13// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
14// | General Public License for more details.                              |
15// |                                                                       |
16// | You should have received a copy of the GNU General Public License     |
17// | along with this program; if not, write to the Free Software           |
18// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
19// | USA.                                                                  |
20// +-----------------------------------------------------------------------+
21
22
23add_event_handler('loading_lang', 'reset_level_loading_lang');   
24function reset_level_loading_lang(){
25  load_language('plugin.lang', DELLE_PATH);
26}
27
28add_event_handler('loc_begin_admin', 'plugrlPf');
29add_event_handler('loc_begin_admin_page', 'plugrlaction');
30
31function plugrlPf(){
32  global $template;
33  $admin_base_url = $_SERVER['REQUEST_URI'];
34  $template->set_prefilter('maintenance', 'plugrlPT');
35  $template->assign(
36    array(
37                'U_RESETLEVEL' => $admin_base_url . '&amp;resetlevel&amp;pwg_token='.get_pwg_token(),
38  ));
39}
40
41function plugrlPT($content, &$smarty){
42  $search = '#  </li>
43</ul>#';
44  $replacement = '
45        </li>
46</ul>
47    <ul>
48          <li><a href="{$U_RESETLEVEL}" title="{\'delle_all\'|@translate}" onclick="return confirm(\'{\'Are you sure?\'|@translate|@escape:javascript}\');"><span class="icon-arrows-cw"></span>{\'delle_purgeall\'|@translate}</a></li>
49    </ul>';
50  return preg_replace($search, $replacement, $content);
51}
52
53function plugrlaction(){
54  if (isset($_GET['resetlevel'])){
55  //$admin_base_url=explode('&resetlevel', $_SERVER['REQUEST_URI']);
56  $query = 'UPDATE ' . IMAGES_TABLE . ' SET level= \'0\';';
57  $result = pwg_query($query);
58  invalidate_user_cache();
59  $_SESSION['page_infos'] = array(l10n('delle_totalok'));
60  redirect(get_root_url().'admin.php?page=maintenance');
61  } 
62}
Note: See TracBrowser for help on using the repository browser.