ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCronJob Class Reference

Cron job application base class. More...

+ Inheritance diagram for ilCronJob:
+ Collaboration diagram for ilCronJob:

Public Member Functions

 isActive ($a_ts_last_run, $a_schedule_type, $a_schedule_value, $a_manual=false)
 Is job currently active?
 getScheduleType ()
 Get current schedule type (if flexible)
 getScheduleValue ()
 Get current schedule value (if flexible)
 setSchedule ($a_type, $a_value)
 Update current schedule (if flexible)
 getValidScheduleTypes ()
 Get all available schedule types.
 getTitle ()
 Get title.
 getDescription ()
 Get description.
 isManuallyExecutable ()
 Defines whether or not a cron job can be started manually.
 hasCustomSettings ()
 Has cron job any custom setting which can be edited?
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 Add custom settings to form.
 saveCustomSettings (ilPropertyFormGUI $a_form)
 Save custom settings.
 addToExternalSettingsForm ($a_form_id, array &$a_fields, $a_is_active)
 Add external settings to form.
 activationWasToggled ($a_currently_active)
 Cron job status was changed.
 getId ()
 Get id.
 hasAutoActivation ()
 Is to be activated on "installation".
 hasFlexibleSchedule ()
 Can the schedule be configured?
 getDefaultScheduleType ()
 Get schedule type.
 getDefaultScheduleValue ()
 Get schedule value.
 run ()
 Run job.

Data Fields

const SCHEDULE_TYPE_DAILY = 1
const SCHEDULE_TYPE_IN_MINUTES = 2
const SCHEDULE_TYPE_IN_HOURS = 3
const SCHEDULE_TYPE_IN_DAYS = 4
const SCHEDULE_TYPE_WEEKLY = 5
const SCHEDULE_TYPE_MONTHLY = 6
const SCHEDULE_TYPE_QUARTERLY = 7
const SCHEDULE_TYPE_YEARLY = 8

Protected Member Functions

 checkSchedule ($a_ts_last_run, $a_schedule_type, $a_schedule_value)

Detailed Description

Cron job application base class.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 11 of file class.ilCronJob.php.

Member Function Documentation

ilCronJob::activationWasToggled (   $a_currently_active)

Cron job status was changed.

Parameters
bool$a_currently_active

Reimplemented in ilForumCronNotification, ilMembershipCronNotifications, ilDAVCronDiskQuota, ilWebResourceCronLinkCheck, ilMailCronAddressbookSync, ilPaymentCronNotification, and ilMailCronNotification.

Definition at line 259 of file class.ilCronJob.php.

Referenced by ilCronManager\activateJob(), ilCronManager\createDefaultEntry(), and ilCronManager\deactivateJob().

{
// we cannot use ilObject or any higher level construct here
// this may be called from setup, so it is limited to handling ilSetting/ilDB mostly
}

+ Here is the caller graph for this function:

ilCronJob::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)
ilCronJob::addToExternalSettingsForm (   $a_form_id,
array &  $a_fields,
  $a_is_active 
)

Add external settings to form.

Parameters
int$a_form_id
array$a_fields
bool$a_is_active

Reimplemented in ilMembershipCronNotifications, ilLDAPCronSynchronization, and ilDAVCronDiskQuota.

Definition at line 244 of file class.ilCronJob.php.

{
}
ilCronJob::checkSchedule (   $a_ts_last_run,
  $a_schedule_type,
  $a_schedule_value 
)
protected

Definition at line 114 of file class.ilCronJob.php.

Referenced by isActive().

{
if(!$a_schedule_type)
{
return false;
}
if(!$a_ts_last_run)
{
return true;
}
$now = time();
switch($a_schedule_type)
{
case self::SCHEDULE_TYPE_DAILY:
$last = date("Y-m-d", $a_ts_last_run);
$ref = date("Y-m-d", $now);
return ($last != $ref);
case self::SCHEDULE_TYPE_WEEKLY:
$last = date("Y-W", $a_ts_last_run);
$ref = date("Y-W", $now);
return ($last != $ref);
case self::SCHEDULE_TYPE_MONTHLY:
$last = date("Y-n", $a_ts_last_run);
$ref = date("Y-n", $now);
return ($last != $ref);
case self::SCHEDULE_TYPE_QUARTERLY:
$last = date("Y", $a_ts_last_run)."-".ceil(date("n", $a_ts_last_run)/3);
$ref = date("Y", $now)."-".ceil(date("n", $now)/3);
return ($last != $ref);
case self::SCHEDULE_TYPE_YEARLY:
$last = date("Y", $a_ts_last_run);
$ref = date("Y", $now);
return ($last != $ref);
case self::SCHEDULE_TYPE_IN_MINUTES:
$diff = floor(($now-$a_ts_last_run)/60);
return ($diff >= $a_schedule_value);
case self::SCHEDULE_TYPE_IN_HOURS:
$diff = floor(($now-$a_ts_last_run)/(60*60));
return ($diff >= $a_schedule_value);
case self::SCHEDULE_TYPE_IN_DAYS:
$diff = floor(($now-$a_ts_last_run)/(60*60*24));
return ($diff >= $a_schedule_value);
}
}

+ Here is the caller graph for this function:

ilCronJob::getScheduleType ( )

Get current schedule type (if flexible)

Returns
int

Definition at line 54 of file class.ilCronJob.php.

References hasFlexibleSchedule().

Referenced by ilWebResourceCronLinkCheck\__getCheckPeriod().

{
if($this->hasFlexibleSchedule() && $this->schedule_type)
{
return $this->schedule_type;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCronJob::getScheduleValue ( )

Get current schedule value (if flexible)

Returns
int

Definition at line 67 of file class.ilCronJob.php.

References hasFlexibleSchedule().

{
if($this->hasFlexibleSchedule() && $this->schedule_value)
{
return $this->schedule_value;
}
}

+ Here is the call graph for this function:

ilCronJob::getValidScheduleTypes ( )

Get all available schedule types.

Returns
int

Definition at line 98 of file class.ilCronJob.php.

Referenced by setSchedule(), and ilCronManager\updateJobSchedule().

{
return array(self::SCHEDULE_TYPE_DAILY, self::SCHEDULE_TYPE_IN_MINUTES,
self::SCHEDULE_TYPE_IN_HOURS, self::SCHEDULE_TYPE_IN_DAYS,
self::SCHEDULE_TYPE_WEEKLY, self::SCHEDULE_TYPE_MONTHLY,
self::SCHEDULE_TYPE_QUARTERLY, self::SCHEDULE_TYPE_YEARLY);
}

+ Here is the caller graph for this function:

ilCronJob::hasCustomSettings ( )

Has cron job any custom setting which can be edited?

Returns
boolean

Reimplemented in ilCronDeleteInactiveUserAccounts, ilCronDeleteInactivatedUserAccounts, ilForumCronNotification, ilMailCronAddressbookSync, ilDAVCronDiskQuota, ilConsultationHourCron, ilMailCronNotification, and ilPaymentCronNotification.

Definition at line 211 of file class.ilCronJob.php.

Referenced by ilCronManagerTableGUI\parseJobToData().

{
return false;
}

+ Here is the caller graph for this function:

ilCronJob::isActive (   $a_ts_last_run,
  $a_schedule_type,
  $a_schedule_value,
  $a_manual = false 
)

Is job currently active?

Parameters
timestamp$a_ts_last_run
integer$a_ts_last_run
integer$a_ts_last_run
bool$a_ts_last_run
Returns
boolean

Definition at line 35 of file class.ilCronJob.php.

References checkSchedule(), getDefaultScheduleType(), getDefaultScheduleValue(), and hasFlexibleSchedule().

Referenced by ilCronManager\runJob().

{
if($a_manual)
{
return true;
}
if(!$this->hasFlexibleSchedule())
{
$a_schedule_type = $this->getDefaultScheduleType();
$a_schedule_value = $this->getDefaultScheduleValue();
}
return $this->checkSchedule($a_ts_last_run, $a_schedule_type, $a_schedule_value);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCronJob::isManuallyExecutable ( )

Defines whether or not a cron job can be started manually.

Returns
bool

Definition at line 197 of file class.ilCronJob.php.

Referenced by ilCronManagerTableGUI\parseJobToData().

{
return true;
}

+ Here is the caller graph for this function:

ilCronJob::saveCustomSettings ( ilPropertyFormGUI  $a_form)
ilCronJob::setSchedule (   $a_type,
  $a_value 
)

Update current schedule (if flexible)

Parameters
integer$a_type
integer$a_value
Returns
int

Definition at line 82 of file class.ilCronJob.php.

References getValidScheduleTypes(), and hasFlexibleSchedule().

{
if($this->hasFlexibleSchedule() &&
in_array($a_type, $this->getValidScheduleTypes()) &&
$a_value)
{
$this->schedule_type = $a_type;
$this->schedule_value = $a_value;
}
}

+ Here is the call graph for this function:

Field Documentation


The documentation for this class was generated from the following file: