$fsar) { // remove from fieldset
if (in_array('consent', $fsar['fields'])) {
$OC_reviewerFieldSetAR[$fsid]['fields'] = array_diff($OC_reviewerFieldSetAR[$fsid]['fields'], array('consent'));
continue; // field should only be in one fieldset
}
}
}
}
// Process submission
if (isset($_POST['ocaction']) && ($_POST['ocaction'] == "Update Profile")) {
// Check for valid submission
if ( $chair ) {
if ( !validToken('chair') ) {
warn(oc_('Invalid submission'));
}
} elseif ( ! validToken('ac') ) {
warn(oc_('Invalid submission'));
}
$err = '';
$qfields = array();
$tfields = array();
require_once 'committee-validate.inc';
if (!empty($err)) {
print '
' . oc_('Please check the following:') . '
';
} else {
// check password
$q = "SELECT `password` FROM `" . OCC_TABLE_REVIEWER . "` WHERE `reviewerid`='" . safeSQLstr($rid) . "'";
$r = ocsql_query($q) or err('Unable to retrieve reviewer information');
$rinfo = ocsql_fetch_array($r);
if ($chair || oc_password_verify($_POST['oldpwd'], $rinfo['password'])) {
// Update fields
$q = "UPDATE `" . OCC_TABLE_REVIEWER . "` SET `lastupdate`='" . safeSQLstr(date('Y-m-d')) . "', ";
foreach ($qfields as $qid => $qval) {
$q .= "`" . $qid . "`=" . $qval . ", ";
}
$q = rtrim($q, ', ');
$q .= " WHERE `reviewerid`='" . safeSQLstr($rid) . "' LIMIT 1";
ocsql_query($q) or err('Unable to update database');
// Update topics
issueSQL("DELETE FROM `" . OCC_TABLE_REVIEWERTOPIC . "` WHERE `reviewerid`='" . safeSQLstr($rid) . "'");
if (!empty($tfields)) {
$q = "INSERT INTO `" . OCC_TABLE_REVIEWERTOPIC . "` (`reviewerid`,`topicid`) VALUES";
foreach ($tfields as $t) {
$q .= " (" . safeSQLstr($rid) . ",$t),";
}
$r = ocsql_query(rtrim($q, ',')) or err("unable to add reviewer topic, but account created ");
}
if ($chair) { // display back links
print '';
} else {
print '' . sprintf(oc_('Your profile has been successfully updated. Return to the main Committee page.'), 'reviewer.php') . '
';
// ocIgnore included so poEdit picks up (DB) template translation
$ocIgnoreSubject = oc_('Committee Member Profile Updated');
$ocIgnoreBody = oc_('Your profile has been updated. The submitted information follows below:
[:fields:]');
list($mailsubject, $mailbody) = oc_getTemplate('committee-update');
$fields = oc_genFieldMessage($OC_reviewerFieldSetAR, $OC_reviewerFieldAR, $_POST);
$templateExtraAR = array(
'fields' => oc_('Username') . ": " . $_SESSION[OCC_SESSION_VAR_NAME]['acusername'] . "\n\n" . $fields
);
$mailsubject = oc_replaceVariables($mailsubject, $templateExtraAR);
$mailbody = oc_replaceVariables($mailbody, $templateExtraAR);
if (oc_hookSet('committee-signup-update')) {
foreach ($GLOBALS['OC_hooksAR']['committee-signup-update'] as $hook) {
require_once $hook;
}
}
sendEmail($_POST['email'], $mailsubject, $mailbody, $OC_configAR['OC_notifyReviewerProfileUpdate']);
}
printFooter();
// log
oc_logit('committee', 'Member ID ' . $rid . ' profile edited' . ($chair ? ' by Chair' : ''));
exit;
} else {
print '' . oc_('Current password is not correct') . '
';
}
}
$postFields = $_POST;
} else { // not submitting
// get stored values
$q = "SELECT * FROM `" . OCC_TABLE_REVIEWER . "` WHERE `reviewerid`='" . safeSQLstr($rid) . "'";
$r = ocsql_query($q) or err("Unable to retrieve reviewer information");
$postFields = array_merge((array)$_POST, ocsql_fetch_assoc($r));
// Get list of reviewer topics
$tq = "SELECT * FROM `" . OCC_TABLE_REVIEWERTOPIC . "` WHERE `reviewerid`='" . safeSQLstr($rid) . "'";
$tr = ocsql_query($tq) or err("Unable to retrieve topics");
$postFields['topics'] = array();
while ($tl = ocsql_fetch_assoc($tr)) {
$postFields['topics'][] = $tl['topicid'];
}
if ( isset($OC_reviewerFieldAR['topics']['type']) && ($OC_reviewerFieldAR['topics']['type'] == 'radio') && isset($postFields['topics'][0]) ) {
$postFields['topics'] = $postFields['topics'][0];
}
}
print '
';
printFooter();
?>