. ' as a leader.
public formatCategoryTree ( array $forums ) : array | ||
$forums | array | The list of forums to format. |
리턴 | array | Formatted forum list. |
/** */ function __construct(&$vars, $title) { global $forums, $conf; parent::__construct($vars, $title); try { $forums_list = Agora::formatCategoryTree($forums->getForums(0, false, 'forum_name', 0, true)); } catch (Horde_Exception_NotFound $e) { $this->addHidden('', 'forum_parent_id', 'text', false); $vars->set('forum_parent_id', key($forums_list)); } $this->setButtons($vars->get('forum_id') ? _("Update") : _("Create")); $this->addHidden('', 'forum_id', 'int', false); $this->addVariable(_("Forum name"), 'forum_name', 'text', true); $this->addVariable(_("Parent forum"), 'forum_parent_id', 'enum', false, false, null, array($forums_list, true)); $this->addVariable(_("Enter a brief description of this forum"), 'forum_description', 'longtext', false, false, null, array(4, 40)); $this->addVariable(_("Is this a moderated forum?"), 'forum_moderated', 'boolean', false, false, _("Set this if you want all messages to be checked by a moderator before they are posted.")); $this->addVariable(_("Optional email address to recieve a copy of each posted message"), 'forum_distribution_address', 'text', false, false); if ($conf['forums']['enable_attachments'] == '0') { $this->addVariable(_("Allow attachments in this forum?"), 'forum_attachments', 'boolean', false, false, _("If selected users will be able to attach files to their messages.")); } }
Horde::url('forums.php', true)->redirect(); } /* Check delete permissions */ if (!$messages->hasPermission(Horde_Perms::DELETE)) { $notification->push(sprintf(_("You don't have permission to delete messages in forum %s."), $forum_id), 'horde.warning'); $url = Agora::setAgoraId($forum_id, $message_id, Horde::url('messages/index.php', true), $scope); header('Location: ' . $url); exit; } /* Get the form object. */ $vars = Horde_Variables::getDefaultVariables(); $form = new Horde_Form($vars, sprintf(_("Move \"%s\" to another forum"), $message['message_subject'])); $form->setButtons(array(_("Move"), _("Cancel"))); $form->addHidden('', 'agora', 'text', false); $form->addHidden('', 'scope', 'text', false); $forums_list = Agora::formatCategoryTree($messages->getForums(0, false)); $v =& $form->addVariable(_("Forum"), 'new_forum_id', 'enum', true, false, null, array($forums_list)); $v->setDefault($forum_id); /* Validate the form. */ if ($form->validate()) { $form->getInfo($vars, $info); if ($vars->get('submitbutton') == _("Move")) { $move = $messages->moveThread($message_id, $info['new_forum_id']); if ($move instanceof PEAR_Error) { $notification->push($move->getMessage(), 'horde.error'); } else { $notification->push(sprintf(_("Thread %s moved to from forum %s to %s."), $message_id, $forum_id, $info['new_forum_id']), 'horde.success'); header('Location: ' . Agora::setAgoraId($info['new_forum_id'], $message_id, Horde::url('messages/index.php', true), $scope)); exit; } }
} foreach ($forum['moderators'] as $id => $moderator) { $delete = $url->add(array('moderator' => $moderator, 'forum_id' => $forum['forum_id'])); $forums_list[$key]['moderators'][$id] = Horde::link($delete, _("Delete")) . $moderator . '</a>'; } } $title = _("Moderators"); $vars = Horde_Variables::getDefaultVariables(); $form = new Horde_Form($vars, $title); $form->addHidden('', 'scope', 'text', false); $form->addHidden('', 'action', 'text', false); $vars->set('action', 'add'); $form->addVariable(_("Moderator"), 'moderator', 'text', true); if ($messages->countForums() > 50) { $form->addVariable(_("Forum"), 'forum_id', 'int', true); } else { $forums_enum = Agora::formatCategoryTree($messages->getForums(0, false, 'forum_name', 0, !$registry->isAdmin())); $form->addVariable(_("Forum"), 'forum_id', 'enum', true, false, false, array($forums_enum)); } /* Set up template data. */ $view = new Agora_View(); Horde::startBuffer(); $form->renderActive(null, null, Horde::url('moderators.php'), 'post'); $view->formbox = Horde::endBuffer(); Horde::startBuffer(); $notification->notify(array('listeners' => 'status')); $view->notify = Horde::endBuffer(); $view->forums = $forums_list; $page_output->header(array('title' => $title)); echo $view->render('moderators'); $page_output->footer();
$notification->push($forum->message, 'horde.error'); Horde::url('forums.php', true)->redirect(); } /* Prepare forum. */ $vars = Horde_Variables::getDefaultVariables(); $form = new Horde_Form($vars, _("Delete Forum")); // TODO Cancel button doesn't work currently, because it has no condition set $form->setButtons(array(_("Delete"), _("Cancel"))); $form->addHidden('', 'forum_id', 'int', $forum_id); $form->addHidden('', 'scope', 'text', $scope); $form->addVariable(_("This will delete the forum, any subforums and all relative messages."), 'prompt', 'description', false); $form->addVariable(_("Forum name"), 'forum_name', 'text', false, true); $vars->set('forum_name', $forum['forum_name']); $vars->set('forum_id', $forum_id); /* Get a list of available forums. */ $forums_list = Agora::formatCategoryTree($forums->getForums($forum_id, false, null, null)); if (!empty($forums_list)) { $html = implode('<br />', $forums_list); $form->addVariable(_("Subforums"), 'subforums', 'html', false, true); $vars->set('subforums', $html); } /* Process delete. */ if ($form->validate()) { if ($vars->get('submitbutton') == _("Delete")) { try { // TODO also delete child forums as we state in the GUI $forums->deleteForum($vars->get('forum_id')); $notification->push(_("Forum deleted."), 'horde.success'); } catch (Agora_Exception $e) { $notification->push(sprintf(_("Could not delete the forum. %s"), $e->getMessage()), 'horde.error'); }