Пример #1
0
 /**
  * Add object to tree at given position
  *
  * @param ilObject $a_obj
  * @param int $a_parent_node_id
  */
 protected function putObjectInTree(ilObject $a_obj, $a_parent_node_id = null)
 {
     global $rbacreview, $ilUser, $objDefinition;
     $this->object_id = $a_obj->getId();
     if (!$a_parent_node_id) {
         $a_parent_node_id = $this->parent_id;
     }
     // add new object to custom parent container
     if ((int) $_REQUEST["crtptrefid"]) {
         $a_parent_node_id = (int) $_REQUEST["crtptrefid"];
     }
     switch ($this->id_type) {
         case self::REPOSITORY_NODE_ID:
         case self::REPOSITORY_OBJECT_ID:
             if (!$this->node_id) {
                 $a_obj->createReference();
                 $this->node_id = $a_obj->getRefId();
             }
             $a_obj->putInTree($a_parent_node_id);
             $a_obj->setPermissions($a_parent_node_id);
             // rbac log
             include_once "Services/AccessControl/classes/class.ilRbacLog.php";
             $rbac_log_roles = $rbacreview->getParentRoleIds($this->node_id, false);
             $rbac_log = ilRbacLog::gatherFaPa($this->node_id, array_keys($rbac_log_roles), true);
             ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $this->node_id, $rbac_log);
             $this->ctrl->setParameter($this, "ref_id", $this->node_id);
             break;
         case self::WORKSPACE_NODE_ID:
         case self::WORKSPACE_OBJECT_ID:
             if (!$this->node_id) {
                 $this->node_id = $this->tree->insertObject($a_parent_node_id, $this->object_id);
             }
             $this->getAccessHandler()->setPermissions($a_parent_node_id, $this->node_id);
             $this->ctrl->setParameter($this, "wsp_id", $this->node_id);
             break;
         case self::OBJECT_ID:
         case self::PORTFOLIO_OBJECT_ID:
             // do nothing
             break;
     }
     // BEGIN ChangeEvent: Record save object.
     require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
     ilChangeEvent::_recordWriteEvent($this->object_id, $ilUser->getId(), 'create');
     // END ChangeEvent: Record save object.
     // use forced callback after object creation
     self::handleAfterSaveCallback($a_obj, $_REQUEST["crtcb"]);
 }
Пример #2
0
 /**
  * Add object to tree at given position
  *
  * @param ilObject $a_obj
  * @param int $a_parent_node_id
  */
 protected function putObjectInTree(ilObject $a_obj, $a_parent_node_id = null)
 {
     global $rbacreview, $ilUser, $objDefinition;
     if (!$a_parent_node_id) {
         $a_parent_node_id = $_GET["ref_id"];
     }
     // add new object to custom parent container
     if ((int) $_REQUEST["crtptrefid"]) {
         $a_parent_node_id = (int) $_REQUEST["crtptrefid"];
     }
     $a_obj->createReference();
     $a_obj->putInTree($a_parent_node_id);
     $a_obj->setPermissions($a_parent_node_id);
     $this->obj_id = $a_obj->getId();
     $this->ref_id = $a_obj->getRefId();
     // BEGIN ChangeEvent: Record save object.
     require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
     ilChangeEvent::_recordWriteEvent($this->obj_id, $ilUser->getId(), 'create');
     // END ChangeEvent: Record save object.
     // rbac log
     include_once "Services/AccessControl/classes/class.ilRbacLog.php";
     $rbac_log_roles = $rbacreview->getParentRoleIds($this->ref_id, false);
     $rbac_log = ilRbacLog::gatherFaPa($this->ref_id, array_keys($rbac_log_roles), true);
     ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $this->ref_id, $rbac_log);
     // use forced callback after object creation
     if ($_REQUEST["crtcb"]) {
         $callback_type = ilObject::_lookupType((int) $_REQUEST["crtcb"], true);
         $class_name = "ilObj" . $objDefinition->getClassName($callback_type) . "GUI";
         $location = $objDefinition->getLocation($callback_type);
         include_once $location . "/class." . $class_name . ".php";
         if (in_array(strtolower($class_name), array("ilobjitemgroupgui"))) {
             $callback_obj = new $class_name((int) $_REQUEST["crtcb"]);
         } else {
             // #10368
             $callback_obj = new $class_name(null, (int) $_REQUEST["crtcb"], true, false);
         }
         $callback_obj->afterSaveCallback($a_obj);
     }
 }
Пример #3
0
 /**
  * Handles the upload of a single file and adds it to the parent object.
  * 
  * @param array $file_upload An array containing the file upload parameters.
  * @return object The response object.
  */
 protected function handleFileUpload($file_upload)
 {
     global $ilUser;
     // file upload params
     $filename = $file_upload["name"];
     $type = $file_upload["type"];
     $size = $file_upload["size"];
     $temp_name = $file_upload["tmp_name"];
     // additional params
     $title = $file_upload["title"];
     $description = $file_upload["description"];
     $extract = $file_upload["extract"];
     $keep_structure = $file_upload["keep_structure"];
     // create answer object
     $response = new stdClass();
     $response->fileName = $filename;
     $response->fileSize = intval($size);
     $response->fileType = $type;
     $response->fileUnzipped = $extract;
     $response->error = null;
     // extract archive?
     if ($extract) {
         $zip_file = $filename;
         $adopt_structure = $keep_structure;
         include_once "Services/Utilities/classes/class.ilFileUtils.php";
         // Create unzip-directory
         $newDir = ilUtil::ilTempnam();
         ilUtil::makeDir($newDir);
         // Check if permission is granted for creation of object, if necessary
         if ($this->id_type != self::WORKSPACE_NODE_ID) {
             $type = ilObject::_lookupType((int) $this->parent_id, true);
         } else {
             $type = ilObject::_lookupType($this->tree->lookupObjectId($this->parent_id), false);
         }
         $tree = $access_handler = null;
         switch ($type) {
             // workspace structure
             case 'wfld':
             case 'wsrt':
                 $permission = $this->checkPermissionBool("create", "", "wfld");
                 $containerType = "WorkspaceFolder";
                 $tree = $this->tree;
                 $access_handler = $this->getAccessHandler();
                 break;
                 // use categories as structure
             // use categories as structure
             case 'cat':
             case 'root':
                 $permission = $this->checkPermissionBool("create", "", "cat");
                 $containerType = "Category";
                 break;
                 // use folders as structure (in courses)
             // use folders as structure (in courses)
             default:
                 $permission = $this->checkPermissionBool("create", "", "fold");
                 $containerType = "Folder";
                 break;
         }
         try {
             // 	processZipFile (
             //		Dir to unzip,
             //		Path to uploaded file,
             //		should a structure be created (+ permission check)?
             //		ref_id of parent
             //		object that contains files (folder or category)
             //		should sendInfo be persistent?)
             ilFileUtils::processZipFile($newDir, $temp_name, $adopt_structure && $permission, $this->parent_id, $containerType, $tree, $access_handler);
         } catch (ilFileUtilsException $e) {
             $response->error = $e->getMessage();
         } catch (Exception $ex) {
             $response->error = $ex->getMessage();
         }
         ilUtil::delDir($newDir);
         // #15404
         if ($this->id_type != self::WORKSPACE_NODE_ID) {
             foreach (ilFileUtils::getNewObjects() as $parent_ref_id => $objects) {
                 if ($parent_ref_id != $this->parent_id) {
                     continue;
                 }
                 foreach ($objects as $object) {
                     $this->after_creation_callback_objects[] = $object;
                 }
             }
         }
     } else {
         if (trim($title) == "") {
             $title = $filename;
         } else {
             // BEGIN WebDAV: Ensure that object title ends with the filename extension
             $fileExtension = ilObjFileAccess::_getFileExtension($filename);
             $titleExtension = ilObjFileAccess::_getFileExtension($title);
             if ($titleExtension != $fileExtension && strlen($fileExtension) > 0) {
                 $title .= '.' . $fileExtension;
             }
             // END WebDAV: Ensure that object title ends with the filename extension
         }
         // create and insert file in grp_tree
         include_once "./Modules/File/classes/class.ilObjFile.php";
         $fileObj = new ilObjFile();
         $fileObj->setTitle($title);
         $fileObj->setDescription($description);
         $fileObj->setFileName($filename);
         include_once "./Services/Utilities/classes/class.ilMimeTypeUtil.php";
         $fileObj->setFileType(ilMimeTypeUtil::getMimeType("", $filename, $type));
         $fileObj->setFileSize($size);
         $this->object_id = $fileObj->create();
         $this->putObjectInTree($fileObj, $this->parent_id);
         // see uploadFiles()
         if (is_array($this->after_creation_callback_objects)) {
             $this->after_creation_callback_objects[] = $fileObj;
         }
         // upload file to filesystem
         $fileObj->createDirectory();
         $fileObj->raiseUploadError(false);
         $fileObj->getUploadFile($temp_name, $filename);
         $this->handleAutoRating($fileObj);
         // BEGIN ChangeEvent: Record write event.
         require_once './Services/Tracking/classes/class.ilChangeEvent.php';
         ilChangeEvent::_recordWriteEvent($fileObj->getId(), $ilUser->getId(), 'create');
         // END ChangeEvent: Record write event.
     }
     return $response;
 }
Пример #4
0
 /**
  * COPY method handler
  *
  * @param  array  general parameter passing array
  * @return bool   true on success
  */
 public function COPY($options, $del = false)
 {
     global $ilUser;
     $this->writelog('COPY(' . var_export($options, true) . ' ,del=' . $del . ')');
     $this->writelog('COPY ' . $options['path'] . ' ' . $options['dest']);
     // no copying to different WebDAV Servers
     if (isset($options["dest_url"])) {
         return "502 bad gateway";
     }
     $src = $this->davDeslashify($options['path']);
     $srcParent = dirname($src);
     $srcName = $this->davBasename($src);
     $dst = $this->davDeslashify($options['dest']);
     $dstParent = dirname($dst);
     $dstName = $this->davBasename($dst);
     // sanity check
     if ($src == $dst) {
         return '409 Conflict';
         // src and dst are the same
     }
     if (substr($dst, strlen($src) + 1) == $src . '/') {
         return '409 Conflict';
         // dst is in subtree of src
     }
     $this->writelog('COPY src=' . $src . ' dst=' . $dst);
     // get dav object for path
     $srcDAV =& $this->getObject($src);
     $dstDAV =& $this->getObject($dst);
     $dstParentDAV =& $this->getObject($dstParent);
     if (is_null($srcDAV) || $srcDAV->isNullResource()) {
         return '409 Conflict';
         // src does not exist
     }
     if (is_null($dstParentDAV) || $dstParentDAV->isNullResource()) {
         return '409 Conflict';
         // parent of dst does not exist
     }
     $isOverwritten = false;
     // XXX Handle nulltype for dstDAV
     if (!is_null($dstDAV)) {
         if ($options['overwrite'] == 'T') {
             if ($dstDAV->isPermitted('delete')) {
                 $dstParentDAV->remove($dstDAV);
                 ilChangeEvent::_recordWriteEvent($dstDAV->getObjectId(), $ilUser->getId(), 'delete', $dstParentDAV->getObjectId());
                 $dstDAV = null;
                 $isOverwritten = true;
             } else {
                 return '403 Forbidden';
             }
         } else {
             return '412 Precondition Failed';
         }
     }
     if (!$dstParentDAV->isPermitted('create', $srcDAV->getILIASType())) {
         return '403 Forbidden';
     }
     $dstDAV = $dstParentDAV->addCopy($srcDAV, $dstName);
     // Record write event
     ilChangeEvent::_recordReadEvent($srcDAV->getILIASType(), $srcDAV->getRefId(), $srcDAV->getObjectId(), $ilUser->getId());
     ilChangeEvent::_recordWriteEvent($dstDAV->getObjectId(), $ilUser->getId(), 'create', $dstParentDAV->getObjectId());
     return $isOverwritten ? '204 No Content' : '201 Created';
 }
 /**
  * updates object entry in object_data
  *
  * @access	public
  */
 function updateObject()
 {
     if (!$this->checkPermissionBool("write")) {
         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilias->error_obj->MESSAGE);
     } else {
         $form = $this->initEditForm();
         if ($form->checkInput()) {
             include_once 'Services/Container/classes/class.ilContainerSortingSettings.php';
             $settings = new ilContainerSortingSettings($this->object->getId());
             $settings->setSortMode($form->getInput("sorting"));
             $settings->update();
             // save custom icons
             if ($this->ilias->getSetting("custom_icons")) {
                 if ($form->getItemByPostVar("cont_big_icon")->getDeletionFlag()) {
                     $this->object->removeBigIcon();
                 }
                 if ($form->getItemByPostVar("cont_small_icon")->getDeletionFlag()) {
                     $this->object->removeSmallIcon();
                 }
                 if ($form->getItemByPostVar("cont_tiny_icon")->getDeletionFlag()) {
                     $this->object->removeTinyIcon();
                 }
                 $this->object->saveIcons($_FILES["cont_big_icon"]['tmp_name'], $_FILES["cont_small_icon"]['tmp_name'], $_FILES["cont_tiny_icon"]['tmp_name']);
             }
             // BEGIN ChangeEvent: Record update
             global $ilUser;
             require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
             ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
             ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
             // END ChangeEvent: Record update
             // Update ecs export settings
             include_once 'Modules/Category/classes/class.ilECSCategorySettings.php';
             $ecs = new ilECSCategorySettings($this->object);
             if ($ecs->handleSettingsUpdate()) {
                 return $this->afterUpdate();
             }
         }
         // display form to correct errors
         $this->setEditTabs();
         $form->setValuesByPost();
         $this->tpl->setContent($form->getHTML());
     }
 }
Пример #6
0
 /**
  * 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);
 }
Пример #7
0
 /**
  * Move objects from trash back to repository
  */
 function restoreObjects($a_cur_ref_id, $a_ref_ids)
 {
     global $rbacsystem, $log, $ilAppEventHandler, $lng;
     $cur_obj_id = ilObject::_lookupObjId($a_cur_ref_id);
     foreach ($a_ref_ids as $id) {
         $obj_data = ilObjectFactory::getInstanceByRefId($id);
         if (!$rbacsystem->checkAccess('create', $a_cur_ref_id, $obj_data->getType())) {
             $no_create[] = ilObject::_lookupTitle(ilObject::_lookupObjId($id));
         }
     }
     if (count($no_create)) {
         include_once "./Services/Repository/exceptions/class.ilRepositoryException.php";
         throw new ilRepositoryException($lng->txt("msg_no_perm_paste") . " " . implode(',', $no_create));
     }
     $affected_ids = array();
     foreach ($a_ref_ids as $id) {
         $affected_ids[$id] = $id;
         // INSERT AND SET PERMISSIONS
         ilRepUtil::insertSavedNodes($id, $a_cur_ref_id, -(int) $id, $affected_ids);
         // DELETE SAVED TREE
         $saved_tree = new ilTree(-(int) $id);
         $saved_tree->deleteTree($saved_tree->getNodeData($id));
         // BEGIN ChangeEvent: Record undelete.
         require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
         global $ilUser, $tree;
         $node_data = $saved_tree->getNodeData($id);
         $saved_tree->deleteTree($node_data);
         // Record undelete event
         $node_data = $tree->getNodeData($id);
         $parent_data = $tree->getParentNodeData($node_data['ref_id']);
         ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'undelete', $parent_data['obj_id']);
         ilChangeEvent::_catchupWriteEvents($cur_obj_id, $ilUser->getId());
         // END PATCH ChangeEvent: Record undelete.
     }
     // send events
     foreach ($affected_ids as $id) {
         // send global event
         $ilAppEventHandler->raise("Services/Object", "undelete", array("obj_id" => ilObject::_lookupObjId($id), "ref_id" => $id));
     }
 }
Пример #8
0
 /**
  * updates object entry in object_data
  *
  * @access	public
  */
 function updateObject()
 {
     if (!$this->checkPermissionBool("write")) {
         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilias->error_obj->MESSAGE);
     } else {
         $form = $this->initEditForm();
         if ($form->checkInput()) {
             $title = $form->getInput("title");
             $desc = $form->getInput("desc");
             $lang = $this->object->getTranslations();
             $lang = $lang["Fobject"][0]["lang"];
             $this->object->deleteTranslation($lang);
             $this->object->addTranslation($title, $desc, $lang, true);
             $this->object->setTitle($title);
             $this->object->setDescription($desc);
             $this->object->update();
             $this->saveSortingSettings($form);
             // save custom icons
             /*				if ($this->ilias->getSetting("custom_icons"))
             				{
             					if($form->getItemByPostVar("cont_big_icon")->getDeletionFlag())
             					{
             						$this->object->removeBigIcon();
             					}
             					if($form->getItemByPostVar("cont_small_icon")->getDeletionFlag())
             					{
             						$this->object->removeSmallIcon();
             					}
             					if($form->getItemByPostVar("cont_tiny_icon")->getDeletionFlag())
             					{
             						$this->object->removeTinyIcon();
             					}
             
             					$this->object->saveIcons($_FILES["cont_big_icon"]['tmp_name'],
             						$_FILES["cont_small_icon"]['tmp_name'],
             						$_FILES["cont_tiny_icon"]['tmp_name']);
             				}*/
             // BEGIN ChangeEvent: Record update
             global $ilUser;
             require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
             ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
             ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
             // END ChangeEvent: Record update
             // services
             include_once './Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
             ilObjectServiceSettingsGUI::updateServiceSettingsForm($this->object->getId(), $form, array(ilObjectServiceSettingsGUI::INFO_TAB_VISIBILITY, ilObjectServiceSettingsGUI::NEWS_VISIBILITY, ilObjectServiceSettingsGUI::TAXONOMIES));
             // Update ecs export settings
             include_once 'Modules/Category/classes/class.ilECSCategorySettings.php';
             $ecs = new ilECSCategorySettings($this->object);
             if ($ecs->handleSettingsUpdate()) {
                 return $this->afterUpdate();
             }
         }
         // display form to correct errors
         $this->setEditTabs();
         $form->setValuesByPost();
         $this->tpl->setContent($form->getHTML());
     }
 }
Пример #9
0
 /**
  * save object
  * @access	public
  */
 protected function afterSave(ilObject $a_new_object)
 {
     global $rbacadmin, $ilUser;
     $a_new_object->getMemberObject()->add($ilUser->getId(), IL_CRS_ADMIN);
     $a_new_object->getMemberObject()->updateNotification($ilUser->getId(), 1);
     $a_new_object->update();
     // BEGIN ChangeEvent: Record write event.
     require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
     global $ilUser;
     ilChangeEvent::_recordWriteEvent($a_new_object->getId(), $ilUser->getId(), 'create');
     // END ChangeEvent: Record write event.
     // always send a message
     ilUtil::sendSuccess($this->lng->txt("crs_added"), true);
     $this->ctrl->setParameter($this, "ref_id", $a_new_object->getRefId());
     ilUtil::redirect($this->getReturnLocation("save", $this->ctrl->getLinkTarget($this, "edit", "", false, false)));
 }
Пример #10
0
 /**
  * updates object entry in object_data
  *
  * @access	public
  */
 function updateObject()
 {
     global $ilSetting;
     if (!$this->checkPermissionBool("write")) {
         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilias->error_obj->MESSAGE);
     } else {
         $form = $this->initEditForm();
         if ($form->checkInput()) {
             $this->saveSortingSettings($form);
             // save custom icons
             //save custom icons
             if ($ilSetting->get("custom_icons")) {
                 if ($_POST["cont_icon_delete"]) {
                     $this->object->removeCustomIcon();
                 }
                 $this->object->saveIcons($_FILES["cont_icon"]['tmp_name']);
             }
             // hide icon/title
             ilContainer::_writeContainerSetting($this->object->getId(), "hide_header_icon_and_title", $form->getInput("hide_header_icon_and_title"));
             // BEGIN ChangeEvent: Record update
             global $ilUser;
             require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
             ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
             ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
             // END ChangeEvent: Record update
             ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
             $this->ctrl->redirect($this, "edit");
         }
         // display form to correct errors
         $this->setEditTabs();
         $form->setValuesByPost();
         $this->tpl->setContent($form->getHTML());
     }
 }
 /**
  * update GroupObject
  * @param bool update group type
  * @access public
  */
 public function updateObject()
 {
     global $ilErr;
     $this->checkPermission('write');
     $this->initForm();
     $this->form->checkInput();
     $old_type = $this->object->getGroupType();
     $this->load();
     $ilErr->setMessage('');
     if (!$this->object->validate()) {
         $err = $this->lng->txt('err_check_input');
         ilUtil::sendFailure($err);
         $err = $ilErr->getMessage();
         ilUtil::sendInfo($err);
         $this->editObject();
         return true;
     }
     $modified = false;
     if ($this->object->isGroupTypeModified($old_type) and !$update_group_type) {
         $modified = true;
         $this->object->setGroupType($old_type);
     }
     $this->object->update();
     include_once './Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
     ilObjectServiceSettingsGUI::updateServiceSettingsForm($this->object->getId(), $this->form, array(ilObjectServiceSettingsGUI::CALENDAR_VISIBILITY, ilObjectServiceSettingsGUI::NEWS_VISIBILITY));
     // Save sorting
     include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
     $sort = new ilContainerSortingSettings($this->object->getId());
     $sort->setSortMode((int) $_POST['sor']);
     $sort->update();
     // BEGIN ChangeEvents: Record update Object.
     require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
     global $ilUser;
     ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
     ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
     // END PATCH ChangeEvents: Record update Object.
     // Update ecs export settings
     include_once 'Modules/Group/classes/class.ilECSGroupSettings.php';
     $ecs = new ilECSGroupSettings($this->object);
     $ecs->handleSettingsUpdate();
     if ($modified) {
         include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
         ilUtil::sendQuestion($this->lng->txt('grp_warn_grp_type_changed'));
         $confirm = new ilConfirmationGUI();
         $confirm->setFormAction($this->ctrl->getFormAction($this));
         $confirm->addItem('grp_type', $this->object->getGroupType(), $this->lng->txt('grp_info_new_grp_type') . ': ' . ($this->object->getGroupType() == GRP_TYPE_CLOSED ? $this->lng->txt('il_grp_status_open') : $this->lng->txt('il_grp_status_closed')));
         $confirm->addButton($this->lng->txt('grp_change_type'), 'updateGroupType');
         $confirm->setCancel($this->lng->txt('cancel'), 'edit');
         $this->tpl->setContent($confirm->getHTML());
         return true;
     } else {
         ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
         $this->ctrl->redirect($this, 'edit');
         return true;
     }
 }
Пример #12
0
 /**
  * Move objects from trash back to repository
  */
 function restoreObjects($a_cur_ref_id, $a_ref_ids)
 {
     global $rbacsystem, $log, $ilAppEventHandler, $lng, $tree;
     $cur_obj_id = ilObject::_lookupObjId($a_cur_ref_id);
     foreach ($a_ref_ids as $id) {
         $obj_data = ilObjectFactory::getInstanceByRefId($id);
         if (!$rbacsystem->checkAccess('create', $a_cur_ref_id, $obj_data->getType())) {
             $no_create[] = ilObject::_lookupTitle(ilObject::_lookupObjId($id));
         }
     }
     if (count($no_create)) {
         include_once "./Services/Repository/exceptions/class.ilRepositoryException.php";
         throw new ilRepositoryException($lng->txt("msg_no_perm_paste") . " " . implode(',', $no_create));
     }
     $affected_ids = array();
     foreach ($a_ref_ids as $id) {
         $affected_ids[$id] = $id;
         // INSERT AND SET PERMISSIONS
         ilRepUtil::insertSavedNodes($id, $a_cur_ref_id, -(int) $id, $affected_ids);
         // DELETE SAVED TREE
         $saved_tree = new ilTree(-(int) $id);
         $saved_tree->deleteTree($saved_tree->getNodeData($id));
         include_once './Services/Object/classes/class.ilObjectFactory.php';
         $factory = new ilObjectFactory();
         $ref_obj = $factory->getInstanceByRefId($id, FALSE);
         if ($ref_obj instanceof ilObject) {
             $lroles = $GLOBALS['rbacreview']->getRolesOfRoleFolder($id, FALSE);
             foreach ($lroles as $role_id) {
                 include_once './Services/AccessControl/classes/class.ilObjRole.php';
                 $role = new ilObjRole($role_id);
                 $role->setParent($id);
                 $role->delete();
             }
             $parent_ref = $GLOBALS['tree']->getParentId($id);
             if ($parent_ref) {
                 $ref_obj->setPermissions($parent_ref);
             }
         }
         // BEGIN ChangeEvent: Record undelete.
         require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
         global $ilUser;
         ilChangeEvent::_recordWriteEvent(ilObject::_lookupObjId($id), $ilUser->getId(), 'undelete', ilObject::_lookupObjId($tree->getParentId($id)));
         ilChangeEvent::_catchupWriteEvents($cur_obj_id, $ilUser->getId());
         // END PATCH ChangeEvent: Record undelete.
     }
     // send events
     foreach ($affected_ids as $id) {
         // send global event
         $ilAppEventHandler->raise("Services/Object", "undelete", array("obj_id" => ilObject::_lookupObjId($id), "ref_id" => $id));
     }
 }
 /**
  * updates object entry in object_data
  *
  * @access	public
  */
 function update()
 {
     global $ilTabs;
     $form = $this->initPropertiesForm();
     if (!$form->checkInput()) {
         $ilTabs->activateTab("settings");
         $form->setValuesByPost();
         $this->tpl->setContent($form->getHTML());
         return false;
     }
     $data = $form->getInput('file');
     // delete trailing '/' in filename
     while (substr($data["name"], -1) == '/') {
         $data["name"] = substr($data["name"], 0, -1);
     }
     $filename = empty($data["name"]) ? $this->object->getFileName() : $data["name"];
     $title = $form->getInput('title');
     if (strlen(trim($title)) == 0) {
         $title = $filename;
     } else {
         $title = $this->object->checkFileExtension($filename, $title);
     }
     $this->object->setTitle($title);
     if (!empty($data["name"])) {
         switch ($form->getInput('replace')) {
             case 1:
                 $this->object->deleteVersions();
                 $this->object->clearDataDirectory();
                 $this->object->replaceFile($data['tmp_name'], $data['name']);
                 break;
             case 0:
                 $this->object->addFileVersion($data['tmp_name'], $data['name']);
                 break;
         }
         $this->object->setFileName($data['name']);
         include_once "./Services/Utilities/classes/class.ilMimeTypeUtil.php";
         $this->object->setFileType(ilMimeTypeUtil::getMimeType("", $data["name"], $data["type"]));
         $this->object->setFileSize($data['size']);
     }
     $this->object->setDescription($form->getInput('description'));
     $this->update = $this->object->update();
     // BEGIN ChangeEvent: Record update event.
     if (!empty($data["name"])) {
         require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
         global $ilUser;
         ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
         ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
     }
     // END ChangeEvent: Record update event.
     // Update ecs export settings
     include_once 'Modules/File/classes/class.ilECSFileSettings.php';
     $ecs = new ilECSFileSettings($this->object);
     $ecs->handleSettingsUpdate();
     ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
     ilUtil::redirect($this->ctrl->getLinkTarget($this, 'edit', '', false, false));
 }