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

Determines the requested forum_id, message_id and application by checking first if they are passed as the single encoded var or individual vars.
public getAgoraId ( ) : array
Результат array Forum, message id and application.
Пример #1
0
<?php

/**
 * Copyright 2007-2016 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @author Duck <*****@*****.**>
 */
require_once __DIR__ . '/../lib/Application.php';
Horde_Registry::appInit('agora', array('authentication' => 'none'));
// Show a specific scope?
list($forum_id, $message_id, $scope) = Agora::getAgoraId();
$cache_key = 'agora_rss_' . $scope . '_' . $forum_id . '_' . $message_id;
/* Initialize the Cache object. */
$cache = $injector->getInstance('Horde_Cache');
$rss = $cache->get($cache_key, $conf['cache']['default_lifetime']);
if (!$rss) {
    $messages = $injector->getInstance('Agora_Factory_Driver')->create($scope, $forum_id);
    $message = $messages->getMessage($message_id);
    if ($message instanceof PEAR_Error) {
        exit;
    }
    $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>
Пример #2
0
/**
 * The Agora script to display a list of threads in a forum.
 *
 * Copyright 2003-2016 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @author Jan Schneider <*****@*****.**>
 * @author Marko Djukic <*****@*****.**>
 */
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('agora');
/* Make sure we have a forum id. */
list($forum_id, , $scope) = Agora::getAgoraId();
if (empty($forum_id)) {
    Horde::url('forums.php', true)->redirect();
}
/* Check if this is a valid thread, otherwise show the forum list. */
$threads = $injector->getInstance('Agora_Factory_Driver')->create($scope, $forum_id);
if ($threads instanceof PEAR_Error) {
    $notification->push(sprintf(_("Could not list threads. %s"), $threads->getMessage()), 'horde.warning');
    Horde::url('forums.php', true)->redirect();
}
/* Which thread page are we on?  Default to page 0. */
$thread_page = Horde_Util::getFormData('thread_page', 0);
$threads_per_page = $prefs->getValue('threads_per_page');
$thread_start = $thread_page * $threads_per_page;
/* Get the forum data. */
$forum_array = $threads->getForum();
Пример #3
0
 *
 * @author Jan Schneider <*****@*****.**>
 * @author Marko Djukic <*****@*****.**>
 */
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('agora');
/* Set up the forums object. */
$scope = Horde_Util::getFormData('scope', 'agora');
$forums = $injector->getInstance('Agora_Factory_Driver')->create($scope);
/* Check permissions */
if (!$forums->hasPermission(Horde_Perms::DELETE)) {
    $notification->push(sprintf(_("You don't have permissions to delete forums in %s"), $registry->get('name', $scope)), 'horde.warning');
    Horde::url('forums.php', true)->redirect();
}
/* Get forum. */
list($forum_id) = Agora::getAgoraId();
$forum = $forums->getForum($forum_id);
if ($forum instanceof PEAR_Error) {
    $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']);
Пример #4
0
 /**
  * Allows other Horde apps to post messages.
  *
  * In most apps we use the same code to make comments possible. This function
  * does most of that. Allow comments to be added to any app. The app itself
  * should check if the agora api is present, determine a key and call this
  * function before app::menu is called (before any output has started. At the
  * end of its output it can print the array returned to show the comments.
  *
  * @access private
  *
  * @param string $scope          The application which is posting this message.
  * @param string $key            Unique key from the object (picture etc we're
  *                               viewing. It will be used as the forum name.
  * @param string $callback       A callback method of the specified application
  *                               that gets called to make sure that posting to
  *                               this forum is allowed.
  * @param boolean $body          Show the comment bodies in the thread view or
  *                               not.
  * @param string $base_url       Base URL the edit/delete/reply links should
  *                               point to.
  * @param string $url            If specified, the form gets submitted to this
  *                               URL instead of the current page.
  * @param array $variables       A hash with all variables of a submitted form
  *                               generated by this method.
  * @param string $template_file  Template file to use.
  *
  * @return mixed array  Returns either the rendered Horde_Form for comments
  *                      and threads for posting/viewing a message or PEAR
  *                      objects on error.
  */
 public function doComments($scope, $key, $callback, $bodies = true, $base_url = null, $url = null, $variables = null, $template_file = false)
 {
     if (is_null($base_url)) {
         $base_url = Horde::selfUrl(true);
     }
     list($forum_id, $message_id) = Agora::getAgoraId();
     $params = array();
     if ($message_id) {
         $params['message_id'] = $message_id;
     }
     if ($parent = Horde_Util::getFormData('message_parent_id')) {
         $params['message_parent_id'] = $parent;
     }
     // See if we're editing.
     if (isset($params['message_id'])) {
         $params['title'] = _("Edit a comment");
     } else {
         $params['title'] = _("Add a comment");
         $params['message_id'] = null;
     }
     if (Horde_Util::getFormData('delete') === null) {
         $comments = $this->postMessage($scope, $key, $callback, $params, $url, $variables);
     } else {
         $comments = $this->removeMessage($scope, $key, $callback, $params, $url, $variables);
     }
     if ($comments instanceof PEAR_Error) {
         return $comments;
     }
     include AGORA_BASE . '/lib/Comments.php';
     $threads = Agora_ViewComments::render($key, $scope, $base_url, $template_file);
     if ($threads instanceof PEAR_Error) {
         $threads = $threads->getMessage();
     }
     if ($comments instanceof PEAR_Error) {
         $comments = $comments->getMessage();
     }
     return array('threads' => $threads, 'comments' => $comments);
 }