public function moveThreadsObject() { /** * @var $lng ilLanguage * @var $ilToolbar ilToolbarGUI * @var $tree ilTree */ global $lng, $ilToolbar, $tree; if (!$this->is_moderator) { $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE); } $threads2move = $_SESSION['threads2move']; if (empty($threads2move)) { ilUtil::sendInfo($this->lng->txt('select_at_least_one_thread'), true); $this->ctrl->redirect($this, 'showThreads'); } $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_threads_move.html', 'Modules/Forum'); if (!$this->hideToolbar()) { $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this)); } $tblThr = new ilTable2GUI($this); $tblThr->setId('il_frm_thread_move_table_' . $this->object->getRefId()); $tblThr->setTitle($this->lng->txt('move_chosen_topics')); $tblThr->addColumn($this->lng->txt('subject'), 'top_name', '100%'); $tblThr->disable('header'); $tblThr->disable('footer'); $tblThr->disable('linkbar'); $tblThr->disable('sort'); $tblThr->disable('linkbar'); $tblThr->setLimit(0); $tblThr->setRowTemplate('tpl.forums_threads_move_thr_row.html', 'Modules/Forum'); $tblThr->setDefaultOrderField('is_sticky'); $counter = 0; $result = array(); foreach ($threads2move as $thr_pk) { $objCurrentTopic = new ilForumTopic($thr_pk, $this->is_moderator); $result[$counter]['num'] = $counter + 1; $result[$counter]['thr_subject'] = $objCurrentTopic->getSubject(); unset($objCurrentTopic); ++$counter; } $tblThr->setData($result); $this->tpl->setVariable('THREADS_TABLE', $tblThr->getHTML()); // selection tree require_once 'Modules/Forum/classes/class.ilForumMoveTopicsExplorer.php'; $exp = new ilForumMoveTopicsExplorer($this->ctrl->getLinkTarget($this, 'moveThreads'), 'frm_topic_paste_expand'); $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 'moveThreads')); $exp->setTargetGet('ref_id'); $exp->setPostVar('frm_ref_id'); $exp->excludeObjIdFromSelection($this->object->getId()); $exp->setCheckedItem(isset($_POST['frm_ref_id']) && (int) $_POST['frm_ref_id'] ? (int) $_POST['frm_ref_id'] : 0); // open current position in tree if (!is_array($_SESSION['frm_topic_paste_expand'])) { $_SESSION['frm_topic_paste_expand'] = array(); $path = $tree->getPathId($this->object->getRefId()); foreach ((array) $path as $node_id) { if (!in_array($node_id, $_SESSION['frm_topic_paste_expand'])) { $_SESSION['frm_topic_paste_expand'][] = $node_id; } } } if (!isset($_GET['frm_topic_paste_expand']) || $_GET['frm_topic_paste_expand'] == '') { $expanded = $tree->readRootId(); } else { $expanded = $_GET['frm_topic_paste_expand']; } $exp->setExpand($expanded); // build html-output $exp->setOutput(0); $output = $exp->getOutput(); $this->tpl->setVariable('FRM_SELECTION_TREE', $output); $this->tpl->setVariable('CMD_SUBMIT', 'performMoveThreads'); $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('move')); $this->tpl->setVariable('FORMACTION', $this->ctrl->getFormAction($this, 'performMoveThreads')); return true; }
public function moveThreadsObject() { /** * @var $lng ilLanguage * @var $ilToolbar ilToolbarGUI * @var $tree ilTree */ global $lng, $ilToolbar, $tree; if (!$this->is_moderator) { $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE); } $threads2move = $_SESSION['threads2move']; if (!count($threads2move)) { ilUtil::sendInfo($this->lng->txt('select_at_least_one_thread'), true); $this->ctrl->redirect($this, 'showThreads'); } require_once 'Modules/Forum/classes/class.ilForumMoveTopicsExplorer.php'; $exp = new ilForumMoveTopicsExplorer($this, 'moveThreads'); $exp->setPathOpen($this->object->getRefId()); $exp->setNodeSelected(isset($_POST['frm_ref_id']) && (int) $_POST['frm_ref_id'] ? (int) $_POST['frm_ref_id'] : 0); $exp->setCurrentFrmRefId($this->object->getRefId()); $exp->setHighlightedNode($this->object->getRefId()); if (!$exp->handleCommand()) { $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_threads_move.html', 'Modules/Forum'); if (!$this->hideToolbar()) { $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this)); } $tblThr = new ilTable2GUI($this); $tblThr->setId('il_frm_thread_move_table_' . $this->object->getRefId()); $tblThr->setTitle($this->lng->txt('move_chosen_topics')); $tblThr->addColumn($this->lng->txt('subject'), 'top_name', '100%'); $tblThr->disable('header'); $tblThr->disable('footer'); $tblThr->disable('linkbar'); $tblThr->disable('sort'); $tblThr->disable('linkbar'); $tblThr->setLimit(PHP_INT_MAX); $tblThr->setRowTemplate('tpl.forums_threads_move_thr_row.html', 'Modules/Forum'); $tblThr->setDefaultOrderField('is_sticky'); $counter = 0; $result = array(); foreach ($threads2move as $thr_pk) { $objCurrentTopic = new ilForumTopic($thr_pk, $this->is_moderator); $result[$counter]['num'] = $counter + 1; $result[$counter]['thr_subject'] = $objCurrentTopic->getSubject(); unset($objCurrentTopic); ++$counter; } $tblThr->setData($result); $this->tpl->setVariable('THREADS_TABLE', $tblThr->getHTML()); $this->tpl->setVariable('FRM_SELECTION_TREE', $exp->getHTML()); $this->tpl->setVariable('CMD_SUBMIT', 'performMoveThreads'); $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('move')); $this->tpl->setVariable('FORMACTION', $this->ctrl->getFormAction($this, 'performMoveThreads')); } return true; }