예제 #1
0
            $workflow = $model->get($id);
            $pManager->invokeMethod('component', 'onNewEntry', array($component), array($workflow, $args));
        }
    }
}
/**
 * Cron job handler : Checks for tasks that are overdue and reports them to administrators [ Currently a stub ]
 *
 * @return void
 */
function plgJWFCheckDelayedTasks()
{
}
/**
 * Cron job handler : Deletes orphaned tasks , those are tasks that are pointing to a content element that has been deleted "e.g. an Article that has been deleted outside the workflow control"
 *
 * @return void
 */
function plgJWFDeletedOrphanedTasks()
{
    //Clean up orphans in "steps" table
    $pManager =& getPluginManager();
    $pManager->loadPlugins('component');
    $pManager->invokeMethod('component', 'deleteOrphans', null, null);
    //Clean up orphans in "fields" table
    $db =& JFactory::getDBO();
    $db->setQuery('DELETE FROM `#__jwf_fields` WHERE `tid` NOT IN (SELECT `id` FROM `#__jwf_steps`)');
    $db->query();
}
JWFCronJobManager::check();
예제 #2
0
 /**
  * Performs a check to see if a job is due to be executed
  *
  * @access	public
  * @return void
  */
 function check()
 {
     if (!file_exists(JWF_CRON_CRONTAB)) {
         return;
     }
     $cronJobs = new JRegistry();
     $cronJobs->loadINI(JFile::read(JWF_CRON_CRONTAB));
     $jobsArray = $cronJobs->toArray();
     $jobsDone = 0;
     foreach ($jobsArray as $jobName => $jobFrequency) {
         $seconds = JWFCronJobManager::getTimeUnit('s', $jobFrequency);
         $minutes = JWFCronJobManager::getTimeUnit('m', $jobFrequency);
         $hours = JWFCronJobManager::getTimeUnit('h', $jobFrequency);
         $days = JWFCronJobManager::getTimeUnit('d', $jobFrequency);
         $weeks = JWFCronJobManager::getTimeUnit('w', $jobFrequency);
         $frequency = $seconds + $minutes * 60 + $hours * 3600 + $days * 86400 + $weeks * 604800;
         $lastExecuteTime = JWFCronJobManager::getLastExecuteTime($jobName);
         $nextExecuteTime = $lastExecuteTime + $frequency;
         $doneEnoughJobs = $jobsDone >= JWF_CRON_MAXJOBPERCYCLE;
         if (($lastExecuteTime == 0 || $nextExecuteTime <= time()) && !$doneEnoughJobs && JWF_CRON_MAXJOBPERCYCLE != 0) {
             JWFCronJobManager::setLastExecuteTime($jobName);
             call_user_func($jobName);
             $jobsDone++;
         }
     }
 }