hello there,
the project I'm working on involves users filling out a form to apply for a staff position for an event. the current feature I'm trying to tackle is a page for the admin/chairman of the event to approve pending staff members. so i have a table of pending staff members, and next to each row is a check box that corresponds to the row. there are three buttons for three actions: accept, deny, mark as SPAM. also, if the pending staff that are checked are to be accepted, a select box must be completed to assign the pending staff to a committee. here is my code:
//from process.php
function procManagePending(){
global $database, $session, $form;
$pendingStaff = $database->getPendingStaff();
$selectedIDs = array();
$selAssignments = array();
foreach($pendingStaff as $key => $value){
if(isset($_POST['pendingStaff_$key'])){
$selectedIDs[$key] = $_POST['pendingStaff_$key'];
}
if(isset($_POST['assign_$key']) && isset($selectedIDs[$key])){
$selAssignments[$key] = $_POST['assign_$key'];
}
}
//echo($selectedIds.$selAssignments);
if(isset($_POST['accept'])){
$retval = $session->acceptPendingStaff(array_combine($selectedIds, $selAssignments),
$pendingStaff);
$sesKey = 'acceptPending';
}elseif(isset($_POST['deny'])){
$retval = $session->denyPendingStaff($selectedIds, $pendingStaff);
$sesKey = 'denyPending';
}elseif(isset($_POST['spam'])){
$retval = $session->markPendingStaffSpam($selectedIds, $pendingStaff);
$sesKey = 'spamPending';
}
if($retval){
//sucess
$_SESSION['$seskey'] = true;
header("Location: ".INSTALL."/staff/pending.php");
}else{
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $form->getErrorArray();
header("Location: ".INSTALL."/staff/pending.php");
}
}
//from session.php
function acceptPendingStaff($assignments, $pendingStaff){
global $form, $database, $staff;
$retval = array();
foreach($pendingStaff as $key => $staff){
if(array_key_exists($staff->id, $assignments)){
$staff->setCommitteeAssignment($assignments[$staff->id]);
$retval[] = $staff->acceptStaffMember();
}
}
return !in_array(false, $retval);
}
//from staff.php
function acceptStaffMember(){
global $mailer, $database;
$this->setMetaStatus(STATUS_UNCONFIRMED);
$this->setConfirmationTime();
$q = "UPDATE ".TBL_STAFF
." SET `com_assignment` = '$this->committee[\'assign\']', `status` = '$status',
`confirmed` = '$confirmed' "
." WHERE `id` = '$id' LIMIT 1";
if($database->query($q)){
$mailer->sendNewlyAcceptedStaff($this->contact->name, $this->contact->email,
$this->committee['assign'], $this->rndKey);
return true; //staff member accepted succesfully
}else{
return false; //staff member acception attempt failed
}
}
i know that the $database->getPendingStaff() (which returns an array of staff objects) works, as i use the, method to display the table data. this is the first time i am attempting a form that involves "batch" processing (for lack of a better term). my current code is not working! i just get returned to pending.php page. any help or pointing to a tutorial would be helpful. i have tried searching, but no useful results! thanks for any help!
take care,
--Josh