/** * Atuliza os dados sobre os perfis do usuário * * Essa tarefa estava dentro de addUser, foi retirada pois o cadastro agora é feito em dois *passos (1o dados do ususario, 2o dados do perfil) */ function updateProfiles() { $perfis = $this->getProfiles(); $userProfileDAO = new UserProfileDAO(); foreach ($perfis as $perfil) { $userProfileDAO->UpdateUserProfile($perfil); } $userProfileDAO = new UserProfileDAO(); $currentProfiles = $userProfileDAO->getUserProfilesStatusOn($this->getID()); $userProfileAction = new UserProfileAction(); $userProfileAction->generateProfileArticleRelationship($currentProfiles); }
/** * Altera os dados do usuário no Banco de Dados * * Ele pega os dados que estão armazenados nos campos da classe e adiciona no Bancp * @returns integer $sucess 1 em caso de sucesso, 0 em caso de erro */ function UpdateUser() { if ($this->loginExists($this->getLogin(), $this->getID())) { return array("ERROR" => "Login já existente"); } //atualizando os dados do usuário $strsql = "UPDATE users SET user_firstname = '" . $this->getFirstName() . "', user_lastname = '" . $this->getLastName() . "', user_gender = '" . $this->getGender() . "' , user_email = '" . $this->getEMail() . "'"; if ($this->getPassword() != '') { $strsql .= " , user_password = '******'"; } $strsql .= " WHERE user_id = '" . $this->getID() . "'"; $this->_db->databaseExecUpdate($strsql); //atualizando os dados dos perfis do usuário $perfis = $this->getProfiles(); $userProfileDAO = new UserProfileDAO(); foreach ($perfis as $perfil) { $userProfileDAO->UpdateUserProfile($perfil); } $userProfileDAO = new UserProfileDAO(); $currentProfiles = $userProfileDAO->getUserProfilesStatusOn($this->getID()); // die(var_dump($currentProfiles)); $userProfileAction = new UserProfileAction(); $userProfileAction->generateProfileArticleRelationship($currentProfiles); $this->loadUser($this->getID()); return true; }