Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Data/Class.Application.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * Document Object Definition
9  *
10  * @author Anakeen 2009
11  * @version $Id: $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  */
15 /**
16  */
17 include_once ("DATA/Class.Document.php");
18 /**
19  * Document Class
20  *
21  */
23 {
24  private $_app = null;
25  public $id = 0;
26  public $name = '';
27  function __construct(&$app)
28  {
29  if ($app) {
30  $this->_app = $app;
31  $this->id = $app->id;
32  $this->name = $app->name;
33  }
34  }
35  /**
36  * return parameter value
37  * @return string
38  */
39  function getParameter($key)
40  {
41 
42  if (!$this->_app) {
43  $this->error = sprintf(_("application not initialized"));
44  return null;
45  } else {
46  $out->value = $this->_app->getParam($key, null);
47  if ($out->value === null) $this->error = sprintf(_("parameter %s not exists") , $key);
48  $js = json_decode($out->value);
49  if ($js) $out->value = $js;
50  }
51  $out->error = $this->error;
52  return $out;
53  }
54  /**
55  * return parameter value
56  * @return string
57  */
58  function setParameter($key, $nv)
59  {
60  if (!$this->_app) {
61  $this->error = sprintf(_("application not initialized"));
62  return null;
63  } else {
64  $op = new ParamDef("", $key);
65  if ($op->isAffected()) {
66  if ($op->isuser == "Y") {
67  $this->_app->setParamU($key, $nv);
68  $out->value = $this->_app->getParam($key);
69  } else $this->error = sprintf(_("not authorized : parameter %s is not a user parameter") , $key);
70  } else {
71  $this->error = sprintf(_("parameter %s not exists") , $key);
72  }
73  }
74  $out->error = $this->error;
75  return $out;
76  }
77  /**
78  * return properties of application
79  */
80  function getApplication()
81  {
82  $info = array(
83  "id" => $this->_app->id,
84  "name" => $this->_app->name,
85  "description" => $this->_app->description ? _($this->_app->description) : '',
86  "label" => $this->_app->short_name ? _($this->_app->short_name) : '',
87  "icon" => $this->_app->icon ? 'Images/' . $this->_app->icon : '',
88  "available" => ($this->_app->available != 'N') ,
89  "version" => $this->_app->getParam("VERSION") ,
90  "displayable" => ($this->_app->displayable != 'N')
91  );
92 
93  return $info;
94  }
95  /**
96  * return list of executable actions
97  */
99  {
100 
101  $queryact = new QueryDb($action->dbaccess, "Action");
102  $queryact->AddQuery(sprintf("id_application=%d", $this->id));
103  $queryact->AddQuery("available!='N'");
104  $listact = $queryact->Query(0, 0, "TABLE");
105  $actions = array();
106  foreach ($listact as $k => $v) {
107  if ($this->_app->HasPermission($v["acl"])) {
108  $actions[] = array(
109  "id" => $v["id"],
110  "name" => $v["name"],
111  "root" => ($v["root"] == "Y") ,
112  "label" => ($v["short_name"]) ? _($v["short_name"]) : ''
113  );
114  }
115  }
116 
117  return $actions;
118  }
119 }
120 ?>
← centre documentaire © anakeen - published under CC License - Dynacase