/** * paste object from clipboard to current place * Depending on the chosen command the object(s) are linked, copied or moved * * @access public */ function pasteObject() { global $rbacsystem, $rbacadmin, $rbacreview, $log, $tree; global $ilUser, $lng, $ilCtrl; // BEGIN ChangeEvent: Record paste event. require_once 'Services/Tracking/classes/class.ilChangeEvent.php'; // END ChangeEvent: Record paste event. //var_dump($_SESSION["clipboard"]);exit; if (!in_array($_SESSION["clipboard"]["cmd"], array("cut", "link", "copy"))) { $message = get_class($this) . "::pasteObject(): cmd was neither 'cut','link' or 'copy'; may be a hack attempt!"; $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING); } // this loop does all checks foreach ($_SESSION["clipboard"]["ref_ids"] as $ref_id) { $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($ref_id); // CHECK ACCESS if (!$rbacsystem->checkAccess('create', $this->object->getRefId(), $obj_data->getType())) { $no_paste[] = $ref_id; $no_paste_titles[] = $obj_data->getTitle(); } // CHECK IF REFERENCE ALREADY EXISTS if ($this->object->getRefId() == $this->tree->getParentId($obj_data->getRefId())) { $exists[] = $ref_id; break; } // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF if ($this->tree->isGrandChild($ref_id, $this->object->getRefId())) { $is_child[] = ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id)); } if ($ref_id == $this->object->getRefId()) { $is_child[] = ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id)); } // CHECK IF OBJECT IS ALLOWED TO CONTAIN PASTED OBJECT AS SUBOBJECT $obj_type = $obj_data->getType(); if (!in_array($obj_type, array_keys($this->objDefinition->getSubObjects($this->object->getType())))) { $not_allowed_subobject[] = $obj_data->getType(); } } //////////////////////////// // process checking results // BEGIN WebDAV: Copying an object into the same container is allowed if (count($exists) && $_SESSION["clipboard"]["cmd"] != "copy") { $this->ilias->raiseError($this->lng->txt("msg_obj_exists"), $this->ilias->error_obj->MESSAGE); } if (count($is_child)) { $this->ilias->raiseError($this->lng->txt("msg_not_in_itself") . " " . implode(',', $is_child), $this->ilias->error_obj->MESSAGE); } if (count($not_allowed_subobject)) { $this->ilias->raiseError($this->lng->txt("msg_may_not_contain") . " " . implode(',', $not_allowed_subobject), $this->ilias->error_obj->MESSAGE); } if (count($no_paste)) { $this->ilias->raiseError($this->lng->txt("msg_no_perm_paste") . " " . implode(',', $no_paste), $this->ilias->error_obj->MESSAGE); } // log pasteObject call $log->write("ilObjectGUI::pasteObject(), cmd: " . $_SESSION["clipboard"]["cmd"]); //////////////////////////////////////////////////////// // everything ok: now paste the objects to new location // to prevent multiple actions via back/reload button $ref_ids = $_SESSION["clipboard"]["ref_ids"]; unset($_SESSION["clipboard"]["ref_ids"]); // BEGIN WebDAV: Support a copy command in the repository // process COPY command if ($_SESSION["clipboard"]["cmd"] == "copy") { unset($_SESSION["clipboard"]["cmd"]); // new implementation, redirects to ilObjectCopyGUI if (count($ref_ids) == 1) { $ilCtrl->setParameterByClass("ilobjectcopygui", "target", $this->object->getRefId()); $ilCtrl->setParameterByClass("ilobjectcopygui", "source_id", $ref_ids[0]); $ilCtrl->redirectByClass("ilobjectcopygui", "saveTarget"); } else { $ilCtrl->setParameterByClass("ilobjectcopygui", "target", $this->object->getRefId()); $ilCtrl->setParameterByClass("ilobjectcopygui", "source_ids", implode($ref_ids, "_")); $ilCtrl->redirectByClass("ilobjectcopygui", "saveTarget"); } /* old implementation foreach($ref_ids as $ref_id) { $revIdMapping = array(); $oldNode_data = $tree->getNodeData($ref_id); if ($oldNode_data['parent'] == $this->object->getRefId()) { require_once 'Modules/File/classes/class.ilObjFileAccess.php'; $newTitle = ilObjFileAccess::_appendNumberOfCopyToFilename($oldNode_data['title'],null); $newRef = $this->cloneNodes($ref_id, $this->object->getRefId(), $refIdMapping, $newTitle); } else { $newRef = $this->cloneNodes($ref_id, $this->object->getRefId(), $refIdMapping, null); } // BEGIN ChangeEvent: Record copy event. $old_parent_data = $tree->getParentNodeData($ref_id); $newNode_data = $tree->getNodeData($newRef); ilChangeEvent::_recordReadEvent($oldNode_data['type'], $ref_id, $oldNode_data['obj_id'], $ilUser->getId()); ilChangeEvent::_recordWriteEvent($newNode_data['obj_id'], $ilUser->getId(), 'add', $this->object->getId()); ilChangeEvent::_catchupWriteEvents($newNode_data['obj_id'], $ilUser->getId()); // END ChangeEvent: Record copy event. }*/ $log->write("ilObjectGUI::pasteObject(), copy finished"); } // END WebDAV: Support a Copy command in the repository // process CUT command if ($_SESSION["clipboard"]["cmd"] == "cut") { foreach ($ref_ids as $ref_id) { // Store old parent $old_parent = $tree->getParentId($ref_id); $this->tree->moveTree($ref_id, $this->object->getRefId()); $rbacadmin->adjustMovedObjectPermissions($ref_id, $old_parent); include_once './Services/AccessControl/classes/class.ilConditionHandler.php'; ilConditionHandler::_adjustMovedObjectConditions($ref_id); // BEGIN ChangeEvent: Record cut event. $node_data = $tree->getNodeData($ref_id); $old_parent_data = $tree->getNodeData($old_parent); ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'remove', $old_parent_data['obj_id']); ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add', $this->object->getId()); ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId()); // END PATCH ChangeEvent: Record cut event. } } // END CUT // process LINK command if ($_SESSION["clipboard"]["cmd"] == "link") { foreach ($ref_ids as $ref_id) { // get node data $top_node = $this->tree->getNodeData($ref_id); // get subnodes of top nodes $subnodes[$ref_id] = $this->tree->getSubtree($top_node); } // now move all subtrees to new location foreach ($subnodes as $key => $subnode) { // first paste top_node.... $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($key); $new_ref_id = $obj_data->createReference(); $obj_data->putInTree($_GET["ref_id"]); $obj_data->setPermissions($_GET["ref_id"]); // BEGIN ChangeEvent: Record link event. $node_data = $tree->getNodeData($new_ref_id); ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add', $this->object->getId()); ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId()); // END PATCH ChangeEvent: Record link event. } $log->write("ilObjectGUI::pasteObject(), link finished"); // inform other objects in hierarchy about link operation //$this->object->notify("link",$this->object->getRefId(),$_SESSION["clipboard"]["parent_non_rbac_id"],$this->object->getRefId(),$subnodes); } // END LINK // save cmd for correct message output after clearing the clipboard $last_cmd = $_SESSION["clipboard"]["cmd"]; // clear clipboard $this->clearObject(); if ($last_cmd == "cut") { ilUtil::sendSuccess($this->lng->txt("msg_cut_copied"), true); } else { if ($last_cmd == "copy") { ilUtil::sendSuccess($this->lng->txt("msg_cloned"), true); } else { if ($last_cmd == 'link') { ilUtil::sendSuccess($this->lng->txt("msg_linked"), true); } } } $this->ctrl->returnToParent($this); }
function moveObject($sid, $ref_id, $target_id) { $this->initAuth($sid); $this->initIlias(); if (!$this->__checkSession($sid)) { return $this->__raiseError($this->__getMessage(), $this->__getMessageCode()); } include_once './webservice/soap/classes/class.ilSoapUtils.php'; global $rbacreview, $rbacadmin, $objDefinition, $rbacsystem, $lng, $ilUser, $tree; // does source object exist if (!($source_object_type = ilObjectFactory::getTypeByRefId($ref_id, false))) { return $this->__raiseError('No valid source given.', 'Client'); } // does target object exist if (!($target_object_type = ilObjectFactory::getTypeByRefId($target_id, false))) { return $this->__raiseError('No valid target given.', 'Client'); } // check for trash if (ilObject::_isInTrash($ref_id)) { return $this->__raiseError('Object is trashed.', 'Client'); } if (ilObject::_isInTrash($target_id)) { return $this->__raiseError('Object is trashed.', 'Client'); } $canAddType = $this->canAddType($source_object_type, $target_object_type, $target_id); if ($this->isFault($canAddType)) { return $canAddType; } // check if object already linked to target $possibleChilds = $tree->getChildsByType($target_id, $ref_id); foreach ($possibleChilds as $child) { if ($child["obj_id"] == $ref_id) { return $this->__raiseError("Object already exists in target.", "Client"); } } // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF if ($tree->isGrandChild($ref_id, $target_id)) { return $this->__raiseError("Cannot move object into itself.", "Client"); } $old_parent = $tree->getParentId($ref_id); $tree->moveTree($ref_id, $target_id); $rbacadmin->adjustMovedObjectPermissions($ref_id, $old_parent); include_once './Services/AccessControl/classes/class.ilConditionHandler.php'; ilConditionHandler::_adjustMovedObjectConditions($ref_id); return true; }
/** * @param int $ref_id */ public static function ensureCorrectPublicChatroomTreeLocation($ref_id) { /** * @var $tree ilTree * @var $ilDB ilDB * @var $rbacadmin ilRbacAdmin */ global $tree, $ilDB, $rbacadmin; $ilDB->setLimit(1); $query = "\n\t\t\tSELECT object_data.obj_id, object_reference.ref_id\n\t\t\tFROM object_data\n\t\t\tINNER JOIN object_reference ON object_reference.obj_id = object_data.obj_id\n\t\t\tWHERE type = " . $ilDB->quote('chta', 'text'); $rset = $ilDB->query($query); $row = $ilDB->fetchAssoc($rset); $chatfolder_ref_id = $row['ref_id']; $pid = $tree->getParentId($ref_id); if ($chatfolder_ref_id && $pid != $chatfolder_ref_id && !$tree->isDeleted($chatfolder_ref_id)) { $tree->moveTree($ref_id, $chatfolder_ref_id); $rbacadmin->adjustMovedObjectPermissions($ref_id, $pid); include_once './Services/AccessControl/classes/class.ilConditionHandler.php'; ilConditionHandler::_adjustMovedObjectConditions($ref_id); } }