From 15570725e21bac4f6b4d41f9d82275b9b5f8ea4a Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sun, 12 Jul 2015 09:11:16 +0000 Subject: [PATCH] support jobs --- lam/docs/devel/mod_index.htm | 3 ++ lam/docs/devel/mod_jobs.htm | 96 ++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 lam/docs/devel/mod_jobs.htm diff --git a/lam/docs/devel/mod_index.htm b/lam/docs/devel/mod_index.htm index fa10521d..1266ac3b 100644 --- a/lam/docs/devel/mod_index.htm +++ b/lam/docs/devel/mod_index.htm @@ -2,6 +2,7 @@ LAM module HowTo + @@ -50,6 +51,8 @@ existing modules.

5. Defining required PHP extensions

6. Self service

+

7. Jobs

+

diff --git a/lam/docs/devel/mod_jobs.htm b/lam/docs/devel/mod_jobs.htm new file mode 100644 index 00000000..44151aaf --- /dev/null +++ b/lam/docs/devel/mod_jobs.htm @@ -0,0 +1,96 @@ + + + Module HowTo - Jobs + + + + + + + + + +
+

Module HowTo - Jobs
+

+

+Jobs can be used to run actions in regular intervals like daily.
+They are configured on tab "Jobs" in LAM server profile.
+
+
+
See ppolicyUser module for an example.
+
+

Adding the job class

+The module defines the list of suuported jobs with function +getSupportedJobs().
+ + + + + + +
    /**
+    * Returns a list of jobs that can be run.
+    *
+    * @param LAMConfig $config configuration
+    * @return array list of jobs
+    */
+    public function getSupportedJobs(&$config) {
+        return array(
+            new +PPolicyPasswordNotifyJob()
+        );
+    }
+
+
+
The job class itself can be in the module file or in any file +included +by the module file. Please add the class definition in an interface +check as the example below. The job interface is not loaded on all +pages.
+ + + + + + + +
if (interface_exists('\LAM\JOB\Job')) {
+
+    /**
+     * Job to notify users about password expiration.
+     *
+     * @package jobs
+     */
+    class PPolicyPasswordNotifyJob implements \LAM\JOB\Job {
+[...]
+
+}
+
+
+

Basic job attributes

+Each job needs to provide a unique name, icon, alias and job +description. You need also to specify if multiple configurations of the +same job are allowed on a server profile.
+
+If your job requires any configuration options then use get/checkConfigOptions() functions.
+
+

Database

+Jobs can access a database to read and store data about job runs. Use +this e.g. if you need to save any status information accross job runs.
+Database access is specified with needsDatabaseAccess().
+
+There is a built-in database upgrade mechanism. Your job must return +its current schema version with getDatabaseSchemaVersion() and LAM will +call updateSchemaVersion() whenever it detects a higher version in job +class than on database.
+
+

Execution

+When jobs are run the the execute() function is called. Please put all your logic in there.
+ + +

+
+
+ + \ No newline at end of file