ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSoapObjectAdministration Class Reference
+ Inheritance diagram for ilSoapObjectAdministration:
+ Collaboration diagram for ilSoapObjectAdministration:

Public Member Functions

 addDesktopItems ($sid, $user_id, $reference_ids)
 Add desktop items for user. More...
 
 removeDesktopItems ($sid, $user_id, $reference_ids)
 Remove desktop items for user. More...
 
 getObjIdByImportId ($sid, $import_id)
 
 getRefIdsByImportId ($sid, $import_id)
 
 getRefIdsByObjId ($sid, $obj_id)
 
 getObjIdsByRefIds ($sid, $ref_ids)
 Returns a array of object ids which match the references id, given by a comma seperated string. More...
 
 getObjectByReference ($sid, $a_ref_id, $user_id)
 
 getObjectsByTitle ($sid, $a_title, $user_id)
 
 searchObjects ($sid, $types, $key, $combination, $user_id)
 
 getTreeChilds ($sid, $ref_id, $types, $user_id)
 
 getXMLTree ($sid, $ref_id, $types, $user_id)
 
 addReference ($sid, $a_source_id, $a_target_id)
 
 deleteObject ($sid, $reference_id)
 
 removeFromSystemByImportId ($sid, $import_id)
 
 moveObject ($sid, $ref_id, $target_id)
 
 copyObject ($sid, $copy_settings_xml)
 copy object in repository $sid session id $settings_xml contains copy wizard settings following ilias_copy_wizard_settings.dtd More...
 
 getPathForRefId ($sid, $ref_id)
 
- Public Member Functions inherited from ilSoapAdministration
 __construct ($use_nusoap=true)
 Constructor. More...
 
 initErrorWriter ()
 Overwrite error handler. More...
 
 __explodeSid ($sid)
 
 __setMessage ($a_str)
 
 __getMessage ()
 
 __appendMessage ($a_str)
 
 __setMessageCode ($a_code)
 
 __getMessageCode ()
 
 initAuth ($sid)
 Init authentication. More...
 
 initIlias ()
 
 __initAuthenticationObject ($a_auth_mode=AUTH_LOCAL)
 
 __raiseError ($a_message, $a_code)
 
 getNIC ($sid)
 get client information from current as xml result set More...
 
 isFault ($object)
 
 checkObjectAccess ($ref_id, $expected_type, $permission, $returnObject=false)
 check access for ref id: expected type, permission, return object instance if returnobject is true More...
 
 getInstallationInfoXML ()
 
 getClientInfoXML ($clientid)
 

Private Member Functions

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

Additional Inherited Members

- Static Public Member Functions inherited from ilSoapAdministration
static return_bytes ($val)
 calculate bytes from K,M,G modifiers e.g: 8M = 8 * 1024 * 1024 bytes More...
 
- Data Fields inherited from ilSoapAdministration
 $sauth = null
 
 $error_method = null
 
- Protected Attributes inherited from ilSoapAdministration
 $soap_check = true
 

Detailed Description

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

Member Function Documentation

◆ addDesktopItems()

ilSoapObjectAdministration::addDesktopItems (   $sid,
  $user_id,
  $reference_ids 
)

Add desktop items for user.

Parameters
string$sid
int$user_id
int[]$reference_ids
Returns
bool

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

References $DIC, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjectFactory\getInstanceByObjId(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

47  {
48  return; // abandonded
49  $this->initAuth($sid);
50  $this->initIlias();
51 
52  if (!$this->__checkSession($sid)) {
53  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
54  }
55 
56  global $DIC;
57 
58  $access = $DIC->rbac()->system();
59  $logger = $DIC->logger()->wsrv();
60 
61  if (!$access->checkAccess('edit_userassignment', ROLE_FOLDER_ID)) {
62  $logger->warning('Missing permission "edit_userassignment".');
63  return $this->__raiseError(
64  'Missing permission "edit_userassignment".',
65  'Client'
66  );
67  }
68 
69  $user = ilObjectFactory::getInstanceByObjId($user_id, false);
70  if (!$user instanceof ilObjUser) {
71  $logger->warning('Invalid user id given. Cannot instantiate user for id: ' . $user_id);
72  return $this->__raiseError(
73  'Invalid user id given. Cannot instantiate user for id: ' . $user_id,
74  'Client'
75  );
76  }
77  $num_added = 0;
78  foreach ($reference_ids as $ref_id) {
79  // short "validation" of reference id
80  $ref_obj = ilObjectFactory::getInstanceByRefId($ref_id, false);
81  if (!$ref_obj instanceof ilObject) {
82  $logger->warning('Invalid reference id passed to SOAP::addDesktopItems: ' . $ref_id);
83  continue;
84  }
85 
86  $num_added++;
87  /* ilObjUser::_addDesktopItem(
88  $user->getId(),
89  $ref_id,
90  ilObject::_lookupType($ref_id,true)
91  );*/
92  }
93  return $num_added;
94  }
__raiseError($a_message, $a_code)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
initAuth($sid)
Init authentication.
$DIC
Definition: xapitoken.php:46
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:

◆ addReference()

ilSoapObjectAdministration::addReference (   $sid,
  $a_source_id,
  $a_target_id 
)

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

References $DIC, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

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 (!is_numeric($a_source_id)) {
834  return $this->__raiseError(
835  'No source id given.',
836  'Client'
837  );
838  }
839  if (!is_numeric($a_target_id)) {
840  return $this->__raiseError(
841  'No target id given.',
842  'Client'
843  );
844  }
845 
846  global $DIC;
847 
848  $objDefinition = $DIC['objDefinition'];
849  $rbacsystem = $DIC['rbacsystem'];
850  $tree = $DIC['tree'];
851 
852  if (!$source_obj =&ilObjectFactory::getInstanceByRefId($a_source_id, false)) {
853  return $this->__raiseError(
854  'No valid source id given.',
855  'Client'
856  );
857  }
858  if (!$target_obj =&ilObjectFactory::getInstanceByRefId($a_target_id, false)) {
859  return $this->__raiseError(
860  'No valid target id given.',
861  'Client'
862  );
863  }
864 
865  if (!$objDefinition->allowLink($source_obj->getType()) and
866  $source_obj->getType() != 'cat' and
867  $source_obj->getType() != 'crs') {
868  return $this->__raiseError(
869  'Linking of object type: ' . $source_obj->getType() . ' is not allowed',
870  'Client'
871  );
872  }
873 
874  $allowed_subtypes = $target_obj->getPossibleSubObjects();
875  foreach ($allowed_subtypes as $row) {
876  if ($row['name'] != 'rolf') {
877  $allowed[] = $row['name'];
878  }
879  }
880  if (!in_array($source_obj->getType(), $allowed)) {
881  return $this->__raiseError(
882  'Objects of type: ' . $source_obj->getType() . ' are not allowed to be subobjects of type ' .
883  $target_obj->getType() . '!',
884  'Client'
885  );
886  }
887 
888  // Permission checks
889  if (!$rbacsystem->checkAccess('create', $target_obj->getRefId(), $source_obj->getType())) {
890  return $this->__raiseError(
891  'No permission to create objects of type ' . $source_obj->getType() . '!',
892  'Client'
893  );
894  }
895  if (!$rbacsystem->checkAccess('delete', $source_obj->getRefId())) {
896  return $this->__raiseError(
897  'No permission to link object with id: ' . $source_obj->getRefId() . '!',
898  'Client'
899  );
900  }
901 
902 
903  if ($source_obj->getType() != 'cat' and $source_obj->getType() != 'crs') {
904  // check if object already linked to target
905  $possibleChilds = $tree->getChildsByType($target_obj->getRefId(), $source_obj->getType());
906  foreach ($possibleChilds as $child) {
907  if ($child["obj_id"] == $source_obj->getId()) {
908  return $this->__raiseError("Object already linked to target.", "Client");
909  }
910  }
911 
912  // Finally link it to target position
913 
914  $new_ref_id = $source_obj->createReference();
915  $source_obj->putInTree($target_obj->getRefId());
916  $source_obj->setPermissions($target_obj->getRefId());
917 
918  return $new_ref_id ? $new_ref_id : "0";
919  } else {
920  switch ($source_obj->getType()) {
921  case 'cat':
922  include_once('./Modules/CategoryReference/classes/class.ilObjCategoryReference.php');
923  $new_ref = new ilObjCategoryReference();
924  break;
925 
926  case 'crs':
927  include_once('./Modules/CourseReference/classes/class.ilObjCourseReference.php');
928  $new_ref = new ilObjCourseReference();
929  break;
930  case 'grp':
931  include_once('./Modules/GroupReference/classes/class.ilObjGroupReference.php');
932  $new_ref = new ilObjGroupReference();
933  break;
934  }
935  $new_ref->create();
936  $new_ref_id = $new_ref->createReference();
937 
938  $new_ref->putInTree($target_obj->getRefId());
939  $new_ref->setPermissions($target_obj->getRefId());
940 
941  $new_ref->setTargetId($source_obj->getId());
942  $new_ref->update();
943 
944  return $new_ref_id ? $new_ref_id : 0;
945  }
946  }
__raiseError($a_message, $a_code)
initAuth($sid)
Init authentication.
$DIC
Definition: xapitoken.php:46
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:

◆ addReferences()

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

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

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

Referenced by getXMLTree().

1545  {
1546  global $DIC;
1547 
1548  $tree = $DIC['tree'];
1549  $ilLog = $DIC['ilLog'];
1550 
1551  if (!isset($a_object_data['references']) or !count($a_object_data['references'])) {
1552  return true;
1553  }
1554 
1555  $original_id = $source->getRefId();
1556 
1557  foreach ($a_object_data['references'] as $ref_data) {
1558  $new_ref_id = $ref_id = $original_id;
1559  if ($tree->getParentId($original_id) != $ref_data['parent_id']) {
1560  // New reference requested => create it
1561  $new_ref_id = $source->createReference();
1562  $source->putInTree($ref_data['parent_id']);
1563  $source->setPermissions($ref_data['parent_id']);
1564  }
1565  if (isset($ref_data['time_target']) /* and ($crs_ref_id = $tree->checkForParentType($new_ref_id,'crs')) */) {
1566  include_once('./webservice/soap/classes/class.ilObjectXMLWriter.php');
1567  include_once('./Services/Object/classes/class.ilObjectActivation.php');
1568 
1569  if (!isset($ref_data['time_target']['starting_time'])) {
1570  $ref_data['time_target']['starting_time'] = time();
1571  }
1572  if (!isset($ref_data['time_target']['ending_time'])) {
1573  $ref_data['time_target']['ending_time'] = time();
1574  }
1575 
1576  $items = new ilObjectActivation();
1577  $items->toggleChangeable($ref_data['time_target']['changeable']);
1578  $items->setTimingStart($ref_data['time_target']['starting_time']);
1579  $items->setTimingEnd($ref_data['time_target']['ending_time']);
1580  $items->toggleVisible($ref_data['time_target']['timing_visibility']);
1581  $items->setSuggestionStart($ref_data['time_target']['suggestion_start']);
1582  $items->setSuggestionEnd($ref_data['time_target']['suggestion_end']);
1583 
1584  switch ($ref_data['time_target']['timing_type']) {
1586  $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_DEACTIVATED . ' ' . $ref_data['time_target']['timing_type']);
1587  $items->setTimingType(ilObjectActivation::TIMINGS_DEACTIVATED);
1588  break;
1589 
1591  $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_ACTIVATION . ' ' . $ref_data['time_target']['timing_type']);
1592  $items->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
1593  break;
1594 
1596  $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_PRESETTING . ' ' . $ref_data['time_target']['timing_type']);
1597  $items->setTimingType(ilObjectActivation::TIMINGS_PRESETTING);
1598  break;
1599  }
1600  $items->update($new_ref_id);
1601  }
1602  }
1603  }
$DIC
Definition: xapitoken.php:46
Class ilObjectActivation.
$source
Definition: metadata.php:76
+ Here is the caller graph for this function:

◆ canAddType()

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

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

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

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

1409  {
1410  // checking for target subtypes. Can we add source to target
1411  global $DIC;
1412 
1413  $objDefinition = $DIC['objDefinition'];
1414  $rbacsystem = $DIC['rbacsystem'];
1415 
1416  $allowed_types = array('root','cat','grp','crs','fold');
1417  if (!in_array($target_type, $allowed_types)) {
1418  return $this->__raiseError('No valid target type. Target must be reference id of "course, group, category or folder"', 'Client');
1419  }
1420 
1421  $allowed_subtypes = $objDefinition->getSubObjects($target_type);
1422  $allowed = array();
1423 
1424  foreach ($allowed_subtypes as $row) {
1425  if ($row['name'] != 'rolf') {
1426  $allowed[] = $row['name'];
1427  }
1428  }
1429 
1430  if (!in_array($type, $allowed)) {
1431  return $this->__raiseError('Objects of type: ' . $type . ' are not allowed to be subobjects of type ' . $target_type . '!', 'Client');
1432  }
1433  if (!$rbacsystem->checkAccess('create', $target_id, $type)) {
1434  return $this->__raiseError('No permission to create objects of type ' . $type . '!', 'Client');
1435  }
1436 
1437  return true;
1438  }
$target_type
Definition: goto.php:48
$type
$target_id
Definition: goto.php:49
__raiseError($a_message, $a_code)
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyObject()

ilSoapObjectAdministration::copyObject (   $sid,
  $copy_settings_xml 
)

copy object in repository $sid session id $settings_xml contains copy wizard settings following ilias_copy_wizard_settings.dtd

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

References $DIC, $ilUser, $lng, $ret, $target_id, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilCopyWizardOptions\_allocateCopyId(), ilCopyWizardOptions\_getInstance(), canAddType(), ilObjectFactory\getInstanceByRefId(), ilObjectFactory\getTypeByRefId(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\isFault().

1259  {
1260  $this->initAuth($sid);
1261  $this->initIlias();
1262 
1263  if (!$this->__checkSession($sid)) {
1264  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
1265  }
1266 
1267 
1268  include_once './webservice/soap/classes/class.ilSoapUtils.php';
1269  global $DIC;
1270 
1271  $rbacreview = $DIC['rbacreview'];
1272  $objDefinition = $DIC['objDefinition'];
1273  $rbacsystem = $DIC['rbacsystem'];
1274  $lng = $DIC['lng'];
1275  $ilUser = $DIC['ilUser'];
1276 
1277  include_once './webservice/soap/classes/class.ilCopyWizardSettingsXMLParser.php';
1278  $xml_parser = new ilCopyWizardSettingsXMLParser($copy_settings_xml);
1279  try {
1280  $xml_parser->startParsing();
1281  } catch (ilSaxParserException $se) {
1282  return $this->__raiseError($se->getMessage(), "Client");
1283  }
1284 
1285  // checking copy permissions, objects and create permissions
1286  if (!$rbacsystem->checkAccess('copy', $xml_parser->getSourceId())) {
1287  return $this->__raiseError("Missing copy permissions for object with reference id " . $xml_parser->getSourceId(), 'Client');
1288  }
1289 
1290  // checking copy permissions, objects and create permissions
1291  $source_id = $xml_parser->getSourceId();
1292  $target_id = $xml_parser->getTargetId();
1293 
1294 
1295  // does source object exist
1296  if (!$source_object_type = ilObjectFactory::getTypeByRefId($source_id, false)) {
1297  return $this->__raiseError('No valid source given.', 'Client');
1298  }
1299 
1300  // does target object exist
1301  if (!$target_object_type = ilObjectFactory::getTypeByRefId($xml_parser->getTargetId(), false)) {
1302  return $this->__raiseError('No valid target given.', 'Client');
1303  }
1304 
1305 
1306  $canAddType = $this->canAddType($source_object_type, $target_object_type, $target_id);
1307  if ($this->isFault($canAddType)) {
1308  return $canAddType;
1309  }
1310 
1311  // if is container object than clone with sub items
1312  $options = $xml_parser->getOptions();
1313  // print_r($options);
1314  $source_object = ilObjectFactory::getInstanceByRefId($source_id);
1315  if ($source_object instanceof ilContainer) {
1316  // get client id from sid
1317  $clientid = substr($sid, strpos($sid, "::") + 2);
1318  $sessionid = str_replace("::" . $clientid, "", $sid);
1319  // call container clone
1320  $ret = $source_object->cloneAllObject(
1321  $sessionid,
1322  $clientid,
1323  $source_object_type,
1324  $target_id,
1325  $source_id,
1326  $options,
1327  true
1328  );
1329 
1330  return $ret['ref_id'];
1331  } else {
1332  // create copy wizard settings
1334  $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
1335  $wizard_options->saveOwner($ilUser->getId());
1336  $wizard_options->saveRoot($source_id);
1337 
1338  foreach ($options as $source_id => $option) {
1339  $wizard_options->addEntry($source_id, $option);
1340  }
1341  $wizard_options->read();
1342 
1343  // call object clone
1344  $newObject = $source_object->cloneObject($xml_parser->getTargetId(), $copy_id);
1345  return is_object($newObject) ? $newObject->getRefId() : -1;
1346  }
1347  }
$target_id
Definition: goto.php:49
SaxParserException thrown by ilSaxParser if property throwException is set.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
$lng
__raiseError($a_message, $a_code)
$ilUser
Definition: imgupload.php:18
static _allocateCopyId()
Allocate a copy for further entries.
Class ilContainer.
static getTypeByRefId($a_ref_id, $stop_on_error=true)
get object type by reference id
initAuth($sid)
Init authentication.
$ret
Definition: parser.php:6
$DIC
Definition: xapitoken.php:46
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
canAddType($type, $target_type, $target_id)
+ Here is the call graph for this function:

◆ deleteObject()

ilSoapObjectAdministration::deleteObject (   $sid,
  $reference_id 
)

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

References $DIC, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

949  {
950  $this->initAuth($sid);
951  $this->initIlias();
952 
953  if (!$this->__checkSession($sid)) {
954  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
955  }
956  if (!is_numeric($reference_id)) {
957  return $this->__raiseError(
958  'No reference id given.',
959  'Client'
960  );
961  }
962  global $DIC;
963 
964  $tree = $DIC->repositoryTree();
965  $rbacsystem = $DIC['rbacsystem'];
966  $rbacadmin = $DIC['rbacadmin'];
967  $user = $DIC->user();
968 
969  if (!$del_obj =&ilObjectFactory::getInstanceByRefId($reference_id, false)) {
970  return $this->__raiseError(
971  'No valid reference id given.',
972  'Client'
973  );
974  }
975  if (!$rbacsystem->checkAccess('delete', $del_obj->getRefId())) {
976  return $this->__raiseError(
977  'No permission to delete object with id: ' . $del_obj->getRefId() . '!',
978  'Client'
979  );
980  }
981 
982  // Delete tree
983  if ($tree->isDeleted($reference_id)) {
984  return $this->__raiseError('Node already deleted', 'Server');
985  }
986 
987  if ($del_obj->getType() == 'rolf') {
988  return $this->__raiseError('Delete is not available for role folders.', 'Client');
989  }
990 
991  $subnodes = $tree->getSubtree($tree->getNodeData($reference_id));
992  foreach ($subnodes as $subnode) {
993  $rbacadmin->revokePermission($subnode["child"]);
994  }
995  if (!$tree->moveToTrash($reference_id, true, $user->getId())) {
996  return $this->__raiseError('Node already deleted', 'Client');
997  }
998 
999  return true;
1000  }
__raiseError($a_message, $a_code)
initAuth($sid)
Init authentication.
$DIC
Definition: xapitoken.php:46
static getInstanceByRefId($a_ref_id, $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 (   $sid,
  $a_ref_id,
  $user_id 
)

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

References ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_isInTrash(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

282  {
283  $this->initAuth($sid);
284  $this->initIlias();
285 
286  if (!$this->__checkSession($sid)) {
287  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
288  }
289  if (!is_numeric($a_ref_id)) {
290  return $this->__raiseError(
291  'No valid reference id given. Please choose an existing reference id of an ILIAS object',
292  'Client'
293  );
294  }
295 
296  if (!$tmp_obj = ilObjectFactory::getInstanceByRefId($a_ref_id, false)) {
297  return $this->__raiseError('Cannot create object instance!', 'Server');
298  }
299 
300 
301  if (ilObject::_isInTrash($a_ref_id)) {
302  return $this->__raiseError("Object with ID $a_ref_id has been deleted.", 'Client');
303  }
304 
305  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
306 
307  $xml_writer = new ilObjectXMLWriter();
308  $xml_writer->enablePermissionCheck(true);
309  if ($user_id) {
310  $xml_writer->setUserId($user_id);
311  $xml_writer->enableOperations(true);
312  }
313  $xml_writer->setObjects(array($tmp_obj));
314  if ($xml_writer->start()) {
315  return $xml_writer->getXML();
316  }
317 
318  return $this->__raiseError('Cannot create object xml !', 'Server');
319  }
static _isInTrash($a_ref_id)
checks wether object is in trash
__raiseError($a_message, $a_code)
initAuth($sid)
Init authentication.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:

◆ getObjectsByTitle()

ilSoapObjectAdministration::getObjectsByTitle (   $sid,
  $a_title,
  $user_id 
)

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

References $res, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjectFactory\getInstanceByObjId(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and QP_COMBINATION_AND.

322  {
323  $this->initAuth($sid);
324  $this->initIlias();
325 
326  if (!$this->__checkSession($sid)) {
327  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
328  }
329  if (!strlen($a_title)) {
330  return $this->__raiseError(
331  'No valid query string given.',
332  'Client'
333  );
334  }
335 
336  include_once './Services/Search/classes/class.ilQueryParser.php';
337 
338  $query_parser = new ilQueryParser($a_title);
339  $query_parser->setMinWordLength(0, true);
340  $query_parser->setCombination(QP_COMBINATION_AND);
341  $query_parser->parse();
342  if (!$query_parser->validate()) {
343  return $this->__raiseError(
344  $query_parser->getMessage(),
345  'Client'
346  );
347  }
348 
349  include_once './Services/Search/classes/class.ilObjectSearchFactory.php';
350 
351  include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
352  $object_search = new ilLikeObjectSearch($query_parser);
353 
354  #$object_search =& ilObjectSearchFactory::_getObjectSearchInstance($query_parser);
355  $object_search->setFields(array('title'));
356  $object_search->appendToFilter('role');
357  $object_search->appendToFilter('rolt');
358  $res =&$object_search->performSearch();
359  if ($user_id) {
360  $res->setUserId($user_id);
361  }
362 
363  $res->filter(ROOT_FOLDER_ID, true);
364 
365  $objs = array();
366  foreach ($res->getUniqueResults() as $entry) {
367  if ($entry['type'] == 'role' or $entry['type'] == 'rolt') {
368  if ($tmp = ilObjectFactory::getInstanceByObjId($entry['obj_id'], false)) {
369  $objs[] = $tmp;
370  }
371  continue;
372  }
373  if ($tmp = ilObjectFactory::getInstanceByRefId($entry['ref_id'], false)) {
374  $objs[] = $tmp;
375  }
376  }
377  if (!count($objs)) {
378  return '';
379  }
380 
381  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
382 
383  $xml_writer = new ilObjectXMLWriter();
384  $xml_writer->enablePermissionCheck(true);
385  if ($user_id) {
386  $xml_writer->setUserId($user_id);
387  $xml_writer->enableOperations(true);
388  }
389  $xml_writer->setObjects($objs);
390  if ($xml_writer->start()) {
391  return $xml_writer->getXML();
392  }
393 
394  return $this->__raiseError('Cannot create object xml !', 'Server');
395  }
foreach($_POST as $key=> $value) $res
__raiseError($a_message, $a_code)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
initAuth($sid)
Init authentication.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
const QP_COMBINATION_AND
+ Here is the call graph for this function:

◆ getObjIdByImportId()

ilSoapObjectAdministration::getObjIdByImportId (   $sid,
  $import_id 
)

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

References $DIC, $ilLog, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_lookupObjIdByImportId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

157  {
158  $this->initAuth($sid);
159  $this->initIlias();
160 
161  if (!$this->__checkSession($sid)) {
162  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
163  }
164  if (!$import_id) {
165  return $this->__raiseError(
166  'No import id given.',
167  'Client'
168  );
169  }
170 
171  global $DIC;
172 
173  $ilLog = $DIC['ilLog'];
174 
175  $obj_id = ilObject::_lookupObjIdByImportId($import_id);
176  $ilLog->write("SOAP getObjIdByImportId(): import_id = " . $import_id . ' obj_id = ' . $obj_id);
177 
178  return $obj_id ? $obj_id : "0";
179  }
__raiseError($a_message, $a_code)
initAuth($sid)
Init authentication.
$DIC
Definition: xapitoken.php:46
static _lookupObjIdByImportId($a_import_id)
+ Here is the call graph for this function:

◆ getObjIdsByRefIds()

ilSoapObjectAdministration::getObjIdsByRefIds (   $sid,
  $ref_ids 
)

Returns a array of object ids which match the references id, given by a comma seperated string.

Parameters
string$sidSession ID
arrayof int $ref ids as comma separated list
Returns
array of ref ids, same order as object ids there for there might by duplicates

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

References ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_hasUntrashedReference(), ilObject\_lookupObjectId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

245  {
246  $this->initAuth($sid);
247  $this->initIlias();
248 
249  if (!$this->__checkSession($sid)) {
250  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
251  }
252 
253 
254  if (!count($ref_ids) || !is_array($ref_ids)) {
255  return $this->__raiseError('No reference id(s) given.', 'Client');
256  }
257 
258  $obj_ids = array();
259  if (count($ref_ids)) {
260  foreach ($ref_ids as $ref_id) {
261  $ref_id = trim($ref_id);
262  if (!is_numeric($ref_id)) {
263  return $this->__raiseError('Reference ID has to be numeric. Value: ' . $ref_id, 'Client');
264  }
265 
266  $obj_id = ilObject::_lookupObjectId($ref_id);
267  if (!$obj_id) {
268  return $this->__raiseError('No object found for reference ID. Value: ' . $ref_id, 'Client');
269  }
270  if (!ilObject::_hasUntrashedReference($obj_id)) {
271  return $this->__raiseError('No untrashed reference found for reference ID. Value: ' . $ref_id, 'Client');
272  }
273  $obj_ids[] = $obj_id;
274  }
275  }
276  return $obj_ids;
277  }
static _hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
static _lookupObjectId($a_ref_id)
lookup object id
__raiseError($a_message, $a_code)
initAuth($sid)
Init authentication.
+ Here is the call graph for this function:

◆ getPathForRefId()

ilSoapObjectAdministration::getPathForRefId (   $sid,
  $ref_id 
)

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

References $DIC, $ilUser, $lng, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_isInTrash(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

1350  {
1351  $this->initAuth($sid);
1352  $this->initIlias();
1353 
1354  if (!$this->__checkSession($sid)) {
1355  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
1356  }
1357 
1358  global $DIC;
1359 
1360  $ilAccess = $DIC['ilAccess'];
1361  $objDefinition = $DIC['objDefinition'];
1362  $rbacsystem = $DIC['rbacsystem'];
1363  $lng = $DIC['lng'];
1364  $ilUser = $DIC['ilUser'];
1365 
1366  if (!$rbacsystem->checkAccess('read', $ref_id)) {
1367  return $this->__raiseError("Missing read permissions for object with reference id " . $ref_id, 'Client');
1368  }
1369 
1370  if (ilObject::_isInTrash($ref_id)) {
1371  return $this->__raiseError("Object is in Trash", 'Client');
1372  }
1373  global $DIC;
1374 
1375  $tree = $DIC['tree'];
1376  $lng = $DIC['lng'];
1377  $items = $tree->getPathFull($ref_id);
1378 
1379  include_once 'webservice/soap/classes/class.ilXMLResultSet.php';
1380  include_once 'webservice/soap/classes/class.ilXMLResultSetWriter.php';
1381  include_once 'Modules/Course/classes/class.ilCourseXMLWriter.php';
1382 
1383  $xmlResultSet = new ilXMLResultSet();
1384  $xmlResultSet->addColumn("ref_id");
1385  $xmlResultSet->addColumn("type");
1386  $xmlResultSet->addColumn("title");
1387 
1388  $writer = new ilXMLResultSetWriter($xmlResultSet);
1389  foreach ($items as $item) {
1390  if ($item["ref_id"] == $ref_id) {
1391  continue;
1392  }
1393  if ($item["title"] == "ILIAS" && $item["type"] == "root") {
1394  $item["title"] = $lng->txt("repository");
1395  }
1396 
1397  $row = new ilXMLResultSetRow();
1398  $xmlResultSet->addRow($row);
1399  $row->setValue("ref_id", $item["ref_id"]);
1400  $row->setValue("type", $item["type"]);
1401  $row->setValue("title", $item["title"]);
1402  }
1403  $writer->start();
1404  return $writer->getXML();
1405  }
XML Writer for XMLResultSet.
static _isInTrash($a_ref_id)
checks wether object is in trash
$lng
__raiseError($a_message, $a_code)
$ilUser
Definition: imgupload.php:18
initAuth($sid)
Init authentication.
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

◆ getRefIdsByImportId()

ilSoapObjectAdministration::getRefIdsByImportId (   $sid,
  $import_id 
)

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

References $DIC, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_getAllReferences(), ilObject\_lookupObjIdByImportId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

182  {
183  $this->initAuth($sid);
184  $this->initIlias();
185 
186  if (!$this->__checkSession($sid)) {
187  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
188  }
189  if (!$import_id) {
190  return $this->__raiseError(
191  'No import id given.',
192  'Client'
193  );
194  }
195 
196  global $DIC;
197 
198  $tree = $DIC['tree'];
199 
200  $obj_id = ilObject::_lookupObjIdByImportId($import_id);
201 
202 
203  $ref_ids = ilObject::_getAllReferences($obj_id);
204 
205  foreach ($ref_ids as $ref_id) {
206  // only get non deleted reference ids
207  if ($tree->isInTree($ref_id)) {
208  $new_refs[] = $ref_id;
209  }
210  }
211  return $new_refs ? $new_refs : array();
212  }
static _getAllReferences($a_id)
get all reference ids of object
__raiseError($a_message, $a_code)
initAuth($sid)
Init authentication.
$DIC
Definition: xapitoken.php:46
static _lookupObjIdByImportId($a_import_id)
+ Here is the call graph for this function:

◆ getRefIdsByObjId()

ilSoapObjectAdministration::getRefIdsByObjId (   $sid,
  $obj_id 
)

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

References ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_getAllReferences(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

215  {
216  $this->initAuth($sid);
217  $this->initIlias();
218 
219  if (!$this->__checkSession($sid)) {
220  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
221  }
222  if (!$obj_id) {
223  return $this->__raiseError(
224  'No object id given.',
225  'Client'
226  );
227  }
228 
229  $ref_ids = ilObject::_getAllReferences($obj_id);
230  foreach ($ref_ids as $ref_id) {
231  $new_refs[] = $ref_id;
232  }
233  return $new_refs ? $new_refs : array();
234  }
static _getAllReferences($a_id)
get all reference ids of object
__raiseError($a_message, $a_code)
initAuth($sid)
Init authentication.
+ Here is the call graph for this function:

◆ getTreeChilds()

ilSoapObjectAdministration::getTreeChilds (   $sid,
  $ref_id,
  $types,
  $user_id 
)

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

References $DIC, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilFMSettings\getInstance(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

537  {
538  $this->initAuth($sid);
539  $this->initIlias();
540 
541  if (!$this->__checkSession($sid)) {
542  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
543  }
544 
545  $all = false;
546 
547  global $DIC;
548 
549  $tree = $DIC['tree'];
550 
551  if (!$target_obj =&ilObjectFactory::getInstanceByRefId($ref_id, false)) {
552  return $this->__raiseError(
553  'No valid reference id given.',
554  'Client'
555  );
556  }
557  if (intval($ref_id) == SYSTEM_FOLDER_ID) {
558  return $this->__raiseError(
559  'No valid reference id given.',
560  'Client'
561  );
562  }
563 
564  if (!$types) {
565  $all = true;
566  }
567 
568  $objs = array();
569 
570  // begin-patch filemanager
571  include_once './Services/WebServices/FileManager/classes/class.ilFMSettings.php';
572  if (in_array('parent', (array) $types)) {
573  $objs[] = $target_obj;
574  }
575  // end-patch filemanager
576 
577  foreach ($tree->getChilds($ref_id, 'title') as $child) {
578  if ($all or in_array($child['type'], $types)) {
579  if ($tmp = ilObjectFactory::getInstanceByRefId($child['ref_id'], false)) {
580  $objs[] = $tmp;
581  }
582  }
583  }
584 
585  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
586 
587  $xml_writer = new ilObjectXMLWriter();
588  // begin-patch filemanager
589  if (ilFMSettings::getInstance()->isEnabled()) {
590  $xml_writer->enableReferences(false);
591  }
592  // end-patch filemanager
593  $xml_writer->enablePermissionCheck(true);
594  $xml_writer->setObjects($objs);
595  $xml_writer->enableOperations(true);
596  if ($user_id) {
597  $xml_writer->setUserId($user_id);
598  }
599 
600  if ($xml_writer->start()) {
601  #$GLOBALS['DIC']['ilLog']->write(__METHOD__.': '.$xml_writer->getXML());
602  return $xml_writer->getXML();
603  }
604 
605  return $this->__raiseError('Cannot create object xml !', 'Server');
606  }
__raiseError($a_message, $a_code)
static getInstance()
Get singleton instance.
initAuth($sid)
Init authentication.
$DIC
Definition: xapitoken.php:46
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:

◆ getXMLTree()

ilSoapObjectAdministration::getXMLTree (   $sid,
  $ref_id,
  $types,
  $user_id 
)

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

References $DIC, Vendor\Package\$e, $ilUser, $lng, $location, $res, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_exists(), ilObject\_isInTrash(), ilObjUser\_lookupId(), ilObject\_lookupObjIdByImportId(), addReferences(), ilObjectFactory\getInstanceByRefId(), IL_CRS_ADMIN, ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilSoapAdministration\isFault(), and validateReferences().

609  {
610  $this->initAuth($sid);
611  $this->initIlias();
612 
613  if (!$this->__checkSession($sid)) {
614  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
615  }
616 
617  global $DIC;
618 
619  $tree = $DIC['tree'];
620 
621  $nodedata = $tree->getNodeData($ref_id);
622  $nodearray = $tree->getSubTree($nodedata);
623 
624 
625  $filter = (array) $types;
626 
627  global $DIC;
628 
629  $objDefinition = $DIC['objDefinition'];
630  foreach ($nodearray as $node) {
631  if (!$objDefinition->isAdministrationObject($node['type']) && !$objDefinition->isSystemObject($node['type'])) {
632  if (!in_array($node['type'], $filter)) {
633  if ($tmp = ilObjectFactory::getInstanceByRefId($node['ref_id'], false)) {
634  $nodes[] = $tmp;
635  }
636  }
637  }
638  }
639 
640 
641  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
642 
643  $xml_writer = new ilObjectXMLWriter();
644  $xml_writer->enablePermissionCheck(true);
645  $xml_writer->setObjects($nodes);
646  $xml_writer->enableOperations(false);
647 
648  if ($user_id) {
649  $xml_writer->setUserId($user_id);
650  }
651 
652  if ($xml_writer->start()) {
653  return $xml_writer->getXML();
654  }
655 
656  return $this->__raiseError('Cannot create object xml !', 'Server');
657  }
__raiseError($a_message, $a_code)
initAuth($sid)
Init authentication.
$DIC
Definition: xapitoken.php:46
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:

◆ moveObject()

ilSoapObjectAdministration::moveObject (   $sid,
  $ref_id,
  $target_id 
)

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

References $DIC, $ilUser, $lng, $target_id, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilConditionHandler\_adjustMovedObjectConditions(), ilObject\_isInTrash(), canAddType(), ilObjectFactory\getTypeByRefId(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\isFault().

1188  {
1189  $this->initAuth($sid);
1190  $this->initIlias();
1191 
1192  if (!$this->__checkSession($sid)) {
1193  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
1194  }
1195 
1196  include_once './webservice/soap/classes/class.ilSoapUtils.php';
1197  global $DIC;
1198 
1199  $rbacreview = $DIC['rbacreview'];
1200  $rbacadmin = $DIC['rbacadmin'];
1201  $objDefinition = $DIC['objDefinition'];
1202  $rbacsystem = $DIC['rbacsystem'];
1203  $lng = $DIC['lng'];
1204  $ilUser = $DIC['ilUser'];
1205  $tree = $DIC['tree'];
1206 
1207  // does source object exist
1208  if (!$source_object_type = ilObjectFactory::getTypeByRefId($ref_id, false)) {
1209  return $this->__raiseError('No valid source given.', 'Client');
1210  }
1211 
1212  // does target object exist
1213  if (!$target_object_type = ilObjectFactory::getTypeByRefId($target_id, false)) {
1214  return $this->__raiseError('No valid target given.', 'Client');
1215  }
1216 
1217  // check for trash
1218  if (ilObject::_isInTrash($ref_id)) {
1219  return $this->__raiseError('Object is trashed.', 'Client');
1220  }
1221 
1223  return $this->__raiseError('Object is trashed.', 'Client');
1224  }
1225 
1226  $canAddType = $this->canAddType($source_object_type, $target_object_type, $target_id);
1227  if ($this->isFault($canAddType)) {
1228  return $canAddType;
1229  }
1230 
1231  // check if object already linked to target
1232  $possibleChilds = $tree->getChildsByType($target_id, $ref_id);
1233  foreach ($possibleChilds as $child) {
1234  if ($child["obj_id"] == $ref_id) {
1235  return $this->__raiseError("Object already exists in target.", "Client");
1236  }
1237  }
1238 
1239  // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
1240  if ($tree->isGrandChild($ref_id, $target_id)) {
1241  return $this->__raiseError("Cannot move object into itself.", "Client");
1242  }
1243 
1244  $old_parent = $tree->getParentId($ref_id);
1245  $tree->moveTree($ref_id, $target_id);
1246  $rbacadmin->adjustMovedObjectPermissions($ref_id, $old_parent);
1247 
1248  include_once('./Services/Conditions/classes/class.ilConditionHandler.php');
1250  return true;
1251  }
static _isInTrash($a_ref_id)
checks wether object is in trash
$target_id
Definition: goto.php:49
$lng
__raiseError($a_message, $a_code)
$ilUser
Definition: imgupload.php:18
static getTypeByRefId($a_ref_id, $stop_on_error=true)
get object type by reference id
static _adjustMovedObjectConditions($a_ref_id)
In the moment it is not allowed to create preconditions on objects that are located outside of a cour...
initAuth($sid)
Init authentication.
$DIC
Definition: xapitoken.php:46
canAddType($type, $target_type, $target_id)
+ Here is the call graph for this function:

◆ removeDesktopItems()

ilSoapObjectAdministration::removeDesktopItems (   $sid,
  $user_id,
  $reference_ids 
)

Remove desktop items for user.

Parameters
string$sid
int$user_id
int[]$reference_ids
Returns
bool

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

References $DIC, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjectFactory\getInstanceByObjId(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

105  {
106  return; // abandonded with 6.0
107  $this->initAuth($sid);
108  $this->initIlias();
109 
110  if (!$this->__checkSession($sid)) {
111  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
112  }
113 
114  global $DIC;
115 
116  $access = $DIC->rbac()->system();
117  $logger = $DIC->logger()->wsrv();
118 
119  if (!$access->checkAccess('edit_userassignment', ROLE_FOLDER_ID)) {
120  $logger->warning('Missing permission "edit_userassignment".');
121  return $this->__raiseError(
122  'Missing permission "edit_userassignment".',
123  'Client'
124  );
125  }
126 
127  $user = ilObjectFactory::getInstanceByObjId($user_id, false);
128  if (!$user instanceof ilObjUser) {
129  $logger->warning('Invalid user id given. Cannot instantiate user for id: ' . $user_id);
130  return $this->__raiseError(
131  'Invalid user id given. Cannot instantiate user for id: ' . $user_id,
132  'Client'
133  );
134  }
135  $num_removed = 0;
136  foreach ($reference_ids as $ref_id) {
137  // short "validation" of reference id
138  $ref_obj = ilObjectFactory::getInstanceByRefId($ref_id, false);
139  if (!$ref_obj instanceof ilObject) {
140  $logger->warning('Invalid reference id passed to SOAP::removeDesktopItems: ' . $ref_id);
141  continue;
142  }
143 
144  $num_added++;
145  /*
146  ilObjUser::_dropDesktopItem(
147  $user->getId(),
148  $ref_id,
149  ilObject::_lookupType($ref_id,true)
150  );*/
151  }
152  return $num_removed;
153  }
__raiseError($a_message, $a_code)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
initAuth($sid)
Init authentication.
$DIC
Definition: xapitoken.php:46
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:

◆ removeFromSystemByImportId()

ilSoapObjectAdministration::removeFromSystemByImportId (   $sid,
  $import_id 
)

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

References $DIC, Vendor\Package\$e, $ilLog, $lng, $res, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_getAllReferences(), ilObject\_isInTrash(), ilObject\_lookupObjectId(), ilObject\_lookupObjIdByImportId(), ilObjectFactory\getInstanceByObjId(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilSoapAdministration\isFault(), updateReferences(), and validateReferences().

1003  {
1004  $this->initAuth($sid);
1005  $this->initIlias();
1006 
1007  if (!$this->__checkSession($sid)) {
1008  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
1009  }
1010  if (!strlen($import_id)) {
1011  return $this->__raiseError(
1012  'No import id given. Aborting!',
1013  'Client'
1014  );
1015  }
1016  global $DIC;
1017 
1018  $rbacsystem = $DIC['rbacsystem'];
1019  $tree = $DIC['tree'];
1020  $ilLog = $DIC['ilLog'];
1021 
1022  // get obj_id
1023  if (!$obj_id = ilObject::_lookupObjIdByImportId($import_id)) {
1024  return $this->__raiseError(
1025  'No object found with import id: ' . $import_id,
1026  'Client'
1027  );
1028  }
1029 
1030  // Check access
1031  $permission_ok = false;
1032  foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) {
1033  if ($rbacsystem->checkAccess('delete', $ref_id)) {
1034  $permission_ok = true;
1035  break;
1036  }
1037  }
1038  if (!$permission_ok) {
1039  return $this->__raiseError(
1040  'No permission to delete the object with import id: ' . $import_id,
1041  'Server'
1042  );
1043  }
1044 
1045  // Delete all references (delete permssions and entries in object_reference)
1046  foreach ($ref_ids as $ref_id) {
1047  // All subnodes
1048  $node_data = $tree->getNodeData($ref_id);
1049  $subtree_nodes = $tree->getSubtree($node_data);
1050 
1051  foreach ($subtree_nodes as $node) {
1052  $ilLog->write('Soap: removeFromSystemByImportId(). Deleting object with title id: ' . $node['title']);
1053  $tmp_obj = ilObjectFactory::getInstanceByRefId($node['ref_id']);
1054  if (!is_object($tmp_obj)) {
1055  return $this->__raiseError(
1056  'Cannot create instance of reference id: ' . $node['ref_id'],
1057  'Server'
1058  );
1059  }
1060  $tmp_obj->delete();
1061  }
1062  // Finally delete tree
1063  $tree->deleteTree($node_data);
1064  }
1065 
1066  return true;
1067  }
static _getAllReferences($a_id)
get all reference ids of object
__raiseError($a_message, $a_code)
initAuth($sid)
Init authentication.
$DIC
Definition: xapitoken.php:46
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _lookupObjIdByImportId($a_import_id)
+ Here is the call graph for this function:

◆ searchObjects()

ilSoapObjectAdministration::searchObjects (   $sid,
  $types,
  $key,
  $combination,
  $user_id 
)

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

References $res, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilSearchSettings\getInstance(), ilLuceneSearcher\getInstance(), ilLuceneSearchResultFilter\getInstance(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), QP_COMBINATION_AND, and QP_COMBINATION_OR.

398  {
399  $this->initAuth($sid);
400  $this->initIlias();
401 
402  if (!$this->__checkSession($sid)) {
403  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
404  }
405  if (!is_array($types)) {
406  return $this->__raiseError(
407  'Types must be an array of object types.',
408  'Client'
409  );
410  }
411  if ($combination != 'and' and $combination != 'or') {
412  return $this->__raiseError(
413  'No valid combination given. Must be "and" or "or".',
414  'Client'
415  );
416  }
417 
418  // begin-patch fm
419  include_once './Services/Search/classes/class.ilSearchSettings.php';
420  if (ilSearchSettings::getInstance()->enabledLucene()) {
421  ilSearchSettings::getInstance()->setMaxHits(25);
422 
423  $typeFilterQuery = '';
424  if (is_array($types)) {
425  foreach ($types as $objectType) {
426  if (0 === strlen($typeFilterQuery)) {
427  $typeFilterQuery .= '+( ';
428  } else {
429  $typeFilterQuery .= 'OR';
430  }
431  $typeFilterQuery .= (' type:' . (string) $objectType . ' ');
432  }
433  $typeFilterQuery .= ') ';
434  }
435 
436  include_once './Services/Search/classes/Lucene/class.ilLuceneQueryParser.php';
437  $query_parser = new ilLuceneQueryParser($typeFilterQuery . $key);
438  $query_parser->parse();
439 
440  include_once './Services/Search/classes/Lucene/class.ilLuceneSearcher.php';
441  $searcher = ilLuceneSearcher::getInstance($query_parser);
442  $searcher->search();
443 
444  include_once './Services/Search/classes/Lucene/class.ilLuceneSearchResultFilter.php';
445  include_once './Services/Search/classes/Lucene/class.ilLucenePathFilter.php';
446  $filter = ilLuceneSearchResultFilter::getInstance($user_id);
447  $filter->setCandidates($searcher->getResult());
448  $filter->filter();
449 
450  $result_ids = $filter->getResults();
451  $objs = array();
452  $objs[ROOT_FOLDER_ID] = ilObjectFactory::getInstanceByRefId(ROOT_FOLDER_ID, false);
453  foreach ((array) $result_ids as $ref_id => $obj_id) {
454  $obj = ilObjectFactory::getInstanceByRefId($ref_id, false);
455  if ($obj instanceof ilObject) {
456  $objs[] = $obj;
457  }
458  }
459  include_once './Services/Search/classes/Lucene/class.ilLuceneHighlighterResultParser.php';
460  $highlighter = new ilLuceneHighlighterResultParser();
461  if ($filter->getResultObjIds()) {
462  $highlighter = $searcher->highlight($filter->getResultObjIds());
463  }
464  } else {
465  include_once './Services/Search/classes/class.ilQueryParser.php';
466 
467  $query_parser = new ilQueryParser($key);
468  #$query_parser->setMinWordLength(3);
469  $query_parser->setCombination($combination == 'and' ? QP_COMBINATION_AND : QP_COMBINATION_OR);
470  $query_parser->parse();
471  if (!$query_parser->validate()) {
472  return $this->__raiseError(
473  $query_parser->getMessage(),
474  'Client'
475  );
476  }
477 
478  #include_once './Services/Search/classes/class.ilObjectSearchFactory.php';
479  #$object_search =& ilObjectSearchFactory::_getObjectSearchInstance($query_parser);
480 
481  include_once './Services/Search/classes/Like/class.ilLikeObjectSearch.php';
482  $object_search = new ilLikeObjectSearch($query_parser);
483 
484  $object_search->setFilter($types);
485 
486  $res =&$object_search->performSearch();
487  if ($user_id) {
488  $res->setUserId($user_id);
489  }
490  // begin-patch fm
491  $res->setMaxHits(100);
492  // begin-patch fm
493  $res->filter(ROOT_FOLDER_ID, $combination == 'and' ? true : false);
494 
495  $counter = 0;
496  $objs = array();
497  foreach ($res->getUniqueResults() as $entry) {
498  $obj = ilObjectFactory::getInstanceByRefId($entry['ref_id'], false);
499  if ($obj instanceof ilObject) {
500  $objs[] = $obj;
501  }
502  }
503  }
504 
505  if (!count($objs)) {
506  return '';
507  }
508 
509  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
510 
511  $xml_writer = new ilObjectXMLWriter();
512 
513  // begin-patch fm
514  if (ilSearchSettings::getInstance()->enabledLucene()) {
515  $xml_writer->enableReferences(false);
516  $xml_writer->setMode(ilObjectXmlWriter::MODE_SEARCH_RESULT);
517  $xml_writer->setHighlighter($highlighter);
518  }
519 
520  $xml_writer->enablePermissionCheck(true);
521 
522  if ($user_id) {
523  $xml_writer->setUserId($user_id);
524  $xml_writer->enableOperations(true);
525  }
526 
527  $xml_writer->setObjects($objs);
528  if ($xml_writer->start()) {
529  #$GLOBALS['DIC']['ilLog']->write(__METHOD__.': '.$xml_writer->xmlDumpMem(true));
530  return $xml_writer->getXML();
531  }
532 
533  return $this->__raiseError('Cannot create object xml !', 'Server');
534  }
Parses result XML from lucene search highlight.
static getInstance(ilLuceneQueryParser $qp)
Get singleton instance.
const QP_COMBINATION_OR
foreach($_POST as $key=> $value) $res
__raiseError($a_message, $a_code)
initAuth($sid)
Init authentication.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
const QP_COMBINATION_AND
+ Here is the call graph for this function:

◆ updateReferences()

ilSoapObjectAdministration::updateReferences (   $a_object_data)
private

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

References $DIC, $ilLog, 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().

1497  {
1498  global $DIC;
1499 
1500  $tree = $DIC['tree'];
1501  $ilLog = $DIC['ilLog'];
1502 
1503  if (!isset($a_object_data['references']) or !count($a_object_data['references'])) {
1504  return true;
1505  }
1506 
1507  foreach ($a_object_data['references'] as $ref_data) {
1508  if (isset($ref_data['time_target']) /* and ($crs_ref_id = $tree->checkForParentType($ref_data['ref_id'],'crs')) */) {
1509  include_once('./webservice/soap/classes/class.ilObjectXMLWriter.php');
1510  include_once('./Services/Object/classes/class.ilObjectActivation.php');
1511  $old = ilObjectActivation::getItem($ref_data['ref_id']);
1512 
1513  $items = new ilObjectActivation();
1514  $items->toggleChangeable(isset($ref_data['time_target']['changeable']) ? $ref_data['time_target']['changeable'] : $old['changeable']);
1515  $items->setTimingStart(isset($ref_data['time_target']['starting_time']) ? $ref_data['time_target']['starting_time'] : $old['timing_start']);
1516  $items->setTimingEnd(isset($ref_data['time_target']['ending_time']) ? $ref_data['time_target']['ending_time'] : $old['timing_end']);
1517  $items->toggleVisible(isset($ref_data['time_target']['timing_visibility']) ? $ref_data['time_target']['timing_visibility'] : $old['visible']);
1518  $items->setSuggestionStart(isset($ref_data['time_target']['suggestion_start']) ? $ref_data['time_target']['suggestion_start'] : $old['suggestion_start']);
1519  $items->setSuggestionEnd(isset($ref_data['time_target']['suggestion_end']) ? $ref_data['time_target']['suggestion_end'] : $old['suggestion_end']);
1520 
1521  switch ($ref_data['time_target']['timing_type']) {
1523  $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_DEACTIVATED . ' ' . $ref_data['time_target']['timing_type']);
1524  $items->setTimingType(ilObjectActivation::TIMINGS_DEACTIVATED);
1525  break;
1526 
1528  $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_ACTIVATION . ' ' . $ref_data['time_target']['timing_type']);
1529  $items->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
1530  break;
1531 
1533  $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_PRESETTING . ' ' . $ref_data['time_target']['timing_type']);
1534  $items->setTimingType(ilObjectActivation::TIMINGS_PRESETTING);
1535  break;
1536  }
1537  $items->update($ref_data['ref_id']);
1538  }
1539  }
1540  return true;
1541  }
static getItem($a_ref_id)
Get item data.
$DIC
Definition: xapitoken.php:46
Class ilObjectActivation.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validateReferences()

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

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

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

Referenced by getXMLTree(), and removeFromSystemByImportId().

1441  {
1442  global $DIC;
1443 
1444  $ilAccess = $DIC['ilAccess'];
1445 
1446  if (!isset($a_object_data['references']) or !count($a_object_data['references'])) {
1447  return true;
1448  }
1449  if ($a_action == 'create') {
1450  if (count($a_object_data['references']) > 1) {
1451  if (in_array($a_object_data['type'], array('cat','crs','grp','fold'))) {
1452  return $this->__raiseError(
1453  "Cannot create references for type " . $a_object_data['type'],
1454  'Client'
1455  );
1456  }
1457  }
1458  if (count($a_object_data['references']) == 1) {
1459  if ($a_target_id != $a_object_data['references'][0]['parent_id']) {
1460  return $this->__raiseError(
1461  "Cannot create references for type " . $a_object_data['type'],
1462  'Client'
1463  );
1464  }
1465  }
1466 
1467  foreach ($a_object_data['references'] as $ref_data) {
1468  if (!$ref_data['parent_id']) {
1469  return $this->__raiseError('Element References: No parent Id given!', 'Client');
1470  }
1471 
1472  $target_type = ilObject::_lookupType(ilObject::_lookupObjId($ref_data['parent_id']));
1473  $can_add_type = $this->canAddType($a_object_data['type'], $target_type, $ref_data['parent_id']);
1474  if ($this->isFault($can_add_type)) {
1475  return $can_add_type;
1476  }
1477  }
1478  return true;
1479  }
1480 
1481  if ($a_action == 'update') {
1482  foreach ($a_object_data['references'] as $ref_data) {
1483  if (!$ref_data['ref_id']) {
1484  return $this->__raiseError('Element References: No reference id given!', 'Client');
1485  }
1486  // check permissions
1487  if (!$ilAccess->checkAccess('write', '', $ref_data['ref_id'])) {
1488  return $this->__raiseError('No write permission for object with reference id ' . $ref_data['ref_id'] . '!', 'Client');
1489  }
1490  // TODO: check if all references belong to the same object
1491  }
1492  return true;
1493  }
1494  }
$target_type
Definition: goto.php:48
static _lookupObjId($a_id)
__raiseError($a_message, $a_code)
static _lookupType($a_id, $a_reference=false)
lookup object type
$DIC
Definition: xapitoken.php:46
canAddType($type, $target_type, $target_id)
+ 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: