forked from science-ation/science-ation
Fix user_save to properly update the status of all roles that the user has
Fix special awards tab to load&save properly Fix volunteer positions tab to load&save properly
This commit is contained in:
parent
347b12ab2e
commit
b4d018f771
@ -123,7 +123,6 @@ function judge_status_update(&$u)
|
||||
else
|
||||
$u['judge_complete'] = 'no';
|
||||
|
||||
user_save($u);
|
||||
return ($u['judge_complete'] == 'yes') ? 'complete' : 'incomplete';
|
||||
}
|
||||
|
||||
|
@ -45,14 +45,14 @@ $u = user_load($eid);
|
||||
switch($_GET['action']) {
|
||||
case 'save':
|
||||
if(array_key_exists('spaward', $_POST)) {
|
||||
foreach($u['special_awards'] as $id => $val){
|
||||
if(in_array($id, $_POST['spaward'])){
|
||||
$u['special_awards'][$id] = 'yes';
|
||||
}else{
|
||||
$u['special_awards'][$id] = 'no';
|
||||
}
|
||||
$awards=array();
|
||||
foreach($_POST['spaward'] AS $a) {
|
||||
$awards[]=$a;
|
||||
}
|
||||
$u['special_awards']=$awards;
|
||||
}
|
||||
else
|
||||
$u['special_awards']=array();
|
||||
user_save($u);
|
||||
happy_("Special Award preferences successfully saved");
|
||||
exit;
|
||||
@ -105,10 +105,6 @@ if($_SESSION['embed'] != true) {
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
|
||||
$q=mysql_query("SELECT * FROM judges_specialaward_sel WHERE users_id='{$u['id']}'");
|
||||
$spawards = array();
|
||||
while($r=mysql_fetch_object($q)) $spawards[] = $r->award_awards_id;
|
||||
|
||||
echo "<table>\n";
|
||||
|
||||
|
||||
@ -133,9 +129,9 @@ if($_SESSION['embed'] != true) {
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
?>
|
||||
<tr><td rowspan=\"2\">
|
||||
<? $ch = (in_array($r->id,$spawards)) ? "checked=\"checked\"" : ""; ?>
|
||||
<input onclick="checkboxclicked(this)" <?=$ch?> type="checkbox" name="spaward[]" value="<?=$r->id?>" />
|
||||
<tr><td rowspan="2">
|
||||
<? $ch = (in_array($r->id,$u['special_awards'])) ? "checked=\"checked\"" : ""; ?>
|
||||
<input <?=$ch?> type="checkbox" name="spaward[]" value="<?=$r->id?>" />
|
||||
</td><td>
|
||||
<b><?=$r->name?></b> (<?=$r->organization?>)</td>
|
||||
</tr><tr>
|
||||
|
30
user.inc.php
30
user.inc.php
@ -24,6 +24,13 @@
|
||||
?>
|
||||
<?
|
||||
include_once('account.inc.php');
|
||||
|
||||
//we need these for the <type>_status_update() functions, to determine who's complete and who's isnt
|
||||
//these are called on user_save for each role, if the function exists. The functions themselves
|
||||
//shoudlnt change anything, just return the results, the user_save does the updating
|
||||
require_once('judge.inc.php');
|
||||
require_once('volunteer.inc.php');
|
||||
|
||||
function user_valid_role($role)
|
||||
{
|
||||
global $roles;
|
||||
@ -712,16 +719,15 @@ function user_save(&$u)
|
||||
if(mysql_error() != '') return "SQLERR2: " . mysql_error();
|
||||
|
||||
// Save the other user data that is not stored in the users table
|
||||
|
||||
if( // if this user has an altered special awards selection, it needs to be saved
|
||||
array_key_exists('special_awards', $u) &&
|
||||
count(array_diff_assoc($u['special_awards'], $u['orig']['special_awards'])) > 0
|
||||
array_key_exists('special_awards', $u)
|
||||
){
|
||||
mysql_query("DELETE FROM judges_specialaward_sel WHERE users_id = {$u['id']}");
|
||||
if(count($u['special_awards']) > 0){
|
||||
$query = "INSERT INTO judges_specialaward_sel (users_id, award_awards_id) VALUES (" . $u['id'] . ", ";
|
||||
$query .= implode('), (' . $u['id'] . ', ', $u['special_awards']);
|
||||
$query .= ")";
|
||||
echo $query;
|
||||
mysql_query($query);
|
||||
}
|
||||
}
|
||||
@ -765,10 +771,8 @@ function user_save(&$u)
|
||||
}
|
||||
}
|
||||
if(mysql_error() != '') return "SQLERR4: " . mysql_error();
|
||||
|
||||
if( // if this user has an altered selection of volunteer positions, we'll need to change that too
|
||||
array_key_exists('volunteer_positions', $u) &&
|
||||
count(array_diff_assoc($u['volunteer_positions'], $u['orig']['volunteer_positions'])) > 0
|
||||
if( // if this user has volunteer positions, or at least, an empty array for volunteer positions...
|
||||
array_key_exists('volunteer_positions', $u)
|
||||
){
|
||||
mysql_query("DELETE FROM volunteer_positions_signup WHERE users_id = {$u['id']}");
|
||||
if(count($u['volunteer_positions']) > 0){
|
||||
@ -780,6 +784,17 @@ function user_save(&$u)
|
||||
}
|
||||
if(mysql_error() != '') return "SQLERR5: " . mysql_error();
|
||||
|
||||
foreach($new_roles as $r) {
|
||||
$result = user_check_role_complete($u, $r);
|
||||
if($result == 'complete'){
|
||||
mysql_query("UPDATE user_roles SET complete='yes' WHERE roles_id='{$u['roles'][$r]['roles_id']}' AND users_id='{$u['id']}'");
|
||||
echo mysql_error();
|
||||
}else{
|
||||
mysql_query("UPDATE user_roles SET complete='no' WHERE roles_id='{$u['roles'][$r]['roles_id']}' AND users_id='{$u['id']}'");
|
||||
echo mysql_error();
|
||||
}
|
||||
}
|
||||
|
||||
/* Record all the data in orig that we saved so subsequent
|
||||
* calls to user_save don't try to overwrite data already
|
||||
* saved to the database */
|
||||
@ -1594,7 +1609,6 @@ function user_invite($username, $password, $email, $roles_id){
|
||||
if($returnval == null){
|
||||
// if we've gotten this far, then either the user was created successfully, or they've
|
||||
// been loaded and our permission to modify them has been confirmed; we can add the role.
|
||||
//james1234
|
||||
$result = user_add_role($newUser, $roletype);
|
||||
if($result == 'ok'){
|
||||
$returnval = user_load($newUser['id']);
|
||||
|
@ -30,9 +30,9 @@ function volunteer_status_position($u)
|
||||
global $conference;
|
||||
if($conferenceid === null) $conferenceid = $conference['id'];
|
||||
// See if they have selected something
|
||||
$q = "SELECT * FROM volunteer_positions_signup WHERE users_id = '{$u['id']}' AND conferences_id = $conferenceid";
|
||||
$r = mysql_query($q);
|
||||
if(mysql_num_rows($r) >= 1) {
|
||||
$sql = "SELECT * FROM volunteer_positions_signup WHERE users_id = '{$u['id']}' AND conferences_id = $conferenceid";
|
||||
$q = mysql_query($sql);
|
||||
if(mysql_num_rows($q) >= 1) {
|
||||
return "complete";
|
||||
}
|
||||
return "incomplete";
|
||||
@ -40,7 +40,6 @@ function volunteer_status_position($u)
|
||||
|
||||
function volunteer_status_update(&$u)
|
||||
{
|
||||
/*
|
||||
global $config;
|
||||
|
||||
if( user_personal_info_status($u) == 'complete'
|
||||
@ -49,10 +48,7 @@ function volunteer_status_update(&$u)
|
||||
else
|
||||
$u['volunteer_complete'] = 'no';
|
||||
|
||||
user_save($u);
|
||||
return ($u['volunteer_complete'] == 'yes') ? 'complete' : 'incomplete';
|
||||
*/
|
||||
return 'complete';
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -36,6 +36,7 @@ if(array_key_exists('embed_edit_id', $_SESSION)){
|
||||
|
||||
if($_GET['action']=="save"){
|
||||
$vals = '';
|
||||
print_r($_POST);
|
||||
if(is_array($_POST['posn'])) {
|
||||
|
||||
/* Load available IDs */
|
||||
@ -51,8 +52,12 @@ if($_GET['action']=="save"){
|
||||
if(!in_array($id, $posns)) continue;
|
||||
$vals[] = $id;
|
||||
}
|
||||
$u['volunteer_positions'] = $vals;
|
||||
}
|
||||
else {
|
||||
//if they didnt select anything...
|
||||
$u['volunteer_positions']=array();
|
||||
}
|
||||
$u['volunteer_positions'] = $vals;
|
||||
user_save($u);
|
||||
$newstatus = volunteer_status_position($u);
|
||||
?>
|
||||
@ -152,7 +157,7 @@ while($p = mysql_fetch_object($r)) {
|
||||
}
|
||||
|
||||
echo "</table>";
|
||||
echo "<button>" . i18n("Save Information") . "</button>";
|
||||
echo "<input type=\"submit\" value=\"" . i18n("Save Information") . "\">";
|
||||
echo "</form>";
|
||||
|
||||
echo "<br />";
|
||||
|
Loading…
Reference in New Issue
Block a user