source: extensions/dynareceperio/profile.inc.php @ 9227

Last change on this file since 9227 was 8425, checked in by rub, 14 years ago

Happy new year!

Change header of maintained extensions

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 2.9 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Dynamic Recent Period - a Piwigo Plugin                               |
4// | Copyright (C) 2007-2011 Ruben ARNAUD - rub@piwigo.org                 |
5// +-----------------------------------------------------------------------+
6// | This program is free software; you can redistribute it and/or modify  |
7// | it under the terms of the GNU General Public License as published by  |
8// | the Free Software Foundation                                          |
9// |                                                                       |
10// | This program is distributed in the hope that it will be useful, but   |
11// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
12// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
13// | General Public License for more details.                              |
14// |                                                                       |
15// | You should have received a copy of the GNU General Public License     |
16// | along with this program; if not, write to the Free Software           |
17// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
18// | USA.                                                                  |
19// +-----------------------------------------------------------------------+
20
21if (!defined('PHPWG_ROOT_PATH'))
22{
23  die('Hacking attempt!');
24}
25
26add_event_handler('init', 'dynareceperio_user_init_post');
27add_event_handler('loc_begin_page_tail', 'dynareceperio_remove_recent_period');
28
29function dynareceperio_is_profile_udpate()
30{
31  global $conf, $page, $edit_user;
32
33  return
34      (
35        (script_basename() == 'profile')
36        or
37        (
38          (script_basename() == 'admin') and
39          (!isset($page['page']) or in_array($page['page'], array('profile', 'configuration', 'user_list')))
40        )
41      ) 
42    and
43      $conf['dynareceperio']['force']
44    and 
45      !(isset($edit_user) and ($edit_user['id'] == $conf['default_user_id']));
46}
47
48function dynareceperio_user_init_post()
49{
50  if (dynareceperio_is_profile_udpate())
51  {
52    if (isset($_POST['validate']) or isset($_POST['pref_submit']))
53    {
54      if (empty($_POST['recent_period']))
55      {
56        $_POST['recent_period'] = get_default_user_value('recent_period', 7);
57      }
58      if (empty($_POST['recent_period_action']))
59      {
60        $_POST['recent_period_action'] = 'leave';
61      }
62    }
63  }
64}
65
66function dynareceperio_remove_recent_period()
67{
68  global $page, $template;
69
70  if (dynareceperio_is_profile_udpate())
71  {
72    $js = '
73<script type="text/javascript">
74var FindNode = document.getElementsByName("recent_period")[0].parentNode';
75    if (isset($page['page']) and ($page['page'] == 'user_list'))
76    {
77      $js.= '.parentNode';
78    }
79    $js.= ';
80FindNode.parentNode.removeChild(FindNode);
81</script>
82';
83    $template->append('footer_elements', $js);
84  }
85}
86
87?>
Note: See TracBrowser for help on using the repository browser.