ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 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 677 of file class.ilSoapObjectAdministration.php.

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

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

◆ addReferences()

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

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

References $DIC, ilObject\createReference(), ilObject\getRefId(), ILIAS\Repository\int(), ilObject\putInTree(), ilObject\setPermissions(), ilObjectXMLWriter\TIMING_DEACTIVATED, ilObjectXMLWriter\TIMING_PRESETTING, ilObjectXMLWriter\TIMING_TEMPORARILY_AVAILABLE, ilObjectActivation\TIMINGS_ACTIVATION, ilObjectActivation\TIMINGS_DEACTIVATED, and ilObjectActivation\TIMINGS_PRESETTING.

Referenced by getXMLTree().

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

◆ canAddType()

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

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

References $DIC, and ilSoapAdministration\raiseError().

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

1268  {
1269  // checking for target subtypes. Can we add source to target
1270  global $DIC;
1271 
1272  $objDefinition = $DIC['objDefinition'];
1273  $rbacsystem = $DIC['rbacsystem'];
1274 
1275  $allowed_types = array('root', 'cat', 'grp', 'crs', 'fold');
1276  if (!in_array($target_type, $allowed_types, true)) {
1277  return $this->raiseError(
1278  'No valid target type. Target must be reference id of "course, group, category or folder"',
1279  'Client'
1280  );
1281  }
1282 
1283  $allowed_subtypes = $objDefinition->getSubObjects($target_type);
1284  $allowed = array();
1285 
1286  foreach ($allowed_subtypes as $row) {
1287  if ($row['name'] !== 'rolf') {
1288  $allowed[] = $row['name'];
1289  }
1290  }
1291 
1292  if (!in_array($type, $allowed, true)) {
1293  return $this->raiseError(
1294  'Objects of type: ' . $type . ' are not allowed to be subobjects of type ' . $target_type . '!',
1295  'Client'
1296  );
1297  }
1298  if (!$rbacsystem->checkAccess('create', $target_id, $type)) {
1299  return $this->raiseError('No permission to create objects of type ' . $type . '!', 'Client');
1300  }
1301 
1302  return true;
1303  }
raiseError(string $a_message, $a_code)
global $DIC
Definition: feed.php:28
+ 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 1115 of file class.ilSoapObjectAdministration.php.

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

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

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

797  {
798  $this->initAuth($sid);
799  $this->initIlias();
800 
801  if (!$this->checkSession($sid)) {
802  return $this->raiseError($this->getMessage(), $this->getMessageCode());
803  }
804 
805  global $DIC;
806 
807  $tree = $DIC->repositoryTree();
808  $rbacsystem = $DIC['rbacsystem'];
809  $rbacadmin = $DIC['rbacadmin'];
810  $user = $DIC->user();
811 
812  if (!$del_obj = ilObjectFactory::getInstanceByRefId($reference_id, false)) {
813  return $this->raiseError(
814  'No valid reference id given.',
815  'Client'
816  );
817  }
818  if (!$rbacsystem->checkAccess('delete', $del_obj->getRefId())) {
819  return $this->raiseError(
820  'No permission to delete object with id: ' . $del_obj->getRefId() . '!',
821  'Client'
822  );
823  }
824 
825  if ($tree->isDeleted($reference_id)) {
826  return $this->raiseError('Node already deleted', 'Server');
827  }
828 
829  if ($del_obj->getType() === 'rolf') {
830  return $this->raiseError('Delete is not available for role folders.', 'Client');
831  }
832 
833  $subnodes = $tree->getSubTree($tree->getNodeData($reference_id));
834  foreach ($subnodes as $subnode) {
835  $rbacadmin->revokePermission($subnode["child"]);
836  }
837  if (!$tree->moveToTrash($reference_id, true, $user->getId())) {
838  return $this->raiseError('Node already deleted', 'Client');
839  }
840  return true;
841  }
raiseError(string $a_message, $a_code)
global $DIC
Definition: feed.php:28
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
+ 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.

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

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  }
raiseError(string $a_message, $a_code)
static _isInTrash(int $ref_id)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
XML writer class Class to simplify manual writing of xml documents.
+ 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.

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.

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  }
$res
Definition: ltiservices.php:69
const ROOT_FOLDER_ID
Definition: constants.php:32
raiseError(string $a_message, $a_code)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
XML writer class Class to simplify manual writing of xml documents.
+ 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.

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

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.
raiseError(string $a_message, $a_code)
global $DIC
Definition: feed.php:28
+ 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.

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

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 
143  $obj_id = ilObject::_lookupObjectId($ref_id);
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  }
raiseError(string $a_message, $a_code)
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
static _lookupObjectId(int $ref_id)
+ 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 1209 of file class.ilSoapObjectAdministration.php.

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

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

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

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 _lookupObjIdByImportId(string $import_id)
Get (latest) object id for an import id.
static _getAllReferences(int $id)
get all reference ids for object ID
raiseError(string $a_message, $a_code)
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
+ 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.

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

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  }
static _getAllReferences(int $id)
get all reference ids for object ID
raiseError(string $a_message, $a_code)
$ref_id
Definition: ltiauth.php:67
+ 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 392 of file class.ilSoapObjectAdministration.php.

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

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) || empty($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  }
raiseError(string $a_message, $a_code)
const SYSTEM_FOLDER_ID
Definition: constants.php:35
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
XML writer class Class to simplify manual writing of xml documents.
+ 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 452 of file class.ilSoapObjectAdministration.php.

References $DIC, Vendor\Package\$e, $lng, $location, $ref_id, $res, ilObject\_exists(), ilObject\_isInTrash(), ilObjUser\_lookupId(), ilObject\_lookupObjIdByImportId(), addReferences(), ilSoapAdministration\checkSession(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilParticipants\IL_CRS_ADMIN, ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilSoapAdministration\isFault(), ilSoapAdministration\raiseError(), and validateReferences().

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  $all = false;
470  if (!is_array($types) || empty($types)) {
471  $all = true;
472  }
473 
474  $filter = $types;
475 
476  global $DIC;
477 
478  $objDefinition = $DIC['objDefinition'];
479  $nodes = [];
480  foreach ($nodearray as $node) {
481  if (
482  !$objDefinition->isAdministrationObject($node['type']) &&
483  !$objDefinition->isSystemObject($node['type']) &&
484  ($all || !in_array($node['type'], $filter, true)) &&
485  $access->checkAccess("read", "", (int) $node['ref_id']) &&
486  ($tmp = ilObjectFactory::getInstanceByRefId($node['ref_id'], false))) {
487  $nodes[] = $tmp;
488  }
489  }
490 
491  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
492  $xml_writer = new ilObjectXMLWriter();
493  $xml_writer->enablePermissionCheck(true);
494  $xml_writer->setObjects($nodes);
495  $xml_writer->enableOperations(false);
496 
497  if (is_int($user_id)) {
498  $xml_writer->setUserId($user_id);
499  }
500 
501  if ($xml_writer->start()) {
502  return $xml_writer->getXML();
503  }
504 
505  return $this->raiseError('Cannot create object xml !', 'Server');
506  }
raiseError(string $a_message, $a_code)
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
XML writer class Class to simplify manual writing of xml documents.
+ 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 1047 of file class.ilSoapObjectAdministration.php.

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

1048  {
1049  $this->initAuth($sid);
1050  $this->initIlias();
1051 
1052  if (!$this->checkSession($sid)) {
1053  return $this->raiseError($this->getMessage(), $this->getMessageCode());
1054  }
1055 
1056  include_once './webservice/soap/classes/class.ilSoapUtils.php';
1057  global $DIC;
1058 
1059  $rbacreview = $DIC['rbacreview'];
1060  $rbacadmin = $DIC['rbacadmin'];
1061  $objDefinition = $DIC['objDefinition'];
1062  $rbacsystem = $DIC['rbacsystem'];
1063  $lng = $DIC['lng'];
1064  $ilUser = $DIC['ilUser'];
1065  $tree = $DIC['tree'];
1066 
1067  // does source object exist
1068  if (!$source_object_type = ilObjectFactory::getTypeByRefId($ref_id, false)) {
1069  return $this->raiseError('No valid source given.', 'Client');
1070  }
1071 
1072  // does target object exist
1073  if (!$target_object_type = ilObjectFactory::getTypeByRefId($target_id, false)) {
1074  return $this->raiseError('No valid target given.', 'Client');
1075  }
1076 
1077  // check for trash
1079  return $this->raiseError('Object is trashed.', 'Client');
1080  }
1081 
1082  if (ilObject::_isInTrash($target_id)) {
1083  return $this->raiseError('Object is trashed.', 'Client');
1084  }
1085 
1086  $canAddType = $this->canAddType($source_object_type, $target_object_type, $target_id);
1087  if ($this->isFault($canAddType)) {
1088  return $canAddType;
1089  }
1090 
1091  // check if object already linked to target
1092  $possibleChilds = $tree->getChildsByType($target_id, $ref_id);
1093  foreach ($possibleChilds as $child) {
1094  if ((int) $child["obj_id"] === $ref_id) {
1095  return $this->raiseError("Object already exists in target.", "Client");
1096  }
1097  }
1098 
1099  // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
1100  if ($tree->isGrandChild($ref_id, $target_id)) {
1101  return $this->raiseError("Cannot move object into itself.", "Client");
1102  }
1103 
1104  $old_parent = $tree->getParentId($ref_id);
1105  $tree->moveTree($ref_id, $target_id);
1106  $rbacadmin->adjustMovedObjectPermissions($ref_id, $old_parent);
1107 
1109  return true;
1110  }
raiseError(string $a_message, $a_code)
static getTypeByRefId(int $ref_id, bool $stop_on_error=true)
get object type by reference id
global $DIC
Definition: feed.php:28
canAddType(string $type, string $target_type, int $target_id)
$ref_id
Definition: ltiauth.php:67
$lng
static _isInTrash(int $ref_id)
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...
+ 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 846 of file class.ilSoapObjectAdministration.php.

References $DIC, Vendor\Package\$e, $lng, $ref_id, $res, ilObject\_getAllReferences(), ilObject\_isInTrash(), ilObject\_lookupObjectId(), ilObject\_lookupObjIdByImportId(), ilSoapAdministration\checkSession(), ilObjectFactory\getInstanceByObjId(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilSoapAdministration\isFault(), ilSoapAdministration\raiseError(), updateReferences(), and validateReferences().

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

References $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.

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  }
$res
Definition: ltiservices.php:69
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const ROOT_FOLDER_ID
Definition: constants.php:32
static getInstance(ilLuceneQueryParser $qp)
Get singleton instance.
raiseError(string $a_message, $a_code)
$ref_id
Definition: ltiauth.php:67
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
string $key
Consumer key/client ID value.
Definition: System.php:193
XML writer class Class to simplify manual writing of xml documents.
+ Here is the call graph for this function:

◆ updateReferences()

ilSoapObjectAdministration::updateReferences ( array  $a_object_data)
private

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

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

Referenced by removeFromSystemByImportId().

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

◆ validateReferences()

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

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

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

Referenced by getXMLTree(), and removeFromSystemByImportId().

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

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