source: extensions/reset_level/initadmin.php @ 32607

Last change on this file since 32607 was 32410, checked in by ddtddt, 4 years ago

[reset_level] piwigo 11

File size: 2.9 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | reset level plugin for piwigo by TEMMII                               |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2011-2021 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="{\'Discount level of confidentiality for all photos in the gallery: for all\'|@translate}" onclick="return confirm(\'{\'Are you sure?\'|@translate|@escape:javascript}\');"><span class="icon-arrows-cw"></span>{\'Reset levels of privacy\'|@translate}</a></li>
49    </ul>';
50  return preg_replace($search, $replacement, $content);
51}
52
53function plugrlaction(){
54  if (isset($_GET['resetlevel'])){
55        if (is_webmaster()){
56          $query = 'UPDATE ' . IMAGES_TABLE . ' SET level= \'0\';';
57          $result = pwg_query($query);
58          invalidate_user_cache();
59          $_SESSION['page_infos'] = array(l10n('All Photos now have a level of confidentiality "for all "'));
60        }else{
61          $_SESSION['page_errors'] = array(l10n('Only webmaster can be reset privacy level'));
62        }
63        redirect(get_root_url().'admin.php?page=maintenance'); 
64  }
65}
Note: See TracBrowser for help on using the repository browser.