ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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, $user, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjUser\_addDesktopItem(), ilObject\_lookupType(), ilObjectFactory\getInstanceByObjId(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

47  {
48  $this->initAuth($sid);
49  $this->initIlias();
50 
51  if (!$this->__checkSession($sid)) {
52  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
53  }
54 
55  global $DIC;
56 
57  $access = $DIC->rbac()->system();
58  $logger = $DIC->logger()->wsrv();
59 
60  if (!$access->checkAccess('edit_userassignment', ROLE_FOLDER_ID)) {
61  $logger->warning('Missing permission "edit_userassignment".');
62  return $this->__raiseError(
63  'Missing permission "edit_userassignment".',
64  'Client'
65  );
66  }
67 
68  $user = ilObjectFactory::getInstanceByObjId($user_id, false);
69  if (!$user instanceof ilObjUser) {
70  $logger->warning('Invalid user id given. Cannot instantiate user for id: ' . $user_id);
71  return $this->__raiseError(
72  'Invalid user id given. Cannot instantiate user for id: ' . $user_id,
73  'Client'
74  );
75  }
76  $num_added = 0;
77  foreach ($reference_ids as $ref_id) {
78  // short "validation" of reference id
79  $ref_obj = ilObjectFactory::getInstanceByRefId($ref_id, false);
80  if (!$ref_obj instanceof ilObject) {
81  $logger->warning('Invalid reference id passed to SOAP::addDesktopItems: ' . $ref_id);
82  continue;
83  }
84 
85  $num_added++;
87  $user->getId(),
88  $ref_id,
89  ilObject::_lookupType($ref_id, true)
90  );
91  }
92  return $num_added;
93  }
global $DIC
Definition: saml.php:7
__raiseError($a_message, $a_code)
$user
Definition: migrateto20.php:57
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupType($a_id, $a_reference=false)
lookup object type
static _addDesktopItem($a_usr_id, $a_item_id, $a_type, $a_par="")
add an item to user's personal desktop
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:

◆ addReference()

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

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

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

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

◆ addReferences()

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

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

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

Referenced by getXMLTree().

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

◆ canAddType()

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

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

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

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

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

References $DIC, $ilUser, $lng, PHPMailer\PHPMailer\$options, $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().

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

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

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

◆ getObjectByReference()

ilSoapObjectAdministration::getObjectByReference (   $sid,
  $a_ref_id,
  $user_id 
)

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

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

279  {
280  $this->initAuth($sid);
281  $this->initIlias();
282 
283  if (!$this->__checkSession($sid)) {
284  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
285  }
286  if (!is_numeric($a_ref_id)) {
287  return $this->__raiseError(
288  'No valid reference id given. Please choose an existing reference id of an ILIAS object',
289  'Client'
290  );
291  }
292 
293  if (!$tmp_obj = ilObjectFactory::getInstanceByRefId($a_ref_id, false)) {
294  return $this->__raiseError('Cannot create object instance!', 'Server');
295  }
296 
297 
298  if (ilObject::_isInTrash($a_ref_id)) {
299  return $this->__raiseError("Object with ID $a_ref_id has been deleted.", 'Client');
300  }
301 
302  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
303 
304  $xml_writer = new ilObjectXMLWriter();
305  $xml_writer->enablePermissionCheck(true);
306  if ($user_id) {
307  $xml_writer->setUserId($user_id);
308  $xml_writer->enableOperations(true);
309  }
310  $xml_writer->setObjects(array($tmp_obj));
311  if ($xml_writer->start()) {
312  return $xml_writer->getXML();
313  }
314 
315  return $this->__raiseError('Cannot create object xml !', 'Server');
316  }
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 318 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.

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

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

154  {
155  $this->initAuth($sid);
156  $this->initIlias();
157 
158  if (!$this->__checkSession($sid)) {
159  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
160  }
161  if (!$import_id) {
162  return $this->__raiseError(
163  'No import id given.',
164  'Client'
165  );
166  }
167 
168  global $DIC;
169 
170  $ilLog = $DIC['ilLog'];
171 
172  $obj_id = ilObject::_lookupObjIdByImportId($import_id);
173  $ilLog->write("SOAP getObjIdByImportId(): import_id = " . $import_id . ' obj_id = ' . $obj_id);
174 
175  return $obj_id ? $obj_id : "0";
176  }
global $DIC
Definition: saml.php:7
__raiseError($a_message, $a_code)
initAuth($sid)
Init authentication.
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 241 of file class.ilSoapObjectAdministration.php.

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

242  {
243  $this->initAuth($sid);
244  $this->initIlias();
245 
246  if (!$this->__checkSession($sid)) {
247  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
248  }
249 
250 
251  if (!count($ref_ids) || !is_array($ref_ids)) {
252  return $this->__raiseError('No reference id(s) given.', 'Client');
253  }
254 
255  $obj_ids = array();
256  if (count($ref_ids)) {
257  foreach ($ref_ids as $ref_id) {
258  $ref_id = trim($ref_id);
259  if (!is_numeric($ref_id)) {
260  return $this->__raiseError('Reference ID has to be numeric. Value: ' . $ref_id, 'Client');
261  }
262 
263  $obj_id = ilObject::_lookupObjectId($ref_id);
264  if (!$obj_id) {
265  return $this->__raiseError('No object found for reference ID. Value: ' . $ref_id, 'Client');
266  }
267  if (!ilObject::_hasUntrashedReference($obj_id)) {
268  return $this->__raiseError('No untrashed reference found for reference ID. Value: ' . $ref_id, 'Client');
269  }
270  $obj_ids[] = $obj_id;
271  }
272  }
273  return $obj_ids;
274  }
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 1347 of file class.ilSoapObjectAdministration.php.

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

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

◆ getRefIdsByImportId()

ilSoapObjectAdministration::getRefIdsByImportId (   $sid,
  $import_id 
)

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

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

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

◆ getRefIdsByObjId()

ilSoapObjectAdministration::getRefIdsByObjId (   $sid,
  $obj_id 
)

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

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

212  {
213  $this->initAuth($sid);
214  $this->initIlias();
215 
216  if (!$this->__checkSession($sid)) {
217  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
218  }
219  if (!$obj_id) {
220  return $this->__raiseError(
221  'No object id given.',
222  'Client'
223  );
224  }
225 
226  $ref_ids = ilObject::_getAllReferences($obj_id);
227  foreach ($ref_ids as $ref_id) {
228  $new_refs[] = $ref_id;
229  }
230  return $new_refs ? $new_refs : array();
231  }
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 533 of file class.ilSoapObjectAdministration.php.

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

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

◆ getXMLTree()

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

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

References $DIC, $ilUser, $lng, $location, $nodes, $res, $row, $tree, 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().

606  {
607  $this->initAuth($sid);
608  $this->initIlias();
609 
610  if (!$this->__checkSession($sid)) {
611  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
612  }
613 
614  global $DIC;
615 
616  $tree = $DIC['tree'];
617 
618  $nodedata = $tree->getNodeData($ref_id);
619  $nodearray = $tree->getSubTree($nodedata);
620 
621 
622  $filter = (array) $types;
623 
624  global $DIC;
625 
626  $objDefinition = $DIC['objDefinition'];
627  foreach ($nodearray as $node) {
628  if (!$objDefinition->isAdministrationObject($node['type']) && !$objDefinition->isSystemObject($node['type'])) {
629  if (!in_array($node['type'], $filter)) {
630  if ($tmp = ilObjectFactory::getInstanceByRefId($node['ref_id'], false)) {
631  $nodes[] = $tmp;
632  }
633  }
634  }
635  }
636 
637 
638  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
639 
640  $xml_writer = new ilObjectXMLWriter();
641  $xml_writer->enablePermissionCheck(true);
642  $xml_writer->setObjects($nodes);
643  $xml_writer->enableOperations(false);
644 
645  if ($user_id) {
646  $xml_writer->setUserId($user_id);
647  }
648 
649  if ($xml_writer->start()) {
650  return $xml_writer->getXML();
651  }
652 
653  return $this->__raiseError('Cannot create object xml !', 'Server');
654  }
global $DIC
Definition: saml.php:7
__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:

◆ moveObject()

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

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

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

1186  {
1187  $this->initAuth($sid);
1188  $this->initIlias();
1189 
1190  if (!$this->__checkSession($sid)) {
1191  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
1192  }
1193 
1194  include_once './webservice/soap/classes/class.ilSoapUtils.php';
1195  global $DIC;
1196 
1197  $rbacreview = $DIC['rbacreview'];
1198  $rbacadmin = $DIC['rbacadmin'];
1199  $objDefinition = $DIC['objDefinition'];
1200  $rbacsystem = $DIC['rbacsystem'];
1201  $lng = $DIC['lng'];
1202  $ilUser = $DIC['ilUser'];
1203  $tree = $DIC['tree'];
1204 
1205  // does source object exist
1206  if (!$source_object_type = ilObjectFactory::getTypeByRefId($ref_id, false)) {
1207  return $this->__raiseError('No valid source given.', 'Client');
1208  }
1209 
1210  // does target object exist
1211  if (!$target_object_type = ilObjectFactory::getTypeByRefId($target_id, false)) {
1212  return $this->__raiseError('No valid target given.', 'Client');
1213  }
1214 
1215  // check for trash
1216  if (ilObject::_isInTrash($ref_id)) {
1217  return $this->__raiseError('Object is trashed.', 'Client');
1218  }
1219 
1221  return $this->__raiseError('Object is trashed.', 'Client');
1222  }
1223 
1224  $canAddType = $this->canAddType($source_object_type, $target_object_type, $target_id);
1225  if ($this->isFault($canAddType)) {
1226  return $canAddType;
1227  }
1228 
1229  // check if object already linked to target
1230  $possibleChilds = $tree->getChildsByType($target_id, $ref_id);
1231  foreach ($possibleChilds as $child) {
1232  if ($child["obj_id"] == $ref_id) {
1233  return $this->__raiseError("Object already exists in target.", "Client");
1234  }
1235  }
1236 
1237  // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
1238  if ($tree->isGrandChild($ref_id, $target_id)) {
1239  return $this->__raiseError("Cannot move object into itself.", "Client");
1240  }
1241 
1242  $old_parent = $tree->getParentId($ref_id);
1243  $tree->moveTree($ref_id, $target_id);
1244  $rbacadmin->adjustMovedObjectPermissions($ref_id, $old_parent);
1245 
1246  include_once('./Services/Conditions/classes/class.ilConditionHandler.php');
1248  return true;
1249  }
global $DIC
Definition: saml.php:7
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.
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 103 of file class.ilSoapObjectAdministration.php.

References $DIC, $user, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjUser\_dropDesktopItem(), ilObject\_lookupType(), ilObjectFactory\getInstanceByObjId(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

104  {
105  $this->initAuth($sid);
106  $this->initIlias();
107 
108  if (!$this->__checkSession($sid)) {
109  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
110  }
111 
112  global $DIC;
113 
114  $access = $DIC->rbac()->system();
115  $logger = $DIC->logger()->wsrv();
116 
117  if (!$access->checkAccess('edit_userassignment', ROLE_FOLDER_ID)) {
118  $logger->warning('Missing permission "edit_userassignment".');
119  return $this->__raiseError(
120  'Missing permission "edit_userassignment".',
121  'Client'
122  );
123  }
124 
125  $user = ilObjectFactory::getInstanceByObjId($user_id, false);
126  if (!$user instanceof ilObjUser) {
127  $logger->warning('Invalid user id given. Cannot instantiate user for id: ' . $user_id);
128  return $this->__raiseError(
129  'Invalid user id given. Cannot instantiate user for id: ' . $user_id,
130  'Client'
131  );
132  }
133  $num_removed = 0;
134  foreach ($reference_ids as $ref_id) {
135  // short "validation" of reference id
136  $ref_obj = ilObjectFactory::getInstanceByRefId($ref_id, false);
137  if (!$ref_obj instanceof ilObject) {
138  $logger->warning('Invalid reference id passed to SOAP::removeDesktopItems: ' . $ref_id);
139  continue;
140  }
141 
142  $num_added++;
144  $user->getId(),
145  $ref_id,
146  ilObject::_lookupType($ref_id, true)
147  );
148  }
149  return $num_removed;
150  }
global $DIC
Definition: saml.php:7
__raiseError($a_message, $a_code)
static _dropDesktopItem($a_usr_id, $a_item_id, $a_type)
drop an item from user's personal desktop
$user
Definition: migrateto20.php:57
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupType($a_id, $a_reference=false)
lookup object type
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:

◆ removeFromSystemByImportId()

ilSoapObjectAdministration::removeFromSystemByImportId (   $sid,
  $import_id 
)

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

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

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

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

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

◆ updateReferences()

ilSoapObjectAdministration::updateReferences (   $a_object_data)
private

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

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

1495  {
1496  global $DIC;
1497 
1498  $tree = $DIC['tree'];
1499  $ilLog = $DIC['ilLog'];
1500 
1501  if (!isset($a_object_data['references']) or !count($a_object_data['references'])) {
1502  return true;
1503  }
1504 
1505  foreach ($a_object_data['references'] as $ref_data) {
1506  if (isset($ref_data['time_target']) /* and ($crs_ref_id = $tree->checkForParentType($ref_data['ref_id'],'crs')) */) {
1507  include_once('./webservice/soap/classes/class.ilObjectXMLWriter.php');
1508  include_once('./Services/Object/classes/class.ilObjectActivation.php');
1509  $old = ilObjectActivation::getItem($ref_data['ref_id']);
1510 
1511  $items = new ilObjectActivation();
1512  $items->toggleChangeable(isset($ref_data['time_target']['changeable']) ? $ref_data['time_target']['changeable'] : $old['changeable']);
1513  $items->setTimingStart(isset($ref_data['time_target']['starting_time']) ? $ref_data['time_target']['starting_time'] : $old['timing_start']);
1514  $items->setTimingEnd(isset($ref_data['time_target']['ending_time']) ? $ref_data['time_target']['ending_time'] : $old['timing_end']);
1515  $items->toggleVisible(isset($ref_data['time_target']['timing_visibility']) ? $ref_data['time_target']['timing_visibility'] : $old['visible']);
1516  $items->setSuggestionStart(isset($ref_data['time_target']['suggestion_start']) ? $ref_data['time_target']['suggestion_start'] : $old['suggestion_start']);
1517  $items->setSuggestionEnd(isset($ref_data['time_target']['suggestion_end']) ? $ref_data['time_target']['suggestion_end'] : $old['suggestion_end']);
1518 
1519  switch ($ref_data['time_target']['timing_type']) {
1521  $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_DEACTIVATED . ' ' . $ref_data['time_target']['timing_type']);
1522  $items->setTimingType(ilObjectActivation::TIMINGS_DEACTIVATED);
1523  break;
1524 
1526  $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_ACTIVATION . ' ' . $ref_data['time_target']['timing_type']);
1527  $items->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
1528  break;
1529 
1531  $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_PRESETTING . ' ' . $ref_data['time_target']['timing_type']);
1532  $items->setTimingType(ilObjectActivation::TIMINGS_PRESETTING);
1533  break;
1534  }
1535  $items->update($ref_data['ref_id']);
1536  }
1537  }
1538  return true;
1539  }
global $DIC
Definition: saml.php:7
static getItem($a_ref_id)
Get item data.
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 1438 of file class.ilSoapObjectAdministration.php.

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

Referenced by getXMLTree(), and removeFromSystemByImportId().

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