source: trunk/admin/user_add.php @ 61

Last change on this file since 61 was 57, checked in by z0rglub, 21 years ago

improve the header of each file

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