mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +00:00
Added utility methods updateJobs and generateJobs to controller core/JQW_Controller
This commit is contained in:
@@ -14,7 +14,7 @@ $config['job_type_permissions_white_list'] = array(
|
||||
|
||||
// List of schedulers that can be run by the scheduler
|
||||
$config['job_schedulers_list'] = array( // Controllers
|
||||
'extensions/FHC-Core-SAP/JBMScheduler' => array( // Methods
|
||||
'extensions/FHC-Core-SAP/JQMScheduler' => array( // Methods
|
||||
'newUsers',
|
||||
'updateUsers'
|
||||
)
|
||||
|
||||
@@ -74,5 +74,43 @@ abstract class JQW_Controller extends JOB_Controller
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to update the specified properties of the given jobs with the given values
|
||||
*/
|
||||
protected function updateJobs($jobs, $properties, $values)
|
||||
{
|
||||
// If not valid arrays of properties and values arrays are not of the same size then exit
|
||||
if (isEmptyArray($jobs) || isEmptyArray($properties) || isEmptyArray($values)) return;
|
||||
if (count($properties) != count($values)) return;
|
||||
|
||||
// For each job
|
||||
foreach ($jobs as $job)
|
||||
{
|
||||
// For each propery of the job
|
||||
for ($pI = 0; $pI < count($properties); $pI++)
|
||||
{
|
||||
// If this property is present in the job object
|
||||
if (property_exists($job, $properties[$pI]))
|
||||
{
|
||||
$job->{$properties[$pI]} = $values[$pI]; // set a new value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to generate a job with the given parameters and return it inside an array
|
||||
* ready to be used by addNewJobsToQueue and updateJobsQueue
|
||||
*/
|
||||
protected function generateJobs($status, $input)
|
||||
{
|
||||
$job = stdClass();
|
||||
|
||||
$job->{self::PROPERTY_STATUS} = $status;
|
||||
$job->{self::PROPERTY_INPUT} = $input;
|
||||
|
||||
return array($job);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -335,7 +335,7 @@ class JobsQueueLib
|
||||
$found = $this->_inArray($job->{self::PROPERTY_STATUS}, $statuses, self::PROPERTY_STATUS);
|
||||
}
|
||||
|
||||
// No status was not found and does NOT already contain the property error
|
||||
// No status was found and does NOT already contain the property error
|
||||
if (!$found && !property_exists($job, self::PROPERTY_ERROR))
|
||||
{
|
||||
$job->{self::PROPERTY_ERROR} = 'The provided status of this job is not valid'; // store the error message in the object
|
||||
|
||||
Reference in New Issue
Block a user