/** * Check Request object for required params * as well as for required form token * * @return object $this */ protected function initParams() { if ($this->bRequirePost && 'POST' !== Request::getRequestMethod()) { throw new \Lampcms\HttpResponseCodeException('HTTP POST request method required', 405); } $this->Request->setRequired($this->aRequired); try { $this->Request->checkRequired(); } catch (\Exception $e) { throw new \Lampcms\HttpResponseCodeException($e->getMessage(), 400); } return $this; }
/** * Check Request object for required params * as well as for required form token * * @return object $this */ protected function initParams() { if ($this->bRequirePost && 'POST' !== Request::getRequestMethod()) { throw new Exception('POST method required'); } $this->Request->setRequired($this->aRequired)->checkRequired(); if (true === $this->requireToken) { \Lampcms\Forms\Form::validateToken($this->Registry); } d('cp'); return $this; }
/** * Process the submitted "select default blog" form * This form is displayed to user when we detect that * user has more than one blog on Blogger, in which * case user is asked to pick one blog that will * be connected to this account * * * @throws \Exception if user does not have any blogs, which * is not really possible, so this would be totally unexpected */ protected function selectBlog() { if ('POST' !== Request::getRequestMethod()) { throw new \Lampcms\Exception('POST method required'); } \Lampcms\Forms\Form::validateToken($this->Registry); $a = $this->Registry->Viewer->getBloggerBlogs(); d('$a: ' . print_r($a, 1)); if (empty($a)) { throw new \Exception('No blogs found for this user'); } $selectedID = (int) substr($this->Request->get('blog'), 4); d('$selectedID: ' . $selectedID); /** * Pull the selected blog from array of user blogs * * @var unknown_type */ $aBlog = \array_splice($a, $selectedID, 1); d('$aBlog: ' . print_r($aBlog, 1)); d('a now: ' . print_r($a, 1)); /** * Now stick this blog to the * beginning of array. It will become * the first element, pushing other blogs * down in the array * User's "Connected" blog is always * the first blog in array! * */ \array_unshift($a, $aBlog[0]); d('a after unshift: ' . print_r($a, 1)); $this->Registry->Viewer->setBloggerBlogs($a); /** * Set b_bg to true which will result * in "Post to Blogger" checkbox to * be checked. User can uncheck in later */ $this->Registry->Viewer['b_bg'] = true; $this->Registry->Viewer->save(); $this->closeWindow(); }