Updated user/add to prompt for first name, last name, callsign and locator

pull/106/merge
Andy Smith 2011-09-26 20:45:07 +01:00
rodzic 19774bf670
commit 5d2e890da0
4 zmienionych plików z 72 dodań i 27 usunięć

Wyświetl plik

@ -25,6 +25,10 @@ class User extends CI_Controller {
$this->form_validation->set_rules('user_email', 'E-mail', 'required');
$this->form_validation->set_rules('user_password', 'Password', 'required');
$this->form_validation->set_rules('user_type', 'Type', 'required');
$this->form_validation->set_rules('user_firstname', 'First name', 'required');
$this->form_validation->set_rules('user_lastname', 'Last name', 'required');
$this->form_validation->set_rules('user_callsign', 'Callsign', 'required');
$this->form_validation->set_rules('user_locator', 'Locator', 'required');
if ($this->form_validation->run() == FALSE)
{
@ -35,6 +39,10 @@ class User extends CI_Controller {
$data['user_email'] = $this->input->post('user_email');
$data['user_password'] = $this->input->post('user_password');
$data['user_type'] = $this->input->post('user_type');
$data['user_firstname'] = $this->input->post('user_firstname');
$data['user_lastname'] = $this->input->post('user_lastname');
$data['user_callsign'] = $this->input->post('user_callsign');
$data['user_locator'] = $this->input->post('user_locator');
$this->load->view('user/add', $data);
} else {
$this->load->view('user/add');
@ -43,7 +51,7 @@ class User extends CI_Controller {
}
else
{
switch($this->user_model->add($this->input->post('user_name'), $this->input->post('user_password'), $this->input->post('user_email'), $this->input->post('user_type'))) {
switch($this->user_model->add($this->input->post('user_name'), $this->input->post('user_password'), $this->input->post('user_email'), $this->input->post('user_type'), $this->input->post('user_firstname'), $this->input->post('user_lastname'), $this->input->post('user_callsign'), $this->input->post('user_locator'))) {
// Check for errors
case EUSERNAMEEXISTS:
$data['username_error'] = 'Username <b>'.$this->input->post('user_name').'</b> already in use!';
@ -65,6 +73,10 @@ class User extends CI_Controller {
$data['user_email'] = $this->input->post('user_email');
$data['user_password'] = $this->input->post('user_password');
$data['user_type'] = $this->input->post('user_type');
$data['user_firstname'] = $this->input->post('user_firstname');
$data['user_lastname'] = $this->input->post('user_lastname');
$data['user_callsign'] = $this->input->post('user_callsign');
$data['user_locator'] = $this->input->post('user_locator');
$this->load->view('user/add', $data);
$this->load->view('layout/footer');
}

Wyświetl plik

@ -74,14 +74,18 @@ class User_Model extends CI_Model {
// FUNCTION: bool add($username, $password, $email, $type)
// Add a user
function add($username, $password, $email, $type) {
function add($username, $password, $email, $type, $firstname, $lastname, $callsign, $locator) {
// Check that the user isn't already used
if(!$this->exists($username)) {
$data = array(
'user_name' => $username,
'user_password' => $this->_hash($password),
'user_email' => $email,
'user_type' => $type
'user_type' => $type,
'user_firstname' => $firstname,
'user_lastname' => $lastname,
'user_callsign' => $callsign,
'user_locator' => $locator
);
// Check the password is valid

Wyświetl plik

@ -17,6 +17,20 @@
</td>
</tr>
<tr>
<td>Level</td>
<td><select name="user_type">
<?php
$levels = $this->config->item('auth_level');
while (list($key, $val) = each($levels)) {
?>
<option value="<?php echo $key; ?>" <?php if(isset($user_type)) { if($user_type == $key) { echo "selected=\"selected\""; } } ?>><?php echo $val; ?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td>E-mail</td>
<td><input type="text" name="user_email" value="<?php if(isset($user_email)) { echo $user_email; } ?>" />
@ -32,18 +46,33 @@
</tr>
<tr>
<td>Type</td>
<td><select name="user_type">
<?php
$levels = $this->config->item('auth_level');
while (list($key, $val) = each($levels)) {
?>
<option value="<?php echo $key; ?>" <?php if(isset($user_type)) { if($user_type == $key) { echo "selected=\"selected\""; } } ?>><?php echo $val; ?></option>
<?php } ?>
</select>
<td>First name</td>
<td><input type="text" name="user_firstname" value="<?php if(isset($user_firstname)) { echo $user_firstname; } ?>" />
<?php if(isset($firstname_error)) { echo "<div class=\"small error\">".$firstname_error."</div>"; } ?>
</td>
</tr>
<tr>
<td>Last name</td>
<td><input type="text" name="user_lastname" value="<?php if(isset($user_lastname)) { echo $user_lastname; } ?>" />
<?php if(isset($lastname_error)) { echo "<div class=\"small error\">".$lastname_error."</div>"; } ?>
</td>
</tr>
<tr>
<td>Callsign</td>
<td><input type="text" name="user_callsign" value="<?php if(isset($user_callsign)) { echo $user_callsign; } ?>" />
<?php if(isset($callsign_error)) { echo "<div class=\"small error\">".$callsign_error."</div>"; } ?>
</td>
</tr>
<tr>
<td>Locator</td>
<td><input type="text" name="user_locator" value="<?php if(isset($user_locator)) { echo $user_locator; } ?>" />
<?php if(isset($locator_error)) { echo "<div class=\"small error\">".$locator_error."</div>"; } ?>
</td>
</tr>
</table>
<input type="hidden" name="id" value="<?php echo $this->uri->segment(3); ?>" />
<div><input type="submit" value="Submit" /></div>

Wyświetl plik

@ -46,20 +46,6 @@
<?php } ?>
</tr>
<tr>
<td>Callsign</td>
<td><input type="text" name="user_callsign" value="<?php if(isset($user_callsign)) { echo $user_callsign; } ?>" />
<?php if(isset($callsign_error)) { echo "<div class=\"small error\">".$callsign_error."</div>"; } else { ?>
<?php } ?>
</tr>
<tr>
<td>Locator</td>
<td><input type="text" name="user_locator" value="<?php if(isset($user_locator)) { echo $user_locator; } ?>" />
<?php if(isset($locator_error)) { echo "<div class=\"small error\">".$locator_error."</div>"; } else { ?>
<?php } ?>
</tr>
<tr>
<td>First name</td>
<td><input type="text" name="user_firstname" value="<?php if(isset($user_firstname)) { echo $user_firstname; } ?>" />
@ -74,6 +60,20 @@
<?php } ?>
</tr>
<tr>
<td>Callsign</td>
<td><input type="text" name="user_callsign" value="<?php if(isset($user_callsign)) { echo $user_callsign; } ?>" />
<?php if(isset($callsign_error)) { echo "<div class=\"small error\">".$callsign_error."</div>"; } else { ?>
<?php } ?>
</tr>
<tr>
<td>Locator</td>
<td><input type="text" name="user_locator" value="<?php if(isset($user_locator)) { echo $user_locator; } ?>" />
<?php if(isset($locator_error)) { echo "<div class=\"small error\">".$locator_error."</div>"; } else { ?>
<?php } ?>
</tr>
</table>
<input type="hidden" name="id" value="<?php echo $this->uri->segment(3); ?>" />
<div><input type="submit" value="Update profile" /></div>