Exemple #1
0
 public static function isCanonicalVootaUser($user)
 {
     return $user && $user->getProfile()->getNombre() && $user->getProfile()->getNombre() != '' && SfVoUtil::isEmail($user->getUsername());
 }
Exemple #2
0
 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'), 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'), true);
             }
             return "Confirm";
         }
     }
     return "Ask";
 }
Exemple #3
0
            ?>
</li>
            	<?php 
        }
        ?>
            <?php 
    }
    ?>
          </ul>
        </div>
      <?php 
}
?>

	  <?php 
if ($user->getProfile()->getMailsContacto() && SfVoUtil::isEmail($user->getUsername())) {
    ?>
      <p class="contact">
        <img src="/images/email.png" width="16" height="16" alt="email" />
        <?php 
    echo link_to(__('Mandar un mensaje a') . ' ' . fullName($user), '@usuario_contact?username=' . $user->getProfile()->getVanity());
    ?>
      </p>
	  <?php 
}
?>
    </div>
  </div>

  <div class="propuestas">
    <?php 
Exemple #4
0
 public function executeEdit(sfWebRequest $request)
 {
     $this->hasDeepUpdates = false;
     $c = new Criteria();
     $c->add(PropuestaPeer::IS_ACTIVE, true);
     $this->propuestasCount = PropuestaPeer::doCount($c);
     $this->isCanonicalVootaUser = SfVoUtil::isCanonicalVootaUser($this->getUser()->getGuardUser());
     if ($this->getUser()->isAuthenticated()) {
         $this->lastReview = SfReviewManager::getLastReviewByUserId($this->getUser()->getGuardUser()->getId());
         $this->lastReviewOnReview = SfReviewManager::getLastReviewOnReviewByUserId($this->getUser()->getGuardUser()->getId());
     }
     $this->redirectUnless($this->getUser()->isAuthenticated(), "@sf_guard_signin");
     $formData = sfGuardUserPeer::retrieveByPk($this->getUser()->getGuardUser()->getId());
     if (!SfVoUtil::isEmail($formData->getUsername())) {
         $formData->setUsername('');
     }
     $this->profileEditForm = new ProfileEditForm($formData);
     $this->politico = false;
     $politicos = $this->getUser()->getGuardUser()->getPoliticos();
     if ($politicos && count($politicos) != 0) {
         $this->politico = $politicos[0];
         unset($this->profileEditForm['nombre'], $this->profileEditForm['apellidos']);
     }
     $imagenOri = $formData->getProfile()->getImagen();
     $criteria = new Criteria();
     $criteria->add(SfReviewPeer::IS_ACTIVE, true);
     $criteria->add(SfReviewPeer::SF_GUARD_USER_ID, $this->getUser()->getGuardUser()->getId());
     $this->numReviews = SfReviewPeer::doCount($criteria);
     if ($request->isMethod('post')) {
         $this->profileEditForm->bind($request->getParameter('profile'), $request->getFiles('profile'));
         if ($this->profileEditForm->isValid()) {
             /*if ($this->politico){
             		  	$cacheManager = $this->getContext()->getViewCacheManager();
             		  	if ($cacheManager != null) {
             		  		$politico = $this->getRoute()->getObject();
             		    	$cacheManager->remove("politico/show?id=".$politico->getVanity()."");
             		  	}				
             		}*/
             $profile = $request->getParameter('profile');
             $this->hasDeepUpdates = $profile['presentacion'] != $formData->getProfile()->getPresentacion();
             if ($this->profileEditForm->getValue('imagen_delete') != "") {
                 // Si se elimina la imagen, hay que recargar el formulario para que se refresque
                 $formData->getProfile()->setImagen("");
                 //$formData->getProfile()->save();
                 $this->profileEditForm->setImageSrc("");
                 $this->profileEditForm->resetImageWidget();
                 //$this->profileEditForm = new ProfileEditForm( $formData );
             } else {
                 $imageOri = $this->profileEditForm->getObject()->getProfile()->getImagen();
                 $imagen = $this->profileEditForm->getValue('imagen');
                 $this->profileEditForm->save();
                 if ($imagen) {
                     $arr = array_reverse(explode(".", $imagen->getOriginalName()));
                     $ext = strtolower($arr[0]);
                     if (!$ext || $ext == "") {
                         $ext = "png";
                     }
                     $imageName = $this->profileEditForm->getValue('nombre') ? $this->profileEditForm->getValue('nombre') : $arr[1];
                     if ($this->profileEditForm->getValue('apellidos') != '') {
                         $imageName .= "-" . $this->profileEditForm->getValue('apellidos');
                     }
                     $imageName .= "-" . sprintf("%04d", rand(0, 999));
                     $imageName .= ".{$ext}";
                     $imagen->save(sfConfig::get('sf_upload_dir') . '/usuarios/' . $imageName);
                     $this->profileEditForm->getObject()->getProfile()->setImagen($imageName);
                     $this->profileEditForm->setImageSrc($imageName);
                     $this->profileEditForm->resetImageWidget();
                     $this->hasDeepUpdates = true;
                 } else {
                     $this->profileEditForm->getObject()->getProfile()->setImagen($imagenOri);
                     $this->profileEditForm->setImageSrc($imagenOri);
                 }
             }
             if ($profile['passwordNew'] != '') {
                 // Check old password
                 if ($this->getUser()->checkPassword($profile['passwordOld'])) {
                     $this->getUser()->setPassword($profile['passwordNew']);
                 } else {
                     $this->getUser()->setFlash('notice_type', 'error', false);
                     $this->getUser()->setFlash('notice', sfVoForm::getMissingPasswordMessage(), false);
                     return;
                 }
             }
             $this->getUser()->setFlash('notice_type', 'notice', false);
             $this->getUser()->setFlash('notice', sfVoForm::getFormSavesMessage(), false);
             $this->profileEditForm->save();
             $profile = $this->profileEditForm->getObject()->getProfile();
             $profile->save();
             $aText = utf8_decode($this->profileEditForm->getValue('presentacion'));
             $aText = strip_tags(substr($aText, 0, 280));
             $aText = utf8_encode($aText);
             $profile->setPresentacion($aText);
             $profile->save();
             if ($profile->isColumnModified(SfGuardUserProfileI18nPeer::PRESENTACION)) {
                 $this->hasDeepUpdates = true;
             }
             $this->presentacionValue = $aText;
         } else {
             $this->getUser()->setFlash('notice_type', 'error', false);
             $this->getUser()->setFlash('notice', sfVoForm::getFormNotValidMessage(), false);
         }
     }
     if (!$this->presentacionValue) {
         $this->presentacionValue = $politicos = $this->getUser()->getGuardUser()->getProfile()->getPresentacion();
     }
 }