本文整理汇总了PHP中Users::getUsername方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::getUsername方法的具体用法?PHP Users::getUsername怎么用?PHP Users::getUsername使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Users
的用法示例。
在下文中一共展示了Users::getUsername方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
public function login($post)
{
$errors = array();
$user = new Users();
$user->exchangeArray($post);
$username = trim($user->getUsername());
$user->setUsername($username);
$password = trim($user->getPassword());
$user->setPassword($password);
$_SESSION['id'] = $this->getLogged_user_id($username);
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
if (empty($username)) {
$errors['username'] = "Моля, въведете потребителско име!";
}
if (empty($password)) {
$errors['password'] = "Моля, въведете парола!";
}
if ($this->select($user) == false && !isset($errors['username'])) {
$errors['username'] = "Въведените потребителско име и/или парола са невалидни!";
} elseif ($this->select($user) == true) {
$_SESSION['isLogged'] = true;
}
if (count($errors) > 0) {
return $errors;
} else {
return $errors = array();
}
}
示例2: modify
public function modify(Users $user)
{
$q = $this->dao->prepare('UPDATE ' . $this->table() . ' SET USERNAME = :username, PASSWORD = :password, MAILINGSTATE = :mailingstate, MAIL = :mail, ROLE_ID = :role_id, IS_ACTIVE = :is_active, IS_MAIL_VERIFIED = :is_mail_verified, ACTIVATION_KEY = :activation_key WHERE ID = :id');
$q->bindValue(':username', $user->getUsername());
$q->bindValue(':password', $user->getPassword());
$q->bindValue(':mail', $user->getMail());
$q->bindValue(':is_active', $user->getIsActive());
$q->bindValue(':role_id', $user->getRoleId(), PDO::PARAM_INT);
$q->bindValue(':is_mail_verified', $user->getIsMailVerified());
$q->bindValue(':activation_key', $user->getActivationKey());
$q->bindvalue(':mailingstate', $user->getMailingState());
$q->bindValue(':id', $user->id(), PDO::PARAM_INT);
$q->execute();
}
示例3: login
/**
* Logs in a user an returns the auth_token
*
* @param Users $user
* @return string auth_token
*/
public static function login(Users $user)
{
UserController::$sendEmailOnVerify = false;
// Deactivate cookie setting
$oldCookieSetting = SessionController::$setCookieOnRegisterSession;
SessionController::$setCookieOnRegisterSession = false;
// Inflate request with user data
$r = new Request(array("usernameOrEmail" => $user->getUsername(), "password" => $user->getPassword()));
// Call the API
$response = UserController::apiLogin($r);
// Sanity check
self::assertEquals("ok", $response["status"]);
// Clean up leftovers of Login API
unset($_REQUEST);
// Set cookie setting as it was before the login
SessionController::$setCookieOnRegisterSession = $oldCookieSetting;
return $response["auth_token"];
}
示例4: getProfileImpl
/**
* Returns the profile of the user given
*
* @param Users $user
* @return array
* @throws InvalidDatabaseOperationException
*/
private static function getProfileImpl(Users $user)
{
$response = array();
$response['userinfo'] = array();
$response['problems'] = array();
$response['userinfo']['username'] = $user->getUsername();
$response['userinfo']['name'] = $user->getName();
$response['userinfo']['solved'] = $user->getSolved();
$response['userinfo']['submissions'] = $user->getSubmissions();
$response['userinfo']['birth_date'] = is_null($user->getBirthDate()) ? null : strtotime($user->getBirthDate());
$response['userinfo']['graduation_date'] = is_null($user->getGraduationDate()) ? null : strtotime($user->getGraduationDate());
$response['userinfo']['scholar_degree'] = $user->getScholarDegree();
if (!is_null($user->getLanguageId())) {
$query = LanguagesDAO::getByPK($user->getLanguageId());
if (!is_null($query)) {
$response['userinfo']['locale'] = UserController::convertToSupportedLanguage($query->getName());
}
}
try {
$response['userinfo']['email'] = EmailsDAO::getByPK($user->getMainEmailId())->getEmail();
$country = CountriesDAO::getByPK($user->getCountryId());
$response['userinfo']['country'] = is_null($country) ? null : $country->getName();
$response['userinfo']['country_id'] = $user->getCountryId();
$state = StatesDAO::getByPK($user->getStateId());
$response['userinfo']['state'] = is_null($state) ? null : $state->getName();
$response['userinfo']['state_id'] = $user->getStateId();
$school = SchoolsDAO::getByPK($user->getSchoolId());
$response['userinfo']['school_id'] = $user->getSchoolId();
$response['userinfo']['school'] = is_null($school) ? null : $school->getName();
} catch (Exception $e) {
throw new InvalidDatabaseOperationException($e);
}
$response['userinfo']['gravatar_92'] = 'https://secure.gravatar.com/avatar/' . md5($response['userinfo']['email']) . '?s=92';
return $response;
}
示例5: verifyUser
/**
* Verifies a user and returns its DAO
*
* @param Users $user
* @return type
*/
public static function verifyUser(Users $user)
{
UserController::apiVerifyEmail(new Request(array('id' => $user->getVerificationId())));
// Get user from db again to pick up verification changes
return UsersDAO::FindByUsername($user->getUsername());
}
示例6: getUsername
public function getUsername()
{
$this->__load();
return parent::getUsername();
}
示例7: getParams
private function getParams(Users $Users)
{
$params = array(':id' => $Users->getId(), ':username' => $Users->getUsername(), ':email' => $Users->getEmail(), ':password' => $Users->getPassword());
if ($Users->getId()) {
// unset created date, this one is never updated
unset($params[':created_on']);
}
return $params;
}
示例8: _save
protected function _save(\Users $user, &$error)
{
$isNew = $user->isNew();
if ($isNew) {
//check username was taken
if (!\Users::checkAvailableUsername($user->getUsername())) {
$error['users.username'] = t('Username was taken');
}
if (!\Users::checkAvailableEmail($user->getEmail())) {
$error['users.email'] = t('Email was taken');
}
}
if (empty($error)) {
if ($user->save()) {
//dispatching event
if ($isNew) {
$this->dispatch('afterCreatingUser', new CMSBackendEvent($this, ['user' => $user]));
} else {
$this->dispatch('afterSavingUser', new CMSBackendEvent($this, ['user' => $user]));
}
return true;
} else {
if (!$user->isValid()) {
/** @var \Flywheel\Model\ValidationFailed[] $validationFailures */
$validationFailures = $user->getValidationFailures();
foreach ($validationFailures as $validationFailure) {
if (!isset($error[$validationFailure->getColumn()])) {
$error[$validationFailure->getColumn()] = '';
}
$error[$validationFailure->getColumn()] .= $validationFailure->getMessage();
}
}
}
}
return false;
}
示例9: executeNewUser
public function executeNewUser()
{
$this->hide = false;
//check to see if exists
$c = new Criteria();
$c->add(UsersPeer::USERNAME, $this->getRequestParameter('username'));
$userExist = UsersPeer::doSelectOne($c);
if ($userExist) {
$this->errors = 'Username already exists, please select another username.';
} else {
//check passwords
$pass = $this->getRequestParameter('password');
$vpass = $this->getRequestParameter('vpassword');
if ($pass == $vpass) {
$user = new Users();
$user->setFname($this->getRequestParameter('fname'));
$user->setLname($this->getRequestParameter('lname'));
$user->setEmail($this->getRequestParameter('email'));
$user->setUsername($this->getRequestParameter('username'));
$user->saltPassword($this->getRequestParameter('password'));
//send email for account activation
$confCode = sha1($user->getSalt() . $user->getUsername());
$user->save();
$this->sendMail($user->getUsername(), $confCode, $user->getUserId(), $user->getEmail());
$this->errors = '';
$this->hide = true;
} else {
$this->errors = 'Passwords do not match, please re-enter';
}
}
}
示例10: sendInvitation
public function sendInvitation(Invite $invitation, Users $user, Profile $profile)
{
$this->from = $user->getMail();
$this->subject = "Vous êtes invité sur TIPKIN";
$this->content = '
<p>Bonjour, <br/><br/>
' . $profile->getFirstname() . " " . $profile->getLastname() . " vous invite à rejoindre sa communauté sur Tipkin :\n\t\t\t\t\t\t\t\t<br/><br/>\n\t\t\t\t\t\t\t\t<q>Si tu ne connais pas encore Tipkin, connecte-toi, et rejoints ma Tipkin-ship !<br/>\nEnsemble nous pourrons partager tous nos objets.\t\t\t\t\t\t\t\t<br />\n N'hésites plus et viens consulter mes annonces sur mon profil <a href='" . $this->serverName . "users/member/" . $profile->getUserId() . "'>" . $user->getUsername() . "</a><br/>\n " . $invitation->commentaire . "</q><br/><br/>\n\t\t\t\t\t\t\t\tRejoignez le mouvement de la consommation collaborative!<br />\n\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\tA tout de suite sur <a href=" . $this->serverName . ">TIPKIN</a> ! <br /><br/>Je possède. Tu empruntes. Nous partageons !\n\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\tL'équipe TIPKIN.</p>\n\t\t\t\t\t\t\t\t";
$email_error = FALSE;
$invitation->explodeEmailsListe();
$this->replaceContentKeywords();
$mail = new PHPmailer();
// $mail->IsSMTP();
$mail->IsSendMail();
//$mail->SMTPDebug=true; //permet de voir les erreurs si ça ne fonctionne pas
$mail->Host = ini_get('SMTP');
// Connexion au serveur SMTP
$mail->Port = 25;
//$mail->SMTPAuth = true; // Cette partie est optionnelle si le serveur SMTP n'a pas besoin d'authentification
//$mail->Username = 'postmaster[at]monsite.e4y.fr'; // mettre l'adresse email que founit l'hébergeur
//$mail->Password = 'monMotDePasse'; // le mot de passe pour se connecter à votre boite mail sur l'hébergeur
$mail->IsHTML(true);
// Permet d'écrire un mail en HTML (=> conversion des balises
$mail->CharSet = 'UTF-8';
// évite d'avoir des caractères chinois :)
$mail->From = 'no-reply@tipkin.fr';
// adresse mail du compte qui envoi
$mail->AddReplyTo($this->from);
$mail->FromName = "L'équipe TIPKIN";
// remplace le nom du destinateur lors de la lecture d'un email
$mail->Subject = $this->subject;
// l'entête = nom du sujet
$mail->Body = $this->content;
// le corps = le message en lui-même, codé en HTML si vous voulez
//$adresses = explode(",", $this->to);
$invitation->email_error = FALSE;
$invitation->email_sent = FALSE;
foreach ($invitation->getEmailsliste() as $email) {
$mail->AddAddress($email);
// adresse du destinataire, plusieurs adresses possibles en même temps !
$Syntaxe = '#^[\\w.-.+]+@[\\w.-]+\\.[a-zA-Z]{2,6}$#';
if (preg_match($Syntaxe, $email)) {
$checkemail = true;
} else {
$checkemail = false;
}
/*$checkemail=FALSE;
if(filter_var($email, FILTER_VALIDATE_EMAIL)){
$checkemail=TRUE;
}
*/
if (!$mail->Send() || !$checkemail) {
$_REQUEST['error'] = $mail->ErrorInfo;
// affiche une erreur => pas toujours explicite
$error_flag = TRUE;
$invitation->email_error[] = $email;
} else {
$invitation->email_sent[] = $email;
}
$mail->ClearAddresses();
}
$mail->SmtpClose();
unset($mail);
// ferme la connexion smtp et désalloue la mémoire...
return $email_error;
}
示例11: equals
public function equals(Users $user)
{
return $user->getUsername() == $this->getUsername();
}