コード例 #1
0
ファイル: actions.class.php プロジェクト: voota/voota
 public function executeContact(sfWebRequest $request)
 {
     $t = $request->getParameter("t", '');
     $e = $request->getParameter("e", '');
     $this->form = new ContactForm();
     if ($t) {
         $this->form->setDefaultMsg("{$e}: {$t}");
     }
     if ($request->isMethod('post') && !$t) {
         $this->form->bind($request->getParameter('contact'));
         if ($this->form->isValid()) {
             try {
                 $mailBody = $this->getPartial('contactMailBody', array('nombre' => $this->form->getValue('nombre'), 'mensaje' => $this->form->getValue('mensaje'), 'email' => $this->form->getValue('email')));
                 VoMail::sendWithRet("Contacto web [" . $this->form->getValue('tipo') . "]", $mailBody, 'info-es@voota.es', array('no-reply@voota.es' => 'no-reply Voota'), $this->form->getValue('email'), true);
                 return "SendSuccess";
             } catch (Exception $e) {
                 return "SendFail";
             }
             /*
             	    $c = new Criteria();
             	    $c->add(sfGuardUserPeer::USERNAME, $this->form->getValue('username'));
             	
             	    $user = sfGuardUserPeer::doSelectOne($c);
             if ($user){
             	$this->sendReminder( $user );
             	return "SentSuccess";
             }
             else {
             	return "SentFail";
             }
             */
         }
     }
 }
コード例 #2
0
 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';
         }
     }
 }
コード例 #3
0
ファイル: actions.class.php プロジェクト: voota/voota
 public function executeContact(sfWebRequest $request)
 {
     $this->checkUser();
     $vanity = $request->getParameter('username');
     $this->f = $request->getParameter('f');
     $c = new Criteria();
     $c->add(SfGuardUserProfilePeer::VANITY, $vanity, Criteria::EQUAL);
     $userProfile = SfGuardUserProfilePeer::doSelectOne($c);
     $this->forward404Unless($userProfile);
     $this->user = $userProfile->getsfGuardUser();
     $this->form = new UserContactForm();
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter('contact'));
         if ($this->form->isValid()) {
             if ($this->user->getProfile()->getMailsContacto() == 1) {
                 $codigo = util::generateUID();
                 $this->user->getProfile()->setCodigo($codigo);
                 $this->user->getProfile()->save();
                 $mailBody = $this->getPartial('contactMailBody', array('destinatario' => $this->user->getProfile()->getNombre(), 'remitente' => $this->getUser()->getProfile()->getNombre(), 'cuerpo' => $this->form->getValue('mensaje'), 'vanity' => $this->getUser()->getProfile()->getVanity(), 'codigo' => $codigo));
                 try {
                     VoMail::sendWithRet("Tienes un mensaje de " . $this->getUser()->getProfile()->getNombre() . "", $mailBody, $this->user->getUsername(), array('no-reply@voota.es' => 'no-reply Voota'), $this->getUser()->getUsername(), true);
                     return "SendSuccess";
                 } catch (Exception $e) {
                     return "SendFail";
                 }
             } else {
                 return "SendFail";
             }
         }
         return "SendSuccess";
     }
 }
コード例 #4
0
ファイル: VoMail.class.php プロジェクト: voota/voota
 public static function sendWithRet($subject, $mailBody, $to, $from, $ret, $spoolMe = false)
 {
     VoMail::doSend($subject, $mailBody, $to, $from, $ret, $spoolMe);
 }
コード例 #5
0
ファイル: actions.class.php プロジェクト: voota/voota
 public function executeTake(sfWebRequest $request)
 {
     $id = $request->getParameter('id');
     $this->politico = PoliticoPeer::retrieveByPK($id);
     if (!$this->getUser()->isAuthenticated()) {
         $url = 'politico/take?id=' . $id;
         $this->getUser()->setAttribute('url_back', $url, 'vo/redir');
     }
     $this->redirectUnless($this->getUser()->isAuthenticated(), "@sf_guard_signin");
     $id = $request->getParameter('id');
     $this->politico = PoliticoPeer::retrieveByPK($id);
     if ($this->politico) {
         $op = $request->getParameter("op", "a");
         if ($op == "c") {
             $this->politico->setSfGuardUserId($this->getUser()->getGuardUser()->getId());
             $this->politico->setModifiedAt(new DateTime());
             $this->politico->save();
             // Send mail to politician
             if ($this->politico->getEmail() && SfVoUtil::isEmail($this->politico->getEmail())) {
                 $mailBody = $this->getPartial('mailTakePolitico', array('nombrePolitico' => $this->politico->getNombre(), "nombreUsuario" => $this->getUser()->getGuardUser()->getProfile()->getNombreOri() . ' ' . $this->getUser()->getGuardUser()->getProfile()->getApellidosOri(), "vanityUsuario" => $this->getUser()->getGuardUser()->getProfile()->getVanity(), "vanityPolitico" => $this->politico->getVanity()));
                 VoMail::send(sfContext::getInstance()->getI18N()->__('%usuario% ha sido autorizado para editar tu información en Voota', array('%usuario%' => $this->getUser()->getGuardUser()->getProfile()->getNombreOri() . ' ' . $this->getUser()->getGuardUser()->getProfile()->getApellidosOri())), $mailBody, $this->politico->getEmail(), array('no-reply@voota.es' => 'no-reply Voota'), true);
             }
             if (SfVoUtil::isEmail($this->getUser()->getGuardUser()->getUsername()) && (!$this->politico->getEmail() || $this->politico->getEmail() != $this->getUser()->getGuardUser()->getUsername())) {
                 $mailBody = $this->getPartial('mailTakeUsuario', array('nombrePolitico' => $this->politico->getNombre(), "nombreUsuario" => $this->getUser()->getGuardUser()->getProfile()->getNombreOri() . ' ' . $this->getUser()->getGuardUser()->getProfile()->getApellidosOri(), "vanityUsuario" => $this->getUser()->getGuardUser()->getProfile()->getVanity(), "vanityPolitico" => $this->politico->getVanity()));
                 VoMail::send(sfContext::getInstance()->getI18N()->__('bienvenido a la comunidad de políticos de Voota'), $mailBody, $this->getUser()->getGuardUser()->getUsername(), array('no-reply@voota.es' => 'no-reply Voota'), true);
             }
             return "Confirm";
         }
     }
     return "Ask";
 }
コード例 #6
0
ファイル: flushMailTask.class.php プロジェクト: voota/voota
 protected function execute($arguments = array(), $options = array())
 {
     VoMail::flush();
 }
コード例 #7
0
ファイル: actions.class.php プロジェクト: voota/voota
 public function sendTasks(sfWebRequest $request)
 {
     $tw_publish = $request->getParameter("tw_publish", 0);
     $t = $request->getParameter("t", false);
     $v = $request->getParameter("v", false);
     $e = $request->getParameter("e", false);
     $review_text = $request->getParameter("review_text", false);
     $this->updateSums($request);
     if ($t) {
         $type = SfReviewTypePeer::retrieveByPk($t);
         $peer = $type->getModel() . "Peer";
         $entity = call_user_func("{$peer}::retrieveByPk", $e);
     } else {
         $review = SfReviewPeer::retrieveByPk($request->getParameter('e'));
         if ($typeId = $review->getSfReviewTypeId()) {
             $type = SfReviewTypePeer::retrieveByPK($typeId);
             $peer = $type->getModule() . 'Peer';
             $entity = call_user_func("{$peer}::retrieveByPk", $review->getEntityId());
         }
     }
     $msg = "";
     if ($tw_publish && TwitterManager::verify($this->getUser())) {
         switch ($t) {
             case Politico::NUM_ENTITY:
                 $entityUrl = sfContext::getInstance()->getController()->genUrl("politico/show?id=" . $entity->getVanity(), true);
                 $msg = sfContext::getInstance()->getI18N()->__('Voto  %1% de %2% en @Voota:  %3%', array('%1%' => $v == -1 ? sfContext::getInstance()->getI18N()->__('en contra') : sfContext::getInstance()->getI18N()->__('a favor'), '%2%' => $entity, '%3%' => TwitterManager::shorten($entityUrl)));
                 break;
             case Partido::NUM_ENTITY:
                 $entityUrl = sfContext::getInstance()->getController()->genUrl("partido/show?id=" . $entity->getAbreviatura(), true);
                 $msg = sfContext::getInstance()->getI18N()->__('Voto %1% del partido %2% en @Voota: %3%', array('%1%' => $v == -1 ? sfContext::getInstance()->getI18N()->__('en contra') : sfContext::getInstance()->getI18N()->__('a favor'), '%2%' => $entity->getAbreviatura(), '%3%' => TwitterManager::shorten($entityUrl)));
                 break;
             case Propuesta::NUM_ENTITY:
                 $entityUrl = sfContext::getInstance()->getController()->genUrl("propuesta/show?id=" . $entity->getVanity(), true);
                 $msg = sfContext::getInstance()->getI18N()->__('Voto %1% de la propuesta "%2%" en @Voota: %3%', array('%1%' => $v == -1 ? sfContext::getInstance()->getI18N()->__('en contra') : sfContext::getInstance()->getI18N()->__('a favor'), '%2%' => SfVoUtil::cutToLength($entity->getTitulo(), 60, '...', true), '%3%' => TwitterManager::shorten($entityUrl)));
                 break;
             case "":
                 $entityUrl = sfContext::getInstance()->getController()->genUrl($type->getModule() . "/show?id=" . $entity->getVanity(), true);
                 $msg = sfContext::getInstance()->getI18N()->__('Vooto %1% de una opinión sobre %2% en @Voota: %3%', array('%1%' => $v == -1 ? sfContext::getInstance()->getI18N()->__('en contra') : sfContext::getInstance()->getI18N()->__('a favor'), '%2%' => $entity, '%3%' => TwitterManager::shorten($entityUrl)));
                 break;
         }
         TwitterManager::post($this->getUser(), $msg);
     }
     // Enviar email
     if (!$t) {
         //echo $request->getParameter('i');
         $user = $review->getsfGuardUser();
         if ($user->getProfile()->getMailsComentarios()) {
             if ($typeId) {
                 $user->getProfile()->setCodigo(util::generateUID());
                 $user->getProfile()->save();
                 $mailBody = $this->getPartial('reviewLeftMailBody', array('nombre' => $user->getProfile()->getNombre(), 'usuario' => $review->getAnonymous() ? sfContext::getInstance()->getI18N()->__('anónimo (está en su derecho)') : $this->getUser()->getProfile()->getNombre() . ' ' . $this->getUser()->getProfile()->getApellidos(), 'entity' => $typeId == Propuesta::NUM_ENTITY ? "\"{$entity}\"" : $entity, 'texto_ori' => $review->getText(), 'comentario' => $request->getParameter('review_text'), 'vanity' => $entity->getVanity(), 'codigo' => $user->getProfile()->getCodigo(), 'voto' => $request->getParameter('v'), 'module' => $entity->getModule()));
                 VoMail::send(sfContext::getInstance()->getI18N()->__('Tu vooto sobre %1% tiene un comentario', array('%1%' => $entity)), $mailBody, $user->getUsername(), array('no-reply@voota.es' => 'no-reply Voota'), true);
             }
         }
     }
 }
コード例 #8
0
ファイル: actions.class.php プロジェクト: voota/voota
 public function executeRemove(sfWebRequest $request)
 {
     $codigo = $request->getParameter("codigo");
     $this->redirectUnless($this->getUser()->isAuthenticated(), "@sf_guard_signin");
     if ($codigo == '') {
         $this->getUser()->getProfile()->setCodigo(util::generateUID());
         $this->getUser()->getProfile()->save();
         $mailBody = $this->getPartial('removeMailBody', array('nombre' => $this->getUser()->getProfile()->getNombre(), 'codigo' => $this->getUser()->getProfile()->getCodigo()));
         $this->email = $this->getUser()->getUsername();
         VoMail::send(sfContext::getInstance()->getI18N()->__('Borrarse de Voota'), $mailBody, $this->getUser()->getUsername(), array('no-reply@voota.es' => 'no-reply Voota'), false);
     } else {
         $c = new Criteria();
         $c->addJoin(SfGuardUserProfilePeer::USER_ID, sfGuardUserPeer::ID);
         $c->add(SfGuardUserProfilePeer::CODIGO, $codigo);
         $user = sfGuardUserPeer::doSelectOne($c);
         $this->forward404Unless($user);
         SfReviewManager::deleteReviewById($user->getId());
         $user->delete();
         if ($this->getUser()->isAuthenticated()) {
             $this->getUser()->signOut();
         }
         return 'Confirm';
     }
 }