added some skeletal function stubs

This commit is contained in:
jacob 2010-10-06 20:01:15 +00:00
parent daa714e5ef
commit 98dcfd6399
2 changed files with 42 additions and 17 deletions

View File

@ -180,6 +180,17 @@ function account_set_email($accounts_id,$email) {
}
}
// add the necessary role to the account's user record for the specified conference
function account_add_role($accounts_id, $roles_id, $conferences_id, $password = null){
// create the user if they don't exist
// active = yes
// complete = no
}
function account_remove_role($accounts_id, $roles_id, $conferences_id){
}
/*
*/
?>

View File

@ -234,6 +234,15 @@ function user_load_by_accounts_id_year($uid, $year)
return user_load($i['id']);
}
// activate the specified role for the specified user if they have that role
function user_activate_role($users_id, $roles_id){
}
// deactivate the specified role for the specified user if they have that role
function user_deactivate_role($users_id, $roles_id){
}
function user_save(&$u)
{
global $conference;
@ -492,13 +501,15 @@ function user_add_role_allowed(&$u, $role)
return true;
}
// Add a role for a user. Return true on success, false on error
function user_add_role(&$u, $role, $password = null)
{
global $config, $roles;
if(!user_add_role_allowed($u, $role)) {
/* If we get in here, someone is hand crafting URLs */
echo "HALT: invalid role add specified for operation.";
exit;
return false;
}
// ensure that this role can indeed be added
@ -529,24 +540,27 @@ function user_add_role(&$u, $role, $password = null)
}
}
if($valid){
// ok, the conditions are met, make sure they don't already have this role
$check = mysql_fetch_assoc(mysql_query("SELECT COUNT(*) AS tally FROM user_roles WHERE users_id = {$u['id']} AND roles_id={$roles[$role]['id']}"));
if($check['tally'] == 0){
if(!$valid){
return false;
}
$q = "INSERT INTO user_roles (accounts_id, users_id, roles_id, active, complete) VALUES(";
$q .= $u['accounts_id'];
$q .= ", " . $u['id'];
$q .= ", " . $roles[$role]['id'];
$q .= ", 'yes', 'no');";
if(mysql_query($q)){
$u['roles'][$role] = array('active' =>'yes', 'complete' => 'no');
}else{
$error = mysql_error();
}
// ok, the conditions are met, make sure they don't already have this role
$check = mysql_fetch_assoc(mysql_query("SELECT COUNT(*) AS tally FROM user_roles WHERE users_id = {$u['id']} AND roles_id={$roles[$role]['id']}"));
if($check['tally'] == 0){
$q = "INSERT INTO user_roles (accounts_id, users_id, roles_id, active, complete) VALUES(";
$q .= $u['accounts_id'];
$q .= ", " . $u['id'];
$q .= ", " . $roles[$role]['id'];
$q .= ", 'yes', 'no');";
if(mysql_query($q)){
$u['roles'][$role] = array('active' =>'yes', 'complete' => 'no');
}else{
return false;
}
}
return true;
}
function user_create($accounts_id, $conferences_id=0)
@ -874,10 +888,10 @@ function user_conference_load($accounts_id,$conferences_id) {
$q = mysql_query("SELECT id FROM users WHERE accounts_id=$accounts_id AND conferences_id=$conferences_id");
if(mysql_num_rows($q) == 0) {
/* FIXME: this should probably just return false, but for now, see if there's an error */
return false;
// return false;
// header("location: user_edit.php");
// echo "No user {$accounts_id} for conference {$_SESSION['conferences_id']}";
exit;
return $config['SFIABDIRECTORY']."/user_main.php";
}
if(mysql_num_rows($q) > 1) {
echo "DATABASE ERROR: More than one user for account $accounts_id conference {$conferences_id}";