public function executeCommand() { /** * @var $ilNavigationHistory ilNavigationHistory * @var $ilAccess ilAccessHandler * @var $ilCtrl ilCtrl * @var $ilTabs ilTabsGUI * @var $ilErr ilErrorHandling * @var $ilUser ilObjUser */ global $ilNavigationHistory, $ilAccess, $ilCtrl, $ilTabs, $ilErr, $ilUser; $next_class = $this->ctrl->getNextClass($this); $cmd = $this->ctrl->getCmd(); $exclude_cmds = array('viewThread', 'markPostUnread', 'markPostRead', 'showThreadNotification', 'cancelPostActivation', 'cancelPostDeactivation', 'performPostActivation', 'performPostDeactivation', 'performPostAndChildPostsActivation', 'askForPostActivation', 'askForPostDeactivation', 'toggleThreadNotification', 'toggleThreadNotificationTab', 'toggleStickiness', 'cancelPost', 'savePost', 'quotePost', 'getQuotationHTMLAsynch', 'setTreeStateAsynch', 'fetchTreeChildrenAsync'); if (!in_array($cmd, $exclude_cmds)) { $this->prepareOutput(); } // add entry to navigation history if (!$this->getCreationMode() && !$ilCtrl->isAsynch() && $ilAccess->checkAccess('read', '', $_GET['ref_id'])) { $ilNavigationHistory->addItem($_GET['ref_id'], 'ilias.php?baseClass=ilRepositoryGUI&cmd=showThreads&ref_id=' . $_GET['ref_id'], 'frm'); } switch ($next_class) { case 'ilpermissiongui': require_once 'Services/AccessControl/classes/class.ilPermissionGUI.php'; $perm_gui = new ilPermissionGUI($this); $this->ctrl->forwardCommand($perm_gui); break; case 'ilforumexportgui': require_once 'Modules/Forum/classes/class.ilForumExportGUI.php'; $fex_gui = new ilForumExportGUI($this); $this->ctrl->forwardCommand($fex_gui); exit; break; case 'ilforummoderatorsgui': require_once 'Modules/Forum/classes/class.ilForumModeratorsGUI.php'; $fm_gui = new ilForumModeratorsGUI($this); $this->ctrl->forwardCommand($fm_gui); break; case 'ilinfoscreengui': $this->infoScreen(); break; case 'ilcolumngui': $this->showThreadsObject(); break; case 'ilpublicuserprofilegui': include_once 'Services/User/classes/class.ilPublicUserProfileGUI.php'; $profile_gui = new ilPublicUserProfileGUI((int) $_GET['user']); $add = $this->getUserProfileAdditional((int) $_GET['ref_id'], (int) $_GET['user']); $profile_gui->setAdditional($add); $ret = $this->ctrl->forwardCommand($profile_gui); $this->tpl->setContent($ret); break; case 'ilobjectcopygui': include_once 'Services/Object/classes/class.ilObjectCopyGUI.php'; $cp = new ilObjectCopyGUI($this); $cp->setType('frm'); $this->ctrl->forwardCommand($cp); break; case 'ilexportgui': $ilTabs->setTabActive('export'); include_once 'Services/Export/classes/class.ilExportGUI.php'; $exp = new ilExportGUI($this); $exp->addFormat('xml'); $this->ctrl->forwardCommand($exp); break; case "ilratinggui": if (!$this->objProperties->isIsThreadRatingEnabled() || $ilUser->isAnonymous()) { $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->MESSAGE); } require_once 'Services/Rating/classes/class.ilRatingGUI.php'; $rating_gui = new ilRatingGUI(); $rating_gui->setObject($this->object->getId(), $this->object->getType(), $this->objCurrentTopic->getId(), 'thread'); $ilCtrl->setParameter($this, 'thr_pk', (int) $_GET['thr_pk']); $this->ctrl->forwardCommand($rating_gui); $avg = ilRating::getOverallRatingForObject($this->object->getId(), $this->object->getType(), (int) $_GET['thr_pk'], 'thread'); $this->objCurrentTopic->setAverageRating($avg['avg']); $this->objCurrentTopic->update(); $ilCtrl->redirect($this, "showThreads"); break; case 'ilcommonactiondispatchergui': include_once 'Services/Object/classes/class.ilCommonActionDispatcherGUI.php'; $gui = ilCommonActionDispatcherGUI::getInstanceFromAjaxCall(); $this->ctrl->forwardCommand($gui); break; default: // alex, 11 Jan 2011: // I inserted this workaround due to bug report 6971. // In general the command handling is quite obscure here. // The form action of the table should be filled // with $ilCtrl->getFormAction(..) not with $ilCtrl->getLinkTarget(..) // Commands should be determined with $ilCtrl->getCmd() not // with accessing $_POST['selected_cmd'], since this is internal // of ilTable2GUI/ilCtrl and may change. if (isset($_POST['select_cmd2'])) { $_POST['selected_cmd'] = $_POST["selected_cmd2"]; } if (isset($_POST['selected_cmd']) && $_POST['selected_cmd'] != null) { $member_cmd = array('enableAdminForceNoti', 'disableAdminForceNoti', 'enableHideUserToggleNoti', 'disableHideUserToggleNoti'); in_array($_POST['selected_cmd'], $member_cmd) ? $cmd = $_POST['selected_cmd'] : ($cmd = 'performThreadsAction'); } else { if (!$cmd && !$_POST['selected_cmd']) { $cmd = 'showThreads'; } } $cmd .= 'Object'; $this->{$cmd}(); break; } // suppress for topic level if ($cmd != 'viewThreadObject' && $cmd != 'showUserObject') { $this->addHeaderAction(); } }
/** * Moves all chosen threads and their posts to a new forum * * @param array chosen thread pks * @param integer object id of src forum * @param integer object id of dest forum * @access public */ public function moveThreads($thread_ids = array(), $src_ref_id = 0, $dest_top_frm_fk = 0) { global $ilDB; $src_top_frm_fk = ilObject::_lookupObjectId($src_ref_id); if (is_numeric($src_top_frm_fk) && $src_top_frm_fk > 0 && is_numeric($dest_top_frm_fk) && $dest_top_frm_fk > 0) { $this->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($src_top_frm_fk)); $oldFrmData = $this->getOneTopic(); $this->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($dest_top_frm_fk)); $newFrmData = $this->getOneTopic(); if ($oldFrmData['top_pk'] && $newFrmData['top_pk']) { $moved_posts = 0; $moved_threads = 0; $visits = 0; foreach ($thread_ids as $id) { $objTmpThread = new ilForumTopic($id); $numPosts = $objTmpThread->movePosts($src_top_frm_fk, $oldFrmData['top_pk'], $dest_top_frm_fk, $newFrmData['top_pk']); if (($last_post_string = $objTmpThread->getLastPostString()) != '') { $last_post_string = explode('#', $last_post_string); $last_post_string[0] = $newFrmData['top_pk']; $last_post_string = implode('#', $last_post_string); $objTmpThread->setLastPostString($last_post_string); } $visits += $objTmpThread->getVisits(); $moved_posts += $numPosts; ++$moved_threads; $objTmpThread->setForumId($newFrmData['top_pk']); $objTmpThread->update(); unset($objTmpThread); } // update frm_data source forum $ilDB->setLimit(1); $res = $ilDB->queryf(' SELECT pos_thr_fk, pos_pk FROM frm_posts WHERE pos_top_fk = %s ORDER BY pos_date DESC', array('integer'), array($oldFrmData['top_pk'])); $row = $ilDB->fetchObject($res); $last_post_src = $oldFrmData['top_pk'] . '#' . $row->pos_thr_fk . '#' . $row->pos_pk; $statement = $ilDB->manipulateF(' UPDATE frm_data SET top_num_posts = top_num_posts - %s, top_num_threads = top_num_threads - %s, visits = visits - %s, top_last_post = %s WHERE top_pk = %s', array('integer', 'integer', 'integer', 'text', 'integer'), array($moved_posts, $moved_threads, $visits, $last_post_src, $oldFrmData['top_pk'])); // update frm_data destination forum $ilDB->setLimit(1); $res = $ilDB->queryf(' SELECT pos_thr_fk, pos_pk FROM frm_posts WHERE pos_top_fk = %s ORDER BY pos_date DESC', array('integer'), array($newFrmData['top_kp'])); $row = $ilDB->fetchObject($res); $last_post_dest = $newFrmData['top_pk'] . '#' . $row->pos_thr_fk . '#' . $row->pos_pk; $statement = $ilDB->manipulateF(' UPDATE frm_data SET top_num_posts = top_num_posts + %s, top_num_threads = top_num_threads + %s, visits = visits + %s, top_last_post = %s WHERE top_pk = %s', array('integer', 'integer', 'integer', 'text', 'integer'), array($moved_posts, $moved_threads, $visits, $last_post_dest, $newFrmData['top_pk'])); /* // update news items include_once("./Services/News/classes/class.ilNewsItem.php"); $objNewsItem = new ilNewsItem(); $news_items = $objNewsItem->getNewsForRefId($src_ref_id); foreach ($news_items as $news_item) { $tmpObjNewsItem = new ilNewsItem($news_item['id']); if ($tmpObjNewsItem->getContextObjId() == $src_top_frm_fk) { $tmpObjNewsItem->setContextObjId($dest_top_frm_fk); $tmpObjNewsItem->update(); } unset($tmpObjNewsItem); } */ } } }