Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
manageContextCrontab.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * API script to manipulate user crontab
8  * @subpackage
9  */
10 /**
11  */
12 
13 include_once ("WHAT/Class.Crontab.php");
14 include_once ("FDL/Lib.Util.php");
15 
16 $usage = new ApiUsage();
17 $usage->setDefinitionText("API script to manipulate user crontab");
18 $cmd = $usage->addRequiredParameter("cmd", "command to execute", array(
19  "list",
20  "register",
21  "unregister",
22  "unregister-all"
23 ));
24 $file = $usage->addOptionalParameter("file", "path to cronfile (needed for cmd=register|unregister)", null, NULL);
25 $user = $usage->addOptionalParameter("user", "id of user", null, NULL);
26 $usage->verify();
27 /*function usage()
28 {
29  print "\n";
30  print "wsh --api=crontab --cmd=list [--user=<uid>]\n";
31  print "wsh --api=crontab --cmd=<register|unregister> --file=<path/to/cronfile> [--user=<uid>]\n";
32  print "\n";
33 }*/
34 
35 switch ($cmd) {
36  case 'list':
37  $crontab = new Crontab($user);
38  $ret = $crontab->listAll();
39  if ($ret === FALSE) {
40  exit(1);
41  }
42  break;
43 
44  case 'register':
45  if ($file === NULL) {
46  error_log("Error: missing --file argument");
47  exit(1);
48  }
49  $crontab = new Crontab($user);
50  $ret = $crontab->registerFile($file);
51  if ($ret === FALSE) {
52  exit(1);
53  }
54  break;
55 
56  case 'unregister':
57  if ($file === NULL) {
58  error_log("Error: missing --file argument");
59  exit(1);
60  }
61  $crontab = new Crontab($user);
62  $ret = $crontab->unregisterFile($file);
63  if ($ret === FALSE) {
64  exit(1);
65  }
66  break;
67 
68  case 'unregister-all':
69  $crontab = new Crontab($user);
70  if ($crontab->unregisterAll() === false) {
71  exit(1);
72  }
73  break;
74 }
75 
76 exit(0);
$ret
switch($command) exit
Definition: checkVault.php:46
Verify arguments for wsh programs.
← centre documentaire © anakeen