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