setAgoraId() публичный Метод

Creates the Agora id.
public setAgoraId ( $forum_id, $message_id, $url = '', $scope = null, $encode = false ) : string
Результат string If passed with the $url parameter, returns a completed url with the agora_id tacked on at the end, otherwise returns the simple agora_id.
Пример #1
0
 /**
  */
 public function menu($menu)
 {
     $scope = Horde_Util::getGet('scope', 'agora');
     /* Agora Home. */
     $url = Horde::url('forums.php')->add('scope', $scope);
     $menu->add($url, _("_Forums"), 'forums.png', null, null, null, dirname($_SERVER['PHP_SELF']) == $GLOBALS['registry']->get('webroot') && basename($_SERVER['PHP_SELF']) == 'index.php' ? 'current' : null);
     /* Thread list, if applicable. */
     if (isset($GLOBALS['forum_id'])) {
         $menu->add(Agora::setAgoraId($GLOBALS['forum_id'], null, Horde::url('threads.php')), _("_Threads"), 'threads.png');
         if ($scope == 'agora' && $GLOBALS['registry']->getAuth()) {
             $menu->add(Agora::setAgoraId($GLOBALS['forum_id'], null, Horde::url('messages/edit.php')), _("New Thread"), 'newmessage.png');
         }
     }
     if ($scope == 'agora' && Agora_Driver::hasPermission(Horde_Perms::DELETE, 0, $scope)) {
         $menu->add(Horde::url('editforum.php'), _("_New Forum"), 'newforum.png', null, null, null, Horde_Util::getFormData('agora') ? '__noselection' : null);
     }
     if (Agora_Driver::hasPermission(Horde_Perms::DELETE, 0, $scope)) {
         $url = Horde::url('moderate.php')->add('scope', $scope);
         $menu->add($url, _("_Moderate"), 'moderate.png');
     }
     if ($GLOBALS['registry']->isAdmin()) {
         $menu->add(Horde::url('moderators.php'), _("_Moderators"), 'hot.png');
     }
     $url = Horde::url('search.php')->add('scope', $scope);
     $menu->add($url, _("_Search"), 'search.png');
 }
Пример #2
0
 /**
  */
 protected function _title()
 {
     if (!isset($this->_params['forum_id'])) {
         return $this->getName();
     }
     if (empty($this->_threads)) {
         $this->_threads = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create('agora', $this->_params['forum_id']);
         if ($this->_threads instanceof PEAR_Error) {
             return $this->getName();
         }
     }
     $title = sprintf(_("Threads in \"%s\""), $this->_threads->_forum['forum_name']);
     $url = Horde::url('threads.php', true);
     if (!empty($scope)) {
         $url->add('scope', $scope);
     }
     return Horde::link(Agora::setAgoraId($this->_params['forum_id'], null, $url)) . $title . '</a>';
 }
Пример #3
0
    }
    $threads_list = $messages->getThreads($message['message_thread'], true, 'message_timestamp', 1, 1, '', null, 0, 10);
    if ($threads_list instanceof PEAR_Error) {
        exit;
    }
    $rss = '<?xml version="1.0" encoding="UTF-8" ?>
    <rss version="2.0">
        <channel>
        <title>' . htmlspecialchars($message['message_subject']) . '</title>
        <language>' . str_replace('_', '-', strtolower($registry->preferredLang())) . '</language>
        <lastBuildDate>' . date('r') . '</lastBuildDate>
        <description>' . htmlspecialchars($message['message_subject']) . '</description>
        <link>' . Horde::url('index.php', true, -1) . '</link>
        <generator>' . htmlspecialchars($registry->get('name')) . '</generator>';
    foreach ($threads_list as $thread) {
        $url = Horde::url('messages/index.php', true, -1);
        $url = Agora::setAgoraId($forum_id, $thread['message_id'], $url, $scope, true);
        $rss .= '
        <item>
            <title>' . htmlspecialchars($thread['message_subject']) . ' </title>
            <description>' . htmlspecialchars(trim($thread['body'])) . ' </description>
            <link>' . $url . '</link>
        </item>';
    }
    $rss .= '
    </channel>
    </rss>';
    $cache->set($cache_key, $rss);
}
header('Content-type: text/xml; charset=UTF-8');
echo $rss;
Пример #4
0
 /**
  * Fetches a list of forums.
  *
  * @todo This function needs refactoring, as it doesn't return consistent
  * results. For example when running with $formatted = false it will return
  * an indexed array, but when running with $formatted = true the result is
  * associative array.
  *
  * @param integer $root_forum  The first level forum.
  * @param boolean $formatted   Whether to return the list formatted or raw.
  * @param string  $sort_by     The column to sort by.
  * @param integer $sort_dir    Sort direction, 0 = ascending,
  *                             1 = descending.
  * @param boolean $add_scope   Add parent forum if forum for another
  *                             scopelication.
  * @param string  $from        The forum to start listing at.
  * @param string  $count       The number of forums to return.
  *
  * @return mixed  An array of forums or PEAR_Error on failure.
  * @throws Agora_Exception
  */
 public function getForums($root_forum = 0, $formatted = true, $sort_by = 'forum_name', $sort_dir = 0, $add_scope = false, $from = 0, $count = 0)
 {
     /* Get messages data */
     $forums = $this->_getForums($root_forum, $formatted, $sort_by, $sort_dir, $add_scope, $from, $count);
     if ($forums instanceof PEAR_Error || empty($forums) || !$formatted) {
         return $forums;
     }
     $user = $GLOBALS['registry']->getAuth();
     $edit_url = Horde::url('messages/edit.php');
     $editforum_url = Horde::url('editforum.php');
     $delete_url = Horde::url('deleteforum.php');
     foreach ($forums as $key => &$forum) {
         if (!$this->hasPermission(Horde_Perms::SHOW, $forum['forum_id'], $forum['scope'])) {
             unset($forums[$key]);
             continue;
         }
         $forum['indentn'] = 0;
         $forum['indent'] = '';
         if (!$this->hasPermission(Horde_Perms::READ, $forum['forum_id'], $forum['scope'])) {
             continue;
         }
         $forum['url'] = Agora::setAgoraId($forum['forum_id'], null, Horde::url('threads.php'), $forum['scope'], true);
         $forum['message_count'] = number_format($forum['message_count']);
         $forum['thread_count'] = number_format($forum['thread_count']);
         if ($forum['last_message_id']) {
             $forum['last_message_date'] = $this->dateFormat($forum['last_message_timestamp']);
             $forum['last_message_url'] = Agora::setAgoraId($forum['forum_id'], $forum['last_message_id'], Horde::url('messages/index.php'), $forum['scope'], true);
         }
         $forum['actions'] = array();
         /* Post message button. */
         if ($this->hasPermission(Horde_Perms::EDIT, $forum['forum_id'], $forum['scope'])) {
             /* New Post forum button. */
             $url = Agora::setAgoraId($forum['forum_id'], null, $edit_url, $forum['scope'], true);
             $forum['actions'][] = Horde::link($url, _("Post message")) . _("New Post") . '</a>';
             if ($GLOBALS['registry']->isAdmin(array('permission' => 'agora:admin'))) {
                 /* Edit forum button. */
                 $url = Agora::setAgoraId($forum['forum_id'], null, $editforum_url, $forum['scope'], true);
                 $forum['actions'][] = Horde::link($url, _("Edit forum")) . _("Edit") . '</a>';
             }
         }
         if ($GLOBALS['registry']->isAdmin(array('permission' => 'agora:admin'))) {
             /* Delete forum button. */
             $url = Agora::setAgoraId($forum['forum_id'], null, $delete_url, $forum['scope'], true);
             $forum['actions'][] = Horde::link($url, _("Delete forum")) . _("Delete") . '</a>';
         }
         /* User is a moderator */
         if (isset($forum['moderators']) && in_array($user, $forum['moderators'])) {
             $sql = 'SELECT COUNT(forum_id) FROM ' . $this->_threads_table . ' WHERE forum_id = ? AND approved = ?' . ' GROUP BY forum_id';
             try {
                 $unapproved = $this->_db->selectValue($sql, array($forum['forum_id'], 0));
             } catch (Horde_Db_Exception $e) {
                 throw new Agora_Exception($e->getMessage());
             }
             $url = Horde::link(Horde::url('moderate.php', true), _("Moderate")) . _("Moderate") . '</a>';
             $forum['actions'][] = $url . ' (' . $unapproved . ')';
         }
     }
     return $forums;
 }
Пример #5
0
        $forums = $injector->getInstance('Agora_Factory_Driver')->create($scope);
        $threads = $forums->getThreadsByForumOwner($owner, 0, false, $sort_by, $sort_dir, false, 0, 5);
        echo '<h1 class="header">' . $scope_name . '</h1>';
        if ($threads instanceof PEAR_Error) {
            echo $threads->getMessage();
        } elseif (empty($threads)) {
            echo _("No threads");
        } else {
            $link_back = $registry->hasMethod('show', $scope);
            $url = Horde::url('agora/messages/index.php');
            /* link threads if possible */
            foreach ($threads as &$thread) {
                if ($link_back) {
                    $thread['link'] = Horde::link($registry->linkByPackage($scope, 'show', array('id' => $thread['forum_name'])));
                } else {
                    $thread['link'] = Horde::link(Agora::setAgoraId($thread['forum_id'], $thread['message_id'], $url, $scope, false));
                }
            }
            /* Set up the column headers. */
            $col_headers = array('message_subject' => _("Subject"), 'message_author' => _("Posted by"), 'message_timestamp' => _("Date"));
            $col_headers = Agora::formatColumnHeaders($col_headers, $sort_by, $sort_dir, 'threads');
            /* Set up the template tags. */
            $view = new Agora_View();
            $view->col_headers = $col_headers;
            $view->threads = $threads;
            echo $view->render('block/threads');
        }
        echo '<br />';
    }
}
$page_output->footer();
Пример #6
0
$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;
        }
    }
}
/* Template object. */
$view = new Agora_View();
Horde::startBuffer();
$form->renderActive(null, $vars, Horde::url('messages/move.php'), 'post');
$view->formbox = Horde::endBuffer();
$view->message_subject = $message['message_subject'];
$view->message_author = $message['message_author'];
$view->message_body = Agora_Driver::formatBody($message['body']);
$page_output->header();
echo $view->render('messages/edit');
$page_output->footer();
Пример #7
0
if ($threads_list instanceof PEAR_Error) {
    $notification->push($threads_list->getMessage(), 'horde.error');
    Horde::url('forums.php', true)->redirect();
}
/* Set up pager. */
if ($thread_count > $thread_per_page && $view_bodies == 2) {
    $vars = new Horde_Variables(array('thread_page' => $thread_page));
    $pager_ob = new Horde_Core_Ui_Pager('thread_page', $vars, array('num' => $thread_count, 'url' => 'messages/index.php', 'perpage' => $thread_per_page));
    $pager_ob->preserve('agora', Horde_Util::getFormData('agora'));
    $view->pager_link = $pager_ob->render();
}
/* Set up the column headers. */
$col_headers = array(array('message_thread' => _("Thread"), 'message_subject' => _("Subject")), 'message_author' => _("Posted by"), 'message_timestamp' => _("Date"));
$col_headers = Agora::formatColumnHeaders($col_headers, $sort_by, $sort_dir, 'thread');
/* Actions. */
$url = Agora::setAgoraId($forum_id, $message_id, Horde::url('messages/index.php'));
/* Get the thread table. */
switch ($view_bodies) {
    case '2':
        $threads_template = 'messages/flat';
        if (!$prefs->isLocked('thread_view_bodies')) {
            $actions[] = Horde::link($url->add('bodies', 0), _("Hide bodies")) . _("Hide bodies") . '</a>';
            $actions[] = Horde::link($url->add('bodies', 1), _("Thread")) . _("Thread") . '</a>';
        }
        $threads = $messages->getThreadsUi($threads_list, $col_headers, $view_bodies, $threads_template);
        break;
    case '1':
        $threads_template = 'messages/flat_thread';
        if (!$prefs->isLocked('thread_view_bodies')) {
            $actions[] = Horde::link($url->add('bodies', 0), _("Hide bodies")) . _("Hide bodies") . '</a>';
            $actions[] = Horde::link($url->add('bodies', 2), _("Flat")) . _("Flat") . '</a>';
Пример #8
0
        <lastBuildDate>' . date('r') . '</lastBuildDate>
        <description>' . htmlspecialchars($title) . '</description>
        <link>' . Horde::url('index.php', true, -1) . '</link>
        <generator>' . htmlspecialchars($registry->get('name')) . '</generator>';
    // Use commentCallback to get the return link
    // show is not enought as we can have many parameters, like turba source etc
    $url = Horde::url('messages/index.php', true, -1);
    if ($scope != 'agora' && $registry->hasMethod('commentCallback', $scope)) {
        $try = $registry->callByPackage($scope, 'commentCallback', array($forum_name, 'link'));
        if ($try instanceof PEAR_Error) {
            die($try->getMessage());
        }
        if (substr($url, 0, 4) == 'http') {
            $url = $try;
        }
    }
    foreach ($threads_list as $thread) {
        $rss .= '
        <item>
            <title>' . htmlspecialchars($thread['message_subject']) . ' </title>
            <description>' . htmlspecialchars(trim($thread['body'])) . ' </description>
            <link>' . Agora::setAgoraId($forum_id, $thread['message_id'], $url, $scope, true) . '</link>
        </item>';
    }
    $rss .= '
    </channel>
    </rss>';
    $cache->set($cache_key, $rss);
}
header('Content-type: text/xml; charset=UTF-8');
echo $rss;
Пример #9
0
if ($form->validate($vars)) {
    $form->getInfo($vars, $info);
    /* Try and store this message and get back a new message_id */
    $message_id = $messages->saveMessage($info);
    if ($message_id instanceof PEAR_Error) {
        $notification->push(_("Could not post the message: ") . $message_id->getDebugInfo(), 'horde.error');
    } else {
        if ($messages->_forum['forum_moderated']) {
            $notification->push(_("Your message has been enqueued and is awaiting moderation.  It will become visible after moderator approval."), 'horde.success');
        } else {
            $notification->push(_("Message posted."), 'horde.success');
        }
        if (!empty($info['url'])) {
            $url = Horde::url($info['url'], true);
        } else {
            $url = Agora::setAgoraId($forum_id, $message_id, Horde::url('messages/index.php', true), $scope);
        }
        header('Location: ' . $url);
        exit;
    }
}
/* Set up template */
$view = new Agora_View();
/* Check if a parent message exists and set up tags accordingly. */
if ($message_parent_id) {
    $message = $messages->replyMessage($message_parent_id);
    if (!$message instanceof PEAR_Error) {
        $vars->set('message_subject', $message['message_subject']);
        $vars->set('message_body_old', $message['body']);
        $view->message_subject = $message['message_subject'];
        $view->message_author = $message['message_author'];
Пример #10
0
        $vars->set('forum_id', $forum_id);
    } catch (Horde_Exception $e) {
        $notification->push($e->getMessage());
        unset($forum_id);
    }
}
$title = isset($forum_id) ? _("Edit Forum") : _("New Forum");
/* Check permissions */
if (isset($forum_id) && !$registry->isAdmin(array('permission' => 'agora:admin'))) {
    $notification->push(sprintf(_("You don't have permissions to edit forum %s"), $registry->get('name', $scope)), 'horde.warning');
    Horde::url('forums.php', true)->redirect();
}
if (!$registry->isAdmin(array('permission' => 'agora:admin'))) {
    $notification->push(sprintf(_("You don't have permissions to create a new forum in %s"), $registry->get('name', $scope)), 'horde.warning');
    Horde::url('forums.php', true)->redirect();
}
$form = new Agora_Form_Forum($vars, $title);
if ($form->validate()) {
    $forum_id = $form->execute($vars);
    if ($forum_id instanceof PEAR_Error) {
        $notification->push(sprintf(_("Could not create the forum. %s"), $forum_id->message), 'horde.error');
        Horde::url('forums.php', true)->redirect();
    }
    $notification->push($vars->get('forum_id') ? _("Forum Modified") : _("Forum created."), 'horde.success');
    header('Location: ' . Agora::setAgoraId($forum_id, null, Horde::url('threads.php', true)));
    exit;
}
$page_output->header(array('title' => $title));
$notification->notify(array('listeners' => 'status'));
$form->renderActive(null, null, Horde::url('editforum.php'), 'post');
$page_output->footer();
Пример #11
0
    $notification->push($forums->message, 'horde.error');
    Horde::url('forums.php', true)->redirect();
}
/* Check permissions */
if (!$forums->hasPermission(Horde_Perms::DELETE)) {
    $notification->push(sprintf(_("You don't have permissions to ban users from forum %s."), $forum_id), 'horde.warning');
    Horde::url('forums.php', true)->redirect();
}
/* Ban action */
if (($action = Horde_Util::getFormData('action')) !== null) {
    $user = Horde_Util::getFormData('user');
    $result = $forums->updateBan($user, $forum_id, $action);
    if ($result instanceof PEAR_Error) {
        $notification->push($result->getMessage(), 'horde.error');
    }
    $url = Agora::setAgoraId($forum_id, null, Horde::url('ban.php', true), $scope);
    header('Location: ' . $url);
    exit;
}
/* Get the list of banned users. */
$delete = Horde::url('ban.php')->add(array('action' => 'delete', 'scope' => $scope, 'forum_id' => $forum_id));
$banned = $forums->getBanned();
foreach ($banned as $user => $level) {
    $banned[$user] = Horde::link($delete->add('user', $user), _("Delete")) . $user . '</a>';
}
$title = _("Ban");
$vars = Horde_Variables::getDefaultVariables();
$form = new Horde_Form($vars, $title);
$form->addHidden('', 'scope', 'text', false);
$form->addHidden('', 'agora', 'text', false);
$form->addHidden('', 'action', 'text', false);