本文整理汇总了PHP中user::find方法的典型用法代码示例。如果您正苦于以下问题:PHP user::find方法的具体用法?PHP user::find怎么用?PHP user::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user
的用法示例。
在下文中一共展示了user::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPosts
public function getPosts($status = null, $limitQuery = null)
{
$P = new post();
$posts = array();
if (is_null($status) === true) {
$posts = $P->findAll("ID,id_user,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", 'ID DESC', $limitQuery, null);
} else {
if (is_array($status) === false) {
$posts = $P->findAll("ID,id_user,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", 'ID DESC', $limitQuery, "WHERE status='{$status}'");
} else {
$status_sql = "";
foreach ($status as $st) {
$status_sql .= "status ='{$st}' OR ";
}
$status_sql = substr($status_sql, 0, -3);
$posts = $P->findAll("ID,id_user,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", 'ID DESC', $limitQuery, "WHERE ({$status_sql})");
}
}
$C = new comment();
foreach ($posts as $k => $p) {
$posts[$k]['title'] = htmlspecialchars($posts[$k]['title']);
$posts[$k]['tags'] = $this->getTags($posts[$k]['ID']);
$posts[$k]['comments_count'] = $C->countCommentsByPost($posts[$k]['ID'], "publish");
$U = new user();
if ($posts[$k]['id_user'] < 2) {
$posts[$k]['autor'] = $U->find(1);
} else {
$posts[$k]['autor'] = $U->find($posts[$k]['id_user']);
}
}
return $posts;
}
示例2: index
public function index($id = NULL, $page = 1)
{
if (is_null($id) or is_numeric($id)) {
$this->redirect($this->conf['blog_siteurl']);
}
$tag = $id;
$post = new post();
$link = new link();
$comment = new comment();
$this->html->useTheme($this->conf['blog_current_theme']);
$info = array();
$info["isAdmin"] = false;
if ($this->cookie->check("logged") and $this->cookie->id_user == 1) {
$info["isAdmin"] = true;
}
$this->themes->info = $info;
$includes['charset'] = $this->html->charsetTag("UTF-8");
$includes['rssFeed'] = $this->html->includeRSS();
if ($page > 1) {
$includes['canonical'] = "<link rel=\"canonical\" href=\"{$this->conf['blog_siteurl']}/tag/" . rawurlencode($post->sql_escape($id)) . "/{$page}\" />";
} else {
$includes['canonical'] = "<link rel=\"canonical\" href=\"{$this->conf['blog_siteurl']}/tag/" . rawurlencode($post->sql_escape($id)) . "\" />";
}
$this->registry->includes = $includes;
$this->plugin->call('index_includes');
$includes = null;
foreach ($this->registry->includes as $include) {
$includes .= $include;
}
$this->themes->includes = $includes;
$this->themes->links = $link->findAll();
$this->themes->single = false;
$total_rows = $post->countPosts(array('status' => 'publish', 'tag' => $tag));
$page = (int) is_null($page) ? 1 : $page;
$limit = $this->conf['blog_posts_per_page'];
$offset = ($page - 1) * $limit;
$limitQuery = $offset . "," . $limit;
$targetpage = $this->path . "tag/{$tag}/";
$this->themes->pagination = $this->pagination->init($total_rows, $page, $limit, $targetpage);
$posts = $post->getPostsByTag($tag, $limitQuery);
foreach ($posts as $k => $p) {
$posts[$k]['title'] = htmlspecialchars($p['title']);
$posts[$k]['tags'] = $post->getTags($p['ID']);
$posts[$k]['comments_count'] = $comment->countCommentsByPost($posts[$k]['ID']);
$user = new user();
if ($posts[$k]['id_user'] < 2) {
$posts[$k]['autor'] = $user->find(1);
} else {
$posts[$k]['autor'] = $user->find($posts[$k]['id_user']);
}
}
$this->registry->posts = $posts;
$this->plugin->call("index_post_content");
$this->themes->posts = $this->registry->posts;
$this->themes->title_for_layout = "{$this->conf['blog_name']} - {$tag}";
$this->render();
}
示例3: process
private function process()
{
$this->commonProcess();
$config = services::getService('config');
$lang = services::getService('lang');
$params = services::getService('pageParams');
$mail = services::getService('mail');
$geo = services::getService('geoinfo');
$categories = services::getService('cats');
if ($params->getParam('add_to_adressbook')) {
$addr = new adressbook();
$addr->sender_id = $this->user->id;
$addr->recipient_id = $params->getParam('showmember');
if (!$addr->find()) {
$addr->insert();
$this->addMsg('msg_adressbook_add_success');
} else {
$this->addMsg('msg_adressbook_add_allready');
}
}
// build userlist
// assotiativ array with object and detail-flag
$smember = new user();
$smember->id = $params->getParam('showmember');
$smember->find(true);
$member = array("obj" => $smember);
$this->member = $member;
$this->member['obj']->getPhoto();
$this->geodist = $geo->getDistance($this->user, $this->member["obj"]);
}
示例4: postReset
/**
* Handle a POST request to reset a user's password.
*
* @return Response
*/
public function postReset()
{
$credentials = Input::only('email', 'password', 'token');
//hack password_confirmation for package
$credentials['password_confirmation'] = $credentials['password'];
$rules = array('email' => 'required|email', 'password' => 'required|min:6', 'token' => 'required');
$v = Validator::make($credentials, $rules);
if ($v->fails()) {
return Output::push(array('path' => 'password/reset', 'errors' => $v, 'input' => TRUE));
}
//new style
$validtoken = $this->_isValidToken($credentials['email'], $credentials['token']);
if ($validtoken) {
$id = $this->_getUserId($credentials['email']);
if ($id) {
$user = user::find($id);
//$user->username = $input['username'];
$user->email = $credentials['email'];
if ($credentials['password']) {
$user->password = Hash::make($credentials['password']);
Event::fire('logger', array(array('account_password_update', array('id' => $id, 'username' => $user->username), 2)));
}
$user->save();
return Output::push(array('path' => 'login', 'messages' => array('success' => _('Password has been reset'))));
} else {
return Output::push(array('path' => 'password/recovery', 'messages' => array('fail' => _('Unable to process password reset'))));
}
} else {
return Output::push(array('path' => 'password/recovery', 'messages' => array('fail' => _('Invalid token'))));
}
}
示例5: substractCredit
public static function substractCredit($price)
{
$user = user::find(Auth::user()->id);
$user_credit = $user->balance;
$user->balance = $user_credit - $price;
$user->save();
}
示例6: login
public function login($msg = null)
{
if ($this->session->check("logged") == true) {
$this->redirect("admin");
}
if ($msg == "nosession") {
$this->session->flash("La URL solicitada necesita autentificacion.");
} elseif ($msg == "fail") {
$this->session->flash("Lo siento, la informacion ingresada es incorrecta.");
} elseif ($msg == "logout") {
$this->session->flash("Haz terminado la sesion correctamente.");
}
if ($this->data) {
$U = new user();
if ($id_user = $U->validateLogin($this->data)) {
$user = $U->find($id_user);
$this->session->user = $user;
$this->session->logged = true;
$this->redirect("admin/");
} else {
$this->redirect("admin/login/fail/");
}
} else {
$this->view->setLayout("admin");
$this->title_for_layout("Login - Codice CMS");
$this->render();
}
}
示例7: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$input = Input::only('email', 'username', 'password');
$rules = array('email' => 'required|email|unique:users,email,' . Auth::user()->id . ',id,deleted_at,NULL,status,' . Auth::user()->status . '');
if ($input['password']) {
$rules['password'] = 'required|min:6';
}
$v = Validator::make($input, $rules);
if ($v->fails()) {
return Output::push(array('path' => 'user', 'errors' => $v, 'input' => TRUE));
}
if ($input['password'] && $id && Auth::user()->id == $id) {
$user = user::find($id);
//$user->username = $input['username'];
$user->email = $input['email'];
if ($input['password']) {
$user->password = Hash::make($input['password']);
Event::fire('logger', array(array('account_password_update', array('id' => $id, 'username' => $user->username), 2)));
}
$user->save();
return Output::push(array('path' => 'user', 'errors' => 'Change Password Successfully', 'messages' => array('success', _('User data has been saved')), 'input' => TRUE));
} else {
return Output::push(array('path' => 'user', 'errors' => 'Unable to update user', 'messages' => array('fail', _('Unable to update user')), 'input' => TRUE));
}
}
示例8: adminNotify
public function adminNotify()
{
if ($this->cookie->check("id_user") and $this->cookie->id_user == 1) {
//no notificamos a administrador de su propio comentario.
return;
}
$id = $this->registry->lastCommentID;
$Comment = new comment();
$comment = $Comment->find($id);
$comment['content'] = utils::nl2br($comment['content']);
if (!defined('GESHI_VERSION')) {
$comment['content'] = $this->comment_source_code_beautifier($comment['content'], 'addTagPRE');
} else {
$comment['content'] = $this->comment_source_code_beautifier($comment['content']);
}
$User = new user();
$user = $User->find(1);
$Post = new post();
$post = $Post->find($comment['ID_post']);
$commentsWaiting = $Comment->countCommentsByPost(null, 'waiting');
$mailStr = "\n\t\t\t<table width=\"100%\">\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<small>\n\t\t\t\t\t\t<strong>From IP</strong>: {$comment['IP']}<br />\n\t\t\t\t\t\t<strong>URL</strong>: <a href=\"{$comment['url']}\">{$comment['url']}</a><br />\n\t\t\t\t\t\t<strong>Email</strong>: <a href=\"mailto:{$comment['email']}\">{$comment['email']}</a><br />\n\t\t\t\t\t\t<strong>DateTime</strong>: {$comment['created']}<br />\n\t\t\t\t\t</small>\n\t\t\t\t\t<hr>\n\t\t\t\t\t<strong>Author</strong>: {$comment['author']}<br />\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t\n\t\t\t<tr><td><strong>Content</strong></td></tr>\n\t\t\t<tr><td bgcolor=\"#f7f7f7\">\n\t\t\t\t{$comment['content']}\n\t\t\t\t<hr />\n\t\t\t</td></tr>\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<p>\n\t\t\t\t\t\tModerate comment: <a href=\"{$this->registry->path}comments/edit/{$comment['ID']}\">{$this->registry->path}comments/edit/{$comment['ID']}</a><br />\n\t\t\t\t\t\tView entry: <a href=\"{$this->registry->path}{$post['urlfriendly']}\">{$this->registry->path}{$post['urlfriendly']}</a>\n\t\t\t\t\t</p>\n\t\t\n\t\t\t\t\t<p>\n\t\t\t\t\t\tThere are {$commentsWaiting} comments waiting for approbal. <br />\n\t\t\t\t\t\tPlease moderate comments: <a href=\"{$this->registry->path}comments/waiting\">{$this->registry->path}comments</a>\n\t\t\t\t\t</p>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t\n\t\t\t</table>\n\t\t";
$conf = $this->registry->conf;
$subject = "[{$conf['blog_name']}] Nuevo Comentario en: {$post['title']}";
$this->enviaMail($user['email'], $subject, $mailStr, $user['email']);
}
示例9: page
public function page()
{
$page_params = services::getService('pageParams');
$config = services::getService('config');
$login = $page_params->getParam('login');
$password = $page_params->getParam('password');
$this->act_page = $page_params->getParam('page');
$this->act_get = $this->getActGet();
if ($login != "" && $password != "") {
$user = new user($login, crypt($password, 'dl'));
if ($user->find(true)) {
$this->user = $user;
}
}
// set interface-language
// if lang is in get, a cookie is set, lang in get is set, is written in db
// else if lang is in db, a cookie is set
// else if lang is in cookie, lang in cookie is set, is written in db
// else if lang is in browser, a cookie is set etc., is written in db
// else if lang is in config.ini, cookie, set, written in db
if ($_GET['lang']) {
setcookie('language', $_GET['lang'], time() + 60 * 60 * 24 * 365);
if (is_object($user)) {
$this->user->language = $_GET['lang'];
$this->user->update();
}
} else {
if ($this->user->language) {
if ($_COOKIE['language'] != $this->user->language) {
setcookie('language', $this->user->language, time() + 60 * 60 * 24 * 365);
}
} else {
if ($_COOKIE['language']) {
if (is_object($user)) {
$this->user->language = $_COOKIE['language'];
$this->user->update();
}
} else {
if (is_array(parseHttpAcceptLanguage())) {
$blang = parseHttpAcceptLanguage();
setcookie('language', $blang[0]['code'], time() + 60 * 60 * 24 * 365);
if (is_object($user)) {
$this->user->language = $blang[0]['code'];
$this->user->update();
}
} else {
setcookie('language', $config->getSetting('language'), time() + 60 * 60 * 24 * 365);
if (is_object($user)) {
$this->user->language = $config->getSetting('language');
$this->user->update();
}
}
}
}
}
$this->addMsg($page_params->getParam('msg'));
$this->assignAll();
}
示例10: validateLogin
public static function validateLogin($email, $password)
{
if ($user = user::find(array('email' => $email))) {
if (authentication::verify($password, $user["password"])) {
return true;
} else {
return false;
}
} else {
return false;
}
}
示例11: showall
function showall($username = null)
{
using('lepton.user.*');
using('lepton.mvc.request');
if ($username) {
$ur = user::find($username);
console::writeLn(__astr('\\b{%-20s}: %s'), 'Username', $ur->username);
console::writeLn(__astr('\\b{%-20s}: %s'), 'Displayname', $ur->displayname);
console::writeLn(__astr('\\b{%-20s}: %s'), 'E-Mail', $ur->email);
console::writeLn(__astr('\\b{%-20s}: %s'), 'UUID', $ur->uuid);
console::writeLn(__astr('\\b{%-20s}: %s'), 'Flags', $ur->flags);
console::writeLn(__astr('\\b{%-20s}: %s'), 'Active', $ur->active == 1 ? 'Yes' : 'No');
console::writeLn(__astr('\\b{%-20s}: %s'), 'Firstname', $ur->firstname);
console::writeLn(__astr('\\b{%-20s}: %s'), 'Lastname', $ur->lastname);
console::writeLn(__astr('\\b{%-20s}: %s'), 'Last login', $ur->lastlogin);
console::writeLn(__astr('\\b{%-20s}: %s'), 'Last IP', $ur->lastip);
console::writeLn(__astr('\\b{%-20s}: %s'), 'Registered', $ur->registered);
foreach ($ur as $af => $ad) {
console::writeLn(__astr('\\g{%-20s}: %s'), $af, $ad);
}
} else {
console::writeLn("Use: user show username");
}
}
示例12: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$detail = table_users_detail::where('users_id', '=', $id)->first();
if (isset($detail->users_detail_id)) {
$idusersdetail = $detail->users_detail_id;
table_users_detail::find($idusersdetail)->delete();
}
user::find($id)->delete();
return redirect('admin/users-detail')->with('warning', 'Data have been removed!');
}
示例13: findUser
/**
* Find a user in the database. Deprecated in favor of User::find()
*
* @deprecated since 1.0.0
* @param string $username
* @return UserRecord The user record if any. Null otherwise.
*/
static function findUser($username)
{
__deprecated('user::findUser', 'user::find');
return user::find($username);
}
示例14: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$input = Input::only('first_name', 'last_name', 'email', 'website', 'username', 'password');
$domain_id = Request::segment(4) ? Request::segment(4) : 'NULL';
$rules = array('first_name' => 'required|min:1', 'email' => 'required|email|unique:users,email,' . $id . ',id,deleted_at,NULL,domain_id,' . $domain_id, 'password' => 'min:6');
$v = Validator::make($input, $rules);
if ($v->fails()) {
return Output::push(array('path' => 'users/edit/' . $id, 'errors' => $v, 'input' => TRUE));
}
$profile = Profile::find($id);
$profile->first_name = $input['first_name'];
$profile->last_name = $input['last_name'];
$profile->website = $input['website'];
$profile->save();
$user = user::find($id);
//$user->username = $input['username'];
$user->email = $input['email'];
if ($input['password']) {
$user->password = Hash::make($input['password']);
Event::fire('logger', array(array('account_password_update', array('id' => $id, 'username' => $user->username), 2)));
}
$user->profile()->associate($profile);
$user->save();
$path = Request::segment(4) ? 'domain/users/' . Request::segment(4) : 'users';
$path = Request::segment(1) == "managers" ? "managers" : $path;
if ($id) {
return Output::push(array('path' => $path, 'messages' => array('success' => _('You have updated user successfully'))));
} else {
return Output::push(array('path' => 'users/edit/' . $id, 'messages' => array('fail' => _('Fail to update user')), 'input' => TRUE));
}
}
示例15: putfollowinotherprofile
public function putfollowinotherprofile()
{
$followerid = $_GET['followerid'];
$authusrid = Auth::user()->ID;
$curdate = date('Y-m-d h:i:s');
$inputdetails['followerid'] = $followerid;
$inputdetails['userid'] = $authusrid;
$inputdetails['createddate'] = $curdate;
$followers = followModel::create($inputdetails);
if ($followers) {
////// Send Mail /////////
$followedetails = user::find($followerid);
$email = $followedetails['email'];
if (Auth::user()->firstname != '') {
$username = Auth::user()->firstname . ' ' . Auth::user()->lastname;
} else {
$username = Auth::user()->username;
}
if ($followedetails['firstname'] != '') {
$followingusername = $followedetails['firstname'] . ' ' . $followedetails['lastname'];
} else {
$followingusername = $followedetails['username'];
}
//$email ='madhupriya@bizarresoftware.in';
Mail::send([], array('followingusername' => $followingusername, 'email' => $email, 'username' => $username), function ($message) use($followingusername, $email, $username) {
/* $mail_body = 'Dear {followingusername},<br><br> The Member {username} is following you.<br><br> Thank You, <br><br>Regards,<br>DingDatt<br><a href="'.URL::to('assets/inner/img/DingDatt_logo_web1.png').'" style="dislay:block;outline: none; padding:25px;margin:25px; min-height:110px; width:100%; overflow:hidden;">
<img src="'.URL::to('assets/inner/img/DingDatt_logo_web1.png').'" width="110" height="86" style="width:110px; padding:0px; margin:0px;" alt="DingDatt"/>
</a>';
$mail_body = str_replace("{username}", $username, $mail_body);
$mail_body = str_replace("{followingusername}", $followingusername, $mail_body); */
$mail_body = '<style>.thank{text-align:center; width:100%;}
.but_color{color:#ffffff;}
.cont_name{width:100px;}
.cont_value{width:500px;}
</style>
<body style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif; margin:0px auto; padding:0px;">
<div style="margin:0px auto;background:#e5e5e5;float:left; width:98%; height:30px;margin:0px 1%; border-bottom:#005377 1px solid;vertical-align: text-middle;">
<a href="' . URL() . '"><img src="' . URL::to('assets/images/logo.png') . '" style="margin-top:3px; line-height:20px;" /></a>
</div>
<div style="background:#ffffff;float:left;padding:10px 20px;margin:1px 1%;" >
<div class="thank" style="font-size:16px;color: #078AC2;font-weight:bold;float:left;width:100%;margin-top:10px;text-align:left;">Dear ' . $followingusername . '</div>
<div style="font-size:12px; color: #000000; float:left;padding:10px 2px;width:100%;margin:15px;">The Member.' . $username . '. is following you.
</div>
<div style="margin:10px;"><a href="' . URL() . '"><img src="' . URL::to('assets/inner/images/vist_dingdatt.png') . '" width="120" height="30" /></a>
</div>
</div>
<div style="font-size:12px; margin-top:10px;color: #5b5b5b;/* background:#e5e5e5;*/width:95%;vertical-align: text-middle;height:30px;margin:0% 1%;padding:0px 15px; border-top:#005377 1px solid; border-bottom:5px solid background:#e5e5e5;line-height:25px; ">
</body>';
$message->setBody($mail_body, 'text/html');
$message->to($email);
$message->subject('Follower details - DingDatt');
});
}
return Redirect::to("other_profile/" . $followerid)->with('Massage', 'You are following ' . $followingusername);
}