source: trunk/admin/user_add.php @ 29

Last change on this file since 29 was 10, checked in by z0rglub, 21 years ago

* empty log message *

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1<?php
2/***************************************************************************
3 *                               user_add.php                              *
4 *                            -------------------                          *
5 *   application          : PhpWebGallery 1.3                              *
6 *   author               : Pierrick LE GALL <pierrick@z0rglub.com>        *
7 *                                                                         *
8 ***************************************************************************/
9
10/***************************************************************************
11 *                                                                         *
12 *   This program is free software; you can redistribute it and/or modify  *
13 *   it under the terms of the GNU General Public License as published by  *
14 *   the Free Software Foundation;                                         *
15 *                                                                         *
16 ***************************************************************************/
17include_once( './include/isadmin.inc.php' );
18//----------------------------------------------------- template initialization
19$sub = $vtp->Open( '../template/'.$user['template'].'/admin/user_add.vtp' );
20$tpl = array( 'adduser_info_message', 'adduser_info_back',
21              'adduser_fill_form', 'login', 'password', 'mail_address',
22              'adduser_status', 'submit' );
23templatize_array( $tpl, 'lang', $sub );
24//--------------------------------------------------------- form criteria check
25$error = array();
26if ( isset( $_POST['submit'] ) )
27{
28  $error = register_user(
29    $_POST['username'], $_POST['password'], $_POST['password'],
30    $_POST['mail_address'], $_POST['status'] );
31}
32//-------------------------------------------------------------- errors display
33if ( sizeof( $error ) != 0 )
34{
35  $vtp->addSession( $sub, 'errors' );
36  for ( $i = 0; $i < sizeof( $error ); $i++ )
37  {
38    $vtp->addSession( $sub, 'li' );
39    $vtp->setVar( $sub, 'li.li', $error[$i] );
40    $vtp->closeSession( $sub, 'li' );
41  }
42  $vtp->closeSession( $sub, 'errors' );
43}
44//---------------------------------------------------------------- confirmation
45if ( sizeof( $error ) == 0 and isset( $_POST['submit'] ) )
46{
47  $vtp->addSession( $sub, 'confirmation' );
48  $vtp->setVar( $sub, 'confirmation.username', $_POST['username'] );
49  $url = add_session_id( './admin.php?page=user_list' );
50  $vtp->setVar( $sub, 'confirmation.url', $url );
51  $vtp->closeSession( $sub, 'confirmation' );
52  // reset all values
53  unset( $_POST );
54}
55//------------------------------------------------------------------------ form
56$action = add_session_id( './admin.php?page=user_add' );
57$vtp->setVar( $sub, 'form_action', $action );
58$vtp->setVar( $sub, 'user:username',     $_POST['username'] );
59$vtp->setVar( $sub, 'user:password',     $_POST['password'] );
60$vtp->setVar( $sub, 'user:mail_address', $_POST['mail_address'] );
61
62if ( !isset( $_POST['status'] ) )
63{
64  $_POST['status'] = 'guest';
65}
66$option = get_enums( PREFIX_TABLE.'users', 'status' );
67for ( $i = 0; $i < sizeof( $option ); $i++ )
68{
69  $vtp->addSession( $sub, 'status_option' );
70  $vtp->setVar( $sub, 'status_option.value', $option[$i] );
71  $vtp->setVar( $sub, 'status_option.option',
72                $lang['adduser_status_'.$option[$i]] );
73  if( $option[$i] == $_POST['status'] )
74  {
75    $vtp->setVar( $sub, 'status_option.selected', ' selected="selected"' );
76  }
77  $vtp->closeSession( $sub, 'status_option' );
78}
79//----------------------------------------------------------- sending html code
80$vtp->Parse( $handle , 'sub', $sub );
81?>
Note: See TracBrowser for help on using the repository browser.