本文整理汇总了PHP中Users::getByEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::getByEmail方法的具体用法?PHP Users::getByEmail怎么用?PHP Users::getByEmail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Users
的用法示例。
在下文中一共展示了Users::getByEmail方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticate
/**
* Performs an authentication attempt
*
* @throws Zend_Auth_Adapter_Exception If authentication cannot be performed
* @return Zend_Auth_Result
*/
public function authenticate()
{
$config = new Zend_Config_Ini('../config/zportal.ini', 'mail');
$mailConfig = array('auth' => 'login', 'username' => $this->name, 'password' => $this->password);
$login = new Zend_Mail_Protocol_Smtp_Auth_Login($config->mail->get('server'), null, $mailConfig);
$login->connect();
try {
$login->helo("localhost");
} catch (Exception $e) {
// unauth user
$result = Zend_Auth_Result::FAILURE;
$identity = $this->name;
$message = 'Authentication failed. Please check your login details or call system admin.';
return new Zend_Auth_Result($result, $identity, array($message));
}
// create result array
$users = new Users();
$email = strtolower($this->name . "@zend.com");
$user = $users->getByEmail($email);
// if first time visit
if (!$user) {
// add record to users
$users->addUser(array('email' => $email, 'role' => 'member'));
$user = $users->getByEmail($email);
// send welcome page
$bodyHtml = 'Dear User<br>Welcome to ZPortal.<br>';
$config = new Zend_Config_Ini('../config/zportal.ini', 'mail');
$transport = new Zend_Mail_Transport_Smtp($config->mail->get('server'), $mailConfig);
$mail = new Zend_Mail();
$mail->setBodyText("See html attachment");
$mail->setBodyHtml($bodyHtml, 'UTF-8', Zend_Mime::ENCODING_BASE64);
$mail->setFrom('zportal@zend.com', 'ZPortal');
$mail->addTo($email, $email);
$mail->setSubject('Welcome to ZPortal');
$mail->send($transport);
}
$result = Zend_Auth_Result::SUCCESS;
$identity = $user;
$message = '';
return new Zend_Auth_Result($result, $identity, array($message));
}
示例2: function
<?php
$redirect = function () {
if (array_key_exists('state', $_GET)) {
header('Location: ' . $_GET['state']);
} else {
header('Location: /');
}
};
$auth = new GoogleAuth(Config::get('GOOGLE_WA_CLIENT_ID'), Config::get('GOOGLE_WA_CLIENT_SECRET'), Config::get('GOOGLE_OAUTH_REDIRECT_URI'), Config::get('GOOGLE_OAUTH_SCOPES'));
$info = $auth->getUserInfo($_GET['code']);
if (null === $info) {
// Access denied
$redirect();
} else {
// Access granted
$email = $info['email'];
$nick = $info['name'];
$picture = $info['picture'];
$user = Users::getByEmail($email);
if (null == $user) {
$user = Users::add($email);
$user->setNick($nick);
$user->setPicture(Image::INSERT($picture));
}
$user->login();
$redirect();
}
示例3: getPersonLinkFromEmailAddress
private static function getPersonLinkFromEmailAddress($email, $addr_name, $clean = true, $add_contact_link = true)
{
$name = $email;
$url = "";
$user = Users::getByEmail($email);
if ($user instanceof User && $user->canSeeUser(logged_user())) {
$name = $clean ? clean($user->getDisplayName()) : $user->getDisplayName();
$url = $user->getCardUrl();
} else {
$contact = Contacts::getByEmail($email);
if ($contact instanceof Contact && $contact->canView(logged_user())) {
$name = $clean ? clean($contact->getDisplayName()) : $contact->getDisplayName();
$url = $contact->getCardUrl();
}
}
if ($url != "") {
return '<a class="internalLink" href="' . $url . '" title="' . $email . '">' . $name . " <{$email}></a>";
} else {
if (!(active_project() instanceof Project ? Contact::canAdd(logged_user(), active_project()) : can_manage_contacts(logged_user()))) {
return $email;
} else {
$url = get_url('contact', 'add', array('ce' => $email));
$to_show = $addr_name == '' ? $email : $addr_name . " <{$email}>";
return $to_show . ($add_contact_link ? ' <a class="internalLink link-ico ico-add" style="padding-left:12px;" href="' . $url . '" title="' . lang('add contact') . '"> </a>' : '');
}
}
}
示例4: forgot_password
/**
* Render and process forgot password form
*
* @param void
* @return null
*/
function forgot_password()
{
$your_email = trim(array_var($_POST, 'your_email'));
tpl_assign('your_email', $your_email);
if (array_var($_POST, 'submitted') == 'submitted') {
if (!is_valid_email($your_email)) {
tpl_assign('error', new InvalidEmailAddressError($your_email, lang('invalid email address')));
$this->render();
}
// if
$user = Users::getByEmail($your_email);
if (!$user instanceof User) {
flash_error(lang('email address not in use', $your_email));
$this->redirectTo('access', 'forgot_password');
}
// if
try {
Notifier::forgotPassword($user);
flash_success(lang('success forgot password'));
} catch (Exception $e) {
flash_error(lang('error forgot password'));
}
// try
$this->redirectTo('access', 'forgot_password');
}
// if
}
示例5: add_mail
//.........这里部分代码省略.........
if (!$email instanceof MailContent) {
flash_error(lang('email dnx'));
$err++;
}
// if
if (!$email->canView(logged_user())) {
flash_error(lang('no access permissions'));
$err++;
}
// if
$attachments[] = array("data" => $email->getContent(), "name" => $email->getSubject() . ".eml", "type" => 'message/rfc822');
}
}
} else {
$linked_attachments[] = array("data" => $object->getViewUrl(), "name" => clean($object->getObjectName()), "type" => lang($object->getObjectTypeName()), "manager" => $object->getObjectManagerName(), "id" => $object->getId());
}
}
}
if ($err > 0) {
flash_error(lang('some objects could not be linked', $err));
ajx_current('empty');
return;
}
}
$to = preg_split('/;|,/', $to);
$to = $utils->parse_to($to);
if ($body == '') {
$body .= ' ';
}
try {
if (count($linked_attachments)) {
$linked_users = array();
foreach ($to as $to_user) {
$linked_user = Users::getByEmail($to_user[1]);
if (!$linked_user instanceof User) {
try {
$linked_user = create_user_from_email($to_user[1], $to_user[0]);
} catch (Exception $e) {
//Logger::log($e->getMessage());
}
}
if ($linked_user instanceof User) {
$linked_users[] = $linked_user;
}
}
$linked_atts = $type == 'text/html' ? '<div style="font-family:arial;"><br><br><br><span style="font-size:12pt;font-weight:bold;color:#777">' . lang('linked attachments') . '</span><ul>' : "\n\n\n-----------------------------------------\n" . lang('linked attachments') . "\n\n";
foreach ($linked_attachments as $att) {
$linked_atts .= $type == 'text/html' ? '<li><a href="' . $att['data'] . '">' . $att['name'] . ' (' . $att['type'] . ')</a></li>' : $att['name'] . ' (' . $att['type'] . '): ' . $att['data'] . "\n";
foreach ($linked_users as $linked_user) {
try {
$linked_user->giveAccessToObject(get_object_by_manager_and_id($att['id'], $att['manager']));
} catch (Exception $e) {
//Logger::log($e->getMessage());
}
}
}
$linked_atts .= $type == 'text/html' ? '</ul></div>' : '';
} else {
$linked_atts = '';
}
$body .= $linked_atts;
if (count($attachments) > 0) {
$i = 0;
$str = "";
/* foreach ($attachments as $att) {
$str .= "--000000000000000000000000000$i\n";
示例6: getSenderUrl
function getSenderUrl()
{
$user = Users::getByEmail($this->getFrom());
if ($user instanceof User && $user->canSeeUser(logged_user())) {
return $user->getCardUrl();
} else {
$contact = Contacts::getByEmail($this->getFrom());
if ($contact instanceof Contact && $contact->canView(logged_user())) {
return $contact->getCardUrl();
}
}
return $this->getViewUrl();
}
示例7: resendActivationAction
/**
* Resend activation email
*/
public function resendActivationAction()
{
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/forms.ini');
$this->view->form = new Zend_Form($config->feed->resendactivation);
if ($this->getRequest()->isPost() && $this->view->form->isValid($_POST)) {
$feeds = new Feeds();
$users = new Users();
$user = $users->getByEmail($this->view->form->email->getValue());
$feed = $feeds->getBySiteUrlAndUserId($this->view->form->url->getValue(), $user->id);
if ($feed) {
$this->sendActivationEmail($feed, $user);
} else {
$this->view->form->email->markAsError();
}
}
}
示例8: actionPassRequest
public function actionPassRequest()
{
if (!isset($_POST['PassRequestForm'])) {
//new request
$requestForm = new PassRequestForm();
$this->render('passrequest', array('model' => $requestForm));
} else {
//requst form has been filled
$requestForm = new PassRequestForm();
$requestForm->attributes = $_POST['PassRequestForm'];
if (!$requestForm->validate()) {
yii::app()->user->setFlash('error', Yii::t('AuthModule.main', 'Restore form validation failed'));
$this->render('passrequest', array('model' => $requestForm));
return;
}
//for is correct so, prepare and send request email
$email = $_POST['PassRequestForm']['email'];
//create new guid and sent it to user
$guid = AuthCommon::getGUID();
$userModel = new Users();
$user = $userModel->getByEmail($email);
if ($user == null) {
yii::app()->user->setFlash('warning', sprintf(Yii::t('AuthModule.main', 'Email address was not found'), $email));
$this->redirect(array('user/passrequest'));
return;
}
$user_id = $user->id;
$validations = new Validations();
$validations->guid = $guid;
$validations->user_id = $user_id;
$validations->email = $email;
$validations->type = self::VALIDATOR_RESTORE;
$date = new DateTime();
$date->modify("+24 hours");
$exp_time = $date->format(AuthCommon::getParam('dateFormat'));
$validations->exp_datetime = $exp_time;
$validations->comments = 'Restore user password';
if (!$validations->validate()) {
yii::app()->user->setFlash('error', Yii::t('AuthModule.main', 'Password restore not complited'));
$this->render('passrequest', array('model' => $requestForm));
return;
}
if (!$validations->save()) {
yii::app()->user->setFlash('error', Yii::t('AuthModule.main', 'Password restore not complited'));
$this->render('passrequest', array('model' => $requestForm));
return;
}
//send email with restore link
if (!$requestForm->validate()) {
yii::app()->user->setFlash('error', Yii::t('AuthModule.main', 'Restore form validation failed'));
$this->render('passrequest', array('model' => $requestForm));
return;
}
$result = AuthCommon::sendPassRequestEmail($email, $guid, $user->username);
if ($result) {
Yii::app()->user->setFlash('success', sprintf(Yii::t('AuthModule.main', 'Password restore link has been sent'), $email));
$this->redirect(array('user/passchange'));
} else {
Yii::app()->user->setFlash('error', Yii::t('AuthModule.main', 'Error sending email message'));
$this->redirect(array('user/passrequest'));
}
}
}
示例9: Users
<?php
if ($page->isPostBack()) {
if (!isset($_POST["username"]) || !isset($_POST["password"])) {
$page->smarty->assign('error', "Please enter your username and password.");
} else {
$page->smarty->assign('username', $_POST["username"]);
$users = new Users();
$res = $users->getByUsername($_POST["username"]);
$dis = $users->isDisabled($_POST["username"]);
if (!$res) {
$res = $users->getByEmail($_POST["username"]);
}
if ($res) {
if ($dis) {
$page->smarty->assign('error', "Your account has been disabled.");
} else {
if ($users->checkPassword($_POST["password"], $res["password"])) {
$rememberMe = isset($_POST['rememberme']) && $_POST['rememberme'] == 'on' ? 1 : 0;
$users->login($res["ID"], $_SERVER['REMOTE_ADDR'], $rememberMe);
if (isset($_POST["redirect"]) && $_POST["redirect"] != "") {
header("Location: " . $_POST["redirect"]);
} else {
header("Location: " . WWW_TOP . $page->site->home_link);
}
die;
} else {
$page->smarty->assign('error', "Incorrect username or password.");
}
}
} else {
示例10: forgot_password
/**
* Render and process forgot password form
*
* @param void
* @return null
*/
function forgot_password()
{
$your_email = trim(array_var($_POST, 'your_email'));
tpl_assign('your_email', $your_email);
if (array_var($_POST, 'submited') == 'submited') {
if (!is_valid_email($your_email)) {
tpl_assign('error', new InvalidEmailAddressError($your_email, lang('invalid email address')));
$this->render();
}
// if
$user = Users::getByEmail($your_email);
if (!$user instanceof User) {
flash_error(lang('email address not in use', $your_email));
$this->redirectTo('access', 'forgot_password');
}
// if
$token = sha1(gen_id() . (defined('SEED') ? SEED : ''));
$timestamp = time() + 60 * 60 * 24;
set_user_config_option('reset_password', $token . ";" . $timestamp, $user->getId());
try {
DB::beginWork();
Notifier::forgotPassword($user, $token);
flash_success(lang('success forgot password'));
DB::commit();
} catch (Exception $e) {
DB::rollback();
flash_error(lang('error forgot password'));
}
// try
$this->redirectTo('access', 'forgot_password');
}
// if
}