Offline Server  1.6
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
off_domainapi.php
Go to the documentation of this file.
1 <?php
2 /**
3  * Return offline domains where current user is affected
4  *
5  * @author Anakeen
6  * @version $Id: $
7  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
8  * @package OFFLINE
9  * @subpackage
10  */
11 /**
12  */
13 
14 include_once ("OFFLINE/Class.DomainApi.php");
15 
16 /**
17  * View folders and document for exchange them
18  * @param Action &$action current action
19  */
20 function off_domainapi(Action &$action)
21 {
22  $method = $action->getArgument("method");
23  $id = $action->getArgument("id");
24  $use = $action->getArgument("use");
25  $redirect = $action->getArgument("htmlRedirect");
26 
27  $out = new stdClass();
28  $out->error = '';
29  if (method_exists("DomainApi", $use ? $use : $method)) {
30  if ($id) {
31  $domain = new_doc($action->dbaccess, $id);
32  if ((!$domain->isAlive()) || ($domain->control('view') != "")) {
33  $out->error = sprintf("unknow domain %s ", $id);
34  $domain = null;
35  }
36  } else {
37  $domain = null;
38  }
39  if (!$out->error) {
40  try {
41  $apiDomain = new DomainApi($domain);
42  if ($action->getArgument("use")) {
43  $apiDomain = $out = call_user_func(array(
44  $apiDomain,
45  $action->getArgument("use")
46  ));
47  if (!method_exists($apiDomain, $method)) {
48  $out->error = sprintf("method %s::%s not registered",get_class($apiDomain), $method);
49  }
50  } else {
51 
52  }
53  if (!$out->error) {
54  $aconfig=array_merge($_GET, $_POST);
55  $config=new stdClass();
56  $strip = get_magic_quotes_gpc();
57  foreach ($aconfig as $k=>$v) {
58  if ($strip) $v=stripslashes($v);
59  $vd=json_decode($v);
60  $config->$k=$vd?$vd:$v;
61  }
62  $out = call_user_func(array(
63  $apiDomain,
64  $method
65  ), $config);
66 
67  }
68  } catch ( Exception $e ) {
69  $out->error = $e->getMessage();
70  $out->errorContext=sprintf("exception in method %s", $method);
71  }
72  }
73  } else {
74  $out->error = sprintf("method %s not registered", $method);
75  }
76  if ($redirect) {
77  if ($out->error) $action->addWarningMsg($out->error);
78  redirect($action, 'FDL','FDL_CARD&latest=Y&refreshfld=Y&id='.$redirect);
79  } else {
80  $action->lay->template = json_encode($out);
81  $action->lay->noparse = true; // no need to parse after - increase performances
82  }
83 }
off_domainapi(Action &$action)
← centre documentaire © anakeen - published under CC License - Dynacase