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

SVN:trunk[1139]
This commit is contained in:
Romain Quetiez
2011-03-21 15:17:08 +00:00
parent 78396eafe3
commit a222b33566
3 changed files with 12 additions and 3 deletions

View File

@@ -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

View File

@@ -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());

View File

@@ -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
//