コード例 #1
0
ファイル: WorkerJobSet.php プロジェクト: lidijakralj/bober
 public function __construct($background = false, $auto_destroy_results = true)
 {
     $this->background = $background;
     $this->auto_destroy_results = $auto_destroy_results;
     $hash_ok = false;
     do {
         $this->randomHash = self::generateRandomString(25);
         $job_set = JobSet::model()->find('hash=:hash', array(':hash' => $this->randomHash));
         if ($job_set == null) {
             $hash_ok = true;
         }
     } while (!$hash_ok);
     $this->JobSet = new JobSet();
     $this->JobSet->hash = $this->randomHash;
     $this->JobSet->needed = 1;
     $this->JobSet->save();
     $this->taskList = new Net_Gearman_Set();
     $this->jobCounter = 0;
     global $WorkerJobSetResults;
     if (!isset($WorkerJobSetResults)) {
         $WorkerJobSetResults = array();
     }
     $WorkerJobSetResults[$this->randomHash] = array();
     $this->results = array();
 }
コード例 #2
0
ファイル: JobSet.php プロジェクト: ngreimel/kovent
 /**
  * @see \C5TL\Parser\DynamicItem::parseManual()
  */
 public function parseManual(\Gettext\Translations $translations, $concrete5version)
 {
     if (class_exists('\\JobSet', true)) {
         foreach (\JobSet::getList() as $js) {
             $this->addTranslation($translations, $js->getJobSetName(), 'JobSetName');
         }
     }
 }
コード例 #3
0
ファイル: Svg2Pdf.php プロジェクト: lidijakralj/bober
 public static function BatchConvert($svg, $data = array(), $background = false)
 {
     $count = count($data);
     if ($count == 0) {
         return null;
     }
     $workerJobSet = new WorkerJobSet($background, false);
     for ($i = 0; $i < $count; ++$i) {
         $workerJobSet->addTask('Svg2Pdf', "Convert", array($svg, $data[$i]));
     }
     // svg 2 pdf jobs
     $svg_to_pdf_jobs = array();
     // optimize fetch from database, not to load everying if we need only id
     $criteria = new CDbCriteria();
     $criteria->select = 't.id';
     $criteria->condition = 't.job_set_id = ' . $workerJobSet->getJobSetId();
     $JobList = Job::model()->findAll($criteria);
     // $JobList = Job::model()->findAll('job_set_id=:job_set_id', array(':job_set_id' => $workerJobSet->getJobSetId()));
     foreach ($JobList as $Job) {
         $svg_to_pdf_jobs[] = $Job->id;
     }
     if (!$background) {
         $result = $workerJobSet->run();
         if ($result != null) {
             $workerJobSetMerge = new WorkerJobSet($background, false);
             $workerJobSetMerge->addTask('Svg2Pdf', 'MergePDF', array($svg_to_pdf_jobs));
             $resultPDF = $workerJobSetMerge->run();
             // clean up database
             $jobSet = JobSet::model()->find('id=:id', array(':id' => $workerJobSet->getJobSetId()));
             if ($jobSet != null) {
                 $jobSet->delete();
             }
             $jobSetMerge = JobSet::model()->find('id=:id', array(':id' => $workerJobSetMerge->getJobSetId()));
             if ($jobSetMerge != null) {
                 $jobSetMerge->delete();
             }
             if (isset($resultPDF[0])) {
                 return $resultPDF[0];
             } else {
                 return null;
             }
         } else {
             return null;
         }
     } else {
         $job_id = $workerJobSet->addTask('Svg2Pdf', 'MergePDF', array($svg_to_pdf_jobs));
         $result = $workerJobSet->run();
         $workerJobSet->setFinalJobResultId($job_id);
         return $workerJobSet->getJobSetId();
     }
 }
コード例 #4
0
ファイル: version_562.php プロジェクト: ronlobo/concrete5
	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);						
					}
				}
			}
		}
	}
コード例 #5
0
ファイル: jobs.php プロジェクト: ppiedaderawnet/concrete5
                echo t('Install');
                ?>
</a>
    			<?php 
            }
            ?>
</td>
    		</tr>
		<?php 
        }
        ?>
	</tbody>
	</table>
<?php 
    }
    $djs = JobSet::getDefault();
    if (is_object($djs)) {
        ?>
<div class="well">
    <h4><?php 
        echo t('Automation Instructions');
        ?>
</h4>
    <p><?php 
        echo t('To run all the jobs in the <a href="%s">%s</a> Job Set, schedule this URL using cron or a similar system:', $view->url('/dashboard/system/optimization/jobs', 'edit_set', $djs->getJobSetID()), $djs->getJobSetDisplayName());
        ?>
</p>
    <div>
        <input type="text" style="width: 700px" class="ccm-default-jobs-url" value="<?php 
        echo $view->url('/ccm/system/jobs?auth=' . $auth);
        ?>
コード例 #6
0
ファイル: jobs.php プロジェクト: ojalehto/concrete5-legacy
 // 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;
             }
         }
     }
 }
 if (strlen($url)) {
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);
     curl_setopt($ch, CURLOPT_TIMEOUT, 1);
コード例 #7
0
ファイル: jobs.php プロジェクト: ojalehto/concrete5-legacy
 public function update_set_schedule()
 {
     $jsID = $this->post('jsID');
     $S = JobSet::getByID($jsID);
     $S->setSchedule($this->post('isScheduled'), $this->post('unit'), $this->post('value'));
     $this->redirect('/dashboard/system/optimization/jobs', 'set_scheduled');
 }
コード例 #8
0
ファイル: job_set.php プロジェクト: ojalehto/concrete5-legacy
 public static function add($jsName, $pkg = false)
 {
     $db = Loader::db();
     $jsName = Loader::helper('security')->sanitizeString($jsName);
     $pkgID = 0;
     if (is_object($pkg)) {
         $pkgID = $pkg->getPackageID();
     }
     $db->Execute('insert into JobSets (jsName, pkgID) values (?,?)', array($jsName, $pkgID));
     $id = $db->Insert_ID();
     $js = JobSet::getByID($id);
     return $js;
 }
コード例 #9
0
 protected function importJobSets(SimpleXMLElement $sx)
 {
     if (isset($sx->jobsets)) {
         foreach ($sx->jobsets->jobset as $js) {
             $pkg = ContentImporter::getPackageObject($js['package']);
             $jso = JobSet::getByName((string) $js['name']);
             if (!is_object($jso)) {
                 $jso = JobSet::add((string) $js['name']);
             }
             foreach ($js->children() as $jsk) {
                 $j = Job::getByHandle((string) $jsk['handle']);
                 if (is_object($j)) {
                     $jso->addJob($j);
                 }
             }
         }
     }
 }