brute-force changed access to $_GET['key'] to use get_array instead
[plewww.git] / planetlab / persons / update.php
1 <?
2
3 // Require login
4 require_once 'plc_login.php';
5
6 // Get session and API handles
7 require_once 'plc_session.php';
8 global $plc, $api;
9
10 // Common functions
11 require_once 'plc_functions.php';
12
13 // find person roles
14 $_person= $plc->person;
15 $_roles= $_person['role_ids'];
16
17
18 $is_submitted= isset($_POST['submitted']) ? $_POST['submitted'] : 0;
19
20 // show details for the current user.
21 if( get_array($_GET, 'id') && is_numeric($_GET['id']) ) {
22   $person_id= intval($_GET['id']);
23  } else {
24   plc_redirect (l_sites());
25  }
26
27 $errors= array();
28
29 if( $is_submitted ) {
30  } else {
31   // get details for the user
32   $person_details= $api->GetPersons( array( intval( $person_id ) ), array( "person_id", "first_name", "last_name", "title", "email", "phone", "url", "bio" ) );
33   if ( $person_details === NULL ) {
34     $errors[] = $api->error();
35   } else {
36     $person_detail= $person_details[0];
37   
38     $first_name= $person_detail['first_name'];
39     $last_name= $person_detail['last_name'];
40     $title= $person_detail['title'];
41     $email= $person_detail['email'];
42     $phone= $person_detail['phone'];
43     $url= $person_detail['url'];
44     $bio= $person_detail['bio'];
45   }
46 }
47
48 // Print header
49 require_once 'plc_drupal.php';
50 drupal_set_title('Update Person');
51 include 'plc_header.php';
52
53 ?>
54
55 <h2>Update Account</h2>
56
57 <?
58 if( count($errors) > 0 )
59 {
60   print( "<p><span class='bold'>The following errors occured:</span>" );
61   print( "<font color='red' size='-1'><ul>\n" );
62   foreach( $errors as $err )
63     {
64       print( "<li>$err\n" );
65     }
66   print( "</ul></font>\n" );
67 }
68 ?>
69
70 <h3>Personal Information</h3>
71
72 <form method="post" action="update.php?id=<?php print($person_id); ?>">
73 <input type="hidden" name="submitted" value="1">
74
75 <table width="100%" cellspacing="0" cellpadding="4" border="0">
76
77 <tr>
78 <td>First Name:</td>
79 <td><input type="text" name="first_name"
80 value="<?php print($first_name); ?>" size="30" maxlength="256"></td>
81 </tr>
82
83 <tr>
84 <td>Last Name:</td>
85 <td><input type="text" name="last_name"
86 value="<?php print($last_name); ?>" size="30" maxlength="256"></td>
87 </tr>
88
89 <tr>
90 <td>Title:</td>
91 <td><input type="text" name="title"
92 value="<?php print($title); ?>" size="30" maxlength="256"></td>
93 </tr>
94
95 <tr>
96 <td>Email:</td>
97 <td><input type="text" name="email"
98 value="<?php print($email); ?>" size="30" maxlength="256"></td>
99 </tr>
100
101 <tr>
102 <td>Phone:</td>
103 <td><input type="text" name="phone"
104 value="<?php print($phone); ?>" size="30" maxlength="32"></td>
105 </tr>
106
107 <tr>
108 <td>URL:</td>
109 <td><input type="text" name="url"
110 value="<?php print($url); ?>" size="30" maxlength="200"></td>
111 </tr>
112
113 <tr>
114 <td valign=top>Bio:</td>
115 <td><textarea name="bio" cols="40" rows="5" wrap>
116 <?php print($bio); ?>
117 </textarea></td>
118 </tr>
119
120 <tr>
121 <td>Password (blank for no change):</td>
122 <td><input type="password" name="password1" size="30" maxlength="256"></td>
123 </tr>
124
125 <tr>
126 <td>Repeat Password:</td>
127 <td><input type="password" name="password2" size="30" maxlength="256"></td>
128 </tr>
129
130 </table>
131
132 <input type="submit" name="Submit" value="Update">
133
134 </form>
135
136 <?
137
138 // Print footer
139 include 'plc_footer.php';
140
141 ?>