Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Candidate] Functions moved to candidate class #3023

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class NDB_Menu_Filter_Candidate_List extends NDB_Menu_Filter
);

$participant_status_options = array(null => 'All')
+ NDB_Form_candidate_parameters::getParticipantStatusOptions();
+ Candidate::getParticipantStatusOptions();
$scan_options = array(
null => 'All',
'Y' => 'Yes',
Expand Down Expand Up @@ -361,7 +361,7 @@ class NDB_Menu_Filter_Candidate_List extends NDB_Menu_Filter
$subprojectlist = Utility::getSubprojectList();
$projectlist = Utility::getProjectList();

$pOptions = NDB_Form_candidate_parameters::getParticipantStatusOptions();
$pOptions = Candidate::getParticipantStatusOptions();
// print out
$x = 0;
foreach ($this->list as $item) {
Expand Down
8 changes: 2 additions & 6 deletions modules/candidate_parameters/ajax/getData.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,6 @@ function getFamilyInfoFields()
*/
function getParticipantStatusFields()
{
include_once __DIR__
. "/../../candidate_parameters/php/"
. "NDB_Form_candidate_parameters.class.inc";

$candID = $_GET['candID'];

$db =& Database::singleton();
Expand All @@ -283,7 +279,7 @@ function getParticipantStatusFields()
array('candid' => $candID)
);

$statusOptions = NDB_Form_candidate_parameters::getParticipantStatusOptions();
$statusOptions = Candidate::getParticipantStatusOptions();
$reasonOptions = array();

$req = $db->pselect(
Expand All @@ -292,7 +288,7 @@ function getParticipantStatusFields()
);
$required = array();
foreach ($req as $k=>$row) {
$required[$k] =$row['ID'];
$required[$k] = $row['ID'];
}
$parentIDs = $db->pselect(
'SELECT distinct(parentID) from participant_status_options',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,19 @@ class NDB_Form_Candidate_Parameters extends NDB_Form
* Gets the participant_status options from participant_status_options
* getParticipantStatusOptions()
*
* @note This function was moved to the Candidate class and should be removed
* in the next major release
* @return array Options array suitable for use in QuickForm select
* element
*/
static function getParticipantStatusOptions()
{
$DB =& Database::singleton();
$options = $DB->pselect(
"SELECT ID,Description
FROM participant_status_options
WHERE parentID IS NULL",
array()
error_log(
"Function getParticipantStatusOptions() was moved out of ".
"the NDB_Form_Candidate_Parameters class and will be removed in ".
"the next Major release. Refer to the Candidate class for new location."
);
$option_array = array();
foreach ($options as $option) {
$option_array[$option['ID']] = $option['Description'];
}
return $option_array;
return Candidate::getParticipantStatusOptions();
}

/**
Expand All @@ -110,23 +106,20 @@ class NDB_Form_Candidate_Parameters extends NDB_Form
*
* @param int $parentID parent ID of the participant status option
*
* @note This function was moved to the Candidate class and should be removed
* in the next major release
*
* @return array Options array suitable for use in QuickForm select
* element
*/
function getParticipantStatusSubOptions($parentID)
{
$DB =& Database::singleton();
$options = $DB->pselect(
"SELECT ID,Description
FROM participant_status_options
WHERE parentID=:pid",
array('pid' => $parentID)
error_log(
"Function getParticipantStatusSubOptions() was moved out of ".
"the NDB_Form_Candidate_Parameters class and will be removed in ".
"the next Major release. Refer to the Candidate class for new location."
);
$option_array = array();
foreach ($options as $option) {
$option_array[$option['ID']] = $option['Description'];
}
return $option_array;
return Candidate::getParticipantStatusSubOptions($parentID);
}

/**
Expand Down
46 changes: 46 additions & 0 deletions php/libraries/Candidate.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -937,5 +937,51 @@ class Candidate
return $arrays;
}

/**
* Gets the participant_status options from participant_status_options table
*
* @return array Options array suitable for use in QuickForm select
* element
*/
static function getParticipantStatusOptions()
{
$DB =& Database::singleton();
$options = $DB->pselect(
"SELECT ID,Description
FROM participant_status_options
WHERE parentID IS NULL",
array()
);
$option_array = array();
foreach ($options as $option) {
$option_array[$option['ID']] = $option['Description'];
}
return $option_array;
}

/**
* Gets the participant_status options suboptions from participant_status_options
*
* @param int $parentID parent ID of the participant status option
*
* @return array Options array suitable for use in QuickForm select
* element
*/
static function getParticipantStatusSubOptions($parentID)
{
$DB =& Database::singleton();
$options = $DB->pselect(
"SELECT ID,Description
FROM participant_status_options
WHERE parentID=:pid",
array('pid' => $parentID)
);
$option_array = array();
foreach ($options as $option) {
$option_array[$option['ID']] = $option['Description'];
}
return $option_array;
}

}
?>