| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| 2 | <html lang="en"><head> |
| 3 | <title>Module HowTo - Jobs</title> |
| 4 | |
| 5 | |
| 6 | |
| 7 | <link rel="stylesheet" type="text/css" href="style/layout.css"> |
| 8 | |
| 9 | |
| 10 | <link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico"> |
| 11 | |
| 12 | </head><body> |
| 13 | <div style="text-align: center;"> |
| 14 | <h1>Module HowTo - Jobs<br> |
| 15 | </h1> |
| 16 | <div style="text-align: left;"><br> |
| 17 | Jobs can be used to run actions in regular intervals like daily.<br> |
| 18 | They are configured on tab "Jobs" in LAM server profile.<br> |
| 19 | <br> |
| 20 | </div> |
| 21 | <div style="text-align: left;">See ppolicyUser module for an example.<br> |
| 22 | <br> |
| 23 | <h2>Adding the job class</h2> |
| 24 | The module defines the list of supported jobs with function |
| 25 | getSupportedJobs().<br> |
| 26 | <div class="mod-code"> |
| 27 | * Returns a list of jobs that can be run.<br> |
| 28 | *<br> |
| 29 | * @param LAMConfig $config configuration<br> |
| 30 | * @return array list of jobs<br> |
| 31 | */<br> |
| 32 | public function getSupportedJobs(&$config) {<br> |
| 33 | return array(<br> |
| 34 | new |
| 35 | PPolicyPasswordNotifyJob()<br> |
| 36 | );<br> |
| 37 | }<br> |
| 38 | <br> |
| 39 | </div> |
| 40 | <br>The job class itself can be in the module file or in any file |
| 41 | included |
| 42 | by the module file. Please add the class definition in an interface |
| 43 | check as the example below. The job interface is not loaded on all |
| 44 | pages.<br> |
| 45 | |
| 46 | <div class="mod-code"> |
| 47 | <br> |
| 48 | /**<br> |
| 49 | * Job to notify users about password expiration.<br> |
| 50 | *<br> |
| 51 | * @package jobs<br> |
| 52 | */<br> |
| 53 | class PPolicyPasswordNotifyJob implements \LAM\JOB\Job {<br> |
| 54 | [...]<br> |
| 55 | <br> |
| 56 | }<br> |
| 57 | </div> |
| 58 | <br> |
| 59 | <h2>Basic job attributes</h2> |
| 60 | Each job needs to provide a unique name, icon, alias and job |
| 61 | description. You need also to specify if multiple configurations of the |
| 62 | same job are allowed on a server profile.<br> |
| 63 | <br> |
| 64 | If your job requires any configuration options then use get/checkConfigOptions() functions.<br> |
| 65 | <br> |
| 66 | <h2>Database</h2> |
| 67 | Jobs can access a database to read and store data about job runs. Use |
| 68 | this e.g. if you need to save any status information across job runs.<br> |
| 69 | Database access is specified with needsDatabaseAccess().<br> |
| 70 | <br> |
| 71 | There is a built-in database upgrade mechanism. Your job must return |
| 72 | its current schema version with getDatabaseSchemaVersion() and LAM will |
| 73 | call updateSchemaVersion() whenever it detects a higher version in job |
| 74 | class than on database.<br> |
| 75 | <br> |
| 76 | <h2>Execution</h2> |
| 77 | When jobs are run the the execute() function is called. Please put all your logic in there.<br> |
| 78 | |
| 79 | </div> |
| 80 | </div> |
| 81 | |
| 82 | </body></html> |