/** * Deletes all data of a room sharing pool. * * @param ilObjRoomSharing $a_pool * * @return bool true if deletion was successful */ public static function deletePool(ilObjRoomSharing $a_pool) { $db = new ilRoomSharingDatabase($a_pool->getPoolId()); // Calendar $calendar_id = $db->getCalendarId(); $db->deleteCalendar($calendar_id); // Bookings $all_bookings_ids = $db->getAllBookingsIds(); // Calendar-Entries $db->deleteCalendarEntriesOfBookings($all_bookings_ids); foreach ($all_bookings_ids as $booking_id) { $db->deleteBooking($booking_id); } // Booking attributes $all_booking_attributes = $db->getAllBookingAttributes(); foreach ($all_booking_attributes as $booking_attribute) { $db->deleteBookingAttribute($booking_attribute['id']); $db->deleteAttributeBookingAssign($booking_attribute['id']); } // Rooms $all_room_ids = $db->getAllRoomIds(); foreach ($all_room_ids as $room_id) { $db->deleteRoom($room_id); } // Room attributes $all_room_attributes = $db->getAllRoomAttributes(); foreach ($all_room_attributes as $room_attribute) { $db->deleteRoomAttribute($room_attribute['id']); $db->deleteAttributeRoomAssign($room_attribute['id']); } // Privileges $classes = $db->getClasses(); foreach ($classes as $class) { $db->deleteClass($class['id']); // Takes also care of assignments } // Floorplans $all_floorplans_ids = $db->getAllFloorplanIds(); foreach ($all_floorplans_ids as $floor_plan_id) { $db->deleteFloorplan($floor_plan_id); } // Files of floorplans and rooms user agreement foreach ($all_floorplans_ids as $floor_plan_file_id) { if (!empty($floor_plan_file_id) && $floor_plan_file_id != "0") { $floor_plan_file = new ilObjMediaObject($floor_plan_file_id); $floor_plan_file->delete(); } } $rooms_agreement_file_id = $a_pool->getRoomsAgreementFileId(); if (ilRoomSharingNumericUtils::isPositiveNumber($rooms_agreement_file_id)) { $rooms_agreement_file = new ilObjMediaObject($rooms_agreement_file_id); $rooms_agreement_file->delete(); } // Pool itself $db->deletePoolEntry("SURE"); }
public function saveStatutoryRegulationsObject() { require_once 'Services/RTE/classes/class.ilRTE.php'; if (isset($_POST['statutory_regulations']) && $_POST['statutory_regulations'] != NULL) { $this->genSetData->set('statutory_regulations', ilRTE::_replaceMediaObjectImageSrc($_POST['statutory_regulations'], 0), 'regulations'); // copy temporary media objects (frm~) include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php'; $mediaObjects = ilRTE::_getMediaObjects($_POST['statutory_regulations'], 0); $myMediaObjects = ilObjMediaObject::_getMobsOfObject('pays~:html', ilObject::_lookupObjId($this->ref_id)); foreach ($mediaObjects as $mob) { foreach ($myMediaObjects as $myMob) { if ($mob == $myMob) { // change usage ilObjMediaObject::_removeUsage($mob, 'pays~:html', ilObject::_lookupObjId($this->ref_id)); break; } } ilObjMediaObject::_saveUsage($mob, 'pays~:html', ilObject::_lookupObjId($this->ref_id)); } } else { $this->genSetData->set('statutory_regulations', NULL, 'regulations'); } // remove usage of deleted media objects include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php'; $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('pays~:html', ilObject::_lookupObjId($this->ref_id)); $curMediaObjects = ilRTE::_getMediaObjects($_POST['statutory_regulations'], 0); foreach ($oldMediaObjects as $oldMob) { $found = false; foreach ($curMediaObjects as $curMob) { if ($oldMob == $curMob) { $found = true; break; } } if (!$found) { if (ilObjMediaObject::_exists($oldMob)) { ilObjMediaObject::_removeUsage($oldMob, 'pays~:html', ilObject::_lookupObjId($this->ref_id)); $mob_obj = new ilObjMediaObject($oldMob); $mob_obj->delete(); } } } $this->genSetData->set('show_sr_shoppingcart', isset($_POST['show_sr_shoppingcart']) ? 1 : 0, 'regulations'); $this->genSetData->set('attach_sr_invoice', isset($_POST['attach_sr_invoice']) ? 1 : 0, 'regulations'); $this->StatutoryRegulationsObject(); ilUtil::sendSuccess($this->lng->txt('pays_updated_general_settings')); return true; }
/** * Delete news item * */ public function delete() { global $ilDB; // delete il_news_read entries $ilDB->manipulate("DELETE FROM il_news_read " . " WHERE news_id = " . $ilDB->quote($this->getId(), "integer")); // delete multimedia object $mob = $this->getMobId(); // delete parent::delete(); // delete mob after news, to have a "mob usage" of 0 if ($mob > 0 and ilObject::_exists($mob)) { include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; $mob = new ilObjMediaObject($mob); $mob->delete(); } }
/** * Uploads a new rooms agreement by using the ILIAS MediaObject Service. * If the old file id is given, the old file will be deleted. * * @param array $a_newfile an array containing the input values of the form * @param string $a_oldFileId to delete trash * * @return string uploaded file id */ public function uploadRoomsAgreement($a_newfile, $a_oldFileId = "0") { if (!empty($a_oldFileId) && $a_oldFileId != "0") { $agreementFile = new ilObjMediaObject($a_oldFileId); $agreementFile->delete(); } $mediaObj = new ilObjMediaObject(); $mediaObj->setTitle("RoomSharingRoomsAgreement"); $mediaObj->setDescription("RoomSharingRoomsAgreement"); $mediaObj->create(); $mob_dir = ilObjMediaObject::_getDirectory($mediaObj->getId()); if (!is_dir($mob_dir)) { $mediaObj->createDirectory(); } $file_name = ilUtil::getASCIIFilename($a_newfile["name"]); $file_name_mod = str_replace(" ", "_", $file_name); $file = $mob_dir . "/" . $file_name_mod; ilUtil::moveUploadedFile($a_newfile["tmp_name"], $file_name_mod, $file); ilUtil::renameExecutables($mob_dir); $format = ilObjMediaObject::getMimeType($file); $media_item = new ilMediaItem(); $mediaObj->addMediaItem($media_item); $media_item->setPurpose("Standard"); $media_item->setFormat($format); $media_item->setLocation($file_name_mod); $media_item->setLocationType("LocalFile"); $mediaObj->update(); return $mediaObj->getId(); }
/** * delete object and all related data * * this method has been tested on may 9th 2004 * media pool tree, media objects and folders * have been deleted correctly as desired * * @access public * @return boolean true if all object data were removed; false if only a references were removed */ function delete() { // always call parent delete function first!! if (!parent::delete()) { return false; } // get childs $childs = $this->tree->getSubTree($this->tree->getNodeData($this->tree->readRootId())); // delete tree $this->tree->removeTree($this->tree->getTreeId()); // delete childs foreach ($childs as $child) { $fid = ilMediaPoolItem::lookupForeignId($child["obj_id"]); switch ($child["type"]) { case "mob": if (ilObject::_lookupType($fid) == "mob") { include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; $mob = new ilObjMediaObject($fid); $mob->delete(); } break; /* case "fold": if (ilObject::_lookupType($fid) == "fold") { include_once("./Modules/Folder/classes/class.ilObjFolder.php"); $fold = new ilObjFolder($fid, false); $fold->delete(); } break;*/ } } return true; }
/** * Before page is being deleted * * @param object $a_page page object */ static function beforePageDelete($a_page) { include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; $mob_ids = ilObjMediaObject::_getMobsOfObject($a_page->getParentType() . ":pg", $a_page->getId(), 0, $a_page->getLanguage()); ilObjMediaObject::_deleteAllUsages($a_page->getParentType() . ":pg", $a_page->getId(), false, $a_page->getLanguage()); foreach ($mob_ids as $mob) { if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob") { $mob_obj = new ilObjMediaObject($mob); $usages = $mob_obj->getUsages(false); if (count($usages) == 0) { $mob_obj->delete(); } } } }
public function deleteMob($obj_id) { if (ilObject2::_lookupObjId($obj_id)) { $mob = new ilObjMediaObject($obj_id); $mob->delete(); } }
/** * remove item from clipboard */ function remove() { global $ilias, $ilUser, $lng, $ilCtrl; // check number of objects if (!isset($_POST["id"])) { $ilias->raiseError($lng->txt("no_checkbox"), $ilias->error_obj->MESSAGE); } foreach ($_POST["id"] as $obj_id) { $id = explode(":", $obj_id); if ($id[0] == "mob") { $ilUser->removeObjectFromClipboard($id[1], "mob"); include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; $mob = new ilObjMediaObject($id[1]); $mob->delete(); // this method don't delete, if mob is used elsewhere } if ($id[0] == "incl") { $ilUser->removeObjectFromClipboard($id[1], "incl"); } } $ilCtrl->redirect($this, "view"); }
public function viewThreadObject() { /** * @var $tpl ilTemplate * @var $lng ilLanguage * @var $ilUser ilObjUser * @var $ilAccess ilAccessHandler * @var $rbacreview ilRbacReview * @var $ilNavigationHistory ilNavigationHistory * @var $ilCtrl ilCtrl * @var $ilToolbar ilToolbarGUI */ global $tpl, $lng, $ilUser, $ilAccess, $rbacreview, $ilNavigationHistory, $ilCtrl, $frm, $ilToolbar, $ilLocator; $tpl->addCss('./Modules/Forum/css/forum_tree.css'); if (!isset($_SESSION['viewmode'])) { $_SESSION['viewmode'] = $this->objProperties->getDefaultView(); } // quick and dirty: check for treeview if (!isset($_SESSION['thread_control']['old'])) { $_SESSION['thread_control']['old'] = $_GET['thr_pk']; $_SESSION['thread_control']['new'] = $_GET['thr_pk']; } else { if (isset($_SESSION['thread_control']['old']) && $_GET['thr_pk'] != $_SESSION['thread_control']['old']) { $_SESSION['thread_control']['new'] = $_GET['thr_pk']; } } if (isset($_GET['viewmode']) && $_GET['viewmode'] != $_SESSION['viewmode']) { $_SESSION['viewmode'] = $_GET['viewmode']; } if (isset($_GET['action']) && $_SESSION['viewmode'] != ilForumProperties::VIEW_DATE || $_SESSION['viewmode'] == ilForumProperties::VIEW_TREE) { $_SESSION['viewmode'] = ilForumProperties::VIEW_TREE; } else { $_SESSION['viewmode'] = ilForumProperties::VIEW_DATE; } if (!$ilAccess->checkAccess('read', '', $this->object->getRefId())) { $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE); } // init objects $oForumObjects = $this->getForumObjects(); /** * @var $forumObj ilObjForum */ $forumObj = $oForumObjects['forumObj']; /** * @var $frm ilForum */ $frm = $oForumObjects['frm']; /** * @var $file_obj ilFileDataForum */ $file_obj = $oForumObjects['file_obj']; // download file if ($_GET['file']) { if (!($path = $file_obj->getFileDataByMD5Filename($_GET['file']))) { ilUtil::sendFailure($this->lng->txt('error_reading_file')); } else { ilUtil::deliverFile($path['path'], $path['clean_filename']); } } if (!$this->objCurrentTopic->getId()) { $ilCtrl->redirect($this, 'showThreads'); } // Set context for login $append = '_' . $this->objCurrentTopic->getId() . ($this->objCurrentPost->getId() ? '_' . $this->objCurrentPost->getId() : ''); $tpl->setLoginTargetPar('frm_' . $_GET['ref_id'] . $append); // delete temporary media object (not in case a user adds media objects and wants to save an invalid form) if ($_GET['action'] != 'showreply' && $_GET['action'] != 'showedit') { try { include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php'; $mobs = ilObjMediaObject::_getMobsOfObject('frm~:html', $ilUser->getId()); foreach ($mobs as $mob) { if (ilObjMediaObject::_exists($mob)) { ilObjMediaObject::_removeUsage($mob, 'frm~:html', $ilUser->getId()); $mob_obj = new ilObjMediaObject($mob); $mob_obj->delete(); } } } catch (Exception $e) { } } require_once './Modules/Forum/classes/class.ilObjForum.php'; require_once './Modules/Forum/classes/class.ilFileDataForum.php'; $lng->loadLanguageModule('forum'); // add entry to navigation history if (!$this->getCreationMode() && $ilAccess->checkAccess('read', '', $this->object->getRefId())) { $ilCtrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId()); $ilNavigationHistory->addItem($this->object->getRefId(), $ilCtrl->getLinkTarget($this, 'showThreads'), 'frm'); } // save last access $forumObj->updateLastAccess($ilUser->getId(), (int) $this->objCurrentTopic->getId()); $this->prepareThreadScreen($forumObj); $tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_threads_view.html', 'Modules/Forum'); if (isset($_GET['anchor'])) { $tpl->setVariable('JUMP2ANCHOR_ID', (int) $_GET['anchor']); } if ($_SESSION['viewmode'] == 'date' || $_SESSION['viewmode'] == ilForumProperties::VIEW_DATE) { $orderField = 'frm_posts_tree.fpt_date'; $this->objCurrentTopic->setOrderDirection(in_array($this->objProperties->getDefaultView(), array(ilForumProperties::VIEW_DATE_ASC, ilForumProperties::VIEW_TREE)) ? 'ASC' : 'DESC'); } else { $orderField = 'frm_posts_tree.rgt'; $this->objCurrentTopic->setOrderDirection('DESC'); } // get forum- and thread-data $frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId())); if (is_array($topicData = $frm->getOneTopic())) { // Visit-Counter for topic $this->objCurrentTopic->updateVisits(); $tpl->setTitle($lng->txt('forums_thread') . " \"" . $this->objCurrentTopic->getSubject() . "\""); // ******************************************************************************** // build location-links $ilLocator->addRepositoryItems(); $ilLocator->addItem($this->object->getTitle(), $ilCtrl->getLinkTarget($this, ""), "_top"); $tpl->setLocator(); // set tabs // menu template (contains linkbar) /** @var $menutpl ilTemplate */ $menutpl = new ilTemplate('tpl.forums_threads_menu.html', true, true, 'Modules/Forum'); include_once "./Services/Accessibility/classes/class.ilAccessKeyGUI.php"; // mark all as read if ($ilUser->getId() != ANONYMOUS_USER_ID && $forumObj->getCountUnread($ilUser->getId(), (int) $this->objCurrentTopic->getId())) { $this->ctrl->setParameter($this, 'mark_read', '1'); $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId()); $ilToolbar->addButton($this->lng->txt('forums_mark_read'), $this->ctrl->getLinkTarget($this, 'viewThread'), '', ilAccessKey::MARK_ALL_READ); $this->ctrl->clearParameters($this); } // print thread $this->ctrl->setParameterByClass('ilforumexportgui', 'print_thread', $this->objCurrentTopic->getId()); $this->ctrl->setParameterByClass('ilforumexportgui', 'thr_top_fk', $this->objCurrentTopic->getForumId()); $ilToolbar->addButton($this->lng->txt('forums_print_thread'), $this->ctrl->getLinkTargetByClass('ilforumexportgui', 'printThread')); $this->ctrl->clearParametersByClass('ilforumexportgui'); $this->addHeaderAction(); if ($_GET['mark_read']) { $forumObj->markThreadRead($ilUser->getId(), (int) $this->objCurrentTopic->getId()); ilUtil::sendInfo($lng->txt('forums_thread_marked'), true); } // delete post and its sub-posts require_once './Modules/Forum/classes/class.ilForum.php'; if ($_GET['action'] == 'ready_delete' && $_POST['confirm'] != '') { if (!$this->objCurrentTopic->isClosed() && ($this->is_moderator || $this->objCurrentPost->isOwner($ilUser->getId()) && !$this->objCurrentPost->hasReplies()) && $ilUser->getId() != ANONYMOUS_USER_ID) { $frm = new ilForum(); $frm->setForumId($forumObj->getId()); $frm->setForumRefId($forumObj->getRefId()); $dead_thr = $frm->deletePost($this->objCurrentPost->getId()); // if complete thread was deleted ... if ($dead_thr == $this->objCurrentTopic->getId()) { $frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($forumObj->getId())); $topicData = $frm->getOneTopic(); ilUtil::sendInfo($lng->txt('forums_post_deleted'), true); if ($topicData['top_num_threads'] > 0) { $this->ctrl->redirect($this, 'showThreads'); } else { $this->ctrl->redirect($this, 'createThread'); } } ilUtil::sendInfo($lng->txt('forums_post_deleted')); } } // form processing (censor) if (!$this->objCurrentTopic->isClosed() && $_GET['action'] == 'ready_censor') { if (($_POST['confirm'] != '' || $_POST['no_cs_change'] != '') && $_GET['action'] == 'ready_censor') { $frm->postCensorship($this->handleFormInput($_POST['formData']['cens_message']), $this->objCurrentPost->getId(), 1); } else { if (($_POST['cancel'] != '' || $_POST['yes_cs_change'] != '') && $_GET['action'] == 'ready_censor') { $frm->postCensorship($this->handleFormInput($_POST['formData']['cens_message']), $this->objCurrentPost->getId()); } } } // get complete tree of thread $first_node = $this->objCurrentTopic->getFirstPostNode(); $this->objCurrentTopic->setOrderField($orderField); $subtree_nodes = $this->objCurrentTopic->getPostTree($first_node); // no posts if (!($posNum = count($subtree_nodes))) { ilUtil::sendInfo($this->lng->txt('forums_no_posts_available')); } $pageHits = $frm->getPageHits(); $z = 0; // navigation to browse if ($posNum > $pageHits) { $params = array('ref_id' => $_GET['ref_id'], 'thr_pk' => $this->objCurrentTopic->getId(), 'orderby' => $_GET['orderby']); if (!$_GET['offset']) { $Start = 0; } else { $Start = $_GET['offset']; } $linkbar = ilUtil::Linkbar($ilCtrl->getLinkTarget($this, 'viewThread'), $posNum, $pageHits, $Start, $params); if ($linkbar != '') { $menutpl->setCurrentBlock('linkbar'); $menutpl->setVariable('LINKBAR', $linkbar); $menutpl->parseCurrentBlock(); } } $tpl->setVariable('THREAD_MENU', $menutpl->get()); // assistance val for anchor-links $jump = 0; // generate post-dates foreach ($subtree_nodes as $node) { /** * @var $node ilForumPost */ $this->ctrl->clearParameters($this); if ($this->objCurrentPost->getId() && $this->objCurrentPost->getId() == $node->getId()) { $jump++; } if ($posNum > $pageHits && $z >= $Start + $pageHits) { // if anchor-link was not found ... if ($this->objCurrentPost->getId() && $jump < 1) { $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId()); $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId()); $this->ctrl->setParameter($this, 'offset', $Start + $pageHits); $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']); $this->ctrl->redirect($this, 'viewThread', $this->objCurrentPost->getId()); exit; } else { break; } } if ($posNum > $pageHits && $z >= $Start || $posNum <= $pageHits) { if ($this->objCurrentPost->getId() == $node->getId()) { # actions for "active" post if ($this->is_moderator || $node->isActivated()) { // reply/edit if (!$this->objCurrentTopic->isClosed() && ($_GET['action'] == 'showreply' || $_GET['action'] == 'showedit')) { if ($_GET['action'] == 'showedit' && (!$this->is_moderator && !$node->isOwner($ilUser->getId()) || $ilUser->getId() == ANONYMOUS_USER_ID || $node->isCensored())) { $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE); } else { if ($_GET['action'] == 'showreply' && !$ilAccess->checkAccess('add_reply', '', (int) $_GET['ref_id'])) { $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE); } } $tpl->setVariable('REPLY_ANKER', $this->objCurrentPost->getId()); $oEditReplyForm = $this->getReplyEditForm(); switch ($this->objProperties->getSubjectSetting()) { case 'add_re_to_subject': $subject = $this->getModifiedReOnSubject(true); break; case 'preset_subject': $subject = $this->objCurrentPost->getSubject(); break; case 'empty_subject': default: $subject = NULL; break; } switch ($_GET['action']) { case 'showreply': if ($this->ctrl->getCmd() == 'savePost') { $oEditReplyForm->setValuesByPost(); } else { if ($this->ctrl->getCmd() == 'quotePost') { require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php'; $authorinfo = new ilForumAuthorInformation($node->getPosAuthorId(), $node->getDisplayUserId(), $node->getUserAlias(), $node->getImportName()); $oEditReplyForm->setValuesByPost(); $oEditReplyForm->getItemByPostVar('message')->setValue(ilRTE::_replaceMediaObjectImageSrc($frm->prepareText($node->getMessage(), 1, $authorinfo->getAuthorName()) . "\n" . $oEditReplyForm->getInput('message'), 1)); } else { $oEditReplyForm->setValuesByArray(array('alias' => '', 'subject' => $subject, 'message' => '', 'notify' => 0, 'userfile' => '', 'del_file' => array())); } } $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId()); $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId()); $jsTpl = new ilTemplate('tpl.forum_post_quoation_ajax_handler.html', true, true, 'Modules/Forum/'); $jsTpl->setVariable('IL_FRM_QUOTE_CALLBACK_SRC', $this->ctrl->getLinkTarget($this, 'getQuotationHTMLAsynch', '', true)); $this->ctrl->clearParameters($this); $this->tpl->setVariable('FORM_ADDITIONAL_JS', $jsTpl->get()); break; case 'showedit': if ($this->ctrl->getCmd() == 'savePost') { $oEditReplyForm->setValuesByPost(); } else { $oEditReplyForm->setValuesByArray(array('alias' => '', 'subject' => $this->objCurrentPost->getSubject(), 'message' => ilRTE::_replaceMediaObjectImageSrc($frm->prepareText($this->objCurrentPost->getMessage(), 2), 1), 'notify' => $this->objCurrentPost->isNotificationEnabled() ? true : false, 'userfile' => '', 'del_file' => array())); } break; } $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId()); $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId()); $this->ctrl->setParameter($this, 'offset', (int) $_GET['offset']); $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']); $this->ctrl->setParameter($this, 'action', $_GET['action']); $tpl->setVariable('FORM', $oEditReplyForm->getHTML()); $this->ctrl->clearParameters($this); } else { if (!$this->objCurrentTopic->isClosed() && $_GET['action'] == 'delete') { if ($this->is_moderator || $node->isOwner($ilUser->getId()) && !$node->hasReplies() && $ilUser->getId() != ANONYMOUS_USER_ID) { // confirmation: delete $tpl->setVariable('FORM', $this->getDeleteFormHTML()); } } else { if (!$this->objCurrentTopic->isClosed() && $_GET['action'] == 'censor') { if ($this->is_moderator) { // confirmation: censor / remove censorship $tpl->setVariable('FORM', $this->getCensorshipFormHTML()); } } else { if (!$this->objCurrentTopic->isClosed() && $this->displayConfirmPostActivation()) { if ($this->is_moderator) { // confirmation: activate $tpl->setVariable('FORM', $this->getActivationFormHTML()); } } } } } } } // if ($this->objCurrentPost->getId() == $node->getId()) if ($this->objCurrentPost->getId() != $node->getId() || $_GET['action'] != 'showreply' && $_GET['action'] != 'showedit' && $_GET['action'] != 'censor' && $_GET['action'] != 'delete' && !$this->displayConfirmPostActivation()) { if ($this->is_moderator || $node->isActivated()) { // button: reply if (!$this->objCurrentTopic->isClosed() && $ilAccess->checkAccess('add_reply', '', (int) $_GET['ref_id']) && !$node->isCensored()) { $tpl->setCurrentBlock('commands'); $this->ctrl->setParameter($this, 'action', 'showreply'); $this->ctrl->setParameter($this, 'pos_pk', $node->getId()); $this->ctrl->setParameter($this, 'offset', $Start); $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']); $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId()); $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId())); $tpl->setVariable('COMMANDS_TXT', $lng->txt('reply')); $this->ctrl->clearParameters($this); $tpl->parseCurrentBlock(); } // button: edit article if (!$this->objCurrentTopic->isClosed() && ($node->isOwner($ilUser->getId()) || $this->is_moderator) && !$node->isCensored() && $ilUser->getId() != ANONYMOUS_USER_ID) { $tpl->setCurrentBlock('commands'); $this->ctrl->setParameter($this, 'action', 'showedit'); $this->ctrl->setParameter($this, 'pos_pk', $node->getId()); $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId()); $this->ctrl->setParameter($this, 'offset', $Start); $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']); $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId())); $tpl->setVariable('COMMANDS_TXT', $lng->txt('edit')); $this->ctrl->clearParameters($this); $tpl->parseCurrentBlock(); } // button: print if (!$node->isCensored()) { $tpl->setCurrentBlock('commands'); $this->ctrl->setParameterByClass('ilforumexportgui', 'print_post', $node->getId()); $this->ctrl->setParameterByClass('ilforumexportgui', 'top_pk', $node->getForumId()); $this->ctrl->setParameterByClass('ilforumexportgui', 'thr_pk', $node->getThreadId()); $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTargetByClass('ilforumexportgui', 'printPost')); $tpl->setVariable('COMMANDS_TXT', $lng->txt('print')); $this->ctrl->clearParameters($this); $tpl->parseCurrentBlock(); } # buttons for every post except the "active" if (!$this->objCurrentTopic->isClosed() && ($this->is_moderator || $node->isOwner($ilUser->getId()) && !$node->hasReplies()) && $ilUser->getId() != ANONYMOUS_USER_ID) { // button: delete $tpl->setCurrentBlock('commands'); $this->ctrl->setParameter($this, 'action', 'delete'); $this->ctrl->setParameter($this, 'pos_pk', $node->getId()); $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId()); $this->ctrl->setParameter($this, 'offset', $Start); $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']); $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId())); $tpl->setVariable('COMMANDS_TXT', $lng->txt('delete')); $this->ctrl->clearParameters($this); $tpl->parseCurrentBlock(); } if (!$this->objCurrentTopic->isClosed() && $this->is_moderator) { // button: censor $tpl->setCurrentBlock('commands'); $this->ctrl->setParameter($this, 'action', 'censor'); $this->ctrl->setParameter($this, 'pos_pk', $node->getId()); $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId()); $this->ctrl->setParameter($this, 'offset', $Start); $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']); $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId())); $tpl->setVariable('COMMANDS_TXT', $lng->txt('censorship')); $this->ctrl->clearParameters($this); $tpl->parseCurrentBlock(); // button: activation/deactivation $tpl->setCurrentBlock('commands'); $this->ctrl->setParameter($this, 'pos_pk', $node->getId()); $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId()); $this->ctrl->setParameter($this, 'offset', $Start); $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']); if (!$node->isActivated()) { $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this, 'askForPostActivation', $node->getId())); $tpl->setVariable('COMMANDS_TXT', $lng->txt('activate_post')); } $this->ctrl->clearParameters($this); $tpl->parseCurrentBlock(); } // button: mark read if ($ilUser->getId() != ANONYMOUS_USER_ID && !$node->isPostRead()) { $tpl->setCurrentBlock('commands'); $this->ctrl->setParameter($this, 'pos_pk', $node->getId()); $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId()); $this->ctrl->setParameter($this, 'offset', $Start); $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']); $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']); $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this, 'markPostRead', $node->getId())); $tpl->setVariable('COMMANDS_TXT', $lng->txt('is_read')); $this->ctrl->clearParameters($this); $tpl->parseCurrentBlock(); } // button: mark unread if ($ilUser->getId() != ANONYMOUS_USER_ID && $node->isPostRead()) { $tpl->setCurrentBlock('commands'); $this->ctrl->setParameter($this, 'pos_pk', $node->getId()); $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId()); $this->ctrl->setParameter($this, 'offset', $Start); $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']); $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']); $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this, 'markPostUnread', $node->getId())); $tpl->setVariable('COMMANDS_TXT', $lng->txt('unread')); $this->ctrl->clearParameters($this); $tpl->parseCurrentBlock(); } } } // if ($this->objCurrentPost->getId() != $node->getId()) // download post attachments $tmp_file_obj = new ilFileDataForum($forumObj->getId(), $node->getId()); if (count($tmp_file_obj->getFilesOfPost())) { if ($node->getId() != $this->objCurrentPost->getId() || $_GET['action'] != 'showedit') { foreach ($tmp_file_obj->getFilesOfPost() as $file) { $tpl->setCurrentBlock('attachment_download_row'); $this->ctrl->setParameter($this, 'pos_pk', $node->getId()); $this->ctrl->setParameter($this, 'file', $file['md5']); $tpl->setVariable('HREF_DOWNLOAD', $this->ctrl->getLinkTarget($this, 'viewThread')); $tpl->setVariable('TXT_FILENAME', $file['name']); $this->ctrl->clearParameters($this); $tpl->parseCurrentBlock(); } $tpl->setCurrentBlock('attachments'); $tpl->setVariable('TXT_ATTACHMENTS_DOWNLOAD', $lng->txt('forums_attachments')); include_once "./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php"; $tpl->setVariable('DOWNLOAD_IMG', ilGlyphGUI::get(ilGlyphGUI::ATTACHMENT, $lng->txt('forums_download_attachment'))); $tpl->parseCurrentBlock(); } } $tpl->setCurrentBlock('posts_row'); // anker for every post $tpl->setVariable('POST_ANKER', $node->getId()); //permanent link for every post // $tpl->setVariable('PERMA_LINK', ILIAS_HTTP_PATH."/goto.php?target="."frm"."_".$this->object->getRefId()."_".$node->getThreadId()."_".$node->getId()."&client_id=".CLIENT_ID); $tpl->setVariable('TXT_PERMA_LINK', $lng->txt('perma_link')); $tpl->setVariable('PERMA_TARGET', '_top'); if ($this->objProperties->getMarkModeratorPosts() == 1) { if ($node->getIsAuthorModerator() === null && ($is_moderator = ilForum::_isModerator($_GET['ref_id'], $node->getPosAuthorId()))) { $rowCol = 'ilModeratorPosting'; } elseif ($node->getIsAuthorModerator()) { $rowCol = 'ilModeratorPosting'; } else { $rowCol = ilUtil::switchColor($z, 'tblrow1', 'tblrow2'); } } else { $rowCol = ilUtil::switchColor($z, 'tblrow1', 'tblrow2'); } if ($_GET['action'] != 'delete' && $_GET['action'] != 'censor' && !$this->displayConfirmPostActivation() || $this->objCurrentPost->getId() != $node->getId()) { $tpl->setVariable('ROWCOL', ' ' . $rowCol); } else { // highlight censored posts $rowCol = 'tblrowmarked'; } // post is censored if ($node->isCensored()) { // display censorship advice if ($_GET['action'] != 'censor') { $tpl->setVariable('TXT_CENSORSHIP_ADVICE', $this->lng->txt('post_censored_comment_by_moderator')); } // highlight censored posts $rowCol = 'tblrowmarked'; } // set row color $tpl->setVariable('ROWCOL', ' ' . $rowCol); // if post is not activated display message for the owner if (!$node->isActivated() && $node->isOwner($ilUser->getId())) { $tpl->setVariable('POST_NOT_ACTIVATED_YET', $this->lng->txt('frm_post_not_activated_yet')); } // Author $this->ctrl->setParameter($this, 'pos_pk', $node->getId()); $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId()); $backurl = urlencode($this->ctrl->getLinkTarget($this, 'viewThread', $node->getId())); $this->ctrl->clearParameters($this); $this->ctrl->setParameter($this, 'backurl', $backurl); $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId()); $this->ctrl->setParameter($this, 'user', $node->getDisplayUserId()); require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php'; $authorinfo = new ilForumAuthorInformation($node->getPosAuthorId(), $node->getDisplayUserId(), $node->getUserAlias(), $node->getImportName(), array('href' => $this->ctrl->getLinkTarget($this, 'showUser'))); $this->ctrl->clearParameters($this); if ($authorinfo->hasSuffix()) { $tpl->setVariable('AUTHOR', $authorinfo->getSuffix()); $tpl->setVariable('USR_NAME', $node->getUserAlias()); } else { $tpl->setVariable('AUTHOR', $authorinfo->getLinkedAuthorShortName()); if ($authorinfo->getAuthorName(true)) { $tpl->setVariable('USR_NAME', $authorinfo->getAuthorName(true)); } } $tpl->setVariable('USR_IMAGE', $authorinfo->getProfilePicture()); if ($authorinfo->getAuthor()->getId() && ilForum::_isModerator((int) $_GET['ref_id'], $node->getPosAuthorId())) { if ($authorinfo->getAuthor()->getGender() == 'f') { $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_f')); } else { if ($authorinfo->getAuthor()->getGender() == 'm') { $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_m')); } } } // get create- and update-dates if ($node->getUpdateUserId() > 0) { $spanClass = ''; // last update from moderator? $posMod = $frm->getModeratorFromPost($node->getId()); if (is_array($posMod) && $posMod['top_mods'] > 0) { $MODS = $rbacreview->assignedUsers($posMod['top_mods']); if (is_array($MODS)) { if (in_array($node->getUpdateUserId(), $MODS)) { $spanClass = 'moderator_small'; } } } $node->setChangeDate($node->getChangeDate()); if ($spanClass == '') { $spanClass = 'small'; } $this->ctrl->setParameter($this, 'backurl', $backurl); $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId()); $this->ctrl->setParameter($this, 'user', $node->getUpdateUserId()); require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php'; $authorinfo = new ilForumAuthorInformation($node->getPosAuthorId(), $node->getUpdateUserId(), '', '', array('href' => $this->ctrl->getLinkTarget($this, 'showUser'))); $this->ctrl->clearParameters($this); $tpl->setVariable('POST_UPDATE_TXT', $lng->txt('edited_on') . ': ' . $frm->convertDate($node->getChangeDate()) . ' - ' . strtolower($lng->txt('by'))); $tpl->setVariable('UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName()); if ($authorinfo->getAuthorName(true)) { $tpl->setVariable('UPDATE_USR_NAME', $authorinfo->getAuthorName(true)); } } // if ($node->getUpdateUserId() > 0)*/ // Author end // prepare post $node->setMessage($frm->prepareText($node->getMessage())); if ($ilUser->getId() == ANONYMOUS_USER_ID || $node->isPostRead()) { $tpl->setVariable('SUBJECT', $node->getSubject()); } else { $this->ctrl->setParameter($this, 'pos_pk', $node->getId()); $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId()); $this->ctrl->setParameter($this, 'offset', $Start); $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']); $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']); $mark_post_target = $this->ctrl->getLinkTarget($this, 'markPostRead', $node->getId()); $tpl->setVariable('SUBJECT', "<a href=\"" . $mark_post_target . "\"><b>" . $node->getSubject() . "</b></a>"); } $tpl->setVariable('POST_DATE', $frm->convertDate($node->getCreateDate())); if (!$node->isCensored() || $this->objCurrentPost->getId() == $node->getId() && $_GET['action'] == 'censor') { // post from moderator? $modAuthor = $frm->getModeratorFromPost($node->getId()); $spanClass = ""; if (is_array($modAuthor) && $modAuthor['top_mods'] > 0) { unset($MODS); $MODS = $rbacreview->assignedUsers($modAuthor['top_mods']); if (is_array($MODS)) { if (in_array($node->getDisplayUserId(), $MODS)) { $spanClass = 'moderator'; } } } // possible bugfix for mantis #8223 if ($node->getMessage() == strip_tags($node->getMessage())) { // We can be sure, that there are not html tags $node->setMessage(nl2br($node->getMessage())); } if ($spanClass != "") { $tpl->setVariable('POST', "<span class=\"" . $spanClass . "\">" . ilRTE::_replaceMediaObjectImageSrc($node->getMessage(), 1) . "</span>"); } else { $tpl->setVariable('POST', ilRTE::_replaceMediaObjectImageSrc($node->getMessage(), 1)); } } else { $tpl->setVariable('POST', "<span class=\"moderator\">" . nl2br($node->getCensorshipComment()) . "</span>"); } $tpl->parseCurrentBlock(); } $z++; } } else { $tpl->setCurrentBlock('posts_no'); $tpl->setVariable('TXT_MSG_NO_POSTS_AVAILABLE', $lng->txt('forums_posts_not_available')); $tpl->parseCurrentBlock(); } $oThreadToolbar = clone $ilToolbar; $oThreadToolbar->addSeparator(); $oThreadToolbar->addButton($this->lng->txt('top_of_page'), '#frm_page_top'); $tpl->setVariable('THREAD_TOOLBAR', $oThreadToolbar->getHTML()); $tpl->setVariable('TPLPATH', $tpl->vars['TPLPATH']); // permanent link include_once 'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php'; $permalink = new ilPermanentLinkGUI('frm', $this->object->getRefId(), '_' . $this->objCurrentTopic->getId()); $this->tpl->setVariable('PRMLINK', $permalink->getHTML()); // Render tree if ($_SESSION['viewmode'] == 'answers' || $_SESSION['viewmode'] == ilForumProperties::VIEW_TREE) { $tpl->setLeftNavContent($this->getForumExplorer()); } return true; }
/** * Deletes a floor plan by file id. * * @param type $a_file_id the file id of the floor plan * * @return the result of the manipulation */ public function deleteFloorPlan($a_file_id) { if (!$this->permission->checkPrivilege(PRIVC::DELETE_FLOORPLANS)) { ilUtil::sendFailure($this->lng->txt("rep_robj_xrs_no_permission_for_action"), true); $this->ctrl->redirectByClass('ilinfoscreengui', 'showSummary', 'showSummary'); return false; } $res = NULL; if ($a_file_id) { $mediaObj = new ilObjMediaObject($a_file_id); $mediaObj->removeAllMediaItems(); $mediaObj->delete(); if ($res = $this->ilRoomsharingDatabase->deleteFloorplan($a_file_id)) { $this->ilRoomsharingDatabase->deleteFloorplanRoomAssociation($a_file_id); } } return $res; }
/** * update complete page content in db (dom xml content is used) */ function update($a_validate = true, $a_no_history = false, $skip_handle_usages = false) { global $lng, $ilDB, $ilUser, $ilLog, $ilCtrl; $lm_set = new ilSetting("lm"); //echo "<br>**".$this->getId()."**"; //echo "<br>PageObject::update[".$this->getId()."],validate($a_validate)"; //echo "\n<br>dump_all2:".$this->dom->dump_mem(0, "UTF-8").":"; //echo "\n<br>PageObject::update:".$this->getXMLFromDom().":"; //echo "<br>PageObject::update:".htmlentities($this->getXMLFromDom()); // add missing pc ids if (!$this->checkPCIds()) { $this->insertPCIds(); } // test validating if ($a_validate) { $errors = $this->validateDom(); } //echo "-".htmlentities($this->getXMLFromDom())."-"; exit; if (empty($errors)) { $this->performAutomaticModifications(); $content = $this->getXMLFromDom(); // this needs to be locked // write history entry $old_set = $ilDB->query("SELECT * FROM page_object WHERE " . "page_id = " . $ilDB->quote($this->getId(), "integer") . " AND " . "parent_type = " . $ilDB->quote($this->getParentType(), "text")); $last_nr_set = $ilDB->query("SELECT max(nr) as mnr FROM page_history WHERE " . "page_id = " . $ilDB->quote($this->getId(), "integer") . " AND " . "parent_type = " . $ilDB->quote($this->getParentType(), "text")); $last_nr = $ilDB->fetchAssoc($last_nr_set); if ($old_rec = $ilDB->fetchAssoc($old_set)) { // only save, if something has changed and not in layout mode if ($content != $old_rec["content"] && !$a_no_history && !$this->history_saved && !$this->layout_mode && $lm_set->get("page_history", 1)) { if ($old_rec["content"] != "<PageObject></PageObject>") { $ilDB->manipulateF("DELETE FROM page_history WHERE " . "page_id = %s AND parent_type = %s AND hdate = %s", array("integer", "text", "timestamp"), array($old_rec["page_id"], $old_rec["parent_type"], $old_rec["last_change"])); // the following lines are a workaround for // bug 6741 $last_c = $old_rec["last_change"]; if ($last_c == "") { $last_c = ilUtil::now(); } $ilDB->insert("page_history", array("page_id" => array("integer", $old_rec["page_id"]), "parent_type" => array("text", $old_rec["parent_type"]), "hdate" => array("timestamp", $last_c), "parent_id" => array("integer", $old_rec["parent_id"]), "content" => array("clob", $old_rec["content"]), "user_id" => array("integer", $old_rec["last_change_user"]), "ilias_version" => array("text", ILIAS_VERSION_NUMERIC), "nr" => array("integer", (int) $last_nr["mnr"] + 1))); /*$h_query = "REPLACE INTO page_history ". "(page_id, parent_type, hdate, parent_id, content, user_id, ilias_version, nr) VALUES (". $ilDB->quote($old_rec["page_id"]).",". $ilDB->quote($old_rec["parent_type"]).",". $ilDB->quote($old_rec["last_change"]).",". $ilDB->quote($old_rec["parent_id"]).",". $ilDB->quote($old_rec["content"]).",". $ilDB->quote($old_rec["last_change_user"]).",". $ilDB->quote(ILIAS_VERSION_NUMERIC).",". $ilDB->quote($last_nr["mnr"] + 1).")"; //echo "<br><br>+$a_no_history+$h_query"; $ilDB->query($h_query);*/ $this->saveMobUsage($old_rec["content"], $last_nr["mnr"] + 1); $this->saveStyleUsage($old_rec["content"], $last_nr["mnr"] + 1); $this->saveFileUsage($old_rec["content"], $last_nr["mnr"] + 1); $this->saveContentIncludeUsage($old_rec["content"], $last_nr["mnr"] + 1); $this->saveSkillUsage($old_rec["content"], $last_nr["mnr"] + 1); $this->history_saved = true; // only save one time } else { $this->history_saved = true; // do not save on first change } } } //echo htmlentities($content); $em = trim($content) == "<PageObject/>" ? 1 : 0; $iel = $this->containsDeactivatedElements($content); $inl = $this->containsIntLinks($content); /*$query = "UPDATE page_object ". "SET content = ".$ilDB->quote($content)." ". ", parent_id= ".$ilDB->quote($this->getParentId())." ". ", last_change_user= "******" ". ", last_change = now() ". ", is_empty = ".$ilDB->quote($em, "integer")." ". ", active = ".$ilDB->quote($this->getActive())." ". ", activation_start = ".$ilDB->quote($this->getActivationStart())." ". ", activation_end = ".$ilDB->quote($this->getActivationEnd())." ". ", inactive_elements = ".$ilDB->quote($iel, "integer")." ". ", int_links = ".$ilDB->quote($inl, "integer")." ". " WHERE page_id = ".$ilDB->quote($this->getId()). " AND parent_type= ".$ilDB->quote($this->getParentType());*/ $ilDB->update("page_object", array("content" => array("clob", $content), "parent_id" => array("integer", $this->getParentId()), "last_change_user" => array("integer", $ilUser->getId()), "last_change" => array("timestamp", ilUtil::now()), "is_empty" => array("integer", $em), "active" => array("integer", $this->getActive()), "activation_start" => array("timestamp", $this->getActivationStart()), "activation_end" => array("timestamp", $this->getActivationEnd()), "show_activation_info" => array("integer", $this->getShowActivationInfo()), "inactive_elements" => array("integer", $iel), "int_links" => array("integer", $inl)), array("page_id" => array("integer", $this->getId()), "parent_type" => array("text", $this->getParentType()))); // todo put this into update function /* if(!$this->ilias->db->checkQuerySize($query)) { $this->ilias->raiseError($lng->txt("check_max_allowed_packet_size"),$this->ilias->error_obj->MESSAGE); return false; }*/ // $this->ilias->db->query($query); if (!$skip_handle_usages) { // handle media object usage include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; $mob_ids = ilObjMediaObject::_getMobsOfObject($this->getParentType() . ":pg", $this->getId()); $this->saveMobUsage($this->getXMLFromDom()); $this->saveMetaKeywords($this->getXMLFromDom()); foreach ($mob_ids as $mob) { if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob") { $mob_obj = new ilObjMediaObject($mob); $usages = $mob_obj->getUsages(false); if (count($usages) == 0) { $mob_obj->delete(); } } } // handle file usages include_once "./Modules/File/classes/class.ilObjFile.php"; $file_ids = ilObjFile::_getFilesOfObject($this->getParentType() . ":pg", $this->getId()); $this->saveFileUsage(); foreach ($file_ids as $file) { if (ilObject::_exists($file)) { $file_obj = new ilObjFile($file, false); $usages = $file_obj->getUsages(); if (count($usages) == 0) { if ($file_obj->getMode() == "filelist") { $file_obj->delete(); } } } } // save style usage $this->saveStyleUsage($this->getXMLFromDom()); // save content include usage $this->saveContentIncludeUsage($this->getXMLFromDom()); $this->saveSkillUsage($this->getXMLFromDom()); } // save internal link information $this->saveInternalLinks($this->getXMLFromDom()); $this->saveAnchors($this->getXMLFromDom()); $this->callUpdateListeners(); //echo "<br>PageObject::update:".htmlentities($this->getXMLContent()).":"; return true; } else { return $errors; } }
/** * delete post and sub-posts * @param integer $post: ID * @access public * @return integer 0 or thread-ID */ public function deletePost($post) { global $ilDB; include_once "./Modules/Forum/classes/class.ilObjForum.php"; // delete tree and get id's of all posts to delete $p_node = $this->getPostNode($post); $del_id = $this->deletePostTree($p_node); // Delete User read entries foreach ($del_id as $post_id) { ilObjForum::_deleteReadEntries($post_id); } // DELETE ATTACHMENTS ASSIGNED TO POST $this->__deletePostFiles($del_id); $dead_pos = count($del_id); $dead_thr = 0; // if deletePost is thread opener ... if ($p_node["parent"] == 0) { // delete thread access data include_once './Modules/Forum/classes/class.ilObjForum.php'; ilObjForum::_deleteAccessEntries($p_node['tree']); // delete thread $dead_thr = $p_node["tree"]; $statement = $ilDB->manipulateF(' DELETE FROM frm_threads WHERE thr_pk = %s', array('integer'), array($p_node['tree'])); // update num_threads $statement = $ilDB->manipulateF(' UPDATE frm_data SET top_num_threads = top_num_threads - 1 WHERE top_frm_fk = %s', array('integer'), array($this->id)); // delete all related news $posset = $ilDB->queryf(' SELECT * FROM frm_posts WHERE pos_thr_fk = %s', array('integer'), array($p_node['tree'])); while ($posrec = $ilDB->fetchAssoc($posset)) { include_once "./Services/News/classes/class.ilNewsItem.php"; $news_id = ilNewsItem::getFirstNewsIdForContext($this->id, "frm", $posrec["pos_pk"], "pos"); if ($news_id > 0) { $news_item = new ilNewsItem($news_id); $news_item->delete(); } try { include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php'; $mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $posrec['pos_pk']); foreach ($mobs as $mob) { if (ilObjMediaObject::_exists($mob)) { ilObjMediaObject::_removeUsage($mob, 'frm:html', $posrec['pos_pk']); $mob_obj = new ilObjMediaObject($mob); $mob_obj->delete(); } } } catch (Exception $e) { } } // delete all posts of this thread $statement = $ilDB->manipulateF(' DELETE FROM frm_posts WHERE pos_thr_fk = %s', array('integer'), array($p_node['tree'])); } else { // delete this post and its sub-posts for ($i = 0; $i < $dead_pos; $i++) { $statement = $ilDB->manipulateF(' DELETE FROM frm_posts WHERE pos_pk = %s', array('integer'), array($del_id[$i])); // delete related news item include_once "./Services/News/classes/class.ilNewsItem.php"; $news_id = ilNewsItem::getFirstNewsIdForContext($this->id, "frm", $del_id[$i], "pos"); if ($news_id > 0) { $news_item = new ilNewsItem($news_id); $news_item->delete(); } try { include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php'; $mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $del_id[$i]); foreach ($mobs as $mob) { if (ilObjMediaObject::_exists($mob)) { ilObjMediaObject::_removeUsage($mob, 'frm:html', $del_id[$i]); $mob_obj = new ilObjMediaObject($mob); $mob_obj->delete(); } } } catch (Exception $e) { } } // update num_posts in frm_threads $statement = $ilDB->manipulateF(' UPDATE frm_threads SET thr_num_posts = thr_num_posts - %s WHERE thr_pk = %s', array('integer', 'integer'), array($dead_pos, $p_node['tree'])); // get latest post of thread and update last_post $res1 = $ilDB->queryf(' SELECT * FROM frm_posts WHERE pos_thr_fk = %s ORDER BY pos_date DESC', array('integer'), array($p_node['tree'])); if ($res1->numRows() == 0) { $lastPost_thr = ""; } else { $z = 0; while ($selData = $ilDB->fetchAssoc($res1)) { if ($z > 0) { break; } $lastPost_thr = $selData["pos_top_fk"] . "#" . $selData["pos_thr_fk"] . "#" . $selData["pos_pk"]; $z++; } } $statement = $ilDB->manipulateF(' UPDATE frm_threads SET thr_last_post = %s WHERE thr_pk = %s', array('text', 'integer'), array($lastPost_thr, $p_node['tree'])); } // update num_posts in frm_data $statement = $ilDB->manipulateF(' UPDATE frm_data SET top_num_posts = top_num_posts - %s WHERE top_frm_fk = %s', array('integer', 'integer'), array($dead_pos, $this->id)); // get latest post of forum and update last_post $res2 = $ilDB->queryf(' SELECT * FROM frm_posts, frm_data WHERE pos_top_fk = top_pk AND top_frm_fk = %s ORDER BY pos_date DESC', array('integer'), array($this->id)); if ($res2->numRows() == 0) { $lastPost_top = ""; } else { $z = 0; while ($selData = $ilDB->fetchAssoc($res2)) { if ($z > 0) { break; } $lastPost_top = $selData["pos_top_fk"] . "#" . $selData["pos_thr_fk"] . "#" . $selData["pos_pk"]; $z++; } } $statement = $ilDB->manipulateF(' UPDATE frm_data SET top_last_post = %s WHERE top_frm_fk = %s', array('text', 'integer'), array($lastPost_top, $this->id)); return $dead_thr; }