ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
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=null, ?int $user_id=null)
 
 getXMLTree (string $sid, int $ref_id, ?array $types=null, ?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 28 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 657 of file class.ilSoapObjectAdministration.php.

658 {
659 $this->initAuth($sid);
660 $this->initIlias();
661
662 if (!$this->checkSession($sid)) {
663 return $this->raiseError($this->getMessage(), $this->getMessageCode());
664 }
665
666 global $DIC;
667
668 $objDefinition = $DIC['objDefinition'];
669 $rbacsystem = $DIC['rbacsystem'];
670 $tree = $DIC['tree'];
671
672 if (!$source_obj = ilObjectFactory::getInstanceByRefId($a_source_id, false)) {
673 return $this->raiseError(
674 'No valid source id given.',
675 'Client'
676 );
677 }
678 if (!$target_obj = ilObjectFactory::getInstanceByRefId($a_target_id, false)) {
679 return $this->raiseError(
680 'No valid target id given.',
681 'Client'
682 );
683 }
684
685 if (
686 !$objDefinition->allowLink($source_obj->getType()) and
687 $source_obj->getType() !== 'cat' and
688 $source_obj->getType() !== 'crs'
689 ) {
690 return $this->raiseError(
691 'Linking of object type: ' . $source_obj->getType() . ' is not allowed',
692 'Client'
693 );
694 }
695
696 $allowed_subtypes = $target_obj->getPossibleSubObjects();
697 $allowed = [];
698 foreach ($allowed_subtypes as $row) {
699 if ($row['name'] !== 'rolf') {
700 $allowed[] = $row['name'];
701 }
702 }
703 if (!in_array($source_obj->getType(), $allowed, true)) {
704 return $this->raiseError(
705 'Objects of type: ' . $source_obj->getType() . ' are not allowed to be subobjects of type ' .
706 $target_obj->getType() . '!',
707 'Client'
708 );
709 }
710
711 // Permission checks
712 if (!$rbacsystem->checkAccess('create', $target_obj->getRefId(), $source_obj->getType())) {
713 return $this->raiseError(
714 'No permission to create objects of type ' . $source_obj->getType() . '!',
715 'Client'
716 );
717 }
718 if (!$rbacsystem->checkAccess('delete', $source_obj->getRefId())) {
719 return $this->raiseError(
720 'No permission to link object with id: ' . $source_obj->getRefId() . '!',
721 'Client'
722 );
723 }
724
725 if ($source_obj->getType() !== 'cat' and $source_obj->getType() !== 'crs') {
726 // check if object already linked to target
727 $possibleChilds = $tree->getChildsByType($target_obj->getRefId(), $source_obj->getType());
728 foreach ($possibleChilds as $child) {
729 if ((int) $child["obj_id"] === $source_obj->getId()) {
730 return $this->raiseError("Object already linked to target.", "Client");
731 }
732 }
733
734 // Finally link it to target position
735
736 $new_ref_id = $source_obj->createReference();
737 $source_obj->putInTree($target_obj->getRefId());
738 $source_obj->setPermissions($target_obj->getRefId());
739
740 return $new_ref_id ?: "0";
741 }
742
743 $new_ref = null;
744 switch ($source_obj->getType()) {
745 case 'cat':
746 $new_ref = new ilObjCategoryReference();
747 break;
748
749 case 'crs':
750 $new_ref = new ilObjCourseReference();
751 break;
752 case 'grp':
753 $new_ref = new ilObjGroupReference();
754 break;
755 }
756 $new_ref->create();
757 $new_ref_id = $new_ref->createReference();
758
759 $new_ref->putInTree($target_obj->getRefId());
760 $new_ref->setPermissions($target_obj->getRefId());
761
762 $new_ref->setTargetId($source_obj->getId());
763 $new_ref->update();
764
765 if (!$new_ref instanceof ilObject) {
766 return 0;
767 }
768
769 return $new_ref_id ?: 0;
770 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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
Class ilObject Basic functions for all objects.
raiseError(string $a_message, $a_code)
global $DIC
Definition: shib_login.php:26

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 1382 of file class.ilSoapObjectAdministration.php.

1382 : void
1383 {
1384 global $DIC;
1385
1386 $tree = $DIC->repositoryTree();
1387 $ilLog = $DIC['ilLog'];
1388
1389 if (!isset($a_object_data['references']) || !count($a_object_data['references'])) {
1390 return;
1391 }
1392
1393 $original_id = $source->getRefId();
1394
1395 foreach ($a_object_data['references'] as $ref_data) {
1396 $new_ref_id = $original_id;
1397 if ($tree->getParentId($original_id) !== (int) $ref_data['parent_id']) {
1398 // New reference requested => create it
1399 $new_ref_id = $source->createReference();
1400 $source->putInTree($ref_data['parent_id']);
1401 $source->setPermissions($ref_data['parent_id']);
1402 }
1403 if (isset($ref_data['time_target']) /* and ($crs_ref_id = $tree->checkForParentType($new_ref_id,'crs')) */) {
1404 if (!isset($ref_data['time_target']['starting_time'])) {
1405 $ref_data['time_target']['starting_time'] = time();
1406 }
1407 if (!isset($ref_data['time_target']['ending_time'])) {
1408 $ref_data['time_target']['ending_time'] = time();
1409 }
1410
1411 $items = new ilObjectActivation();
1412 $items->toggleChangeable($ref_data['time_target']['changeable']);
1413 $items->setTimingStart($ref_data['time_target']['starting_time']);
1414 $items->setTimingEnd($ref_data['time_target']['ending_time']);
1415 $items->toggleVisible($ref_data['time_target']['timing_visibility']);
1416 $items->setSuggestionStart($ref_data['time_target']['suggestion_start']);
1417 $items->setSuggestionEnd($ref_data['time_target']['suggestion_end']);
1418
1419 switch ($ref_data['time_target']['timing_type']) {
1421 $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_DEACTIVATED . ' ' . $ref_data['time_target']['timing_type']);
1422 $items->setTimingType(ilObjectActivation::TIMINGS_DEACTIVATED);
1423 break;
1424
1426 $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_ACTIVATION . ' ' . $ref_data['time_target']['timing_type']);
1427 $items->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
1428 break;
1429
1431 $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_PRESETTING . ' ' . $ref_data['time_target']['timing_type']);
1432 $items->setTimingType(ilObjectActivation::TIMINGS_PRESETTING);
1433 break;
1434 }
1435 $items->update($new_ref_id);
1436 }
1437 }
1438 }
Class ilObjectActivation.
setPermissions(int $parent_ref_id)
createReference()
creates reference for object
putInTree(int $parent_ref_id)
maybe this method should be in tree object!?

References $DIC, ilObject\createReference(), ilObject\getRefId(), ilObject\putInTree(), ilObject\setPermissions(), 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:

◆ canAddType()

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

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

1239 {
1240 // checking for target subtypes. Can we add source to target
1241 global $DIC;
1242
1243 $objDefinition = $DIC['objDefinition'];
1244 $rbacsystem = $DIC['rbacsystem'];
1245
1246 $allowed_types = array('root', 'cat', 'grp', 'crs', 'fold');
1247 if (!in_array($target_type, $allowed_types, true)) {
1248 return $this->raiseError(
1249 'No valid target type. Target must be reference id of "course, group, category or folder"',
1250 'Client'
1251 );
1252 }
1253
1254 $allowed_subtypes = $objDefinition->getSubObjects($target_type);
1255 $allowed = array();
1256
1257 foreach ($allowed_subtypes as $row) {
1258 if ($row['name'] !== 'rolf') {
1259 $allowed[] = $row['name'];
1260 }
1261 }
1262
1263 if (!in_array($type, $allowed, true)) {
1264 return $this->raiseError(
1265 'Objects of type: ' . $type . ' are not allowed to be subobjects of type ' . $target_type . '!',
1266 'Client'
1267 );
1268 }
1269 if (!$rbacsystem->checkAccess('create', $target_id, $type)) {
1270 return $this->raiseError('No permission to create objects of type ' . $type . '!', 'Client');
1271 }
1272
1273 return true;
1274 }

References $DIC, 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 1092 of file class.ilSoapObjectAdministration.php.

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

References $DIC, $lng, ILIAS\UI\Implementation\Component\Input\Field\$options, 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 775 of file class.ilSoapObjectAdministration.php.

776 {
777 $this->initAuth($sid);
778 $this->initIlias();
779
780 if (!$this->checkSession($sid)) {
781 return $this->raiseError($this->getMessage(), $this->getMessageCode());
782 }
783
784 global $DIC;
785
786 $tree = $DIC->repositoryTree();
787 $rbacsystem = $DIC['rbacsystem'];
788 $rbacadmin = $DIC['rbacadmin'];
789 $user = $DIC->user();
790
791 if (!$del_obj = ilObjectFactory::getInstanceByRefId($reference_id, false)) {
792 return $this->raiseError(
793 'No valid reference id given.',
794 'Client'
795 );
796 }
797 if (!$rbacsystem->checkAccess('delete', $del_obj->getRefId())) {
798 return $this->raiseError(
799 'No permission to delete object with id: ' . $del_obj->getRefId() . '!',
800 'Client'
801 );
802 }
803
804 if ($tree->isDeleted($reference_id)) {
805 return $this->raiseError('Node already deleted', 'Server');
806 }
807
808 if ($del_obj->getType() === 'rolf') {
809 return $this->raiseError('Delete is not available for role folders.', 'Client');
810 }
811
812 $subnodes = $tree->getSubTree($tree->getNodeData($reference_id));
813 foreach ($subnodes as $subnode) {
814 $rbacadmin->revokePermission($subnode["child"]);
815 }
816 if (!$tree->moveToTrash($reference_id, true, $user->getId())) {
817 return $this->raiseError('Node already deleted', 'Client');
818 }
819 return true;
820 }

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 157 of file class.ilSoapObjectAdministration.php.

158 {
159 $this->initAuth($sid);
160 $this->initIlias();
161
162 if (!$this->checkSession($sid)) {
163 return $this->raiseError($this->getMessage(), $this->getMessageCode());
164 }
165
166 if (!$tmp_obj = ilObjectFactory::getInstanceByRefId($a_ref_id, false)) {
167 return $this->raiseError('Cannot create object instance!', 'Server');
168 }
169 if (ilObject::_isInTrash($a_ref_id)) {
170 return $this->raiseError("Object with ID $a_ref_id has been deleted.", 'Client');
171 }
172
173 $xml_writer = new ilObjectXMLWriter();
174 $xml_writer->enablePermissionCheck(true);
175 if (is_int($user_id)) {
176 $xml_writer->setUserId($user_id);
177 $xml_writer->enableOperations(true);
178 }
179 $xml_writer->setObjects(array($tmp_obj));
180 if ($xml_writer->start()) {
181 return $xml_writer->getXML();
182 }
183 return $this->raiseError('Cannot create object xml !', 'Server');
184 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _isInTrash(int $ref_id)

References $user_id, 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 189 of file class.ilSoapObjectAdministration.php.

190 {
191 $this->initAuth($sid);
192 $this->initIlias();
193
194 if (!$this->checkSession($sid)) {
195 return $this->raiseError($this->getMessage(), $this->getMessageCode());
196 }
197 if ($a_title === '') {
198 return $this->raiseError(
199 'No valid query string given.',
200 'Client'
201 );
202 }
203 $query_parser = new ilQueryParser($a_title);
204 $query_parser->setMinWordLength(0);
205 $query_parser->setCombination(ilQueryParser::QP_COMBINATION_AND);
206 $query_parser->parse();
207 if (!$query_parser->validate()) {
208 return $this->raiseError(
209 $query_parser->getMessage(),
210 'Client'
211 );
212 }
213
214 $object_search = new ilLikeObjectSearch($query_parser);
215 $object_search->setFields(array('title'));
216 $object_search->appendToFilter('role');
217 $object_search->appendToFilter('rolt');
218 $res = $object_search->performSearch();
219 if ($user_id) {
220 $res->setUserId($user_id);
221 }
222
223 $res->filter(ROOT_FOLDER_ID, true);
224
225 $objs = array();
226 foreach ($res->getUniqueResults() as $entry) {
227 if ($entry['type'] === 'role' || $entry['type'] === 'rolt') {
228 if ($tmp = ilObjectFactory::getInstanceByObjId($entry['obj_id'], false)) {
229 $objs[] = $tmp;
230 }
231 continue;
232 }
233 if ($tmp = ilObjectFactory::getInstanceByRefId($entry['ref_id'], false)) {
234 $objs[] = $tmp;
235 }
236 }
237 if (!count($objs)) {
238 return '';
239 }
240
241 $xml_writer = new ilObjectXMLWriter();
242 $xml_writer->enablePermissionCheck(true);
243 if (is_int($user_id)) {
244 $xml_writer->setUserId($user_id);
245 $xml_writer->enableOperations(true);
246 }
247 $xml_writer->setObjects($objs);
248 if ($xml_writer->start()) {
249 return $xml_writer->getXML();
250 }
251 return $this->raiseError('Cannot create object xml !', 'Server');
252 }
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, $user_id, 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 33 of file class.ilSoapObjectAdministration.php.

34 {
35 $this->initAuth($sid);
36 $this->initIlias();
37
38 if (!$this->checkSession($sid)) {
39 return $this->raiseError($this->getMessage(), $this->getMessageCode());
40 }
41 if (!$import_id) {
42 return $this->raiseError(
43 'No import id given.',
44 'Client'
45 );
46 }
47
48 global $DIC;
49
50 $ilLog = $DIC['ilLog'];
51 $obj_id = ilObject::_lookupObjIdByImportId($import_id);
52 $ilLog->write("SOAP getObjIdByImportId(): import_id = " . $import_id . ' obj_id = ' . $obj_id);
53 return $obj_id ?: "0";
54 }
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 118 of file class.ilSoapObjectAdministration.php.

119 {
120 $this->initAuth($sid);
121 $this->initIlias();
122
123 if (!$this->checkSession($sid)) {
124 return $this->raiseError($this->getMessage(), $this->getMessageCode());
125 }
126
127 if (!count($ref_ids)) {
128 return $this->raiseError('No reference id(s) given.', 'Client');
129 }
130
131 $obj_ids = [];
132 foreach ($ref_ids as $ref_id) {
133 $ref_id = trim($ref_id);
134 if (!is_numeric($ref_id)) {
135 return $this->raiseError('Reference ID has to be numeric. Value: ' . $ref_id, 'Client');
136 }
137
139 if (!$obj_id) {
140 return $this->raiseError('No object found for reference ID. Value: ' . $ref_id, 'Client');
141 }
142 if (!ilObject::_hasUntrashedReference($obj_id)) {
143 return $this->raiseError(
144 'No untrashed reference found for reference ID. Value: ' . $ref_id,
145 'Client'
146 );
147 }
148 $obj_ids[] = $obj_id;
149 }
150
151 return $obj_ids;
152 }
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:66

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 1184 of file class.ilSoapObjectAdministration.php.

1185 {
1186 $this->initAuth($sid);
1187 $this->initIlias();
1188
1189 if (!$this->checkSession($sid)) {
1190 return $this->raiseError($this->getMessage(), $this->getMessageCode());
1191 }
1192
1193 global $DIC;
1194
1195 $ilAccess = $DIC['ilAccess'];
1196 $objDefinition = $DIC['objDefinition'];
1197 $rbacsystem = $DIC['rbacsystem'];
1198 $lng = $DIC['lng'];
1199 $ilUser = $DIC['ilUser'];
1200
1201 if (!$rbacsystem->checkAccess('read', $ref_id)) {
1202 return $this->raiseError("Missing read permissions for object with reference id " . $ref_id, 'Client');
1203 }
1204
1206 return $this->raiseError("Object is in Trash", 'Client');
1207 }
1208 global $DIC;
1209
1210 $tree = $DIC['tree'];
1211 $lng = $DIC['lng'];
1212 $items = $tree->getPathFull($ref_id);
1213
1214 $xmlResultSet = new ilXMLResultSet();
1215 $xmlResultSet->addColumn("ref_id");
1216 $xmlResultSet->addColumn("type");
1217 $xmlResultSet->addColumn("title");
1218
1219 $writer = new ilXMLResultSetWriter($xmlResultSet);
1220 foreach ($items as $item) {
1221 if ((int) $item["ref_id"] === $ref_id) {
1222 continue;
1223 }
1224 if ($item["title"] === "ILIAS" && $item["type"] === "root") {
1225 $item["title"] = $lng->txt("repository");
1226 }
1227
1228 $row = new ilXMLResultSetRow();
1229 $xmlResultSet->addRow($row);
1230 $row->setValue("ref_id", $item["ref_id"]);
1231 $row->setValue("type", $item["type"]);
1232 $row->setValue("title", $item["title"]);
1233 }
1234 $writer->start();
1235 return $writer->getXML();
1236 }
Row Class for XMLResultSet.
XML Writer for XMLResultSet.

References $DIC, $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 59 of file class.ilSoapObjectAdministration.php.

60 {
61 $this->initAuth($sid);
62 $this->initIlias();
63
64 if (!$this->checkSession($sid)) {
65 return $this->raiseError($this->getMessage(), $this->getMessageCode());
66 }
67 if (!$import_id) {
68 return $this->raiseError(
69 'No import id given.',
70 'Client'
71 );
72 }
73
74 global $DIC;
75
76 $tree = $DIC->repositoryTree();
77 $obj_id = ilObject::_lookupObjIdByImportId($import_id);
78 $ref_ids = ilObject::_getAllReferences($obj_id);
79
80 $new_refs = [];
81 foreach ($ref_ids as $ref_id) {
82 if ($tree->isInTree($ref_id)) {
83 $new_refs[] = $ref_id;
84 }
85 }
86 return $new_refs;
87 }
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 92 of file class.ilSoapObjectAdministration.php.

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

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 = null,
?int  $user_id = null 
)
Returns
soap_fault|SoapFault|string|null

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

373 {
374 $this->initAuth($sid);
375 $this->initIlias();
376
377 if (!$this->checkSession($sid)) {
378 return $this->raiseError($this->getMessage(), $this->getMessageCode());
379 }
380
381 $all = false;
382
383 global $DIC;
384
385 $tree = $DIC['tree'];
386
387 if (!$target_obj = ilObjectFactory::getInstanceByRefId($ref_id, false)) {
388 return $this->raiseError(
389 'No valid reference id given.',
390 'Client'
391 );
392 }
393 if ($ref_id === SYSTEM_FOLDER_ID) {
394 return $this->raiseError(
395 'No valid reference id given.',
396 'Client'
397 );
398 }
399
400 if (!is_array($types) || empty($types)) {
401 $all = true;
402 }
403
404 $objs = array();
405
406 foreach ($tree->getChilds($ref_id, 'title') as $child) {
407 if ($all || in_array($child['type'], $types, true)) {
408 if ($tmp = ilObjectFactory::getInstanceByRefId($child['ref_id'], false)) {
409 $objs[] = $tmp;
410 }
411 }
412 }
413
414 $xml_writer = new ilObjectXMLWriter();
415 $xml_writer->enablePermissionCheck(true);
416 $xml_writer->setObjects($objs);
417 $xml_writer->enableOperations(true);
418 if (is_int($user_id)) {
419 $xml_writer->setUserId($user_id);
420 }
421
422 if ($xml_writer->start()) {
423 return $xml_writer->getXML();
424 }
425 return $this->raiseError('Cannot create object xml !', 'Server');
426 }
const SYSTEM_FOLDER_ID
Definition: constants.php:35

References $DIC, $ref_id, $user_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 = null,
?int  $user_id = null 
)
Returns
soap_fault|SoapFault|string|null

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

432 {
433 $this->initAuth($sid);
434 $this->initIlias();
435
436 if (!$this->checkSession($sid)) {
437 return $this->raiseError($this->getMessage(), $this->getMessageCode());
438 }
439
440 global $DIC;
441
442 $tree = $DIC['tree'];
443 $access = $DIC['ilAccess'];
444
445 $nodedata = $tree->getNodeData($ref_id);
446 $nodearray = $tree->getSubTree($nodedata);
447
448 $all = false;
449 if (!is_array($types) || empty($types)) {
450 $all = true;
451 }
452
453 $filter = $types;
454
455 global $DIC;
456
457 $objDefinition = $DIC['objDefinition'];
458 $nodes = [];
459 foreach ($nodearray as $node) {
460 if (
461 !$objDefinition->isAdministrationObject($node['type']) &&
462 !$objDefinition->isSystemObject($node['type']) &&
463 ($all || !in_array($node['type'], $filter, true)) &&
464 $access->checkAccess("read", "", (int) $node['ref_id']) &&
465 ($tmp = ilObjectFactory::getInstanceByRefId($node['ref_id'], false))
466 ) {
467 $nodes[] = $tmp;
468 }
469 }
470
471 $xml_writer = new ilObjectXMLWriter();
472 $xml_writer->enablePermissionCheck(true);
473 $xml_writer->setObjects($nodes);
474 $xml_writer->enableOperations(false);
475
476 if (is_int($user_id)) {
477 $xml_writer->setUserId($user_id);
478 }
479
480 if ($xml_writer->start()) {
481 return $xml_writer->getXML();
482 }
483
484 return $this->raiseError('Cannot create object xml !', 'Server');
485 }

References $DIC, $ref_id, $user_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 1025 of file class.ilSoapObjectAdministration.php.

1026 {
1027 $this->initAuth($sid);
1028 $this->initIlias();
1029
1030 if (!$this->checkSession($sid)) {
1031 return $this->raiseError($this->getMessage(), $this->getMessageCode());
1032 }
1033
1034 global $DIC;
1035
1036 $rbacreview = $DIC['rbacreview'];
1037 $rbacadmin = $DIC['rbacadmin'];
1038 $objDefinition = $DIC['objDefinition'];
1039 $rbacsystem = $DIC['rbacsystem'];
1040 $lng = $DIC['lng'];
1041 $ilUser = $DIC['ilUser'];
1042 $tree = $DIC['tree'];
1043
1044 // does source object exist
1045 if (!$source_object_type = ilObjectFactory::getTypeByRefId($ref_id, false)) {
1046 return $this->raiseError('No valid source given.', 'Client');
1047 }
1048
1049 // does target object exist
1050 if (!$target_object_type = ilObjectFactory::getTypeByRefId($target_id, false)) {
1051 return $this->raiseError('No valid target given.', 'Client');
1052 }
1053
1054 // check for trash
1056 return $this->raiseError('Object is trashed.', 'Client');
1057 }
1058
1059 if (ilObject::_isInTrash($target_id)) {
1060 return $this->raiseError('Object is trashed.', 'Client');
1061 }
1062
1063 $canAddType = $this->canAddType($source_object_type, $target_object_type, $target_id);
1064 if ($this->isFault($canAddType)) {
1065 return $canAddType;
1066 }
1067
1068 // check if object already linked to target
1069 $possibleChilds = $tree->getChildsByType($target_id, $ref_id);
1070 foreach ($possibleChilds as $child) {
1071 if ((int) $child["obj_id"] === $ref_id) {
1072 return $this->raiseError("Object already exists in target.", "Client");
1073 }
1074 }
1075
1076 // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
1077 if ($tree->isGrandChild($ref_id, $target_id)) {
1078 return $this->raiseError("Cannot move object into itself.", "Client");
1079 }
1080
1081 $old_parent = $tree->getParentId($ref_id);
1082 $tree->moveTree($ref_id, $target_id);
1083 $rbacadmin->adjustMovedObjectPermissions($ref_id, $old_parent);
1084
1086 return true;
1087 }
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, $lng, $ref_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 825 of file class.ilSoapObjectAdministration.php.

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

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 257 of file class.ilSoapObjectAdministration.php.

258 {
259 $this->initAuth($sid);
260 $this->initIlias();
261
262 if (!$this->checkSession($sid)) {
263 return $this->raiseError($this->getMessage(), $this->getMessageCode());
264 }
265
266 if ($combination !== 'and' && $combination !== 'or') {
267 return $this->raiseError(
268 'No valid combination given. Must be "and" or "or".',
269 'Client'
270 );
271 }
272
273 $highlighter = null;
274 if (ilSearchSettings::getInstance()->enabledLucene()) {
275 ilSearchSettings::getInstance()->setMaxHits(25);
276
277 $typeFilterQuery = '';
278 if (is_array($types)) {
279 foreach ($types as $objectType) {
280 if ($typeFilterQuery === '') {
281 $typeFilterQuery .= '+( ';
282 } else {
283 $typeFilterQuery .= 'OR';
284 }
285 $typeFilterQuery .= (' type:' . $objectType . ' ');
286 }
287 $typeFilterQuery .= ') ';
288 }
289
290 $query_parser = new ilLuceneQueryParser($typeFilterQuery . $key);
291 $query_parser->parse();
292
293 $searcher = ilLuceneSearcher::getInstance($query_parser);
294 $searcher->search();
295
297 $filter->setCandidates($searcher->getResult());
298 $filter->filter();
299
300 $result_ids = $filter->getResults();
301 $objs = array();
303 foreach ($result_ids as $ref_id => $obj_id) {
305 if ($obj instanceof ilObject) {
306 $objs[] = $obj;
307 }
308 }
309 $highlighter = new ilLuceneHighlighterResultParser();
310 if ($filter->getResultObjIds()) {
311 $highlighter = $searcher->highlight($filter->getResultObjIds());
312 }
313 } else {
314
315 $query_parser = new ilQueryParser($key);
316 $query_parser->setCombination($combination === 'and' ? ilQueryParser::QP_COMBINATION_AND : ilQueryParser::QP_COMBINATION_OR);
317 $query_parser->parse();
318 if (!$query_parser->validate()) {
319 return $this->raiseError(
320 $query_parser->getMessage(),
321 'Client'
322 );
323 }
324
325 $object_search = new ilLikeObjectSearch($query_parser);
326 $object_search->setFilter($types);
327 $res = $object_search->performSearch();
328 if (is_int($user_id)) {
329 $res->setUserId($user_id);
330 }
331 $res->setMaxHits(100);
332 $res->filter(ROOT_FOLDER_ID, $combination === 'and');
333 $counter = 0;
334 $objs = array();
335 foreach ($res->getUniqueResults() as $entry) {
336 $obj = ilObjectFactory::getInstanceByRefId($entry['ref_id'], false);
337 if ($obj instanceof ilObject) {
338 $objs[] = $obj;
339 }
340 }
341 }
342
343 if (!count($objs)) {
344 return '';
345 }
346
347 $xml_writer = new ilObjectXMLWriter();
348 if (ilSearchSettings::getInstance()->enabledLucene()) {
349 $xml_writer->enableReferences(false);
350 $xml_writer->setMode(ilObjectXMLWriter::MODE_SEARCH_RESULT);
351 $xml_writer->setHighlighter($highlighter);
352 }
353
354 $xml_writer->enablePermissionCheck(true);
355
356 if ($user_id) {
357 $xml_writer->setUserId($user_id);
358 $xml_writer->enableOperations(true);
359 }
360
361 $xml_writer->setObjects($objs);
362 if ($xml_writer->start()) {
363 return $xml_writer->getXML();
364 }
365
366 return $this->raiseError('Cannot create object xml !', 'Server');
367 }
Parses result XML from lucene search highlight.
static getInstance(ilLuceneQueryParser $qp)
Get singleton instance.
$counter

References $counter, $ref_id, $res, $user_id, 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 1338 of file class.ilSoapObjectAdministration.php.

1338 : void
1339 {
1340 global $DIC;
1341
1342 $tree = $DIC['tree'];
1343 $ilLog = $DIC['ilLog'];
1344
1345 if (!isset($a_object_data['references']) || !count($a_object_data['references'])) {
1346 return;
1347 }
1348
1349 foreach ($a_object_data['references'] as $ref_data) {
1350 if (isset($ref_data['time_target'])) {
1351 $old = ilObjectActivation::getItem($ref_data['ref_id']);
1352
1353 $items = new ilObjectActivation();
1354 $items->toggleChangeable($ref_data['time_target']['changeable'] ?? $old['changeable']);
1355 $items->setTimingStart($ref_data['time_target']['starting_time'] ?? $old['timing_start']);
1356 $items->setTimingEnd($ref_data['time_target']['ending_time'] ?? $old['timing_end']);
1357 $items->toggleVisible($ref_data['time_target']['timing_visibility'] ?? $old['visible']);
1358 $items->setSuggestionStart($ref_data['time_target']['suggestion_start'] ?? $old['suggestion_start']);
1359 $items->setSuggestionEnd($ref_data['time_target']['suggestion_end'] ?? $old['suggestion_end']);
1360
1361 switch ($ref_data['time_target']['timing_type']) {
1363 $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_DEACTIVATED . ' ' . $ref_data['time_target']['timing_type']);
1364 $items->setTimingType(ilObjectActivation::TIMINGS_DEACTIVATED);
1365 break;
1366
1368 $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_ACTIVATION . ' ' . $ref_data['time_target']['timing_type']);
1369 $items->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
1370 break;
1371
1373 $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_PRESETTING . ' ' . $ref_data['time_target']['timing_type']);
1374 $items->setTimingType(ilObjectActivation::TIMINGS_PRESETTING);
1375 break;
1376 }
1377 $items->update($ref_data['ref_id']);
1378 }
1379 }
1380 }
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 1276 of file class.ilSoapObjectAdministration.php.

1277 {
1278 global $DIC;
1279
1280 $ilAccess = $DIC['ilAccess'];
1281
1282 if (!isset($a_object_data['references']) || !count($a_object_data['references'])) {
1283 return true;
1284 }
1285 if ($a_action === 'create') {
1286 if (
1287 count($a_object_data['references']) > 1 && in_array(
1288 $a_object_data['type'],
1289 ['cat', 'crs', 'grp', 'fold'],
1290 true
1291 )
1292 ) {
1293 return $this->raiseError(
1294 "Cannot create references for type " . $a_object_data['type'],
1295 'Client'
1296 );
1297 }
1298 if (count($a_object_data['references']) === 1 && $a_target_id != $a_object_data['references'][0]['parent_id']) {
1299 return $this->raiseError(
1300 "Cannot create references for type " . $a_object_data['type'],
1301 'Client'
1302 );
1303 }
1304
1305 foreach ($a_object_data['references'] as $ref_data) {
1306 if (!$ref_data['parent_id']) {
1307 return $this->raiseError('Element References: No parent Id given!', 'Client');
1308 }
1309
1310 $target_type = ilObject::_lookupType(ilObject::_lookupObjId($ref_data['parent_id']));
1311 $can_add_type = $this->canAddType($a_object_data['type'], $target_type, $ref_data['parent_id']);
1312 if ($this->isFault($can_add_type)) {
1313 return $can_add_type;
1314 }
1315 }
1316 return true;
1317 }
1318
1319 if ($a_action === 'update') {
1320 foreach ($a_object_data['references'] as $ref_data) {
1321 if (!$ref_data['ref_id']) {
1322 return $this->raiseError('Element References: No reference id given!', 'Client');
1323 }
1324 // check permissions
1325 if (!$ilAccess->checkAccess('write', '', $ref_data['ref_id'])) {
1326 return $this->raiseError(
1327 'No write permission for object with reference id ' . $ref_data['ref_id'] . '!',
1328 'Client'
1329 );
1330 }
1331 // TODO: check if all references belong to the same object
1332 }
1333 return true;
1334 }
1335 return true;
1336 }
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)

References $DIC, 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: