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))); } }
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']); } }
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))); } }
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); }
/** * Redirect the user. * * @param Horde_Controller_Response $response The response handler. * * @return NULL */ private function _redirect(Horde_Controller_Response $response) { $response->setRedirectUrl($this->getUrl()); }