ILIAS  release_7 Revision v7.30-3-g800a261c036
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(), ilSoapAdministration\initIlias(), and ROLE_FOLDER_ID.

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)
global $DIC
Definition: goto.php:24
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
const ROLE_FOLDER_ID
Definition: constants.php:32
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 817 of file class.ilSoapObjectAdministration.php.

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

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

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

Referenced by getXMLTree().

1537  {
1538  global $DIC;
1539 
1540  $tree = $DIC['tree'];
1541  $ilLog = $DIC['ilLog'];
1542 
1543  if (!isset($a_object_data['references']) or !count($a_object_data['references'])) {
1544  return true;
1545  }
1546 
1547  $original_id = $source->getRefId();
1548 
1549  foreach ($a_object_data['references'] as $ref_data) {
1550  $new_ref_id = $ref_id = $original_id;
1551  if ($tree->getParentId($original_id) != $ref_data['parent_id']) {
1552  // New reference requested => create it
1553  $new_ref_id = $source->createReference();
1554  $source->putInTree($ref_data['parent_id']);
1555  $source->setPermissions($ref_data['parent_id']);
1556  }
1557  if (isset($ref_data['time_target']) /* and ($crs_ref_id = $tree->checkForParentType($new_ref_id,'crs')) */) {
1558  include_once('./webservice/soap/classes/class.ilObjectXMLWriter.php');
1559  include_once('./Services/Object/classes/class.ilObjectActivation.php');
1560 
1561  if (!isset($ref_data['time_target']['starting_time'])) {
1562  $ref_data['time_target']['starting_time'] = time();
1563  }
1564  if (!isset($ref_data['time_target']['ending_time'])) {
1565  $ref_data['time_target']['ending_time'] = time();
1566  }
1567 
1568  $items = new ilObjectActivation();
1569  $items->toggleChangeable($ref_data['time_target']['changeable']);
1570  $items->setTimingStart($ref_data['time_target']['starting_time']);
1571  $items->setTimingEnd($ref_data['time_target']['ending_time']);
1572  $items->toggleVisible($ref_data['time_target']['timing_visibility']);
1573  $items->setSuggestionStart($ref_data['time_target']['suggestion_start']);
1574  $items->setSuggestionEnd($ref_data['time_target']['suggestion_end']);
1575 
1576  switch ($ref_data['time_target']['timing_type']) {
1578  $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_DEACTIVATED . ' ' . $ref_data['time_target']['timing_type']);
1579  $items->setTimingType(ilObjectActivation::TIMINGS_DEACTIVATED);
1580  break;
1581 
1583  $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_ACTIVATION . ' ' . $ref_data['time_target']['timing_type']);
1584  $items->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
1585  break;
1586 
1588  $ilLog->write(__METHOD__ . ilObjectActivation::TIMINGS_PRESETTING . ' ' . $ref_data['time_target']['timing_type']);
1589  $items->setTimingType(ilObjectActivation::TIMINGS_PRESETTING);
1590  break;
1591  }
1592  $items->update($new_ref_id);
1593  }
1594  }
1595  }
global $DIC
Definition: goto.php:24
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 1400 of file class.ilSoapObjectAdministration.php.

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

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

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

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

◆ deleteObject()

ilSoapObjectAdministration::deleteObject (   $sid,
  $reference_id 
)

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

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

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

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  }
const ROOT_FOLDER_ID
Definition: constants.php:30
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ getObjIdByImportId()

ilSoapObjectAdministration::getObjIdByImportId (   $sid,
  $import_id 
)

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

References $DIC, 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 
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)
global $DIC
Definition: goto.php:24
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 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 
267  if (!$obj_id) {
268  return $this->__raiseError('No object found for reference ID. Value: ' . $ref_id, 'Client');
269  }
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 1341 of file class.ilSoapObjectAdministration.php.

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

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

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  foreach ($tree->getChilds($ref_id, 'title') as $child) {
571  if ($all or in_array($child['type'], $types)) {
572  if ($tmp = ilObjectFactory::getInstanceByRefId($child['ref_id'], false)) {
573  $objs[] = $tmp;
574  }
575  }
576  }
577 
578  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
579 
580  $xml_writer = new ilObjectXMLWriter();
581  $xml_writer->enablePermissionCheck(true);
582  $xml_writer->setObjects($objs);
583  $xml_writer->enableOperations(true);
584  if ($user_id) {
585  $xml_writer->setUserId($user_id);
586  }
587 
588  if ($xml_writer->start()) {
589  #$GLOBALS['DIC']['ilLog']->write(__METHOD__.': '.$xml_writer->getXML());
590  return $xml_writer->getXML();
591  }
592 
593  return $this->__raiseError('Cannot create object xml !', 'Server');
594  }
const SYSTEM_FOLDER_ID
Definition: constants.php:33
__raiseError($a_message, $a_code)
global $DIC
Definition: goto.php:24
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 596 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().

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

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

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)
global $DIC
Definition: goto.php:24
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
const ROLE_FOLDER_ID
Definition: constants.php:32
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 994 of file class.ilSoapObjectAdministration.php.

References $DIC, Vendor\Package\$e, $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().

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

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();
453  foreach ((array) $result_ids as $ref_id => $obj_id) {
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.
const ROOT_FOLDER_ID
Definition: constants.php:30
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ updateReferences()

ilSoapObjectAdministration::updateReferences (   $a_object_data)
private

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

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

Referenced by removeFromSystemByImportId().

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

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

Referenced by getXMLTree(), and removeFromSystemByImportId().

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