Modifications on editing users

This commit is contained in:
jacob 2010-10-01 18:47:28 +00:00
parent e0eef7effa
commit 9db042fc10
2 changed files with 59 additions and 3 deletions

View File

@ -491,8 +491,27 @@ function user_create($accounts_id, $conferences_id=0)
exit; exit;
} }
$fields = array(
'accounts_id' => $accounts_id,
'conferences_id' => $conferences_id,
);
/* Get old user data if available */
$results = mysql_fetch_assoc(mysql_query("SELECT * FROM users WHERE accounts_id = '$accounts_id' ORDER BY id DESC LIMIT 1"));
if(is_array($results)){
$skipfields = array('id', 'created', 'lastlogin', 'year', 'accounts_id', 'conferences_id', 'deleted', 'deleteddatetime');
foreach($results as $fname => $value){
if(!in_array($fname, $skipfields) && $value != null){
$fields[$fname] = $value;
}
}
}
/* Create the user */ /* Create the user */
mysql_query("INSERT INTO users(`accounts_id`,`conferences_id`) VALUES('$accounts_id','$conferences_id')"); $fieldList = array_keys($fields);
$query = "INSERT INTO users(`created`, `" . implode('`,`', $fieldList) . "`) VALUES(NOW(), '" . implode("','", $fields) . "')";
mysql_query($query);
$id = mysql_insert_id(); $id = mysql_insert_id();
/* Return a loaded user with no roles */ /* Return a loaded user with no roles */
@ -501,7 +520,6 @@ function user_create($accounts_id, $conferences_id=0)
/* Perform some checks. Make sure the person is logged in, and that their /* Perform some checks. Make sure the person is logged in, and that their
* password hasn't expired (the password_expired var is set in the login page) * password hasn't expired (the password_expired var is set in the login page)
*/ */

View File

@ -33,6 +33,44 @@ if($edit_id != $_SESSION['users_id'])
else else
user_auth_required(); user_auth_required();
if(array_key_exists('join', $_GET)){
// this is a request to join this conference
// get the corresponding account id to go with this user id
$result = mysql_fetch_assoc(mysql_query("SELECT accounts_id FROM users WHERE id=$edit_id"));
$edit_accounts_id = $result['accounts_id'];
// find out if they're already a member of this conference
$query = "SELECT COUNT(*) FROM users WHERE conferences_id = {$_SESSION['conferences_id']}"
. " AND accounts_id = " . $_SESSION['accounts_id'];
$data = mysql_fetch_array(mysql_query($query));
if($data[0] == 0){
// apparently not - let's go ahead and hook them up
$u = user_create($edit_accounts_id, $_SESSION['conferences_id']);
$edit_id = $u['id'];
}
}else{
$joinConference = false;
if($edit_id == ''){
// the account in question does not have a users record
$joinConference = true;
}else{
$query = "SELECT COUNT(*) FROM users WHERE conferences_id = {$_SESSION['conferences_id']} AND ";
$query .= "id = $edit_id";
$data = mysql_fetch_array(mysql_query($query));
if($data[0] == 0){
// the user exists, but they are not linked to this conference
$joinConference = true;
}
}
if($joinConference){
send_header(i18n("User Editor").": {$u['name']}");
echo '<a href="user_edit.php?join=' . $_SESSION['conferences_id'] . '">' . i18n('Join this conferenece') . '</a>';
exit;
}
}
$tabs = array( 'fairinfo' => array( $tabs = array( 'fairinfo' => array(
'label' => 'Fair Information', 'label' => 'Fair Information',
'types' => array('fair'), 'types' => array('fair'),
@ -312,7 +350,7 @@ function user_update_tab_status(tabkey,newstatus)
$(".status_overall").addClass('happy'); $(".status_overall").addClass('happy');
} }
} }
</script> </script>