forked from science-ation/science-ation
Modifications on editing users
This commit is contained in:
parent
e0eef7effa
commit
9db042fc10
22
user.inc.php
22
user.inc.php
@ -491,8 +491,27 @@ function user_create($accounts_id, $conferences_id=0)
|
||||
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 */
|
||||
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();
|
||||
|
||||
/* 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
|
||||
* password hasn't expired (the password_expired var is set in the login page)
|
||||
*/
|
||||
|
@ -33,6 +33,44 @@ if($edit_id != $_SESSION['users_id'])
|
||||
else
|
||||
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(
|
||||
'label' => 'Fair Information',
|
||||
'types' => array('fair'),
|
||||
|
Loading…
Reference in New Issue
Block a user