/** * Carrega nos campos da classe os valores que estão armazenados no Banco de Dados * @param string $token Token do usuário, gerado pelo Login * @returns integer $sucess 1 em caso de sucesso, 0 em caso de erro */ function loadUser($token) { $ws = new ChamaWebService(); $param = '<todosDados>'; $param .= '<tokenUsuario>' . $token . '</tokenUsuario>'; $param .= '</todosDados>'; $this->clearFields(); $xml = $ws->retornoChamada('todosDados', $param); preg_match_all("/\\<entry\\>(.*?)\\<\\/entry\\>/s", $xml, $entry); preg_match_all("/\\<status\\>(.*?)\\<\\/status\\>/s", $xml, $status); $this->setToken($token); if ($status[1][0] != "OK") { return 0; } for ($i = 0; $i < count($entry[1]); $i++) { preg_match_all("/\\<string>(.*?)\\<\\/string\\>/s", trim($entry[1][$i]), $string); /* terminar de fazer isso com TODOS os campos . . . hehehehe */ if ($string[1][0] == "IDENTIFICADOR") { $this->setID($string[1][1]); } if ($string[1][0] == "FIRST_NAME") { $this->setFirstName($string[1][1]); } if ($string[1][0] == "LAST_NAME") { $this->setLastName($string[1][1]); } if ($string[1][0] == "GENDER") { $this->setGender($string[1][1]); } if ($string[1][0] == "EMAIL_ADDRESS") { $this->setEMail($string[1][1]); } if ($string[1][0] == "AFILIACAO") { $this->setAfiliacao($string[1][1]); } if ($string[1][0] == "GRAU_DE_FORMACAO") { $this->setGrauDeFormacao($string[1][1]); } } //carregando os dados do profile do usuário $userProfileDAO = new UserProfileDAO(); $this->setProfiles($userProfileDAO->getUserProfilesStatusOn($this->getID())); return 1; }
/** * Carrega nos campos da classe os valores que estão armazenados no Banco de Dados * @param integer $id Identificador do usuário * @returns integer $sucess 1 em caso de sucesso, 0 em caso de erro */ function loadUser($id) { $this->clearFields(); //carregando os dados do usuário $strsql = "SELECT * FROM users WHERE users.user_id = '" . $id . "'"; //$ret = $this->_db->databaseExecInsert($strsql); $arr = $this->_db->databaseQuery($strsql); if (count($arr) > 0) { $this->setID($arr[0]['user_id']); $this->setFirstName($arr[0]['user_firstname']); $this->setLastName($arr[0]['user_lastname']); $this->setGender($arr[0]['user_gender']); $this->setLogin($arr[0]['user_login']); $this->setEMail($arr[0]['user_email']); //carregando os dados do profile do usuário $userProfileDAO = new UserProfileDAO(); $this->setProfiles($userProfileDAO->getUserProfilesStatusOn($id)); return 1; } else { return 0; } }