ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Base.php
Go to the documentation of this file.
1<?php
2
20
21use ilOrgUnitSOAPServicesPlugin;
23use ilSoapMethod;
25
30abstract class Base extends ilSoapAdministration implements ilSoapMethod
31{
35 public const TYPE_INT_ARRAY = 'tns:intArray';
36 public const TYPE_STRING = 'xsd:string';
37 public const TYPE_INT = 'xsd:int';
38 public const TYPE_DOUBLE_ARRAY = 'tns:doubleArray';
39 public const SID = 'sid';
40 public const ORGU_REF_ID = 'orgu_ref_id';
41 public const POSITION_ID = 'position_id';
42 public const USR_IDS = 'usr_ids';
43 public const USR_ID = 'usr_id';
44 protected \ilOrgUnitPositionDBRepository $positionRepo;
45 protected \ilOrgUnitUserAssignmentDBRepository $assignmentRepo;
46
47 public function getServiceStyle(): string
48 {
49 return 'rpc';
50 }
51
52 public function getServiceUse(): string
53 {
54 return 'encoded';
55 }
56
64 protected function initIliasAndCheckSession(string $session_id): void
65 {
66 $this->initAuth($session_id);
67 $this->initIlias();
68 if (!$this->checkSession($session_id)) {
69 throw new ilSoapPluginException($this->getMessage());
70 }
71 }
72
78 protected function checkParameters(array $params): void
79 {
80 for ($i = 0, $iMax = count($this->getInputParams()); $i < $iMax; $i++) {
81 if (!isset($params[$i])) {
82 $names = implode(', ', array_keys($this->getInputParams()));
83 throw new ilSoapPluginException("Request is missing at least one of the following parameters: $names");
84 }
85 }
86 }
87
88 public function getServiceNamespace(): string
89 {
90 return 'urn:' . ilOrgUnitSOAPServicesPlugin::PLUGIN_NAME;
91 }
92
93 abstract protected function getAdditionalInputParams(): array;
94
95 public function getInputParams(): array
96 {
97 return array_merge(
98 array(
99 self::SID => self::TYPE_STRING,
100 ),
102 );
103 }
104
105 abstract protected function run(array $params);
106
107 public function execute(array $params)
108 {
109 $this->checkParameters($params);
110 $session_id = (isset($params[0])) ? $params[0] : '';
111 $this->init($session_id);
112
113 // Check Permissions
114 global $DIC;
115 if (!$DIC->access()->checkAccess('write', '', \ilObjOrgUnit::getRootOrgRefId())) {
116 $this->addError('Permission denied');
117 }
118
119 $clean_params = array();
120 $i = 1;
121 foreach ($this->getAdditionalInputParams() as $key => $type) {
122 $clean_params[$key] = $params[$i];
123 $i++;
124 }
125
126 return $this->run($clean_params);
127 }
128
132 public function addError(string $message)
133 {
134 throw $this->raiseError($message, 'ERROR');
135 }
136
140 private function init(string $session_id): void
141 {
142 $this->initIliasAndCheckSession($session_id); // Throws exception if session is not valid
143
144 if (!isset($_GET["wsdl"])) {
146 $this->positionRepo = $dic["repo.Positions"];
147 $this->assignmentRepo = $dic["repo.UserAssignments"];
148 }
149 }
150}
ilOrgUnitUserAssignmentDBRepository $assignmentRepo
Definition: Base.php:45
ilOrgUnitPositionDBRepository $positionRepo
Definition: Base.php:44
init(string $session_id)
Definition: Base.php:140
initIliasAndCheckSession(string $session_id)
Use this method at the beginning of your execute() method to check if the provided session ID is vali...
Definition: Base.php:64
getInputParams()
Get the input parameters.
Definition: Base.php:95
checkParameters(array $params)
Check that all input parameters are present when executing the soap method.
Definition: Base.php:78
getServiceStyle()
Get the service style, e.g.
Definition: Base.php:47
getServiceNamespace()
Get the namespace of the service where this method belongs to.
Definition: Base.php:88
execute(array $params)
Execute the business logic for this SOAP method (when a SOAP request hits the endpoint defined by the...
Definition: Base.php:107
getServiceUse()
Get the service use, e.g.
Definition: Base.php:52
static getRootOrgRefId()
raiseError(string $a_message, $a_code)
Class ilSoapPluginException.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$_GET['cmd']
Definition: lti.php:26
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
$dic
Definition: ltiresult.php:33
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26