function view() { Job::installByHandle('index_search'); $this->set('availableJobs', Job::getAvailableList(0)); $this->set('jobList', Job::getList()); $this->set('auth', Job::generateAuth()); }
function view(){ $jobObj = Loader::model("job"); Job::installByHandle('index_search'); $this->set( 'availableJobs', Job::getAvailableList(0) ); $this->set( 'jobListRS', Job::getList() ); $this->set('auth', Job::generateAuth()); }
public function reset() { $jobs = Job::getList(); foreach ($jobs as $j) { $j->reset(); } $this->redirect('/dashboard/system/optimization/jobs', 'reset_complete'); }
public function run() { $j = Job::getByHandle('index_search_all'); if (!is_object($j)) { Job::installByHandle('index_search_all'); } $js = JobSet::getByName('Default'); if (!is_object($js)) { $js = JobSet::add('Default'); } $js->clearJobs(); $jobs = Job::getList(); foreach($jobs as $j) { if (!$j->supportsQueue()) { $js->addJob($j); } } // create the view page in sitemap permission $rpk = PermissionKey::getByHandle('view_page'); $vpk = PermissionKey::getByHandle('view_page_in_sitemap'); if (!is_object($vpk)) { $vpk = PermissionKey::add('page', 'view_page_in_sitemap', 'View Page in Sitemap', 'View Page in Sitemap and Intelligent Search.', false, false); } // now we have to get a list of all pages in the site that have their own permissions set. $db = Loader::db(); $r = $db->Execute('select cID from Pages where cInheritPermissionsFrom = "OVERRIDE" order by cID asc'); while ($row = $r->Fetchrow()) { $c = Page::getByID($row['cID']); if (is_object($c) && !$c->isError()) { $rpk->setPermissionObject($c); $vpk->setPermissionObject($c); $rpa = $rpk->getPermissionAccessObject(); if (is_object($rpa)) { $pt = $vpk->getPermissionAssignmentObject(); if (is_object($pt)) { $pt->clearPermissionAssignment(); $pt->assignPermissionAccess($rpa); } } } } }
public static function runAllJobs() { //loop through all installed jobs $jobListRS = Job::getList(); while ($jobItem = $jobListRS->fetchRow()) { $jobObj = Job::getJobObjByHandle($jobItem['jHandle']); $jobObj->executeJob(); } }
<?php defined('C5_EXECUTE') or die('Access Denied.'); if (ENABLE_JOB_SCHEDULING) { $c = Page::getCurrentPage(); if ($c instanceof Page && !$c->isAdminArea()) { // check for non dashboard page $jobs = Job::getList(true); $auth = Job::generateAuth(); $url = ""; // jobs if (count($jobs)) { foreach ($jobs as $j) { if ($j->isScheduledForNow()) { $url = BASE_URL . View::url('/tools/required/jobs/run_single?auth=' . $auth . '&jID=' . $j->getJobID()); break; } } } // job sets if (!strlen($url)) { $jSets = JobSet::getList(); if (is_array($jSets) && count($jSets)) { foreach ($jSets as $set) { if ($set->isScheduledForNow()) { $url = BASE_URL . View::url('/tools/required/jobs?auth=' . $auth . '&jsID=' . $set->getJobSetID()); break; } } } }
<?php defined('C5_EXECUTE') or die("Access Denied."); if (!ini_get('safe_mode')) { @set_time_limit(0); } $json = Loader::helper('json'); if (Job::authenticateRequest($_REQUEST['auth'])) { $list = Job::getList(); foreach ($list as $job) { if ($job->supportsQueue()) { $q = $job->getQueueObject(); // don't process queues that are empty if ($q->count() < 1) { continue; } $obj = new stdClass(); $js = Loader::helper('json'); try { $messages = $q->receive($job->getJobQueueBatchSize()); foreach ($messages as $key => $p) { $job->processQueueItem($p); $q->deleteMessage($p); } $totalItems = $q->count(); $obj->totalItems = $totalItems; $obj->jHandle = $job->getJobHandle(); $obj->jID = $job->getJobID(); if ($q->count() == 0) { $result = $job->finish($q); $obj = $job->markCompleted(0, $result);
public static function getAvailableList($includeConcreteDirJobs=1){ $jobObjs=array(); //get existing jobs $existingJobHandles=array(); $existingJobs = Job::getList(); foreach($existingJobs as $j) { $existingJobHandles[] = $j->getJobHandle(); } if(!$includeConcreteDirJobs) $jobClassLocations = array( DIR_FILES_JOBS ); else $jobClassLocations = Job::jobClassLocations(); foreach( $jobClassLocations as $jobClassLocation){ // Open a known directory, and proceed to read its contents if (is_dir($jobClassLocation)) { if ($dh = opendir($jobClassLocation)) { while (($file = readdir($dh)) !== false) { if( substr($file,strlen($file)-4)!='.php' ) continue; $alreadyInstalled=0; foreach($existingJobHandles as $existingJobHandle){ if( substr($file,0,strlen($file)-4)==$existingJobHandle){ $alreadyInstalled=1; break; } } if($alreadyInstalled) continue; $path=$jobClassLocation .'/'. $file; require_once( $jobClassLocation .'/'. $file ); $jHandle = substr($file,0,strlen($file)-4); $className=Object::camelcase( $jHandle ); if(class_exists($className)){ $jobObjs[$jHandle]=new $className(); $jobObjs[$jHandle]->jHandle=$jHandle; if(!$jobObjs[$jHandle] instanceof Job){ $jobObjs[$jHandle]->jDescription= t('Error: The Job class must be a child class of Job.'); $jobObjs[$jHandle]->invalid=1; } }else{ $invalidJob = new Job(); $invalidJob->jName = $className; $invalidJob->jHandle=$jHandle; $invalidJob->jDescription = t('Error: Invalid Job file. The class %s was not found in %s .', $className, $path); $invalidJob->invalid=1; $jobObjs[$jHandle] = $invalidJob; } } closedir($dh); } } } return $jobObjs; }
public static function getListAll() { $jobsTotal = 1; $jobs = []; for ($page = 1; sizeof($jobs) < $jobsTotal; $page++) { $jobResponse = Job::getList($page); $jobList = $jobResponse->jobs; $jobsTotal = $jobResponse->totalCount; foreach ($jobList as $job) { $jobs[] = $job; } } return $jobs; }