Example #1
0
 public function processRequest(Horde_Controller_Request $request, Horde_Controller_Response $response)
 {
     $this->_mapper = $GLOBALS['injector']->getInstance('Horde_Routes_Mapper');
     $this->_matchDict = new Horde_Support_Array($this->_mapper->match($request->getPath()));
     $injector = $this->getInjector();
     switch ($this->_matchDict->action) {
         case 'category':
             $driver = $injector->getInstance('Dolcore_Factory_Driver')->create($injector);
             $categories = $driver->getCategoriesApi();
             $discussionApi = $driver->getDiscussionApi();
             $category = $categories->getCategory($this->_matchDict->category);
             /* Write a category's currently running Umfragen */
             $now = new Horde_Date(time());
             $template = $this->getInjector()->createInstance('Horde_Template');
             $template->set('updated', $now->format(DATE_ATOM));
             $template->set('category_caption', $category->getCaption());
             $template->set('category_id', $category->id);
             $discussions = array();
             foreach ($discussionApi->listDiscussions(array('category' => $category->id)) as $discussion) {
                 $discussions[$discussion->id]['title'] = $discussion->text;
                 $discussions[$discussion->id]['details'] = $discussion->hintergrund;
                 $discussions[$discussion->id]['modified'] = $discussion->erstelldatum;
                 $discussions[$discussion->id]['id'] = Dolcore::getUrlFor('discussion', array('discussion_id' => $discussion->id), true, true);
                 $discussions[$discussion->id]['url'] = Dolcore::getUrlFor('discussion', array('discussion_id' => $discussion->id), true, true);
             }
             $template->set('discussions', $discussions);
             $response->setBody($template->fetch(DOLCORE_TEMPLATES . '/feeds/atom.xml'));
             break;
         case 'categories':
             break;
     }
 }
Example #2
0
 public function processRequest(Horde_Controller_Request $request, Horde_Controller_Response $response)
 {
     $id = Horde_Util::getFormData('bookmark');
     $gateway = $this->getInjector()->getInstance('Trean_Bookmarks');
     $notification = $this->getInjector()->getInstance('Horde_Notification');
     try {
         $bookmark = $gateway->getBookmark($id);
         $old_url = $bookmark->url;
         $bookmark->url = Horde_Util::getFormData('bookmark_url');
         $bookmark->title = Horde_Util::getFormData('bookmark_title');
         $bookmark->description = Horde_Util::getFormData('bookmark_description');
         $bookmark->tags = Horde_Util::getFormData('treanBookmarkTags');
         if ($old_url != $bookmark->url) {
             $bookmark->http_status = '';
         }
         $bookmark->save();
         $result = array('data' => 'saved');
     } catch (Horde_Exception $e) {
         $notification->push(sprintf(_("There was an error saving the bookmark: %s"), $e->getMessage()), 'horde.error');
         $result = array('error' => $e->getMessage());
     }
     if (Horde_Util::getFormData('format') == 'json') {
         $response->setContentType('application/json');
         $response->setBody(json_encode($result));
     } else {
         $response->setRedirectUrl(Horde_Util::getFormData('url', Horde::url('browse.php', true)));
     }
 }
Example #3
0
 protected function _pageGone(Horde_Controller_Response $response)
 {
     $view = $this->getView();
     $view->page_title = '410 - Page Gone';
     $layout = $this->getInjector()->getInstance('Horde_Core_Ui_Layout');
     $layout->setView($view);
     $layout->setLayoutName('main');
     $response->setHeaders(array('Status' => '410 Page Gone', 'HTTP/1.0' => '410 Page Gone'));
     $response->setBody($layout->render('410'));
 }
Example #4
0
 /**
  *
  * @param Horde_Controller_Response $response
  */
 protected function _index(Horde_Controller_Response $response)
 {
     $view = $this->getView();
     $view->page_title = 'Downloads - The Horde Project';
     $view->appListController = array('controller' => 'download', 'action' => 'app');
     $layout = $this->getInjector()->getInstance('Horde_Core_Ui_Layout');
     $layout->setView($view);
     $layout->setLayoutName('main');
     $response->setBody($layout->render('index'));
 }
Example #5
0
 public function testStreamOutput()
 {
     $output = 'BODY';
     $body = new Horde_Support_StringStream($output);
     $response = new Horde_Controller_Response();
     $response->setBody($body->fopen());
     $writer = new Horde_Controller_ResponseWriter_Web();
     ob_start();
     $writer->writeResponse($response);
     $this->assertEquals('BODY', ob_get_clean());
 }
Example #6
0
 /**
  */
 public function writeResponse(Horde_Controller_Response $response)
 {
     foreach ($response->getHeaders() as $key => $value) {
         header("{$key}: {$value}");
     }
     $body = $response->getBody();
     if (is_resource($body)) {
         stream_copy_to_stream($body, fopen('php://output', 'a'));
     } else {
         echo $body;
     }
 }
Example #7
0
 /**
  *
  * @param Horde_Controller_Response $response
  */
 protected function _index(Horde_Controller_Response $response)
 {
     $view = $this->getView();
     $view->page_title = 'The Horde Project';
     $view->maxHordeItems = 5;
     $view->maxPlanetItems = 10;
     $cache = $GLOBALS['injector']->getInstance('Horde_Cache');
     // Get the planet feed.
     if ($planet = $cache->get('planet', 600)) {
         $view->planet = unserialize($planet);
     } else {
         try {
             $view->planet = Horde_Feed::readUri('http://planet.horde.org/rss/');
         } catch (Exception $e) {
             $view->planet = null;
         }
         $cache->set('planet', serialize($view->planet));
     }
     // Get the complete Horde feed (no tags)
     if ($hordefeed = $cache->get('hordefeed', 600)) {
         $view->hordefeed = unserialize($hordefeed);
     } else {
         try {
             $view->hordefeed = Horde_Feed::readUri($GLOBALS['feed_url']);
         } catch (Exception $e) {
             $view->hordefeed = null;
         }
         $cache->set('hordefeed', serialize($view->hordefeed));
     }
     $layout = $this->getInjector()->getInstance('Horde_Core_Ui_Layout');
     $layout->setView($view);
     $layout->setLayoutName('home');
     $response->setBody($layout->render('index'));
 }
Example #8
0
 public function processRequest(Horde_Controller_Request $request, Horde_Controller_Response $response)
 {
     /* Toggle the task's completion status if we're provided with a
      * valid task ID. */
     $requestVars = $request->getRequestVars();
     if (isset($requestVars['task']) && isset($requestVars['tasklist'])) {
         $nag_task = new Nag_CompleteTask();
         $result = $nag_task->result($requestVars['task'], $requestVars['tasklist']);
     } else {
         $result = array('error' => 'missing parameters');
     }
     $requestVars = $request->getGetVars();
     if (!empty($requestVars['format']) && $requestVars['format'] == 'json') {
         $response->setContentType('application/json');
         $response->setBody(json_encode($result));
     } elseif ($requestVars['url']) {
         $response->setRedirectUrl($requestVars['url']);
     }
 }
Example #9
0
 public function processRequest(Horde_Controller_Request $request, Horde_Controller_Response $response)
 {
     $id = Horde_Util::getFormData('bookmark');
     $gateway = $this->getInjector()->getInstance('Trean_Bookmarks');
     $notification = $this->getInjector()->getInstance('Horde_Notification');
     try {
         $bookmark = $gateway->getBookmark($id);
         $gateway->removeBookmark($bookmark);
         $notification->push(_("Deleted bookmark: ") . $bookmark->title, 'horde.success');
         $result = array('data' => 'deleted');
     } catch (Horde_Exception $e) {
         $notification->push(sprintf(_("There was a problem deleting the bookmark: %s"), $e->getMessage()), 'horde.error');
         $result = array('error' => $e->getMessage());
     }
     if (Horde_Util::getFormData('format') == 'json') {
         $response->setContentType('application/json');
         $response->setBody(json_encode($result));
     } else {
         $response->setRedirectUrl(Horde_Util::getFormData('url', Horde::url('browse.php', true)));
     }
 }
Example #10
0
 public function writeResponse(Horde_Controller_Response $response)
 {
     $headerHtml = '<div><strong>Headers:</strong><pre>';
     $headers = $response->getHeaders();
     foreach ($headers as $key => $value) {
         $headerHtml .= htmlspecialchars("{$key}: {$value}\n");
     }
     echo $headerHtml . '</pre></div>';
     if (isset($headers['Location'])) {
         echo '<p>Redirect To: <a href="' . htmlspecialchars($headers['Location']) . '">' . htmlspecialchars($headers['Location']) . '</a></p>';
     }
     $body = $response->getBody();
     if (is_resource($body)) {
         $body = stream_get_contents($body);
     }
     if (isset($headers['Content-Encoding']) && $headers['Content-Encoding'] == 'gzip') {
         // Strip off the header and inflate it
         echo gzinflate(substr($body, 10));
     } else {
         echo $body;
     }
 }
Example #11
0
 public function processResponse(Horde_Controller_Request $request, Horde_Controller_Response $response, Horde_Controller $controller)
 {
     $body = $response->getBody();
     $body = gzencode($body);
     $response->setHeader('Content-Encoding', 'gzip');
     $response->setHeader('Content-Length', $this->_byteCount($body));
     $response->setBody($body);
     return $response;
 }
Example #12
0
 public function delete(Horde_Controller_Response $response, $params = array())
 {
     $response->setBody('deleted data for user "' . $params->owner . '"');
 }
Example #13
0
 /**
  * Redirect the user.
  *
  * @param Horde_Controller_Response  $response The response handler.
  *
  * @return NULL
  */
 private function _redirect(Horde_Controller_Response $response)
 {
     $response->setRedirectUrl($this->getUrl());
 }
Example #14
0
 /**
  * Library documentation section.
  *
  * @param Horde_Controller_Response $response
  */
 protected function _docs(Horde_Controller_Response $response)
 {
     $view = $this->getView();
     $layout = $this->getInjector()->getInstance('Horde_Core_Ui_Layout');
     if ($this->_isKnownLibrary($view)) {
         $template = 'docs';
         Horde::startBuffer();
         include $GLOBALS['fs_base'] . '/app/views/Library/libraries/' . $view->libraryName . '/docs/' . ($this->_matchDict->file ? $this->_matchDict->file : 'docs') . '.html';
         $view->content = Horde::endBuffer();
     } else {
         $template = '404';
     }
     $layout->setView($view);
     $layout->setLayoutName('main');
     $response->setBody($layout->render($template));
 }
Example #15
0
 protected function _screenshots(Horde_Controller_Response $response, $type)
 {
     $page_output = $GLOBALS['injector']->getInstance('Horde_PageOutput');
     $page_output->addScriptFile($script);
     $script = new Horde_Script_File_External($GLOBALS['host_base'] . '/js/jquery.lightbox-0.5.min.js');
     $page_output->addScriptFile($script);
     $css = new Horde_Themes_Element('jquery.lightbox-0.5.css', array('data' => array('fs' => $GLOBALS['fs_base'] . '/css/jquery.lightbox-0.5.css', 'uri' => $GLOBALS['host_base'] . '/css/jquery.lightbox-0.5.css')));
     $page_output->addStylesheet($css->fs, $css->uri);
     $js = '$(function() { $("a.lightbox").lightBox(
         {"imageBtnPrev": "' . $GLOBALS['host_base'] . '/images/lightbox-btn-prev.gif",
          "imageBtnNext": "' . $GLOBALS['host_base'] . '/images/lightbox-btn-next.gif",
          "imageLoading": "' . $GLOBALS['host_base'] . '/images/lightbox-ico-loading.gif",
          "imageBtnClose": "' . $GLOBALS['host_base'] . '/images/lightbox-btn-close.gif",
          "imageBlank": "' . $GLOBALS['host_base'] . '/images/lightbox-blank.gif"});})';
     $page_output->addInlineScript($js);
     $view = $this->getView();
     $view->page_title = 'Screenshots - ' . $view->appnameHuman . ' - The Horde Project';
     $layout = $this->getInjector()->getInstance('Horde_Core_Ui_Layout');
     $layout->setView($view);
     $layout->setLayoutName('main');
     $response->setBody($layout->render($type));
 }
Example #16
0
 public function processRequest(Horde_Controller_Request $request, Horde_Controller_Response $response)
 {
     global $nag_shares, $prefs;
     $vars = Horde_Variables::getDefaultVariables();
     $registry = $this->getInjector()->getInstance('Horde_Registry');
     $notification = $this->getInjector()->getInstance('Horde_Notification');
     $form = new Nag_Form_Task($vars, $vars->get('task_id') ? sprintf(_("Edit: %s"), $vars->get('name')) : _("New Task"));
     if (!$form->validate($vars)) {
         // Hideous
         $_REQUEST['actionID'] = 'task_form';
         require NAG_BASE . '/task.php';
         exit;
     }
     $form->getInfo($vars, $info);
     // Check if we are here due to a search_return push.
     if ($vars->search_return) {
         Horde::url('list.php', true)->add(array('actionID' => 'search_return', 'list' => $vars->list, 'tab_name' => $vars->tab_name))->redirect();
     }
     // Check if we are here due to a deletebutton push
     if ($vars->deletebutton) {
         try {
             $share = $nag_shares->getShare($info['old_tasklist']);
         } catch (Horde_Share_Exception $e) {
             $notification->push(sprintf(_("Access denied deleting task: %s"), $e->getMessage()), 'horde.error');
             Horde::url('list.php', true)->redirect();
         }
         if (!$share->hasPermission($registry->getAuth(), Horde_Perms::DELETE)) {
             $notification->push(_("Access denied deleting task"), 'horde.error');
             Horde::url('list.php', true)->redirect();
         }
         $storage = $this->getInjector()->getInstance('Nag_Factory_Driver')->create($info['old_tasklist']);
         try {
             $storage->delete($info['task_id']);
         } catch (Nag_Exception $e) {
             $notification->push(sprintf(_("Error deleting task: %s"), $e->getMessage()), 'horde.error');
             Horde::url('list.php', true)->redirect();
         }
         $notification->push(_("Task successfully deleted"), 'horde.success');
         Horde::url('list.php', true)->redirect();
     }
     if ($prefs->isLocked('default_tasklist') || count(Nag::listTasklists(false, Horde_Perms::EDIT, false)) <= 1) {
         $info['tasklist_id'] = $info['old_tasklist'] = Nag::getDefaultTasklist(Horde_Perms::EDIT);
     }
     try {
         $share = $nag_shares->getShare($info['tasklist_id']);
     } catch (Horde_Share_Exception $e) {
         $notification->push(sprintf(_("Access denied saving task: %s"), $e->getMessage()), 'horde.error');
         Horde::url('list.php', true)->redirect();
     }
     if (!$share->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
         $notification->push(_("Access denied saving task to this task list."), 'horde.error');
         Horde::url('list.php', true)->redirect();
     }
     /* If a task id is set, we're modifying an existing task.  Otherwise,
      * we're adding a new task with the provided attributes. */
     if (!empty($info['task_id']) && !empty($info['old_tasklist'])) {
         $storage = $this->getInjector()->getInstance('Nag_Factory_Driver')->create($info['old_tasklist']);
         $info['tasklist'] = $info['tasklist_id'];
         $result = $storage->modify($info['task_id'], $info);
     } else {
         /* Check permissions. */
         $perms = $this->getInjector()->getInstance('Horde_Core_Perms');
         if ($perms->hasAppPermission('max_tasks') !== true && $perms->hasAppPermission('max_tasks') <= Nag::countTasks()) {
             Horde::url('list.php', true)->redirect();
         }
         /* Creating a new task. */
         $storage = $this->getInjector()->getInstance('Nag_Factory_Driver')->create($info['tasklist_id']);
         // These must be unset since the form sets them to NULL
         unset($info['owner']);
         unset($info['uid']);
         try {
             $newid = $storage->add($info);
         } catch (Nag_Exception $e) {
             $notification->push(sprintf(_("There was a problem saving the task: %s."), $e->getMessage()), 'horde.error');
             Horde::url('list.php', true)->redirect();
         }
     }
     $notification->push(sprintf(_("Saved %s."), $info['name']), 'horde.success');
     /* Return to the last page or to the task list. */
     if ($vars->savenewbutton) {
         $url = Horde::url('task.php', true)->add(array('actionID' => 'add_task', 'tasklist_id' => $info['tasklist_id'], 'parent' => $info['parent']));
     } else {
         $url = Horde_Util::getFormData('url', (string) Horde::url('list.php', true));
         $url = Horde::url($url, true);
     }
     $response->setRedirectUrl($url);
 }
Example #17
0
 /**
  * Fetch remote data.
  *
  * @param Horde_Controller_Response  $response The response handler.
  *
  * @return NULL
  */
 public function _passThrough(Horde_Controller_Response $response)
 {
     $url = $this->getUrlWithCredentials($this->_user->getPrimaryId(), $this->_user->getPassword());
     $origin = $this->_client->get($url);
     if ($origin->code !== 200) {
         $url = $this->getUrlWithCredentials($this->_user, 'XXX');
         throw new Horde_Kolab_FreeBusy_Exception_Unauthorized(sprintf('Unable to read free/busy information from %s', $url));
     }
     $response->setHeader('X-Redirect-To', $url);
     $response->setBody($origin->getStream());
 }
Example #18
0
 /**
  */
 public function processRequest(Horde_Controller_Request $request, Horde_Controller_Response $response)
 {
     $response->setHeader('HTTP/1.0 404 ', 'Not Found');
     $response->setBody('<!DOCTYPE html><html><head><title>404 File Not Found</title></head><body><h1>404 File Not Found</h1></body></html>');
 }