public function executeRegister(sfWebRequest $request) { $this->redirectUnless($this->getUser()->isAuthenticated(), "@sf_guard_signin"); $this->form = new OauthRegisterForm(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('application')); if ($this->form->isValid()) { // The currently logged on user $user_id = $this->getUser()->getGuardUser()->getId(); // This should come from a form filled in by the requesting user $consumer = array('requester_name' => $this->form['name']->getValue(), 'requester_email' => $this->form['email']->getValue(), 'callback_uri' => $this->form['callback_uri']->getValue(), 'application_uri' => $this->form['application_uri']->getValue(), 'application_title' => $this->form['application_title']->getValue(), 'application_descr' => $this->form['application_descr']->getValue(), 'application_notes' => $this->form['application_notes']->getValue(), 'application_type' => $this->form['application_type']->getValue(), 'application_commercial' => $this->form['application_commercial']->getValue()); // Register the consumer $store = oauthSecurityManager::storeInstance(); $key = $store->updateConsumer($consumer, $user_id); // Get the complete consumer from the store $consumer = $store->getConsumer($key, $user_id); // Some interesting fields, the user will need the key and secret $this->consumer = $consumer; $this->consumer_id = $consumer['id']; $this->consumer_key = $consumer['consumer_key']; $this->consumer_secret = $consumer['consumer_secret']; $mailBody = $this->getPartial('mailBody', array('nombre' => $this->getUser()->getProfile()->getNombre(), "consumer" => $consumer)); $mailUser = sfConfig::get('app_mail_user'); VoMail::send(sfContext::getInstance()->getI18N()->__('Datos del registro de tu aplicaciĆ³n'), $mailBody, $this->getUser()->getGuardUser()->getUsername(), array($mailUser => 'no-reply'), true); return 'ShowData'; } } }
private function post_review($data) { try { $userId = oauthSecurityManager::checkAuthorized(); } catch (Exception $e) { throw new NotAuthorizedException($e->getMessage()); } $entityId = $this->getRequestParameter("entity"); $value = $this->getRequestParameter("value"); $text = $this->getRequestParameter("text", false); $type = $this->getRequestParameter("type"); $key = oauthSecurityManager::getConsummerKey(); if (!$entityId || !$value || !$type) { throw new BadRequestException("Not enough parameters."); } if ($value != -1 && $value != 1) { throw new BadRequestException("Invalid data for 'value'."); } $typeId = -1; switch ($type) { case 'politician': $typeId = Politico::NUM_ENTITY; $entity = PoliticoPeer::retrieveByPK($entityId); break; case 'party': $typeId = Partido::NUM_ENTITY; $entity = PartidoPeer::retrieveByPK($entityId); break; case 'proposal': $typeId = Propuesta::NUM_ENTITY; $entity = PropuestaPeer::retrieveByPK($entityId); break; default: throw new BadRequestException('Invalid type.'); } try { $this->review = SfReviewManager::postReview($userId, $typeId, $entityId, $value, $text, $entity, false, 0, $key); } catch (Exception $e) { throw new Exception($e->getMessage()); } return "saved."; }