Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
param_mod.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  * Parameters modification
9  *
10  * @author Anakeen 2000
11  * @version $Id: param_mod.php,v 1.10 2006/06/22 12:52:40 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage APPMNG
15  */
16 /**
17  */
18 
19 include_once ("Class.SubForm.php");
20 include_once ("Class.Param.php");
21 // -----------------------------------
22 function param_mod(&$action)
23 {
24  // -----------------------------------
25  // Get all the params
26  $appid = GetHttpVars("appid");
27  $name = GetHttpVars("aname");
28  $atype = GetHttpVars("atype", PARAM_APP);
29  $val = GetHttpVars("val");
30  $direct = ($action->getArgument("direct") == "yes");
31  $err = '';
32  $ParamCour = new Param($action->dbaccess, array(
33  $name,
34  $atype,
35  $appid
36  ));
37 
38  $pdef = new paramdef($action->dbaccess, $name);
39  if (!$ParamCour->isAffected()) {
40  $ParamCour->appid = $appid;
41  $ParamCour->type = $atype;
42  $ParamCour->name = $name;
43  $ParamCour->val = $val;
44  $err = $ParamCour->Add();
45  if ($err != "") {
46  $action->addLogMsg($action->text("err_add_param") . " : $err");
47  } else {
48  $action->lay->set("textModify", _("param Changed"));
49  }
50  } else {
51  if (($pdef->kind == "password") && ($val == '*****')) {
52  $action->lay->set("textModify", _("param not changed"));
53  } else {
54  if ($ParamCour->val == $val || $pdef == 'static' || $pdef == 'readonly') {
55  $action->lay->set("textModify", _("param not changed"));
56  } else {
57  $ParamCour->val = $val;
58  $err = $ParamCour->Modify();
59  if ($err != "") {
60  $action->addLogMsg($action->text("err_mod_parameter") . " : $err");
61  } else {
62  $action->lay->set("textModify", _("param Changed"));
63  }
64  }
65  }
66  }
67  // reopen a new session to update parameters cache
68  //unset($_SESSION["CacheObj"]);
69  $prevact = $action->Read("PARAM_ACT", "PARAM_CULIST");
70 
71  if ($atype[0] == PARAM_USER) {
72  $action->parent->session->close();
73  } else {
74  $action->parent->session->closeAll();
75  }
76 
77  if (!$direct) redirect($action, "APPMNG", $prevact);
78  else {
79  $action->lay->set("error", json_encode($err));
80  if ($pdef->kind == "password") {
81  if ($ParamCour->val == '') $action->lay->set("value", json_encode($ParamCour->val));
82  else $action->lay->set("value", json_encode("*****"));
83  } else {
84  $action->lay->set("value", json_encode($ParamCour->val));
85  }
86  }
87 }
88 // -----------------------------------
89 function param_umod(&$action)
90 {
91  // -----------------------------------
92  $atype = GetHttpVars("atype", PARAM_APP);
93  $appid = GetHttpVars("appid");
94  if ($atype[0] != PARAM_USER) $action->exitError(_("only user parameters can be modified with its action"));
95  if (substr($atype, 1) != $action->user->id) $action->exitError(_("only current user parameters can be modified with its action"));
96 
98 }
99 ?>
← centre documentaire © anakeen - published under CC License - Dynacase