X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FGNUsocialVideo%2Factions%2Fpostvideo.php;h=aae0fe98e649a4e3b5cc4280929a8b049c805851;hb=d9b35208ecda59292680fb55e38c56b2831d5366;hp=8ed664c588c70edfb75e1162ab20dd7e401c9eac;hpb=8f37b432f82ffa5381d670ede65d6e63c8aea574;p=quix0rs-gnu-social.git diff --git a/plugins/GNUsocialVideo/actions/postvideo.php b/plugins/GNUsocialVideo/actions/postvideo.php index 8ed664c588..aae0fe98e6 100644 --- a/plugins/GNUsocialVideo/actions/postvideo.php +++ b/plugins/GNUsocialVideo/actions/postvideo.php @@ -1,7 +1,7 @@ - * @copyright 2010 Free Software Foundation, Inc. + * @copyright 2011 Free Software Foundation, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 */ @@ -32,49 +32,59 @@ if (!defined('STATUSNET')) { class PostvideoAction extends Action { var $user = null; + var $url = null; - function prepare($args) + function prepare(array $args=array()) { parent::prepare($args); $this->user = common_current_user(); + + if(empty($this->user)){ + throw new ClientException(_('Must be logged in to post a video'), + 403); + } + + if($this->isPost()){ + $this->checkSessionToken(); + } + + $this->url = filter_var($this->trimmed('url'), FILTER_SANITIZE_URL); + $this->url = filter_var($this->url, FILTER_VALIDATE_URL); + return true; } - function handle($args) + function handle(array $args=array()) { parent::handle($args); - if ($_SERVER['REQUEST_METHOD'] == 'POST') { + + if ($this->isPost()) { $this->handlePost($args); + } else { + $this->showPage(); } - $this->showPage(); } function handlePost($args) { - if (!$this->arg('post')) { - return; + if (empty($this->url)) { + throw new ClientException(_('Bad URL.')); } - if (empty($_POST['video_uri'])) { - return; - } - $uri = $_POST['video_uri']; - // XXX: validate your inputs, dummy. - $rend = sprintf('', $uri); - Notice::saveNew($this->user->id, 'video : ' . $uri, 'web', array('rendered' => $rend)); + + $profile = $this->user->getProfile(); + + $options = array(); + + ToSelector::fillOptions($this, $options); + + $vid = Video::saveNew($profile, $this->url, $options); + + common_redirect($vid->uri, 303); } function showContent() { - if(empty($this->user)) { - $this->element('p', array(), 'You are not logged in.'); - } else { - $this->elementStart('form', array('method' => 'post', - 'action' => common_local_url('postvideo'))); - $this->element('input', array('name' => 'video_uri', - 'type' => 'text', - 'id' => 'video_uri')); - $this->submit('post', _('Post')); - $this->elementEnd('form'); - } + $form = new VideoForm(); + $form->show(); } }