ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
Base.php
Go to the documentation of this file.
1 <?php
2 
4 
5 require_once('./webservice/soap/classes/class.ilSoapAdministration.php');
6 require_once('./Services/WebServices/SOAP/classes/class.ilSoapPluginException.php');
7 
10 use ilSoapMethod;
12 
18 abstract class Base extends ilSoapAdministration implements ilSoapMethod
19 {
20 
24  const TYPE_INT_ARRAY = 'tns:intArray';
25  const TYPE_STRING = 'xsd:string';
26  const TYPE_INT = 'xsd:int';
27  const TYPE_DOUBLE_ARRAY = 'tns:doubleArray';
28  const SID = 'sid';
29  const ORGU_REF_ID = 'orgu_ref_id';
30  const POSITION_ID = 'position_id';
31  const USR_IDS = 'usr_ids';
32  const USR_ID = 'usr_id';
33 
34 
38  public function getServiceStyle()
39  {
40  return 'rpc';
41  }
42 
43 
47  public function getServiceUse()
48  {
49  return 'encoded';
50  }
51 
52 
62  protected function initIliasAndCheckSession($session_id)
63  {
64  $this->initAuth($session_id);
65  $this->initIlias();
66  if (!$this->__checkSession($session_id)) {
67  throw new ilSoapPluginException($this->__getMessage());
68  }
69  }
70 
71 
79  protected function checkParameters(array $params)
80  {
81  for ($i = 0; $i < count($this->getInputParams()); $i++) {
82  if (!isset($params[$i])) {
83  $names = implode(', ', array_keys($this->getInputParams()));
84  throw new ilSoapPluginException("Request is missing at least one of the following parameters: $names");
85  }
86  }
87  }
88 
89 
93  public function getServiceNamespace()
94  {
95  return 'urn:' . ilOrgUnitSOAPServicesPlugin::PLUGIN_NAME;
96  }
97 
98 
102  abstract protected function getAdditionalInputParams();
103 
104 
108  final public function getInputParams()
109  {
110  return array_merge(
111  array(
112  self::SID => self::TYPE_STRING,
113  ),
114  $this->getAdditionalInputParams()
115  );
116  }
117 
118 
124  abstract protected function run(array $params);
125 
126 
133  public function execute(array $params)
134  {
135  $this->checkParameters($params);
136  $session_id = (isset($params[0])) ? $params[0] : '';
137  $this->init($session_id);
138 
139  // Check Permissions
140  global $DIC;
141  if (!$DIC->access()->checkAccess('write', '', \ilObjOrgUnit::getRootOrgRefId())) {
142  $this->error('Permission denied');
143  }
144 
145  $clean_params = array();
146  $i = 1;
147  foreach ($this->getAdditionalInputParams() as $key => $type) {
148  $clean_params[$key] = $params[$i];
149  $i++;
150  }
151 
152  return $this->run($clean_params);
153  }
154 
155 
161  protected function error($message)
162  {
163  throw $this->__raiseError($message, 'ERROR');
164  }
165 
166 
172  private function init($session_id)
173  {
174  $this->initIliasAndCheckSession($session_id); // Throws exception if session is not valid
175  }
176 }
$type
getServiceUse()
Get the service use, e.g.&#39;encoded&#39;string
Definition: Base.php:47
getInputParams()
Get the input parameters.Array keys must correspond to parameter names and values must correspond to ...
Definition: Base.php:108
__raiseError($a_message, $a_code)
global $DIC
Definition: goto.php:24
initIliasAndCheckSession($session_id)
Use this method at the beginning of your execute() method to check if the provided session ID is vali...
Definition: Base.php:62
static getRootOrgRefId()
initAuth($sid)
Init authentication.
$message
Definition: xapiexit.php:14
checkParameters(array $params)
Check that all input parameters are present when executing the soap method.
Definition: Base.php:79
getServiceStyle()
Get the service style, e.g.&#39;rpc&#39;string
Definition: Base.php:38
getServiceNamespace()
Get the namespace of the service where this method belongs to.string
Definition: Base.php:93
$i
Definition: metadata.php:24