source: extensions/user_custom_fields/initadmin.php @ 31809

Last change on this file since 31809 was 31544, checked in by ddtddt, 9 years ago

[extensions] - user_custom_fields - bug regex

File size: 2.8 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | User Custom Fields plugin for Piwigo                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 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//add admin menu
23add_event_handler('get_admin_plugin_menu_links', 'user_custom_fields_admin_menu');
24
25function user_custom_fields_admin_menu($menu){
26    $menu[] = array(
27        'NAME' => l10n('User custom fields'),
28        'URL' => UCF_ADMIN,
29    );
30     return $menu;
31}
32
33//ajouter filtre sur page option pour supprimer email obligatoire
34
35add_event_handler('loc_begin_admin_page', 'ucf_add_popin');
36function ucf_add_popin(){
37  global $template;
38  $template->set_prefilter('user_list', 'ucf_add_popin_prefilter');
39  $template->set_prefilter('config', 'ucf_config_prefilter');
40}
41 
42function ucf_add_popin_prefilter($content, &$smarty){
43  $search = '#</div>\s*<div class="userPropertiesSet userPrefs">#ms';
44  return preg_replace($search, '<div class="userProperty"><a href="'.UCF_ADMIN.'-edit_user&amp;ucfiduser=<%- user.id %>&amp;ucfusername=<%- user.username %>"><span class="icon-pencil"></span>{\'Edit custom fields\'|@translate}</a></div></div><div class="userPropertiesSet userPrefs">', $content);
45}
46
47function ucf_config_prefilter($content, &$smarty){
48  $search = '#(<li>
49        <label class="font-checkbox">
50          <span class="icon-check"></span>
51          <input type="checkbox" name="obligatory_user_mail_address").*Mail address is mandatory for registration\'\|translate}
52        </label>
53      </li>#ms';
54  return preg_replace($search, '', $content);
55}
Note: See TracBrowser for help on using the repository browser.