Пример #1
0
 /**
  * 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->object->setRating($form->getInput('rating'));
     $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));
 }
Пример #2
0
 /**
  * PUT method handler
  *
  * @param  array  parameter passing array
  * @return bool   true on success
  */
 public function PUT(&$options)
 {
     global $ilUser;
     $this->writelog('PUT(' . var_export($options, true) . ')');
     $path = $this->davDeslashify($options['path']);
     $parent = dirname($path);
     $name = $this->davBasename($path);
     // get dav object for path
     $parentDAV =& $this->getObject($parent);
     // sanity check
     if (is_null($parentDAV) || !$parentDAV->isCollection()) {
         return '409 Conflict';
     }
     // Prevent putting of files which exceed upload limit
     // FIXME: since this is an optional parameter, we should to do the
     // same check again in function PUTfinished.
     if ($options['content_length'] != null && $options['content_length'] > $this->getUploadMaxFilesize()) {
         $this->writelog('PUT is forbidden, because content length=' . $options['content_length'] . ' is larger than upload_max_filesize=' . $this->getUploadMaxFilesize() . 'in php.ini');
         return '403 Forbidden';
     }
     // determine mime type
     include_once "./Services/Utilities/classes/class.ilMimeTypeUtil.php";
     $mime = ilMimeTypeUtil::getMimeType("", $name, $options['content_type']);
     $objDAV =& $this->getObject($path);
     if (is_null($objDAV)) {
         $ttype = $parentDAV->getILIASFileType();
         $isperm = $parentDAV->isPermitted('create', $ttype);
         if (!$isperm) {
             $this->writelog('PUT is forbidden, because user has no create permission');
             return '403 Forbidden';
         }
         $options["new"] = true;
         $objDAV =& $parentDAV->createFile($name);
         $this->writelog('PUT obj=' . $objDAV . ' name=' . $name . ' content_type=' . $options['content_type']);
         //$objDAV->setContentType($options['content_type']);
         $objDAV->setContentType($mime);
         if ($options['content_length'] != null) {
             $objDAV->setContentLength($options['content_length']);
         }
         $objDAV->write();
         // Record write event
         ilChangeEvent::_recordWriteEvent($objDAV->getObjectId(), $ilUser->getId(), 'create', $parentDAV->getObjectId());
     } else {
         if ($objDAV->isNullResource()) {
             if (!$parentDAV->isPermitted('create', $parentDAV->getILIASFileType())) {
                 $this->writelog('PUT is forbidden, because user has no create permission');
                 return '403 Forbidden';
             }
             $options["new"] = false;
             $objDAV =& $parentDAV->createFileFromNull($name, $objDAV);
             $this->writelog('PUT obj=' . $objDAV . ' name=' . $name . ' content_type=' . $options['content_type']);
             //$objDAV->setContentType($options['content_type']);
             $objDAV->setContentType($mime);
             if ($options['content_length'] != null) {
                 $objDAV->setContentLength($options['content_length']);
             }
             $objDAV->write();
             // Record write event
             ilChangeEvent::_recordWriteEvent($objDAV->getObjectId(), $ilUser->getId(), 'create', $parentDAV->getObjectId());
         } else {
             if (!$objDAV->isPermitted('write')) {
                 $this->writelog('PUT is forbidden, because user has no write permission');
                 return '403 Forbidden';
             }
             $options["new"] = false;
             $this->writelog('PUT obj=' . $objDAV . ' name=' . $name . ' content_type=' . $options['content_type'] . ' content_length=' . $options['content_length']);
             // Create a new version if the previous version is not empty
             if ($objDAV->getContentLength() != 0) {
                 $objDAV->createNewVersion();
             }
             //$objDAV->setContentType($options['content_type']);
             $objDAV->setContentType($mime);
             if ($options['content_length'] != null) {
                 $objDAV->setContentLength($options['content_length']);
             }
             $objDAV->write();
             // Record write event
             ilChangeEvent::_recordWriteEvent($objDAV->getObjectId(), $ilUser->getId(), 'update');
             ilChangeEvent::_catchupWriteEvents($objDAV->getObjectId(), $ilUser->getId(), 'update');
         }
     }
     // store this object, we reuse it in method PUTfinished
     $this->putObjDAV = $objDAV;
     $out =& $objDAV->getContentOutputStream();
     $this->writelog('PUT outputstream=' . $out);
     return $out;
 }
 /**
  * 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());
     }
 }
Пример #4
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);
 }
Пример #5
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));
     }
 }
Пример #6
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());
     }
 }
Пример #7
0
 function updateObject()
 {
     $form = $this->initEditForm();
     $form->checkInput();
     $this->object->setTitle(ilUtil::stripSlashes($_POST['title']));
     $this->object->setDescription(ilUtil::stripSlashes($_POST['desc']));
     /*
     $archive_start = $this->loadDate('archive_start');
     $archive_end = $this->loadDate('archive_end');				 
     */
     $period = $form->getItemByPostVar("access_period");
     $sub_period = $form->getItemByPostVar("subscription_period");
     if ((int) $_POST['activation_type']) {
         $this->object->setActivationType(IL_CRS_ACTIVATION_LIMITED);
     } else {
         $this->object->setActivationType(IL_CRS_ACTIVATION_UNLIMITED);
     }
     $this->object->setOfflineStatus(!(bool) $_POST['activation_online']);
     $this->object->setActivationStart($period->getStart()->get(IL_CAL_UNIX));
     $this->object->setActivationEnd($period->getEnd()->get(IL_CAL_UNIX));
     $this->object->setActivationVisibility((int) $_POST['activation_visibility']);
     $sub_type = (int) $_POST['subscription_type'];
     if ($sub_type != IL_CRS_SUBSCRIPTION_DEACTIVATED) {
         $this->object->setSubscriptionType($sub_type);
         if ((int) $_POST['subscription_limitation_type']) {
             $this->object->setSubscriptionLimitationType(IL_CRS_SUBSCRIPTION_LIMITED);
         } else {
             $this->object->setSubscriptionLimitationType(IL_CRS_SUBSCRIPTION_UNLIMITED);
         }
     } else {
         $this->object->setSubscriptionType(IL_CRS_SUBSCRIPTION_DIRECT);
         // see ilObjCourse::__createDefaultSettings()
         $this->object->setSubscriptionLimitationType(IL_CRS_SUBSCRIPTION_DEACTIVATED);
     }
     // save subitems anyways
     $this->object->setSubscriptionPassword(ilUtil::stripSlashes($_POST['subscription_password']));
     $this->object->setSubscriptionStart($sub_period->getStart()->get(IL_CAL_UNIX));
     $this->object->setSubscriptionEnd($sub_period->getEnd()->get(IL_CAL_UNIX));
     $this->object->enableSubscriptionMembershipLimitation((int) $_POST['subscription_membership_limitation']);
     $this->object->setSubscriptionMaxMembers((int) $_POST['subscription_max']);
     $this->object->enableRegistrationAccessCode((int) $_POST['reg_code_enabled']);
     $this->object->setRegistrationAccessCode(ilUtil::stripSlashes($_POST['reg_code']));
     $this->object->enableWaitingList((int) $_POST['waiting_list']);
     #$this->object->setSubscriptionNotify((int) $_POST['subscription_notification']);
     $this->object->setViewMode((int) $_POST['view_mode']);
     if ($this->object->getViewMode() == IL_CRS_VIEW_TIMING) {
         $this->object->setOrderType(ilContainer::SORT_ACTIVATION);
     } else {
         $this->object->setOrderType($form->getInput('sorting'));
     }
     $this->saveSortingSettings($form);
     /*
     		$this->object->setArchiveStart($archive_start->get(IL_CAL_UNIX));
     		$this->object->setArchiveEnd($archive_end->get(IL_CAL_UNIX));		
     		$this->object->setArchiveType($_POST['archive_type']);
     */
     $this->object->setAboStatus((int) $_POST['abo']);
     $this->object->setShowMembers((int) $_POST['show_members']);
     $this->object->setMailToMembersType((int) $_POST['mail_type']);
     $this->object->enableSessionLimit((int) $_POST['sl']);
     $this->object->setNumberOfPreviousSessions(is_numeric($_POST['sp']) ? (int) $_POST['sp'] : -1);
     $this->object->setNumberOfnextSessions(is_numeric($_POST['sn']) ? (int) $_POST['sn'] : -1);
     $this->object->setAutoNotification($_POST['auto_notification'] == 1 ? true : false);
     $show_lp_sync_confirmation = false;
     // could be hidden in form
     if (isset($_POST['status_dt'])) {
         if ($this->object->getStatusDetermination() != ilObjCourse::STATUS_DETERMINATION_LP && (int) $_POST['status_dt'] == ilObjCourse::STATUS_DETERMINATION_LP) {
             $show_lp_sync_confirmation = true;
         } else {
             $this->object->setStatusDetermination((int) $_POST['status_dt']);
         }
     }
     if ($this->object->validate()) {
         $this->object->update();
         // BEGIN ChangeEvent: Record write event
         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 write event
         include_once './Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
         ilObjectServiceSettingsGUI::updateServiceSettingsForm($this->object->getId(), $form, array(ilObjectServiceSettingsGUI::CALENDAR_VISIBILITY, ilObjectServiceSettingsGUI::NEWS_VISIBILITY, ilObjectServiceSettingsGUI::AUTO_RATING_NEW_OBJECTS, ilObjectServiceSettingsGUI::TAG_CLOUD));
         // Update ecs export settings
         include_once 'Modules/Course/classes/class.ilECSCourseSettings.php';
         $ecs = new ilECSCourseSettings($this->object);
         if (!$ecs->handleSettingsUpdate()) {
             $this->editObject();
             return false;
         }
         if ($show_lp_sync_confirmation) {
             return $this->confirmLPSync();
         }
         return $this->afterUpdate();
     } else {
         ilUtil::sendFailure($this->object->getMessage());
         $this->editObject();
         return false;
     }
 }
Пример #8
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());
     }
 }
Пример #9
0
 /**
  * Records a read event and catches up with write events.
  *
  * @param $obj_id int The object which was read.
  * @param $usr_id int The user who performed a read action.
  * @param $catchupWriteEvents boolean If true, this function catches up with
  * 	write events.
  */
 function _recordReadEvent($a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents = true, $a_ext_rc = false, $a_ext_time = false)
 {
     global $ilDB, $tree;
     /* read_event data is now used for several features, so we are always keeping track
     		if (!ilChangeEvent::_isActive())
     		{
     			return;
     		}		 
     		*/
     include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
     $validTimeSpan = ilObjUserTracking::_getValidTimeSpan();
     $query = sprintf('SELECT * FROM read_event ' . 'WHERE obj_id = %s ' . 'AND usr_id = %s ', $ilDB->quote($obj_id, 'integer'), $ilDB->quote($usr_id, 'integer'));
     $res = $ilDB->query($query);
     $row = $ilDB->fetchObject($res);
     // read counter
     if ($a_ext_rc !== false) {
         $read_count = 'read_count = ' . $ilDB->quote($a_ext_rc, "integer") . ", ";
         $read_count_init = max(1, (int) $a_ext_rc);
         $read_count_diff = max(1, (int) $a_ext_rc) - $row->read_count;
     } else {
         $read_count = 'read_count = read_count + 1, ';
         $read_count_init = 1;
         $read_count_diff = 1;
     }
     if ($row) {
         if ($a_ext_time !== false) {
             $time = (int) $a_ext_time;
         } else {
             $time = $ilDB->quote(time() - $row->last_access <= $validTimeSpan ? $row->spent_seconds + time() - $row->last_access : $row->spent_seconds, 'integer');
             // if we are in the valid interval, we do not
             // add anything to the read_count, since this is the
             // same access for us
             if (time() - $row->last_access <= $validTimeSpan) {
                 $read_count = '';
                 $read_count_init = 1;
                 $read_count_diff = 0;
             }
         }
         $time_diff = $time - (int) $row->spent_seconds;
         // Update
         $query = sprintf('UPDATE read_event SET ' . $read_count . 'spent_seconds = %s, ' . 'last_access = %s ' . 'WHERE obj_id = %s ' . 'AND usr_id = %s ', $time, $ilDB->quote(time(), 'integer'), $ilDB->quote($obj_id, 'integer'), $ilDB->quote($usr_id, 'integer'));
         $aff = $ilDB->manipulate($query);
         self::_recordObjStats($obj_id, $time_diff, $read_count_diff);
     } else {
         if ($a_ext_time !== false) {
             $time = (int) $a_ext_time;
         } else {
             $time = 0;
         }
         $time_diff = $time - (int) $row->spent_seconds;
         /*
         $query = sprintf('INSERT INTO read_event (obj_id,usr_id,last_access,read_count,spent_seconds,first_access) '.
         	'VALUES (%s,%s,%s,%s,%s,'.$ilDB->now().') ',
         	$ilDB->quote($obj_id,'integer'),
         	$ilDB->quote($usr_id,'integer'),
         	$ilDB->quote(time(),'integer'),
         	$ilDB->quote($read_count_init,'integer'),
         	$ilDB->quote($time,'integer'));
         $ilDB->manipulate($query);
         */
         // #10407
         $ilDB->replace('read_event', array('obj_id' => array('integer', $obj_id), 'usr_id' => array('integer', $usr_id)), array('read_count' => array('integer', $read_count_init), 'spent_seconds' => array('integer', $time), 'first_access' => array('timestamp', date("Y-m-d H:i:s")), 'last_access' => array('integer', time())));
         self::$has_accessed[$obj_id][$usr_id] = true;
         self::_recordObjStats($obj_id, $time_diff, $read_count_diff);
     }
     if ($isCatchupWriteEvents) {
         ilChangeEvent::_catchupWriteEvents($obj_id, $usr_id);
     }
     // update parents (no categories or root)
     if (!in_array($a_type, array("cat", "root", "crs"))) {
         if ($tree->isInTree($a_ref_id)) {
             $path = $tree->getPathId($a_ref_id);
             foreach ($path as $p) {
                 $obj2_id = ilObject::_lookupObjId($p);
                 $obj2_type = ilObject::_lookupType($obj2_id);
                 //echo "<br>1-$obj2_type-$p-$obj2_id-";
                 if ($p != $a_ref_id && in_array($obj2_type, array("crs", "fold", "grp"))) {
                     $query = sprintf('SELECT * FROM read_event ' . 'WHERE obj_id = %s ' . 'AND usr_id = %s ', $ilDB->quote($obj2_id, 'integer'), $ilDB->quote($usr_id, 'integer'));
                     $res2 = $ilDB->query($query);
                     if ($row2 = $ilDB->fetchAssoc($res2)) {
                         //echo "<br>2";
                         // update read count and spent seconds
                         $query = sprintf('UPDATE read_event SET ' . 'childs_read_count = childs_read_count + %s ,' . 'childs_spent_seconds = childs_spent_seconds + %s ' . 'WHERE obj_id = %s ' . 'AND usr_id = %s ', $ilDB->quote((int) $read_count_diff, 'integer'), $ilDB->quote((int) $time_diff, 'integer'), $ilDB->quote($obj2_id, 'integer'), $ilDB->quote($usr_id, 'integer'));
                         $aff = $ilDB->manipulate($query);
                         self::_recordObjStats($obj2_id, null, null, (int) $time_diff, (int) $read_count_diff);
                     } else {
                         //echo "<br>3";
                         //$ilLog->write("insert read event for obj_id -".$obj2_id."-".$usr_id."-");
                         /*
                         $query = sprintf('INSERT INTO read_event (obj_id,usr_id,last_access,read_count,spent_seconds,first_access,'.
                         	'childs_read_count, childs_spent_seconds) '.
                         	'VALUES (%s,%s,%s,%s,%s,'.$ilDB->now().', %s, %s) ',
                         	$ilDB->quote($obj2_id,'integer'),
                         	$ilDB->quote($usr_id,'integer'),
                         	$ilDB->quote(time(),'integer'),
                         	$ilDB->quote(1,'integer'),
                         	$ilDB->quote($time,'integer'),
                         	$ilDB->quote((int) $read_count_diff,'integer'),
                         	$ilDB->quote((int) $time_diff,'integer')
                         	);
                         $aff = $ilDB->manipulate($query);
                         */
                         // #10407
                         $ilDB->replace('read_event', array('obj_id' => array('integer', $obj2_id), 'usr_id' => array('integer', $usr_id)), array('read_count' => array('integer', 1), 'spent_seconds' => array('integer', $time), 'first_access' => array('timestamp', date("Y-m-d H:i:s")), 'last_access' => array('integer', time()), 'childs_read_count' => array('integer', (int) $read_count_diff), 'childs_spent_seconds' => array('integer', (int) $time_diff)));
                         self::$has_accessed[$obj2_id][$usr_id] = true;
                         self::_recordObjStats($obj2_id, $time, 1, (int) $time_diff, (int) $read_count_diff);
                     }
                 }
             }
         }
     }
     // @todo:
     // - calculate diff of spent_seconds and read_count
     // - use ref id to get parents of types grp, crs, fold
     // - add diffs to childs_spent_seconds and childs_read_count
 }
 /**
  * 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;
     }
 }
Пример #11
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));
     }
 }