Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
manageApplications.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Add, modify or delete WHAT application
8  *
9  *
10  * @param string $appname internal name of the application
11  * @param string $method may be "init","reinit","update","delete"
12  * @subpackage WSH
13  */
14 /**
15  */
16 include_once ("Class.Application.php");
17 global $action;
18 
19 $usage = new ApiUsage();
20 $usage->setDefinitionText("Manage application");
21 $appname = $usage->addRequiredParameter("appname", "application name");
22 $method = $usage->addOptionalParameter("method", "action to do", array(
23  "init",
24  "update",
25  "reinit",
26  "delete"
27 ) , "init");
28 
29 $usage->verify();
30 
31 echo " $appname...$method\n";
32 
33 $app = new Application();
34 
35 $Null = "";
36 
37 switch ($method) {
38  case "init":
39  $app->set($appname, $Null, null, true);
40  break;
41 
42  case "reinit":
43  $app->set($appname, $Null, null, false, false);
44  $ret = $app->InitApp($appname, false);
45  if ($ret === false) {
46  $action->exitError(sprintf("Error initializing application '%s'.", $appname));
47  }
48  break;
49 
50  case "update":
51  // Init if application is not already installed
52  $app->set($appname, $Null, null, true, false);
53  $ret = $app->InitApp($appname, true);
54  if ($ret === false) {
55  $action->exitError(sprintf("Error updating application '%s'.", $appname));
56  }
57  break;
58 
59  case "delete":
60  $app->set($appname, $Null, null, false);
61  if ($app->isAffected()) {
62  $err = $app->DeleteApp();
63  if ($err != '') {
64  $action->exitError($err);
65  }
66  } else {
67  echo "already deleted";
68  }
69  break;
70 }
71 
$ret
global $action
if($file) if($subject==""&&$file) if($subject=="") $err
Verify arguments for wsh programs.
← centre documentaire © anakeen