public function executeLog_in(sfWebRequest $request) { $user = $request->getParameter('txtUsuarioLogin'); $password = $request->getParameter('txtPasswordLogin'); $lib = new practil_lib(); $url = $lib->url_practil_login($user, $password); $respuesta_login = file_get_contents($url); $decode = json_decode($respuesta_login); $this->getUser()->setAttribute('s_pk_practil_associate_account', null); if ($decode->{'success'}) { $criteria = new Criteria(); $criteria->add(UserScPeer::PROFILE, $decode->{'pkaccount'}); $current_user = UserScPeer::doSelectOne($criteria); if (is_object($current_user)) { $this->getUser()->setAuthenticated(true); $this->getUser()->setAttribute(sfConfig::get('app_session_current_user'), $current_user); $this->getUser()->setAttribute(sfConfig::get('app_session_current_user_name'), $decode->{'name'}); return $this->redirect('@homepage'); } else { return $this->redirect('@homepage'); } } else { if ($decode->{'code'} == "p-10004") { $this->token = md5($decode->{'code'}); $this->user = $user; $this->getUser()->setAttribute('s_pk_practil_associate_account', $decode->{'tokenpk'}); return 'Practil'; } else { return $this->redirect('@homepage'); } } }
/** * Executes index action * * @param sfRequest $request A request object */ public function executeIndex(sfWebRequest $request) { $email = $request->getParameter('email'); $token_acount = $request->getParameter('token'); $lib = new practil_lib(); $url = $lib->url_practil_confirmation_account($email, $token_acount); $respuesta = file_get_contents($url); $decode = json_decode($respuesta); $codigo_respuesta = $decode->{'code'}; if ($codigo_respuesta == "j-1003") { $this->getUser()->setAttribute('ses_confirmacion', true); $this->redirect('confirmation/response?email=' . $email); } else { $this->getUser()->setAttribute('ses_confirmacion', false); $this->redirect('confirmation/response?email=' . $email); } }
public function executeAsociate_account(sfWebRequest $request) { $token = $request->getParameter('token-account'); $pk_practil = $this->getUser()->getAttribute('s_pk_practil_associate_account', null); $email = $request->getParameter('email-account'); if ($token == md5('p-10004')) { if ($pk_practil != null) { $lib = new practil_lib(); $url = $lib->url_practil_associate_account($email); $respuesta_servicio = file_get_contents($url); $decode = json_decode($respuesta_servicio); if ($decode->{'success'}) { $new_user = new UserSc(); $new_user->setEmail($email); $new_user->setPassword('practil'); $new_user->setFlag('1'); $new_user->setProfile($decode->{'accountpk'}); $new_user->save(); return sfView::SUCCESS; } else { $this->getUser()->setAttribute('s_pk_practil_associate_account', null); return sfView::ERROR; } } else { $this->getUser()->setAttribute('s_pk_practil_associate_account', null); return sfView::ERROR; } } else { $this->getUser()->setAttribute('s_pk_practil_associate_account', null); return sfView::ERROR; } }
public function getDataUser($profile) { $ids = array(); $ids[] = $profile; $lib = new practil_lib(); $url = $lib->url_practil_get_users($ids); $array_users = array(); $respuesta_get_users = @file_get_contents($url); if ($respuesta_get_users === FALSE) { // echo 'Not connected to Practil'; return sfView::null; } else { $json_get_users = json_decode($respuesta_get_users); if ($json_get_users->{'success'} == false) { //echo $json_get_users->{'message'}; return sfView::null; } else { $array_users = $json_get_users->{'practil'}->{'accounts'}; if (count($array_users) <= 0) { // echo 'Users Array returned 0 elements'; return sfView::null; } } return $array_users; } }