support jobs
This commit is contained in:
parent
daafa828df
commit
15570725e2
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="style/layout.css">
|
<link rel="stylesheet" type="text/css" href="style/layout.css">
|
||||||
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico"></head><body>
|
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico"></head><body>
|
||||||
<div style="text-align: center;">
|
<div style="text-align: center;">
|
||||||
|
@ -50,6 +51,8 @@ existing modules.<br>
|
||||||
|
|
||||||
<h3><a href="mod_ext.htm">5. Defining required PHP extensions</a></h3>
|
<h3><a href="mod_ext.htm">5. Defining required PHP extensions</a></h3>
|
||||||
<h3><a href="mod_selfService.htm">6. Self service</a></h3>
|
<h3><a href="mod_selfService.htm">6. Self service</a></h3>
|
||||||
|
<h3><a href="mod_jobs.htm">7. Jobs</a></h3>
|
||||||
|
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
<html><head>
|
||||||
|
<title>Module HowTo - Jobs</title>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="style/layout.css">
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico">
|
||||||
|
|
||||||
|
</head><body>
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<h1>Module HowTo - Jobs<br>
|
||||||
|
</h1>
|
||||||
|
<div style="text-align: left;"><br>
|
||||||
|
Jobs can be used to run actions in regular intervals like daily.<br>
|
||||||
|
They are configured on tab "Jobs" in LAM server profile.<br>
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
<div style="text-align: left;">See ppolicyUser module for an example.<br>
|
||||||
|
<br>
|
||||||
|
<h2>Adding the job class</h2>
|
||||||
|
The module defines the list of suuported jobs with function
|
||||||
|
getSupportedJobs().<br>
|
||||||
|
<table style="width: 100%; text-align: left;" class="mod-code" border="0" cellpadding="2" cellspacing="2">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="vertical-align: top;"> /**<br>
|
||||||
|
* Returns a list of jobs that can be run.<br>
|
||||||
|
*<br>
|
||||||
|
* @param LAMConfig $config configuration<br>
|
||||||
|
* @return array list of jobs<br>
|
||||||
|
*/<br>
|
||||||
|
public function getSupportedJobs(&$config) {<br>
|
||||||
|
return array(<br>
|
||||||
|
new
|
||||||
|
PPolicyPasswordNotifyJob()<br>
|
||||||
|
);<br>
|
||||||
|
}<br>
|
||||||
|
<br>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<br>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.<br>
|
||||||
|
|
||||||
|
<table style="width: 100%; text-align: left;" class="mod-code" border="0" cellpadding="2" cellspacing="2">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="vertical-align: top;">if (interface_exists('\LAM\JOB\Job')) {<br>
|
||||||
|
<br>
|
||||||
|
/**<br>
|
||||||
|
* Job to notify users about password expiration.<br>
|
||||||
|
*<br>
|
||||||
|
* @package jobs<br>
|
||||||
|
*/<br>
|
||||||
|
class PPolicyPasswordNotifyJob implements \LAM\JOB\Job {<br>
|
||||||
|
[...]<br>
|
||||||
|
<br>
|
||||||
|
}<br>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
<h2>Basic job attributes</h2>
|
||||||
|
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.<br>
|
||||||
|
<br>
|
||||||
|
If your job requires any configuration options then use get/checkConfigOptions() functions.<br>
|
||||||
|
<br>
|
||||||
|
<h2>Database</h2>
|
||||||
|
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.<br>
|
||||||
|
Database access is specified with needsDatabaseAccess().<br>
|
||||||
|
<br>
|
||||||
|
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.<br>
|
||||||
|
<br>
|
||||||
|
<h2>Execution</h2>
|
||||||
|
When jobs are run the the execute() function is called. Please put all your logic in there.<br>
|
||||||
|
|
||||||
|
<span style="font-weight: bold;"></span>
|
||||||
|
<h2><span style="font-weight: bold;"></span></h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body></html>
|
Loading…
Reference in New Issue