ILIAS  release_8 Revision v8.24
ilSoapObjectAdministration Class Reference
+ Inheritance diagram for ilSoapObjectAdministration:
+ Collaboration diagram for ilSoapObjectAdministration:

Public Member Functions

 getObjIdByImportId (string $sid, string $import_id)
 
 getRefIdsByImportId (string $sid, string $import_id)
 
 getRefIdsByObjId (string $sid, int $obj_id)
 
 getObjIdsByRefIds (string $sid, array $ref_ids)
 
 getObjectByReference (string $sid, int $a_ref_id, ?int $user_id=null)
 
 getObjectsByTitle (string $sid, string $a_title, ?int $user_id=null)
 
 searchObjects (string $sid, ?array $types, string $key, string $combination, ?int $user_id=null)
 
 getTreeChilds (string $sid, int $ref_id, ?array $types, ?int $user_id=null)
 
 getXMLTree (string $sid, int $ref_id, ?array $types, ?int $user_id=null)
 
 addReference (string $sid, int $a_source_id, int $a_target_id)
 
 deleteObject (string $sid, int $reference_id)
 
 removeFromSystemByImportId (string $sid, string $import_id)
 
 moveObject (string $sid, int $ref_id, int $target_id)
 
 copyObject (string $sid, string $copy_settings_xml)
 
 getPathForRefId (string $sid, int $ref_id)
 
- Public Member Functions inherited from ilSoapAdministration
 __construct (bool $use_nusoap=true)
 
 getMessage ()
 
 appendMessage (string $a_str)
 
 setMessageCode (string $a_code)
 
 getMessageCode ()
 
 reInitUser ()
 
 isFault ($object)
 
 getInstallationInfoXML ()
 
 getClientInfoXML (string $clientid)
 

Private Member Functions

 canAddType (string $type, string $target_type, int $target_id)
 
 validateReferences (string $a_action, array $a_object_data, int $a_target_id=0)
 
 updateReferences (array $a_object_data)
 
 addReferences (ilObject $source, array $a_object_data)
 

Additional Inherited Members

- Data Fields inherited from ilSoapAdministration
const NUSOAP = 1
 
const PHP5 = 2
 
int $error_method
 Defines type of error handling (PHP5 || NUSOAP) More...
 
- Protected Member Functions inherited from ilSoapAdministration
 checkSession (string $sid)
 
 explodeSid (string $sid)
 
 setMessage (string $a_str)
 
 initAuth (string $sid)
 
 initIlias ()
 
 initAuthenticationObject ()
 
 raiseError (string $a_message, $a_code)
 
 checkObjectAccess (int $ref_id, array $expected_type, string $permission, bool $returnObject=false)
 check access for ref id: expected type, permission, return object instance if returnobject is true More...
 
- Protected Attributes inherited from ilSoapAdministration
bool $soap_check = true
 
string $message = ''
 
string $message_code = ''
 

Detailed Description

Definition at line 33 of file class.ilSoapObjectAdministration.php.

Member Function Documentation

◆ addReference()

ilSoapObjectAdministration::addReference ( string  $sid,
int  $a_source_id,
int  $a_target_id 
)
Returns
int|soap_fault|SoapFault|string|null

Definition at line 672 of file class.ilSoapObjectAdministration.php.

673 {
674 $this->initAuth($sid);
675 $this->initIlias();
676
677 if (!$this->checkSession($sid)) {
678 return $this->raiseError($this->getMessage(), $this->getMessageCode());
679 }
680
681 global $DIC;
682
683 $objDefinition = $DIC['objDefinition'];
684 $rbacsystem = $DIC['rbacsystem'];
685 $tree = $DIC['tree'];
686
687 if (!$source_obj = ilObjectFactory::getInstanceByRefId($a_source_id, false)) {
688 return $this->raiseError(
689 'No valid source id given.',
690 'Client'
691 );
692 }
693 if (!$target_obj = ilObjectFactory::getInstanceByRefId($a_target_id, false)) {
694 return $this->raiseError(
695 'No valid target id given.',
696 'Client'
697 );
698 }
699
700 if (!$objDefinition->allowLink($source_obj->getType()) and
701 $source_obj->getType() !== 'cat' and
702 $source_obj->getType() !== 'crs') {
703 return $this->raiseError(
704 'Linking of object type: ' . $source_obj->getType() . ' is not allowed',
705 'Client'
706 );
707 }
708
709 $allowed_subtypes = $target_obj->getPossibleSubObjects();
710 $allowed = [];
711 foreach ($allowed_subtypes as $row) {
712 if ($row['name'] !== 'rolf') {
713 $allowed[] = $row['name'];
714 }
715 }
716 if (!in_array($source_obj->getType(), $allowed, true)) {
717 return $this->raiseError(
718 'Objects of type: ' . $source_obj->getType() . ' are not allowed to be subobjects of type ' .
719 $target_obj->getType() . '!',
720 'Client'
721 );
722 }
723
724 // Permission checks
725 if (!$rbacsystem->checkAccess('create', $target_obj->getRefId(), $source_obj->getType())) {
726 return $this->raiseError(
727 'No permission to create objects of type ' . $source_obj->getType() . '!',
728 'Client'
729 );
730 }
731 if (!$rbacsystem->checkAccess('delete', $source_obj->getRefId())) {
732 return $this->raiseError(
733 'No permission to link object with id: ' . $source_obj->getRefId() . '!',
734 'Client'
735 );
736 }
737
738 if ($source_obj->getType() !== 'cat' and $source_obj->getType() !== 'crs') {
739 // check if object already linked to target
740 $possibleChilds = $tree->getChildsByType($target_obj->getRefId(), $source_obj->getType());
741 foreach ($possibleChilds as $child) {
742 if ((int) $child["obj_id"] === $source_obj->getId()) {
743 return $this->raiseError("Object already linked to target.", "Client");
744 }
745 }
746
747 // Finally link it to target position
748
749 $new_ref_id = $source_obj->createReference();
750 $source_obj->putInTree($target_obj->getRefId());
751 $source_obj->setPermissions($target_obj->getRefId());
752
753 return $new_ref_id ?: "0";
754 }
755
756 $new_ref = null;
757 switch ($source_obj->getType()) {
758 case 'cat':
759 include_once('./Modules/CategoryReference/classes/class.ilObjCategoryReference.php');
760 $new_ref = new ilObjCategoryReference();
761 break;
762
763 case 'crs':
764 include_once('./Modules/CourseReference/classes/class.ilObjCourseReference.php');
765 $new_ref = new ilObjCourseReference();
766 break;
767 case 'grp':
768 include_once('./Modules/GroupReference/classes/class.ilObjGroupReference.php');
769 $new_ref = new ilObjGroupReference();
770 break;
771 }
772 $new_ref->create();
773 $new_ref_id = $new_ref->createReference();
774
775 $new_ref->putInTree($target_obj->getRefId());
776 $new_ref->setPermissions($target_obj->getRefId());
777
778 $new_ref->setTargetId($source_obj->getId());
779 $new_ref->update();
780
781 if (!$new_ref instanceof ilObject) {
782 return 0;
783 }
784
785 return $new_ref_id ?: 0;
786 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
raiseError(string $a_message, $a_code)
global $DIC
Definition: feed.php:28

References $DIC, ilSoapAdministration\checkSession(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\raiseError().

+ Here is the call graph for this function:

◆ addReferences()

ilSoapObjectAdministration::addReferences ( ilObject  $source,
array  $a_object_data 
)
private

Definition at line 1406 of file class.ilSoapObjectAdministration.php.

1406 : void
1407 {
1408 global $DIC;
1409
1410 $tree = $DIC->repositoryTree();
1411 $ilLog = $DIC['ilLog'];
1412
1413 if (!isset($a_object_data['references']) || !count($a_object_data['references'])) {
1414 return;
1415 }
1416
1417 $original_id = $source->getRefId();
1418
1419 foreach ($a_object_data['references'] as $ref_data) {
1420 $new_ref_id = $original_id;
1421 if ($tree->getParentId($original_id) !== (int) $ref_data['parent_id']) {
1422 // New reference requested => create it
1423 $new_ref_id = $source->createReference();
1424 $source->putInTree($ref_data['parent_id']);
1425 $source->setPermissions($ref_data['parent_id']);
1426 }
1427 if (isset($ref_data['time_target']) /* and ($crs_ref_id = $tree->checkForParentType($new_ref_id,'crs')) */) {
1428 include_once('./webservice/soap/classes/class.ilObjectXMLWriter.php');
1429 include_once('./Services/Object/classes/class.ilObjectActivation.php');
1430
1431 if (!isset($ref_data['time_target']['starting_time'])) {
1432 $ref_data['time_target']['starting_time'] = time();
1433 }
1434 if (!isset($ref_data['time_target']['ending_time'])) {
1435 $ref_data['time_target']['ending_time'] = time();
1436 }
1437
1438 $items = new ilObjectActivation();
1439 $items->toggleChangeable($ref_data['time_target']['changeable']);
1440 $items->setTimingStart($ref_data['time_target']['starting_time']);
1441 $items->setTimingEnd($ref_data['time_target']['ending_time']);
1442 $items->toggleVisible($ref_data['time_target']['timing_visibility']);
1443 $items->setSuggestionStart($ref_data['time_target']['suggestion_start']);
1444 $items->setSuggestionEnd($ref_data['time_target']['suggestion_end']);
1445
1446 switch ($ref_data['time_target']['timing_type']) {
1448 $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_DEACTIVATED . ' ' . $ref_data['time_target']['timing_type']);
1449 $items->setTimingType(ilObjectActivation::TIMINGS_DEACTIVATED);
1450 break;
1451
1453 $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_ACTIVATION . ' ' . $ref_data['time_target']['timing_type']);
1454 $items->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
1455 break;
1456
1458 $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_PRESETTING . ' ' . $ref_data['time_target']['timing_type']);
1459 $items->setTimingType(ilObjectActivation::TIMINGS_PRESETTING);
1460 break;
1461 }
1462 $items->update($new_ref_id);
1463 }
1464 }
1465 }
Class ilObjectActivation.
$source
Definition: metadata.php:93

References $DIC, $source, ilObjectXMLWriter\TIMING_DEACTIVATED, ilObjectXMLWriter\TIMING_PRESETTING, ilObjectXMLWriter\TIMING_TEMPORARILY_AVAILABLE, ilObjectActivation\TIMINGS_ACTIVATION, ilObjectActivation\TIMINGS_DEACTIVATED, and ilObjectActivation\TIMINGS_PRESETTING.

◆ canAddType()

ilSoapObjectAdministration::canAddType ( string  $type,
string  $target_type,
int  $target_id 
)
private

Definition at line 1262 of file class.ilSoapObjectAdministration.php.

1263 {
1264 // checking for target subtypes. Can we add source to target
1265 global $DIC;
1266
1267 $objDefinition = $DIC['objDefinition'];
1268 $rbacsystem = $DIC['rbacsystem'];
1269
1270 $allowed_types = array('root', 'cat', 'grp', 'crs', 'fold');
1271 if (!in_array($target_type, $allowed_types, true)) {
1272 return $this->raiseError(
1273 'No valid target type. Target must be reference id of "course, group, category or folder"',
1274 'Client'
1275 );
1276 }
1277
1278 $allowed_subtypes = $objDefinition->getSubObjects($target_type);
1279 $allowed = array();
1280
1281 foreach ($allowed_subtypes as $row) {
1282 if ($row['name'] !== 'rolf') {
1283 $allowed[] = $row['name'];
1284 }
1285 }
1286
1287 if (!in_array($type, $allowed, true)) {
1288 return $this->raiseError(
1289 'Objects of type: ' . $type . ' are not allowed to be subobjects of type ' . $target_type . '!',
1290 'Client'
1291 );
1292 }
1293 if (!$rbacsystem->checkAccess('create', $target_id, $type)) {
1294 return $this->raiseError('No permission to create objects of type ' . $type . '!', 'Client');
1295 }
1296
1297 return true;
1298 }
$target_id
Definition: goto.php:52
$target_type
Definition: goto.php:51
$type

References $DIC, $target_id, $target_type, $type, and ilSoapAdministration\raiseError().

Referenced by copyObject(), moveObject(), and validateReferences().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyObject()

ilSoapObjectAdministration::copyObject ( string  $sid,
string  $copy_settings_xml 
)
Returns
bool|int|mixed|soap_fault|SoapFault|null

Definition at line 1110 of file class.ilSoapObjectAdministration.php.

1111 {
1112 $this->initAuth($sid);
1113 $this->initIlias();
1114
1115 if (!$this->checkSession($sid)) {
1116 return $this->raiseError($this->getMessage(), $this->getMessageCode());
1117 }
1118
1119 include_once './webservice/soap/classes/class.ilSoapUtils.php';
1120 global $DIC;
1121
1122 $rbacreview = $DIC['rbacreview'];
1123 $objDefinition = $DIC['objDefinition'];
1124 $rbacsystem = $DIC['rbacsystem'];
1125 $lng = $DIC['lng'];
1126 $ilUser = $DIC['ilUser'];
1127
1128 include_once './webservice/soap/classes/class.ilCopyWizardSettingsXMLParser.php';
1129 $xml_parser = new ilCopyWizardSettingsXMLParser($copy_settings_xml);
1130 try {
1131 $xml_parser->startParsing();
1132 } catch (ilSaxParserException $se) {
1133 return $this->raiseError($se->getMessage(), "Client");
1134 }
1135
1136 // checking copy permissions, objects and create permissions
1137 if (!$rbacsystem->checkAccess('copy', $xml_parser->getSourceId())) {
1138 return $this->raiseError(
1139 "Missing copy permissions for object with reference id " . $xml_parser->getSourceId(),
1140 'Client'
1141 );
1142 }
1143
1144 // checking copy permissions, objects and create permissions
1145 $source_id = $xml_parser->getSourceId();
1146 $target_id = $xml_parser->getTargetId();
1147
1148 // does source object exist
1149 if (!$source_object_type = ilObjectFactory::getTypeByRefId($source_id, false)) {
1150 return $this->raiseError('No valid source given.', 'Client');
1151 }
1152
1153 // does target object exist
1154 if (!$target_object_type = ilObjectFactory::getTypeByRefId($xml_parser->getTargetId(), false)) {
1155 return $this->raiseError('No valid target given.', 'Client');
1156 }
1157
1158 $canAddType = $this->canAddType($source_object_type, $target_object_type, $target_id);
1159 if ($this->isFault($canAddType)) {
1160 return $canAddType;
1161 }
1162
1163 // if is container object than clone with sub items
1164 $options = $xml_parser->getOptions();
1165 // print_r($options);
1166 $source_object = ilObjectFactory::getInstanceByRefId($source_id);
1167 if ($source_object instanceof ilContainer) {
1168 // get client id from sid
1169 $clientid = substr($sid, strpos($sid, "::") + 2);
1170 $sessionid = str_replace("::" . $clientid, "", $sid);
1171 // call container clone
1172 $ret = $source_object->cloneAllObject(
1173 $sessionid,
1174 $clientid,
1175 $source_object_type,
1176 $target_id,
1177 $source_id,
1178 $options,
1179 true
1180 );
1181
1182 return $ret['ref_id'];
1183 }
1184
1185 // create copy wizard settings
1187 $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
1188 $wizard_options->saveOwner($ilUser->getId());
1189 $wizard_options->saveRoot($source_id);
1190
1191 foreach ($options as $source_id => $option) {
1192 $wizard_options->addEntry($source_id, $option);
1193 }
1194 $wizard_options->read();
1195
1196 // call object clone
1197 $newObject = $source_object->cloneObject($xml_parser->getTargetId(), $copy_id);
1198 return is_object($newObject) ? $newObject->getRefId() : -1;
1199 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _allocateCopyId()
Allocate a copy for further entries.
static _getInstance(int $a_copy_id)
static getTypeByRefId(int $ref_id, bool $stop_on_error=true)
get object type by reference id
SaxParserException thrown by ilSaxParser if property throwException is set.
canAddType(string $type, string $target_type, int $target_id)
$ilUser
Definition: imgupload.php:34
$lng

References $DIC, $ilUser, $lng, $target_id, ilCopyWizardOptions\_allocateCopyId(), ilCopyWizardOptions\_getInstance(), canAddType(), ilSoapAdministration\checkSession(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilObjectFactory\getTypeByRefId(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilSoapAdministration\isFault(), and ilSoapAdministration\raiseError().

+ Here is the call graph for this function:

◆ deleteObject()

ilSoapObjectAdministration::deleteObject ( string  $sid,
int  $reference_id 
)
Returns
bool|soap_fault|SoapFault|null

Definition at line 791 of file class.ilSoapObjectAdministration.php.

792 {
793 $this->initAuth($sid);
794 $this->initIlias();
795
796 if (!$this->checkSession($sid)) {
797 return $this->raiseError($this->getMessage(), $this->getMessageCode());
798 }
799
800 global $DIC;
801
802 $tree = $DIC->repositoryTree();
803 $rbacsystem = $DIC['rbacsystem'];
804 $rbacadmin = $DIC['rbacadmin'];
805 $user = $DIC->user();
806
807 if (!$del_obj = ilObjectFactory::getInstanceByRefId($reference_id, false)) {
808 return $this->raiseError(
809 'No valid reference id given.',
810 'Client'
811 );
812 }
813 if (!$rbacsystem->checkAccess('delete', $del_obj->getRefId())) {
814 return $this->raiseError(
815 'No permission to delete object with id: ' . $del_obj->getRefId() . '!',
816 'Client'
817 );
818 }
819
820 if ($tree->isDeleted($reference_id)) {
821 return $this->raiseError('Node already deleted', 'Server');
822 }
823
824 if ($del_obj->getType() === 'rolf') {
825 return $this->raiseError('Delete is not available for role folders.', 'Client');
826 }
827
828 $subnodes = $tree->getSubTree($tree->getNodeData($reference_id));
829 foreach ($subnodes as $subnode) {
830 $rbacadmin->revokePermission($subnode["child"]);
831 }
832 if (!$tree->moveToTrash($reference_id, true, $user->getId())) {
833 return $this->raiseError('Node already deleted', 'Client');
834 }
835 return true;
836 }

References $DIC, ilSoapAdministration\checkSession(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\raiseError().

+ Here is the call graph for this function:

◆ getObjectByReference()

ilSoapObjectAdministration::getObjectByReference ( string  $sid,
int  $a_ref_id,
?int  $user_id = null 
)
Returns
soap_fault|SoapFault|string|null

Definition at line 162 of file class.ilSoapObjectAdministration.php.

163 {
164 $this->initAuth($sid);
165 $this->initIlias();
166
167 if (!$this->checkSession($sid)) {
168 return $this->raiseError($this->getMessage(), $this->getMessageCode());
169 }
170
171 if (!$tmp_obj = ilObjectFactory::getInstanceByRefId($a_ref_id, false)) {
172 return $this->raiseError('Cannot create object instance!', 'Server');
173 }
174 if (ilObject::_isInTrash($a_ref_id)) {
175 return $this->raiseError("Object with ID $a_ref_id has been deleted.", 'Client');
176 }
177 include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
178
179 $xml_writer = new ilObjectXMLWriter();
180 $xml_writer->enablePermissionCheck(true);
181 if (is_int($user_id)) {
182 $xml_writer->setUserId($user_id);
183 $xml_writer->enableOperations(true);
184 }
185 $xml_writer->setObjects(array($tmp_obj));
186 if ($xml_writer->start()) {
187 return $xml_writer->getXML();
188 }
189 return $this->raiseError('Cannot create object xml !', 'Server');
190 }
XML writer class Class to simplify manual writing of xml documents.
static _isInTrash(int $ref_id)

References ilObject\_isInTrash(), ilSoapAdministration\checkSession(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\raiseError().

+ Here is the call graph for this function:

◆ getObjectsByTitle()

ilSoapObjectAdministration::getObjectsByTitle ( string  $sid,
string  $a_title,
?int  $user_id = null 
)
Returns
soap_fault|SoapFault|string|null

Definition at line 195 of file class.ilSoapObjectAdministration.php.

196 {
197 $this->initAuth($sid);
198 $this->initIlias();
199
200 if (!$this->checkSession($sid)) {
201 return $this->raiseError($this->getMessage(), $this->getMessageCode());
202 }
203 if ($a_title === '') {
204 return $this->raiseError(
205 'No valid query string given.',
206 'Client'
207 );
208 }
209 include_once './Services/Search/classes/class.ilQueryParser.php';
210 $query_parser = new ilQueryParser($a_title);
211 $query_parser->setMinWordLength(0);
212 $query_parser->setCombination(ilQueryParser::QP_COMBINATION_AND);
213 $query_parser->parse();
214 if (!$query_parser->validate()) {
215 return $this->raiseError(
216 $query_parser->getMessage(),
217 'Client'
218 );
219 }
220
221 include_once './Services/Search/classes/class.ilObjectSearchFactory.php';
222 include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
223 $object_search = new ilLikeObjectSearch($query_parser);
224 $object_search->setFields(array('title'));
225 $object_search->appendToFilter('role');
226 $object_search->appendToFilter('rolt');
227 $res = $object_search->performSearch();
228 if ($user_id) {
229 $res->setUserId($user_id);
230 }
231
232 $res->filter(ROOT_FOLDER_ID, true);
233
234 $objs = array();
235 foreach ($res->getUniqueResults() as $entry) {
236 if ($entry['type'] === 'role' || $entry['type'] === 'rolt') {
237 if ($tmp = ilObjectFactory::getInstanceByObjId($entry['obj_id'], false)) {
238 $objs[] = $tmp;
239 }
240 continue;
241 }
242 if ($tmp = ilObjectFactory::getInstanceByRefId($entry['ref_id'], false)) {
243 $objs[] = $tmp;
244 }
245 }
246 if (!count($objs)) {
247 return '';
248 }
249
250 include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
251
252 $xml_writer = new ilObjectXMLWriter();
253 $xml_writer->enablePermissionCheck(true);
254 if (is_int($user_id)) {
255 $xml_writer->setUserId($user_id);
256 $xml_writer->enableOperations(true);
257 }
258 $xml_writer->setObjects($objs);
259 if ($xml_writer->start()) {
260 return $xml_writer->getXML();
261 }
262 return $this->raiseError('Cannot create object xml !', 'Server');
263 }
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
const ROOT_FOLDER_ID
Definition: constants.php:32
$res
Definition: ltiservices.php:69

References $res, ilSoapAdministration\checkSession(), ilObjectFactory\getInstanceByObjId(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilQueryParser\QP_COMBINATION_AND, ilSoapAdministration\raiseError(), and ROOT_FOLDER_ID.

+ Here is the call graph for this function:

◆ getObjIdByImportId()

ilSoapObjectAdministration::getObjIdByImportId ( string  $sid,
string  $import_id 
)
Returns
int|soap_fault|SoapFault|string|null

Definition at line 38 of file class.ilSoapObjectAdministration.php.

39 {
40 $this->initAuth($sid);
41 $this->initIlias();
42
43 if (!$this->checkSession($sid)) {
44 return $this->raiseError($this->getMessage(), $this->getMessageCode());
45 }
46 if (!$import_id) {
47 return $this->raiseError(
48 'No import id given.',
49 'Client'
50 );
51 }
52
53 global $DIC;
54
55 $ilLog = $DIC['ilLog'];
56 $obj_id = ilObject::_lookupObjIdByImportId($import_id);
57 $ilLog->write("SOAP getObjIdByImportId(): import_id = " . $import_id . ' obj_id = ' . $obj_id);
58 return $obj_id ?: "0";
59 }
static _lookupObjIdByImportId(string $import_id)
Get (latest) object id for an import id.

References $DIC, ilObject\_lookupObjIdByImportId(), ilSoapAdministration\checkSession(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\raiseError().

+ Here is the call graph for this function:

◆ getObjIdsByRefIds()

ilSoapObjectAdministration::getObjIdsByRefIds ( string  $sid,
array  $ref_ids 
)
Returns
array|soap_fault|SoapFault|null

Definition at line 123 of file class.ilSoapObjectAdministration.php.

124 {
125 $this->initAuth($sid);
126 $this->initIlias();
127
128 if (!$this->checkSession($sid)) {
129 return $this->raiseError($this->getMessage(), $this->getMessageCode());
130 }
131
132 if (!count($ref_ids)) {
133 return $this->raiseError('No reference id(s) given.', 'Client');
134 }
135
136 $obj_ids = [];
137 foreach ($ref_ids as $ref_id) {
138 $ref_id = trim($ref_id);
139 if (!is_numeric($ref_id)) {
140 return $this->raiseError('Reference ID has to be numeric. Value: ' . $ref_id, 'Client');
141 }
142
144 if (!$obj_id) {
145 return $this->raiseError('No object found for reference ID. Value: ' . $ref_id, 'Client');
146 }
147 if (!ilObject::_hasUntrashedReference($obj_id)) {
148 return $this->raiseError(
149 'No untrashed reference found for reference ID. Value: ' . $ref_id,
150 'Client'
151 );
152 }
153 $obj_ids[] = $obj_id;
154 }
155
156 return $obj_ids;
157 }
static _lookupObjectId(int $ref_id)
static _hasUntrashedReference(int $obj_id)
checks whether an object has at least one reference that is not in trash
$ref_id
Definition: ltiauth.php:67

References $ref_id, ilObject\_hasUntrashedReference(), ilObject\_lookupObjectId(), ilSoapAdministration\checkSession(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\raiseError().

+ Here is the call graph for this function:

◆ getPathForRefId()

ilSoapObjectAdministration::getPathForRefId ( string  $sid,
int  $ref_id 
)
Returns
soap_fault|SoapFault|string|null

Definition at line 1204 of file class.ilSoapObjectAdministration.php.

1205 {
1206 $this->initAuth($sid);
1207 $this->initIlias();
1208
1209 if (!$this->checkSession($sid)) {
1210 return $this->raiseError($this->getMessage(), $this->getMessageCode());
1211 }
1212
1213 global $DIC;
1214
1215 $ilAccess = $DIC['ilAccess'];
1216 $objDefinition = $DIC['objDefinition'];
1217 $rbacsystem = $DIC['rbacsystem'];
1218 $lng = $DIC['lng'];
1219 $ilUser = $DIC['ilUser'];
1220
1221 if (!$rbacsystem->checkAccess('read', $ref_id)) {
1222 return $this->raiseError("Missing read permissions for object with reference id " . $ref_id, 'Client');
1223 }
1224
1226 return $this->raiseError("Object is in Trash", 'Client');
1227 }
1228 global $DIC;
1229
1230 $tree = $DIC['tree'];
1231 $lng = $DIC['lng'];
1232 $items = $tree->getPathFull($ref_id);
1233
1234 include_once 'webservice/soap/classes/class.ilXMLResultSet.php';
1235 include_once 'webservice/soap/classes/class.ilXMLResultSetWriter.php';
1236 include_once 'Modules/Course/classes/class.ilCourseXMLWriter.php';
1237
1238 $xmlResultSet = new ilXMLResultSet();
1239 $xmlResultSet->addColumn("ref_id");
1240 $xmlResultSet->addColumn("type");
1241 $xmlResultSet->addColumn("title");
1242
1243 $writer = new ilXMLResultSetWriter($xmlResultSet);
1244 foreach ($items as $item) {
1245 if ((int) $item["ref_id"] === $ref_id) {
1246 continue;
1247 }
1248 if ($item["title"] === "ILIAS" && $item["type"] === "root") {
1249 $item["title"] = $lng->txt("repository");
1250 }
1251
1252 $row = new ilXMLResultSetRow();
1253 $xmlResultSet->addRow($row);
1254 $row->setValue("ref_id", $item["ref_id"]);
1255 $row->setValue("type", $item["type"]);
1256 $row->setValue("title", $item["title"]);
1257 }
1258 $writer->start();
1259 return $writer->getXML();
1260 }
Row Class for XMLResultSet.
XML Writer for XMLResultSet.

References $DIC, $ilUser, $lng, $ref_id, ilObject\_isInTrash(), ilSoapAdministration\checkSession(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\raiseError().

+ Here is the call graph for this function:

◆ getRefIdsByImportId()

ilSoapObjectAdministration::getRefIdsByImportId ( string  $sid,
string  $import_id 
)
Returns
array|soap_fault|SoapFault|null

Definition at line 64 of file class.ilSoapObjectAdministration.php.

65 {
66 $this->initAuth($sid);
67 $this->initIlias();
68
69 if (!$this->checkSession($sid)) {
70 return $this->raiseError($this->getMessage(), $this->getMessageCode());
71 }
72 if (!$import_id) {
73 return $this->raiseError(
74 'No import id given.',
75 'Client'
76 );
77 }
78
79 global $DIC;
80
81 $tree = $DIC->repositoryTree();
82 $obj_id = ilObject::_lookupObjIdByImportId($import_id);
83 $ref_ids = ilObject::_getAllReferences($obj_id);
84
85 $new_refs = [];
86 foreach ($ref_ids as $ref_id) {
87 if ($tree->isInTree($ref_id)) {
88 $new_refs[] = $ref_id;
89 }
90 }
91 return $new_refs;
92 }
static _getAllReferences(int $id)
get all reference ids for object ID

References $DIC, $ref_id, ilObject\_getAllReferences(), ilObject\_lookupObjIdByImportId(), ilSoapAdministration\checkSession(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\raiseError().

+ Here is the call graph for this function:

◆ getRefIdsByObjId()

ilSoapObjectAdministration::getRefIdsByObjId ( string  $sid,
int  $obj_id 
)
Returns
array|soap_fault|SoapFault|null

Definition at line 97 of file class.ilSoapObjectAdministration.php.

98 {
99 $this->initAuth($sid);
100 $this->initIlias();
101
102 if (!$this->checkSession($sid)) {
103 return $this->raiseError($this->getMessage(), $this->getMessageCode());
104 }
105 if (!$obj_id) {
106 return $this->raiseError(
107 'No object id given.',
108 'Client'
109 );
110 }
111
112 $ref_ids = ilObject::_getAllReferences($obj_id);
113 $new_refs = [];
114 foreach ($ref_ids as $ref_id) {
115 $new_refs[] = $ref_id;
116 }
117 return $new_refs;
118 }

References $ref_id, ilObject\_getAllReferences(), ilSoapAdministration\checkSession(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\raiseError().

+ Here is the call graph for this function:

◆ getTreeChilds()

ilSoapObjectAdministration::getTreeChilds ( string  $sid,
int  $ref_id,
?array  $types,
?int  $user_id = null 
)
Returns
soap_fault|SoapFault|string|null

Definition at line 392 of file class.ilSoapObjectAdministration.php.

393 {
394 $this->initAuth($sid);
395 $this->initIlias();
396
397 if (!$this->checkSession($sid)) {
398 return $this->raiseError($this->getMessage(), $this->getMessageCode());
399 }
400
401 $all = false;
402
403 global $DIC;
404
405 $tree = $DIC['tree'];
406
407 if (!$target_obj = ilObjectFactory::getInstanceByRefId($ref_id, false)) {
408 return $this->raiseError(
409 'No valid reference id given.',
410 'Client'
411 );
412 }
413 if ($ref_id === SYSTEM_FOLDER_ID) {
414 return $this->raiseError(
415 'No valid reference id given.',
416 'Client'
417 );
418 }
419
420 if (!is_array($types)) {
421 $all = true;
422 }
423
424 $objs = array();
425
426 foreach ($tree->getChilds($ref_id, 'title') as $child) {
427 if ($all || in_array($child['type'], $types, true)) {
428 if ($tmp = ilObjectFactory::getInstanceByRefId($child['ref_id'], false)) {
429 $objs[] = $tmp;
430 }
431 }
432 }
433
434 include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
435 $xml_writer = new ilObjectXMLWriter();
436 $xml_writer->enablePermissionCheck(true);
437 $xml_writer->setObjects($objs);
438 $xml_writer->enableOperations(true);
439 if (is_int($user_id)) {
440 $xml_writer->setUserId($user_id);
441 }
442
443 if ($xml_writer->start()) {
444 return $xml_writer->getXML();
445 }
446 return $this->raiseError('Cannot create object xml !', 'Server');
447 }
const SYSTEM_FOLDER_ID
Definition: constants.php:35

References $DIC, $ref_id, ilSoapAdministration\checkSession(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilSoapAdministration\raiseError(), and SYSTEM_FOLDER_ID.

+ Here is the call graph for this function:

◆ getXMLTree()

ilSoapObjectAdministration::getXMLTree ( string  $sid,
int  $ref_id,
?array  $types,
?int  $user_id = null 
)
Returns
soap_fault|SoapFault|string|null

Definition at line 452 of file class.ilSoapObjectAdministration.php.

453 {
454 $this->initAuth($sid);
455 $this->initIlias();
456
457 if (!$this->checkSession($sid)) {
458 return $this->raiseError($this->getMessage(), $this->getMessageCode());
459 }
460
461 global $DIC;
462
463 $tree = $DIC['tree'];
464 $access = $DIC['ilAccess'];
465
466 $nodedata = $tree->getNodeData($ref_id);
467 $nodearray = $tree->getSubTree($nodedata);
468
469 $filter = $types;
470
471 global $DIC;
472
473 $objDefinition = $DIC['objDefinition'];
474 $nodes = [];
475 foreach ($nodearray as $node) {
476 if (
477 !$objDefinition->isAdministrationObject($node['type']) &&
478 !$objDefinition->isSystemObject($node['type']) &&
479 !in_array($node['type'], $filter, true) &&
480 $access->checkAccess("read", "", (int) $node['ref_id']) &&
481 ($tmp = ilObjectFactory::getInstanceByRefId($node['ref_id'], false))) {
482 $nodes[] = $tmp;
483 }
484 }
485
486 include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
487 $xml_writer = new ilObjectXMLWriter();
488 $xml_writer->enablePermissionCheck(true);
489 $xml_writer->setObjects($nodes);
490 $xml_writer->enableOperations(false);
491
492 if (is_int($user_id)) {
493 $xml_writer->setUserId($user_id);
494 }
495
496 if ($xml_writer->start()) {
497 return $xml_writer->getXML();
498 }
499
500 return $this->raiseError('Cannot create object xml !', 'Server');
501 }

References $DIC, $ref_id, ilSoapAdministration\checkSession(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\raiseError().

+ Here is the call graph for this function:

◆ moveObject()

ilSoapObjectAdministration::moveObject ( string  $sid,
int  $ref_id,
int  $target_id 
)
Returns
bool|soap_fault|SoapFault|null

Definition at line 1042 of file class.ilSoapObjectAdministration.php.

1043 {
1044 $this->initAuth($sid);
1045 $this->initIlias();
1046
1047 if (!$this->checkSession($sid)) {
1048 return $this->raiseError($this->getMessage(), $this->getMessageCode());
1049 }
1050
1051 include_once './webservice/soap/classes/class.ilSoapUtils.php';
1052 global $DIC;
1053
1054 $rbacreview = $DIC['rbacreview'];
1055 $rbacadmin = $DIC['rbacadmin'];
1056 $objDefinition = $DIC['objDefinition'];
1057 $rbacsystem = $DIC['rbacsystem'];
1058 $lng = $DIC['lng'];
1059 $ilUser = $DIC['ilUser'];
1060 $tree = $DIC['tree'];
1061
1062 // does source object exist
1063 if (!$source_object_type = ilObjectFactory::getTypeByRefId($ref_id, false)) {
1064 return $this->raiseError('No valid source given.', 'Client');
1065 }
1066
1067 // does target object exist
1068 if (!$target_object_type = ilObjectFactory::getTypeByRefId($target_id, false)) {
1069 return $this->raiseError('No valid target given.', 'Client');
1070 }
1071
1072 // check for trash
1074 return $this->raiseError('Object is trashed.', 'Client');
1075 }
1076
1078 return $this->raiseError('Object is trashed.', 'Client');
1079 }
1080
1081 $canAddType = $this->canAddType($source_object_type, $target_object_type, $target_id);
1082 if ($this->isFault($canAddType)) {
1083 return $canAddType;
1084 }
1085
1086 // check if object already linked to target
1087 $possibleChilds = $tree->getChildsByType($target_id, $ref_id);
1088 foreach ($possibleChilds as $child) {
1089 if ((int) $child["obj_id"] === $ref_id) {
1090 return $this->raiseError("Object already exists in target.", "Client");
1091 }
1092 }
1093
1094 // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
1095 if ($tree->isGrandChild($ref_id, $target_id)) {
1096 return $this->raiseError("Cannot move object into itself.", "Client");
1097 }
1098
1099 $old_parent = $tree->getParentId($ref_id);
1100 $tree->moveTree($ref_id, $target_id);
1101 $rbacadmin->adjustMovedObjectPermissions($ref_id, $old_parent);
1102
1104 return true;
1105 }
static _adjustMovedObjectConditions(int $a_ref_id)
In the moment it is not allowed to create preconditions on objects that are located outside of a cour...

References $DIC, $ilUser, $lng, $ref_id, $target_id, ilConditionHandler\_adjustMovedObjectConditions(), ilObject\_isInTrash(), canAddType(), ilSoapAdministration\checkSession(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilObjectFactory\getTypeByRefId(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilSoapAdministration\isFault(), and ilSoapAdministration\raiseError().

+ Here is the call graph for this function:

◆ removeFromSystemByImportId()

ilSoapObjectAdministration::removeFromSystemByImportId ( string  $sid,
string  $import_id 
)
Returns
bool|soap_fault|SoapFault|null

Definition at line 841 of file class.ilSoapObjectAdministration.php.

842 {
843 $this->initAuth($sid);
844 $this->initIlias();
845
846 if (!$this->checkSession($sid)) {
847 return $this->raiseError($this->getMessage(), $this->getMessageCode());
848 }
849 if ($import_id === '') {
850 return $this->raiseError(
851 'No import id given. Aborting!',
852 'Client'
853 );
854 }
855 global $DIC;
856
857 $rbacsystem = $DIC['rbacsystem'];
858 $tree = $DIC['tree'];
859 $ilLog = $DIC['ilLog'];
860
861 // get obj_id
862 if (!$obj_id = ilObject::_lookupObjIdByImportId($import_id)) {
863 return $this->raiseError(
864 'No object found with import id: ' . $import_id,
865 'Client'
866 );
867 }
868
869 // Check access
870 $permission_ok = false;
871 foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) {
872 if ($rbacsystem->checkAccess('delete', $ref_id)) {
873 $permission_ok = true;
874 break;
875 }
876 }
877 if (!$permission_ok) {
878 return $this->raiseError(
879 'No permission to delete the object with import id: ' . $import_id,
880 'Server'
881 );
882 }
883
884 // Delete all references (delete permssions and entries in object_reference)
885 foreach ($ref_ids as $ref_id) {
886 // All subnodes
887 $node_data = $tree->getNodeData($ref_id);
888 $subtree_nodes = $tree->getSubtree($node_data);
889
890 foreach ($subtree_nodes as $node) {
891 $ilLog->write('Soap: removeFromSystemByImportId(). Deleting object with title id: ' . $node['title']);
892 $tmp_obj = ilObjectFactory::getInstanceByRefId($node['ref_id']);
893 if (!is_object($tmp_obj)) {
894 return $this->raiseError(
895 'Cannot create instance of reference id: ' . $node['ref_id'],
896 'Server'
897 );
898 }
899 $tmp_obj->delete();
900 }
901 // Finally delete tree
902 $tree->deleteTree($node_data);
903 }
904 return true;
905 }

References $DIC, $ref_id, ilObject\_getAllReferences(), ilObject\_lookupObjIdByImportId(), ilSoapAdministration\checkSession(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\raiseError().

+ Here is the call graph for this function:

◆ searchObjects()

ilSoapObjectAdministration::searchObjects ( string  $sid,
?array  $types,
string  $key,
string  $combination,
?int  $user_id = null 
)
Returns
soap_fault|SoapFault|string|null

Definition at line 268 of file class.ilSoapObjectAdministration.php.

269 {
270 $this->initAuth($sid);
271 $this->initIlias();
272
273 if (!$this->checkSession($sid)) {
274 return $this->raiseError($this->getMessage(), $this->getMessageCode());
275 }
276
277 if ($combination !== 'and' && $combination !== 'or') {
278 return $this->raiseError(
279 'No valid combination given. Must be "and" or "or".',
280 'Client'
281 );
282 }
283
284 $highlighter = null;
285 include_once './Services/Search/classes/class.ilSearchSettings.php';
286 if (ilSearchSettings::getInstance()->enabledLucene()) {
287 ilSearchSettings::getInstance()->setMaxHits(25);
288
289 $typeFilterQuery = '';
290 if (is_array($types)) {
291 foreach ($types as $objectType) {
292 if ($typeFilterQuery === '') {
293 $typeFilterQuery .= '+( ';
294 } else {
295 $typeFilterQuery .= 'OR';
296 }
297 $typeFilterQuery .= (' type:' . $objectType . ' ');
298 }
299 $typeFilterQuery .= ') ';
300 }
301
302 include_once './Services/Search/classes/Lucene/class.ilLuceneQueryParser.php';
303 $query_parser = new ilLuceneQueryParser($typeFilterQuery . $key);
304 $query_parser->parse();
305
306 include_once './Services/Search/classes/Lucene/class.ilLuceneSearcher.php';
307 $searcher = ilLuceneSearcher::getInstance($query_parser);
308 $searcher->search();
309
310 include_once './Services/Search/classes/Lucene/class.ilLuceneSearchResultFilter.php';
311 include_once './Services/Search/classes/Lucene/class.ilLucenePathFilter.php';
312 $filter = ilLuceneSearchResultFilter::getInstance($user_id);
313 $filter->setCandidates($searcher->getResult());
314 $filter->filter();
315
316 $result_ids = $filter->getResults();
317 $objs = array();
319 foreach ($result_ids as $ref_id => $obj_id) {
321 if ($obj instanceof ilObject) {
322 $objs[] = $obj;
323 }
324 }
325 include_once './Services/Search/classes/Lucene/class.ilLuceneHighlighterResultParser.php';
326 $highlighter = new ilLuceneHighlighterResultParser();
327 if ($filter->getResultObjIds()) {
328 $highlighter = $searcher->highlight($filter->getResultObjIds());
329 }
330 } else {
331 include_once './Services/Search/classes/class.ilQueryParser.php';
332
333 $query_parser = new ilQueryParser($key);
334 $query_parser->setCombination($combination === 'and' ? ilQueryParser::QP_COMBINATION_AND : ilQueryParser::QP_COMBINATION_OR);
335 $query_parser->parse();
336 if (!$query_parser->validate()) {
337 return $this->raiseError(
338 $query_parser->getMessage(),
339 'Client'
340 );
341 }
342
343 include_once './Services/Search/classes/Like/class.ilLikeObjectSearch.php';
344 $object_search = new ilLikeObjectSearch($query_parser);
345 $object_search->setFilter($types);
346 $res = $object_search->performSearch();
347 if (is_int($user_id)) {
348 $res->setUserId($user_id);
349 }
350 $res->setMaxHits(100);
351 $res->filter(ROOT_FOLDER_ID, $combination === 'and');
352 $counter = 0;
353 $objs = array();
354 foreach ($res->getUniqueResults() as $entry) {
355 $obj = ilObjectFactory::getInstanceByRefId($entry['ref_id'], false);
356 if ($obj instanceof ilObject) {
357 $objs[] = $obj;
358 }
359 }
360 }
361
362 if (!count($objs)) {
363 return '';
364 }
365
366 include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
367 $xml_writer = new ilObjectXMLWriter();
368 if (ilSearchSettings::getInstance()->enabledLucene()) {
369 $xml_writer->enableReferences(false);
370 $xml_writer->setMode(ilObjectXMLWriter::MODE_SEARCH_RESULT);
371 $xml_writer->setHighlighter($highlighter);
372 }
373
374 $xml_writer->enablePermissionCheck(true);
375
376 if ($user_id) {
377 $xml_writer->setUserId($user_id);
378 $xml_writer->enableOperations(true);
379 }
380
381 $xml_writer->setObjects($objs);
382 if ($xml_writer->start()) {
383 return $xml_writer->getXML();
384 }
385
386 return $this->raiseError('Cannot create object xml !', 'Server');
387 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance(ilLuceneQueryParser $qp)
Get singleton instance.
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\LTI\ToolProvider\$key, $ref_id, $res, ilSoapAdministration\checkSession(), ilSearchSettings\getInstance(), ilLuceneSearcher\getInstance(), ilLuceneSearchResultFilter\getInstance(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilObjectXMLWriter\MODE_SEARCH_RESULT, ilQueryParser\QP_COMBINATION_AND, ilQueryParser\QP_COMBINATION_OR, ilSoapAdministration\raiseError(), and ROOT_FOLDER_ID.

+ Here is the call graph for this function:

◆ updateReferences()

ilSoapObjectAdministration::updateReferences ( array  $a_object_data)
private

Definition at line 1360 of file class.ilSoapObjectAdministration.php.

1360 : void
1361 {
1362 global $DIC;
1363
1364 $tree = $DIC['tree'];
1365 $ilLog = $DIC['ilLog'];
1366
1367 if (!isset($a_object_data['references']) || !count($a_object_data['references'])) {
1368 return;
1369 }
1370
1371 foreach ($a_object_data['references'] as $ref_data) {
1372 if (isset($ref_data['time_target'])) {
1373 include_once('./webservice/soap/classes/class.ilObjectXMLWriter.php');
1374 include_once('./Services/Object/classes/class.ilObjectActivation.php');
1375 $old = ilObjectActivation::getItem($ref_data['ref_id']);
1376
1377 $items = new ilObjectActivation();
1378 $items->toggleChangeable($ref_data['time_target']['changeable'] ?? $old['changeable']);
1379 $items->setTimingStart($ref_data['time_target']['starting_time'] ?? $old['timing_start']);
1380 $items->setTimingEnd($ref_data['time_target']['ending_time'] ?? $old['timing_end']);
1381 $items->toggleVisible($ref_data['time_target']['timing_visibility'] ?? $old['visible']);
1382 $items->setSuggestionStart($ref_data['time_target']['suggestion_start'] ?? $old['suggestion_start']);
1383 $items->setSuggestionEnd($ref_data['time_target']['suggestion_end'] ?? $old['suggestion_end']);
1384
1385 switch ($ref_data['time_target']['timing_type']) {
1387 $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_DEACTIVATED . ' ' . $ref_data['time_target']['timing_type']);
1388 $items->setTimingType(ilObjectActivation::TIMINGS_DEACTIVATED);
1389 break;
1390
1392 $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_ACTIVATION . ' ' . $ref_data['time_target']['timing_type']);
1393 $items->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
1394 break;
1395
1397 $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_PRESETTING . ' ' . $ref_data['time_target']['timing_type']);
1398 $items->setTimingType(ilObjectActivation::TIMINGS_PRESETTING);
1399 break;
1400 }
1401 $items->update($ref_data['ref_id']);
1402 }
1403 }
1404 }
static getItem(int $ref_id)

References $DIC, ilObjectActivation\getItem(), ilObjectXMLWriter\TIMING_DEACTIVATED, ilObjectXMLWriter\TIMING_PRESETTING, ilObjectXMLWriter\TIMING_TEMPORARILY_AVAILABLE, ilObjectActivation\TIMINGS_ACTIVATION, ilObjectActivation\TIMINGS_DEACTIVATED, and ilObjectActivation\TIMINGS_PRESETTING.

+ Here is the call graph for this function:

◆ validateReferences()

ilSoapObjectAdministration::validateReferences ( string  $a_action,
array  $a_object_data,
int  $a_target_id = 0 
)
private

Definition at line 1300 of file class.ilSoapObjectAdministration.php.

1301 {
1302 global $DIC;
1303
1304 $ilAccess = $DIC['ilAccess'];
1305
1306 if (!isset($a_object_data['references']) || !count($a_object_data['references'])) {
1307 return true;
1308 }
1309 if ($a_action === 'create') {
1310 if (count($a_object_data['references']) > 1 && in_array(
1311 $a_object_data['type'],
1312 ['cat', 'crs', 'grp', 'fold'],
1313 true
1314 )) {
1315 return $this->raiseError(
1316 "Cannot create references for type " . $a_object_data['type'],
1317 'Client'
1318 );
1319 }
1320 if (count($a_object_data['references']) === 1 && $a_target_id != $a_object_data['references'][0]['parent_id']) {
1321 return $this->raiseError(
1322 "Cannot create references for type " . $a_object_data['type'],
1323 'Client'
1324 );
1325 }
1326
1327 foreach ($a_object_data['references'] as $ref_data) {
1328 if (!$ref_data['parent_id']) {
1329 return $this->raiseError('Element References: No parent Id given!', 'Client');
1330 }
1331
1333 $can_add_type = $this->canAddType($a_object_data['type'], $target_type, $ref_data['parent_id']);
1334 if ($this->isFault($can_add_type)) {
1335 return $can_add_type;
1336 }
1337 }
1338 return true;
1339 }
1340
1341 if ($a_action === 'update') {
1342 foreach ($a_object_data['references'] as $ref_data) {
1343 if (!$ref_data['ref_id']) {
1344 return $this->raiseError('Element References: No reference id given!', 'Client');
1345 }
1346 // check permissions
1347 if (!$ilAccess->checkAccess('write', '', $ref_data['ref_id'])) {
1348 return $this->raiseError(
1349 'No write permission for object with reference id ' . $ref_data['ref_id'] . '!',
1350 'Client'
1351 );
1352 }
1353 // TODO: check if all references belong to the same object
1354 }
1355 return true;
1356 }
1357 return true;
1358 }
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)

References $DIC, $target_type, ilObject\_lookupObjId(), ilObject\_lookupType(), canAddType(), ilSoapAdministration\isFault(), and ilSoapAdministration\raiseError().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: