本文整理匯總了PHP中Model_Users::getByEmail方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model_Users::getByEmail方法的具體用法?PHP Model_Users::getByEmail怎麽用?PHP Model_Users::getByEmail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Model_Users
的用法示例。
在下文中一共展示了Model_Users::getByEmail方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createUser
public static function createUser($data)
{
$db = JO_Db::getDefaultAdapter();
if (!$data['username'] || Model_Users::getByUsername($data['username'])) {
return false;
}
if (!$data['email'] || Model_Users::getByEmail($data['email'])) {
return false;
}
$db->insert(Model_Users::getPrefixDB() . 'users', array('username' => $data['username'], 'password' => $data['password'], 'email' => $data['email'], 'firstname' => $data['firstname'], 'lastname' => $data['lastname'], 'firmname' => $data['firmname'], 'profile_title' => $data['profile_title'], 'profile_desc' => $data['profile_desc'], 'register_datetime' => $data['register_datetime'], 'status' => 'activate'));
$user_id = $db->lastInsertId();
if ($user_id) {
$upload_path = BASE_PATH . '/uploads';
$user_path = '/users/' . JO_Date::getInstance($data['register_datetime'], 'yy/mm/')->toString() . $user_id . '/';
$upload_path .= $user_path;
if ($data['avatar'] && @getimagesize($data['avatar'])) {
$name = basename($data['avatar']);
if (copy($data['avatar'], $upload_path . $name)) {
$db->update('users', array('avatar' => $user_path . $name), array('user_id' => $user_id));
}
}
if ($data['homeimage'] && @getimagesize($data['homeimage'])) {
$name = basename($data['homeimage']);
if (copy($data['homeimage'], $upload_path . $name)) {
$db->update('users', array('homeimage' => $user_path . $name), array('user_id' => $user_id));
}
}
return Model_Users::getUser($user_id);
}
}
示例2: reset_passwordAction
public function reset_passwordAction()
{
$request = $this->getRequest();
if (JO_Session::get('user_id')) {
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=edit'));
}
$this->view->usersCount = Model_Users::countUsers();
$this->view->itemsCount = Model_Items::countItems();
$this->getLayout()->meta_title = $this->translate('Reset password');
$this->getLayout()->meta_description = $this->translate('Reset password');
if (JO_Session::get('msg_success')) {
$this->view->msg_success = JO_Session::get('msg_success');
JO_Session::clear('msg_success');
} elseif (JO_Session::get('msg_error')) {
$this->view->msg_error = JO_Session::get('msg_error');
JO_Session::clear('msg_error');
} elseif (JO_Session::get('error')) {
$this->view->error = JO_Session::get('error');
JO_Session::clear('error');
}
if ($request->isPost() && $request->getPost('send')) {
$this->view->username = trim($request->getPost('username'));
$this->view->email = trim($request->getPost('email'));
$this->view->error = array();
if (empty($this->view->username)) {
$this->view->error['username'] = $this->translate('You must type your username');
} elseif (!preg_match('/^[a-zA-Z0-9_]+$/i', $this->view->username)) {
$this->view->error['username'] = $this->translate('The username you have entered is not valid');
}
if (empty($this->view->email)) {
$this->view->error['email'] = $this->translate('You must type your email');
} elseif (!Model_Users::ValidMail($this->view->email)) {
$this->view->error['email'] = $this->translate('You must type valid email');
}
if (empty($this->view->error)) {
$user = Model_Users::getByEmail($this->view->email);
if ($user) {
$alphabet = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'M', 'N', 'P', 'R', 'S', 'T', 'W', 'X', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '2', '3', '4', '5', '6', '7', '8', '9');
$password = '';
for ($i = 0; $i < 7; $i++) {
$random_number = rand(0, count($alphabet) - 1);
$password .= $alphabet[$random_number];
}
Model_Users::editPass($user['user_id'], $password);
$is_mail_smtp = JO_Registry::forceGet('config_mail_smtp');
$mail = new JO_Mail();
if ($is_mail_smtp) {
$mail->setSMTPParams(JO_Registry::forceGet('config_mail_smtp_host'), JO_Registry::forceGet('config_mail_smtp_port'), JO_Registry::forceGet('config_mail_smtp_user'), JO_Registry::forceGet('config_mail_smtp_password'));
}
$domain = $request->getDomain();
$mail->setFrom('noreply@' . $domain);
$mail->setReturnPath('noreply@' . $domain);
$mail->setSubject($this->translate('Reset password') . ' ' . JO_Registry::get('store_meta_title'));
$html = 'Your new password for ' . $user['username'] . ' is ' . $password;
$mail->setHTML($html);
$result = (int) $mail->send(array($request->getPost('email')), $is_mail_smtp ? 'smtp' : 'mail');
JO_Session::set('msg_success', $this->translate('Your new password was send to your email'));
} else {
JO_Session::set('msg_error', $this->translate('No match found between your username and the email you have input '));
}
} else {
JO_Session::set('error', $this->view->error);
}
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=reset_password'));
}
$this->view->lost_username = WM_Router::create($request->getBaseUrl() . '?controller=users&action=lost_username');
$this->view->new_account = WM_Router::create($request->getBaseUrl() . '?controller=users&action=registration');
$this->view->children = array();
$this->view->children['header_part'] = 'layout/header_part';
$this->view->children['footer_part'] = 'layout/footer_part';
}
示例3: addUserAction
public function addUserAction()
{
$data = array();
$error = false;
$this->_helper->viewRenderer->setNoRender(true);
$request = $this->getRequest()->getPost();
//print_r($request);exit();
$data['user_name'] = $request['user_name'];
$data['user_firstname'] = $request['user_firstname'];
$data['user_lastname'] = $request['user_lastname'];
$data['user_email'] = $request['user_email'];
$data['user_password'] = $request['user_password'];
$data['user_role'] = $request['user_role'];
$data['user_registered'] = date('Y-m-d H:i:s');
$data['user_status'] = 1;
if (Model_Users::getByUserName($data['user_name'])) {
$error .= 'Username already exists' . '</br>';
}
if (Model_Users::getByEmail($data['user_email'])) {
$error .= 'Email already exists' . '</br>';
}
if (!$error) {
if (Model_Users::addUser($data)) {
$this->view->success = "User details have been added successfully";
} else {
$this->view->error .= 'Unexpected error occured' . '</br>';
}
} else {
$this->view->error = $error;
}
$this->view->activetab = 'add_user';
self::indexAction();
$this->render('index');
}