source: trunk/admin.php @ 815

Last change on this file since 815 was 815, checked in by plg, 19 years ago
  • modification : admin/group_list screen completely rewrite to present the list of existing groups and a form to add a new group. Here you can delete a group, go to permissions management for a group, go to member list of a group (on admin/user_list with a filter on group).
  • modification : admin/user_perm and admin/group_perm are not directly reachable by the admin menu anymore. Only the user/group list lets you reach user/group permissions management screen.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.2 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
5// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $RCSfile$
9// | last update   : $Date: 2005-08-16 15:19:40 +0000 (Tue, 16 Aug 2005) $
10// | last modifier : $Author: plg $
11// | revision      : $Revision: 815 $
12// +-----------------------------------------------------------------------+
13// | This program is free software; you can redistribute it and/or modify  |
14// | it under the terms of the GNU General Public License as published by  |
15// | the Free Software Foundation                                          |
16// |                                                                       |
17// | This program is distributed in the hope that it will be useful, but   |
18// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
19// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
20// | General Public License for more details.                              |
21// |                                                                       |
22// | You should have received a copy of the GNU General Public License     |
23// | along with this program; if not, write to the Free Software           |
24// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
25// | USA.                                                                  |
26// +-----------------------------------------------------------------------+
27
28//----------------------------------------------------------- include
29define('PHPWG_ROOT_PATH','./');
30define('IN_ADMIN', true);
31include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
32include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' );
33
34// +-----------------------------------------------------------------------+
35// |                    synchronize user informations                      |
36// +-----------------------------------------------------------------------+
37
38sync_users();
39
40//--------------------------------------- validating page and creation of title
41$page_valide = false;
42$title = '';
43$username='';
44if (isset($_POST['username']))
45{
46  $username = $_POST['username'];
47}
48else if (isset($_POST['userid']))
49{
50  $username = get_username($_POST['userid']);
51}
52else if (isset($_GET['user_id']))
53{
54  $username = get_username($_GET['user_id']);
55}
56
57$_GET['page'] = isset($_GET['page']) ? $_GET['page'] : 'intro';
58
59switch ( $_GET['page'] )
60{
61  case 'user_list' :
62  {
63    $title = $lang['title_liste_users'];
64    $page_valide = true;
65    break;
66  }
67  case 'profile' :
68  {
69    $title = $lang['title_user_modify'];
70    $page_valide = true; 
71    break;
72  }
73 case 'user_perm':
74   $title = $lang['title_user_perm'].' '.$username;
75   $page_valide = true; break;
76 case 'group_list' :
77   $title = $lang['title_groups'];        $page_valide = true; break;
78 case 'group_perm' :
79   if (!is_numeric($_GET['group_id']))
80   {
81     $_GET['group_id'] = -1;
82   }
83   $query = '
84SELECT name
85  FROM '.GROUPS_TABLE.'
86  WHERE id = '.$_GET['group_id'].'
87;';
88   $result = pwg_query($query);
89   if (mysql_num_rows($result) > 0 )
90   {
91     $row = mysql_fetch_array($result);
92     $title = $lang['title_group_perm'].' "'.$row['name'].'"';
93     $page_valide = true;
94   }
95   else
96   {
97     $page_valide = false;
98   }
99   break;
100 case 'stats':
101   $title = $lang['title_history'];       $page_valide = true; break;
102 case 'update':
103   $title = $lang['title_update'];        $page_valide = true; break;
104 case 'configuration':
105   $title = $lang['title_configuration']; $page_valide = true; break;
106 case 'help':
107   $title = $lang['title_instructions'];  $page_valide = true; break;
108 case 'cat_perm':
109   $title = $lang['title_cat_perm'];
110   if ( isset( $_GET['cat'] ) )
111   {
112     check_cat_id( $_GET['cat'] );
113     if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
114     {
115       $result = get_cat_info( $page['cat'] );
116       $name = get_cat_display_name($result['name'], '');
117       $title.= ' "'.$name.'"';
118     }
119   }
120   $page_valide = true;
121   break;
122 case 'cat_list':
123   $title = $lang['title_categories'];    $page_valide = true; break;
124 case 'cat_modify':
125   $title = $lang['title_edit_cat'];      $page_valide = true; break;
126 case 'infos_images':
127   $title = $lang['title_info_images'];   $page_valide = true; break;
128 case 'waiting':
129   $title = $lang['title_waiting'];       $page_valide = true; break;
130 case 'thumbnail':
131   $title = $lang['title_thumbnails'];
132   if ( isset( $_GET['dir'] ) )
133   {
134     $title.= ' '.$lang['title_thumbnails_2'].' <span class="titreImg">';
135     // $_GET['dir'] contains :
136     // ./galleries/vieux_lyon ou
137     // ./galleries/vieux_lyon/visite ou
138     // ./galleries/vieux_lyon/visite/truc ...
139     $dir = explode( "/", $_GET['dir'] );
140     $title.= $dir[2];
141     for ( $i = 2; $i < sizeof( $dir ) - 1; $i++ )
142     {
143       $title.= ' &gt; '.$dir[$i+1];
144     }
145     $title.= "</span>";
146   }
147   $page_valide = true;
148   break;
149 case 'comments' :
150   $title = $lang['title_comments'];
151   $page_valide = true;
152   break;
153 case 'picture_modify' :
154   $title = $lang['title_picmod'];
155   $page_valide = true;
156   break;
157 case 'remote_site' :
158 {
159   $title = $lang['remote_sites'];
160   $page_valide = true;
161   break;
162 }
163 case 'cat_options' :
164 {
165   $title = $lang['title_cat_options'];
166   $page_valide = true;
167   break;
168 }
169 case 'element_set' :
170 {
171   $title = 'batch management';
172   $page_valide = true;
173   break;
174 }
175 case 'maintenance' :
176 {
177   $title = l10n('Maintenance');
178   $page_valide = true;
179   break;
180 }
181 case 'representative' :
182 {
183   $title = l10n('Representative');
184   $page_valide = true;
185   break;
186 }
187//  case 'element_set_unit' :
188//  {
189//    $title = 'batch management';
190//    $page_valide = true;
191//    break;
192//  }
193 case 'intro' :
194 {
195   $_GET['page'] = 'intro';
196   $title = $lang['title_default'];
197   $page_valide = true;
198   break;
199 }
200 default :
201 {
202   break;
203 }
204}
205if ( $title == '' ) $title = $lang['title_default'];
206
207// waiting
208$query = 'SELECT id FROM '.WAITING_TABLE;
209$query.= " WHERE validated='false'";
210$query.= ';';
211$result = pwg_query( $query );
212$nb_waiting = '';
213if ( mysql_num_rows( $result ) > 0 )
214{
215  $nb_waiting =  ' [ '.mysql_num_rows( $result ).' ]';
216}
217// comments
218$query = 'SELECT id FROM '.COMMENTS_TABLE;
219$query.= " WHERE validated='false'";
220$query.= ';';
221$result = pwg_query( $query );
222$nb_comments = '';
223if ( mysql_num_rows( $result ) > 0 )
224{
225  $nb_comments =  ' [ '.mysql_num_rows( $result ).' ]';
226}
227
228$link_start = PHPWG_ROOT_PATH.'admin.php?page=';
229$conf_link = $link_start.'configuration&amp;section=';
230$opt_link = $link_start.'cat_options&amp;section=';
231//----------------------------------------------------- template initialization
232include(PHPWG_ROOT_PATH.'include/page_header.php');
233$template->set_filenames( array('admin'=>'admin.tpl') );
234
235$template->assign_vars(array(
236  'L_TITLE'=>$lang['admin_panel'],
237  'L_LINKS'=>$lang['links'],
238  'L_GALLERY_INDEX'=>$lang['home'],
239  'L_GENERAL'=>$lang['general'],
240  'L_DEFAULT'=>$lang['gallery_default'],
241  'L_HISTORY'=>$lang['history'],
242  'L_FAQ'=>$lang['instructions'],
243  'L_CONFIGURATION'=>$lang['config'],
244  'L_CONFIG_GENERAL'=>$lang['general'],
245  'L_CONFIG_COMMENTS'=>$lang['comments'],
246  'L_CONFIG_DISPLAY'=>$lang['conf_default'],
247  'L_CONFIG_UPLOAD'=>$lang['upload'],
248  'L_CONFIG_SESSION'=>$lang['conf_cookie'],
249  'L_CONFIG_METADATA'=>$lang['metadata'],
250  'L_SITES'=>$lang['remote_sites'],
251  'L_CATEGORIES'=>$lang['categories'],
252  'L_MANAGE'=>$lang['manage'],
253  'L_IMAGES'=>$lang['pictures'],
254  'L_WAITING'=>$lang['waiting'].$nb_waiting,
255  'L_COMMENTS'=>$lang['comments'].$nb_comments,
256  'L_THUMBNAILS'=>$lang['thumbnails'],
257  'L_IDENTIFY'=>$lang['identification'],
258  'L_USERS'=>$lang['users'],
259  'L_GROUPS'=>$lang['groups'],
260  'L_UPDATE'=>$lang['update'],
261  'L_CAT_UPLOAD'=>$lang['upload'],
262  'L_CAT_COMMENTS'=>$lang['comments'],
263  'L_CAT_VISIBLE'=>$lang['lock'],
264  'L_CAT_STATUS'=>$lang['cat_security'],
265
266  'U_HISTORY'=>add_session_id($link_start.'stats' ),
267  'U_FAQ'=>add_session_id($link_start.'help' ),
268  'U_SITES'=>add_session_id($link_start.'remote_site'),
269  'U_MAINTENANCE'=>add_session_id($link_start.'maintenance'),
270  'U_CONFIG_GENERAL'=>add_session_id($conf_link.'general' ),
271  'U_CONFIG_COMMENTS'=>add_session_id($conf_link.'comments' ),
272  'U_CONFIG_DISPLAY'=>add_session_id($conf_link.'default' ),
273  'U_CONFIG_UPLOAD'=>add_session_id($conf_link.'upload' ),
274  'U_CONFIG_SESSION'=>add_session_id($conf_link.'session' ),
275  'U_CONFIG_METADATA'=>add_session_id($conf_link.'metadata' ),
276  'U_CATEGORIES'=>add_session_id($link_start.'cat_list' ),
277  'U_CAT_UPLOAD'=>add_session_id($opt_link.'upload'),
278  'U_CAT_COMMENTS'=>add_session_id($opt_link.'comments'),
279  'U_CAT_VISIBLE'=>add_session_id($opt_link.'visible'),
280  'U_CAT_STATUS'=>add_session_id($opt_link.'status'),
281  'U_CAT_OPTIONS'=>add_session_id($link_start.'cat_options'),
282  'U_CAT_UPDATE'=>add_session_id($link_start.'update'),
283  'U_WAITING'=>add_session_id($link_start.'waiting' ),
284  'U_COMMENTS'=>add_session_id($link_start.'comments' ),
285  'U_CADDIE'=>add_session_id($link_start.'element_set&amp;cat=caddie'),
286  'U_THUMBNAILS'=>add_session_id($link_start.'thumbnail' ),
287  'U_USERS'=>add_session_id($link_start.'user_list' ),
288  'U_GROUPS'=>add_session_id($link_start.'group_list' ),
289  'U_RETURN'=>add_session_id(PHPWG_ROOT_PATH.'category.php')
290  ));
291
292if ($conf['allow_random_representative'])
293{
294  $template->assign_block_vars(
295    'representative',
296    array(
297      'URL' => add_session_id($opt_link.'representative')
298      )
299    );
300}
301 
302//--------------------------------------------------------------------- summary
303$link_start = PHPWG_ROOT_PATH.'admin.php?page=';
304//------------------------------------------------------------- content display
305$page['errors'] = array();
306$page['infos'] = array();
307
308if ($page_valide)
309{
310  switch ($_GET['page'])
311  {
312    case 'comments' :
313    {
314      include(PHPWG_ROOT_PATH.'comments.php');
315      break;
316    }
317    case 'profile' :
318    {
319      include(PHPWG_ROOT_PATH.'profile.php');
320      break;
321    }
322    default :
323    {
324      include(PHPWG_ROOT_PATH.'admin/'.$_GET['page'].'.php');
325    }
326  }
327}
328else
329{
330  $template->assign_vars(
331    array(
332      'ADMIN_CONTENT'
333      =>'<div style="text-align:center">'.$lang['default_message'].'</div>'
334      )
335    );
336}
337// +-----------------------------------------------------------------------+
338// |                            errors & infos                             |
339// +-----------------------------------------------------------------------+
340if (count($page['errors']) != 0)
341{
342  $template->assign_block_vars('errors',array());
343  foreach ($page['errors'] as $error)
344  {
345    $template->assign_block_vars('errors.error',array('ERROR'=>$error));
346  }
347}
348if (count($page['infos']) != 0)
349{
350  $template->assign_block_vars('infos',array());
351  foreach ($page['infos'] as $info)
352  {
353    $template->assign_block_vars('infos.info',array('INFO'=>$info));
354  }
355}
356
357$template->parse('admin');
358include(PHPWG_ROOT_PATH.'include/page_tail.php');
359// +-----------------------------------------------------------------------+
360// |                     order permission refreshment                      |
361// +-----------------------------------------------------------------------+
362$query = '
363UPDATE '.USER_CACHE_TABLE.'
364  SET need_update = \'true\'
365;';
366pwg_query($query);
367?>
Note: See TracBrowser for help on using the repository browser.