Prechádzať zdrojové kódy

CRON - admin only + queues with timer (field 'planned')

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1139 a333f486-631f-4898-b8df-5754b55c2be0
romainq 14 rokov pred
rodič
commit
a4093c67b5

+ 3 - 1
core/asynctask.class.inc.php

@@ -33,7 +33,7 @@ class ExecAsyncTask implements iBackgroundProcess
 
 	public function Process($iTimeLimit)
 	{
-		$sOQL = "SELECT AsyncTask WHERE ISNULL(started)";
+		$sOQL = "SELECT AsyncTask WHERE ISNULL(started) AND (ISNULL(planned) OR (planned < NOW()))";
 		$oSet = new CMDBObjectSet(DBObjectSearch::FromOQL($sOQL), array('created' => true) /* order by*/, array());
 		$iProcessed = 0;
 		while ((time() < $iTimeLimit) && ($oTask = $oSet->Fetch()))
@@ -83,6 +83,8 @@ abstract class AsyncTask extends DBObject
 //		MetaModel::Init_AddAttribute(new AttributeString("name", array("allowed_values"=>null, "sql"=>"name", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
 		MetaModel::Init_AddAttribute(new AttributeDateTime("created", array("allowed_values"=>null, "sql"=>"created", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
 		MetaModel::Init_AddAttribute(new AttributeDateTime("started", array("allowed_values"=>null, "sql"=>"started", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
+		// planned... still not used - reserved for timer management
+		MetaModel::Init_AddAttribute(new AttributeDateTime("planned", array("allowed_values"=>null, "sql"=>"planned", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
 		MetaModel::Init_AddAttribute(new AttributeExternalKey("event_id", array("targetclass"=>"Event", "jointype"=> "", "allowed_values"=>null, "sql"=>"event_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_SILENT, "depends_on"=>array())));
 
 		// Display lists

+ 1 - 1
test/testlist.inc.php

@@ -3240,7 +3240,7 @@ class TestEmailAsynchronous extends TestBizModel
 		{
 			$oMail = new Email();
 			$oMail->SetRecipientTO('romain.quetiez@combodo.com');
-			//$oMail->SetRecipientFrom('romain.quetiez@combodo.com');
+			$oMail->SetRecipientFrom('romain.quetiez@combodo.com');
 			$oMail->SetRecipientCC('romainquetiez@yahoo.fr');
 			$oMail->SetSubject('automated test - '.$i);
 			$oMail->SetBody('this is one is entirely working fine '.time());

+ 8 - 1
webservices/cron.php

@@ -120,7 +120,7 @@ if (utils::IsModeCLI())
 	}
 	else
 	{
-		$oP->p("Access restricted or wrong credentials ('$sAuthUser')");
+		$oP->p("Access wrong credentials ('$sAuthUser')");
 		exit;
 	}
 }
@@ -133,6 +133,13 @@ else
 	$oP = new WebPage("iTop - CRON");
 }
 
+if (!UserRights::IsAdministrator())
+{
+	$oP->p("Access restricted to administrators");
+	$oP->Output();
+	exit;
+}
+
 
 // Enumerate classes implementing BackgroundProcess
 //