Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
modapplicationparameter.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 
7 include_once ('WHAT/Class.Param.php');
8 /**
9  * Modify application parameters
10  * @param Action $action
11  */
13 {
14  $usage = new ActionUsage($action);
15  $appid = $usage->addRequiredParameter("appid", "application id");
16  $name = $usage->addRequiredParameter("name", "parameter name");
17  $type = $usage->addRequiredParameter("type", "type of parameter");
18  $value = $usage->addOptionalParameter("value", "value for parameter");
19  $usage->setStrictMode();
20  $usage->verify();
21 
22  header('Content-type: text/xml; charset=utf-8');
23 
24  $mb = microtime();
25 
26  $out = array(
27  "errors" => "",
28  "success" => true,
29  "parameterid" => $name,
30  "modify" => false
31  );
32  $app = new Application();
33  $null = null;
34  $err = $app->set($appid, $null);
35  if ($err) {
36  $out["success"] = false;
37  $out["errors"] = sprintf(_("Application not found: [%s]") , $appid);
38  } else {
39  $appid = $app->id;
40  $param = new Param($action->dbaccess, array(
41  $name,
42  $type,
43  $appid
44  ));
45  if ($param->isAffected()) {
46  $oldValue = $param->val;
47  $param->val = $value;
48  $err = $param->Modify();
49  if ($err) {
50  $out["success"] = false;
51  $out["errors"] = sprintf(_("an error has occured: %s") , $err);
52  } else {
53  if ($oldValue != $value) {
54  $out["modify"] = true;
55  }
56  }
57  } else {
58  $out["errors"] = sprintf(_("Parameter [%s] not found") , $name);
59  $out["success"] = false;
60  }
61  }
62 
63  $action->lay->set("success", $out["success"]);
64  $action->lay->set("warning", $out["errors"]);
65  $action->lay->set("count", 1);
66  $action->lay->set("parameterid", $out["parameterid"]);
67  $action->lay->set("modify", $out["modify"]);
68  $action->lay->set("delay", microtime_diff(microtime() , $mb));
69 }
global $action
$app
modapplicationparameter(Action &$action)
microtime_diff($a, $b)
Definition: Lib.Common.php:302
Verify arguments for action function.
if($file) if($subject==""&&$file) if($subject=="") $err
$null
$param
Definition: import_size.php:31
$usage
$value
← centre documentaire © anakeen