<h3> <img src="/images/icoFacebookPref.png" alt="Facebook Connect" /> <?php echo __('Conectado a Facebook como:'); ?> <strong><?php echo jsWrite('fb:name', array('uid' => $sf_user->getProfile()->getFacebookUid(), 'useyou' => 'false', 'linked' => 'false')); ?> </strong> (<a id="facebook-disconnect" href="#"><?php echo __('Desconectar'); ?> </a>) <script type="text/javascript"> <?php if (SfVoUtil::isCanonicalVootaUser($sf_user->getGuardUser())) { ?> $('#facebook-disconnect').click(function() { facebookDisconnectAccount('<?php echo url_for('@usuario_fb_edit?op=dis'); ?> '); return false; }); <?php } else { ?> $('#facebook-disconnect').click(function() { facebookLogoutAndRedirect('<?php echo url_for('@usuario_fb_edit?op=dis'); ?>
<?php echo vo_facebook_connect_associate_button(__('Sincronizar tu cuenta en Voota con Facebook'), 'lo_fb_conn'); ?> <span class="close">(<a href="#" onclick="close_sync_tip('<?php echo url_for('sfGuardAuth/removeTip'); ?> '); return false"><?php echo __('Cerrar'); ?> </a>)</span> </span> <?php } ?> <?php if ($sf_user->getProfile() && $sf_user->getProfile()->getFbTip() && $sf_user->getProfile()->getFacebookUid() && !SfVoUtil::isCanonicalVootaUser($sf_user->getGuardUser())) { ?> <span id="lo_fb_conn"> <strong><?php echo __('Tip:'); ?> </strong> <a href="<?php echo url_for('sfGuardAuth/signin?op=fb'); ?> "><?php echo __('¿Ya tenías cuenta en Voota? Sincronizar con tu Facebook'); ?> </a> <span class="close">(<a href="#" onclick="close_sync_tip('<?php echo url_for('sfGuardAuth/removeTip');
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(); } }