X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fredirecturl.php;h=826ab66a679188dac905bcae3e6b2ce6b3721033;hb=c18020561b8a01bbb2b3fc092694a7bb0fde70f9;hp=0a959b074f8e69a7bd10907fe31ad435ead0e42b;hpb=570c7b63a2c0506e4876e27cd9ab56c16ce60b6c;p=quix0rs-gnu-social.git diff --git a/actions/redirecturl.php b/actions/redirecturl.php index 0a959b074f..826ab66a67 100644 --- a/actions/redirecturl.php +++ b/actions/redirecturl.php @@ -4,7 +4,7 @@ * Copyright (C) 2010, StatusNet, Inc. * * Redirect to the given URL - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -28,11 +28,7 @@ * @link http://status.net/ */ -if (!defined('STATUSNET')) { - // This check helps protect against security problems; - // your code file can't be executed directly from the web. - exit(1); -} +if (!defined('GNUSOCIAL')) { exit(1); } /** * Redirect to a given URL @@ -47,77 +43,27 @@ if (!defined('STATUSNET')) { * @link http://status.net/ */ -class RedirecturlAction extends Action +class RedirecturlAction extends ManagedAction { - protected $id = null; protected $file = null; - /** - * For initializing members of the class. - * - * @param array $argarray misc. arguments - * - * @return boolean true - */ - - function prepare($argarray) + protected function doPreparation() { - parent::prepare($argarray); - - $this->id = $this->trimmed('id'); - - if (empty($this->id)) { - throw new ClientException(_('No id parameter')); - } - - $this->file = File::staticGet('id', $this->id); - - if (empty($this->file)) { - throw new ClientException(sprintf(_('No such file "%d"'), - $this->id), - 404); - } + $this->file = File::getByID($this->int('id')); return true; } - /** - * Handler method - * - * @param array $argarray is ignored since it's now passed in in prepare() - * - * @return void - */ - - function handle($argarray=null) + public function showPage() { - common_redirect($this->file->url, 307); - return; + common_redirect($this->file->getUrl(false), 301); } - /** - * Return true if read only. - * - * MAY override - * - * @param array $args other arguments - * - * @return boolean is read only action? - */ - function isReadOnly($args) { return true; } - /** - * Return last modified, if applicable. - * - * MAY override - * - * @return string last modified http header - */ - function lastModified() { // For comparison with If-Last-Modified @@ -133,12 +79,11 @@ class RedirecturlAction extends Action * * @return string etag http header */ - function etag() { - return 'W/"' . implode(':', array($this->arg('action'), + return 'W/"' . implode(':', array($this->getActionName(), common_user_cache_hash(), common_language(), - $this->file->id)) . '"'; + $this->file->getID())) . '"'; } }