本文整理汇总了PHP中User::find_by_id方法的典型用法代码示例。如果您正苦于以下问题:PHP User::find_by_id方法的具体用法?PHP User::find_by_id怎么用?PHP User::find_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User::find_by_id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRole
public static function getRole()
{
$userRole = array();
$use = User::find_by_id($_SESSION['user_ident']);
$userRole = explode(",", $use->user_role);
return $userRole;
}
示例2: is_probationary_user
/**
* Check whether a user is on probation.
* @param int $userid
* @return boolean TRUE if the user is on probation, FALSE if the user is not on probation
*/
function is_probationary_user($userid = null)
{
global $USER;
// Check whether a new user threshold is in place or not.
if (!is_using_probation()) {
return false;
}
// Get the user's information
if ($userid == null) {
$user = $USER;
} else {
$user = new User();
$user->find_by_id($userid);
}
// Admins and staff get a free pass
if ($user->get('admin') || $user->get('staff') || $user->is_institutional_admin() || $user->is_institutional_staff()) {
return false;
}
// We actually store new user points in reverse. When your account is created, you get $newuserthreshold points, and
// we decrease those when you do something good, and when it hits 0 you're no longer a new user.
$userspoints = get_field('usr', 'probation', 'id', $user->get('id'));
if ($userspoints > 0) {
return true;
} else {
return false;
}
}
示例3: current
public static function current()
{
if (self::$current !== '') {
return self::$current;
}
return self::$current = ($id = Session::getData('user_id')) ? User::find_by_id($id) : null;
}
示例4: show
/**
* Profile page
*/
function show($id)
{
$user = User::find_by_id($id);
if (!$user) {
throw new PageNotFoundException();
}
return array('user' => $user);
}
示例5: __construct
function __construct()
{
parent::__construct();
$this->view_data['core_settings'] = Setting::first();
if ($this->input->cookie('language') != "") {
$language = $this->input->cookie('language');
} else {
if (isset($this->view_data['language'])) {
$language = $this->view_data['language'];
} else {
if (!empty($this->view_data['core_settings']->language)) {
$language = $this->view_data['core_settings']->language;
} else {
$language = "english";
}
}
}
$this->lang->load('application', $language);
$this->lang->load('messages', $language);
$this->lang->load('event', $language);
$this->user = $this->session->userdata('user_id') ? User::find_by_id($this->session->userdata('user_id')) : FALSE;
$this->client = $this->session->userdata('client_id') ? Client::find_by_id($this->session->userdata('client_id')) : FALSE;
if ($this->client) {
$this->theme_view = 'application_client';
}
$this->view_data['datetime'] = date('Y-m-d H:i', time());
$this->view_data['sticky'] = Project::all(array('conditions' => 'sticky = 1'));
$this->view_data['quotations_new'] = Quote::find_by_sql("select count(id) as amount from quotations where status='New'");
if ($this->user || $this->client) {
$access = $this->user ? $this->user->access : $this->client->access;
$access = explode(",", $access);
if ($this->user) {
$this->view_data['menu'] = Module::find('all', array('order' => 'sort asc', 'conditions' => array('id in (?) AND type = ?', $access, 'main')));
$this->view_data['widgets'] = Module::find('all', array('conditions' => array('id in (?) AND type = ?', $access, 'widget')));
} else {
$this->view_data['menu'] = Module::find('all', array('order' => 'sort asc', 'conditions' => array('id in (?) AND type = ?', $access, 'client')));
}
if ($this->user) {
$update = User::find($this->user->id);
} else {
$update = Client::find($this->client->id);
}
$update->last_active = time();
$update->save();
if ($this->user) {
$this->view_data['user_online'] = User::all(array('conditions' => array('last_active+(30 * 60) > ? AND status = ?', time(), "active")));
$this->view_data['client_online'] = Client::all(array('conditions' => array('last_active+(30 * 60) > ? AND inactive = ?', time(), "0")));
}
$email = $this->user ? 'u' . $this->user->id : 'c' . $this->client->id;
$this->view_data['messages_new'] = Privatemessage::find_by_sql("select count(id) as amount from privatemessages where `status`='New' AND recipient = '" . $email . "'");
$this->view_data['tickets_new'] = Ticket::find_by_sql("select count(id) as amount from tickets where `status`='New'");
}
/*$this->load->database();
$sql = "select * FROM templates WHERE type='notes'";
$query = $this->db->query($sql); */
$this->view_data["note_templates"] = "";
//$query->result();
}
示例6: create
function create()
{
if ($_POST) {
$config['upload_path'] = './files/media/';
$config['encrypt_name'] = TRUE;
$config['allowed_types'] = '*';
$this->load->library('upload', $config);
$this->load->helper('notification');
unset($_POST['userfile']);
unset($_POST['file-name']);
unset($_POST['send']);
unset($_POST['_wysihtml5_mode']);
unset($_POST['files']);
$settings = Setting::first();
$client = Client::find_by_id($this->client->id);
$user = User::find_by_id($settings->ticket_default_owner);
$_POST['from'] = $client->firstname . ' ' . $client->lastname . ' - ' . $client->email;
$_POST['company_id'] = $client->company->id;
$_POST['client_id'] = $client->id;
$_POST['user_id'] = $settings->ticket_default_owner;
$_POST['queue_id'] = $settings->ticket_default_queue;
$_POST['type_id'] = $settings->ticket_default_type;
$_POST['status'] = $settings->ticket_default_status;
$_POST['created'] = time();
$_POST['subject'] = htmlspecialchars($_POST['subject']);
$ticket_reference = Setting::first();
$_POST['reference'] = $ticket_reference->ticket_reference;
$ticket = Ticket::create($_POST);
$new_ticket_reference = $_POST['reference'] + 1;
$ticket_reference->update_attributes(array('ticket_reference' => $new_ticket_reference));
if (!$this->upload->do_upload()) {
$error = $this->upload->display_errors('', ' ');
$this->session->set_flashdata('message', 'error:' . $error);
} else {
$data = array('upload_data' => $this->upload->data());
$attributes = array('ticket_id' => $ticket->id, 'filename' => $data['upload_data']['orig_name'], 'savename' => $data['upload_data']['file_name']);
$attachment = TicketHasAttachment::create($attributes);
}
if (!$ticket) {
$this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_create_ticket_error'));
redirect('ctickets');
} else {
$this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_create_ticket_success'));
if (isset($user->email) && isset($ticket->reference)) {
send_ticket_notification($user->email, '[Ticket#' . $ticket->reference . '] - ' . $_POST['subject'], $_POST['text'], $ticket->id);
}
if (isset($client->email) && isset($ticket->reference)) {
send_ticket_notification($client->email, '[Ticket#' . $ticket->reference . '] - ' . $_POST['subject'], $_POST['text'], $ticket->id);
}
redirect('ctickets/view/' . $ticket->id);
}
} else {
$this->theme_view = 'modal';
$this->view_data['title'] = $this->lang->line('application_create_ticket');
$this->view_data['form_action'] = 'ctickets/create';
$this->content_view = 'tickets/client_views/_ticket';
}
}
示例7: init
public static function init()
{
global $site;
global $config;
// IP Address
$site['ip'] = getenv('REMOTE_ADDR');
if (getenv('HTTP_X_FORWARDED_FOR')) {
$site['ip'] = getenv('HTTP_X_FORWARDED_FOR');
}
if (isset($config['dev_sql']) && $config['dev_sql']) {
$date = date("Y-m-d H:i:s");
file_put_contents("logs/sql.log", "[{$date}] - {$site['ip']} - {$_SERVER['REQUEST_METHOD']} {$_SERVER['REQUEST_URI']}\r\n", FILE_APPEND);
}
// Login
if (isset($_SESSION['user'])) {
$user = User::find_by_id($_SESSION['user']);
if ($user) {
if ($user->suspended) {
self::Flash("error", "Your account has been suspended");
unset($_SESSION['user']);
} elseif ($user->activated == 0) {
self::Flash("error", "Your account has not been activated");
unset($_SESSION['user']);
} else {
$site['user'] = $user;
}
} else {
unset($_SESSION['user']);
}
}
// Cookie Login
if (!isset($site['user']) && isset($_COOKIE['userkey'])) {
$cookie = $_COOKIE['userkey'];
if ($cookie) {
$cookie = mysql_real_escape_string($cookie);
$user = User::find("users.cookie = '{$cookie}'", null, false, 1);
if ($user) {
if ($user->suspended) {
self::Flash("error", "Your account has been suspended");
setcookie("userkey", null, -3600, "/");
} elseif ($user->activated == 0) {
self::Flash("error", "Your account has not been activated");
setcookie("userkey", null, -3600, "/");
} else {
$site['user'] = $user;
$_SESSION['user'] = $user->id;
setcookie("userkey", $user->cookie, time() + 31536000, "/");
}
}
}
}
$site['dev'] = $config['dev'];
// Maintain visit history
if (!isset($_SESSION['history'])) {
$_SESSION['history'] = array();
}
array_unshift($_SESSION['history'], $_SERVER["REQUEST_URI"]);
}
示例8: __construct
public function __construct()
{
parent::__construct();
if (in_array($this->uri->rsegments(2, 0), array('edit', 'update', 'destroy'))) {
if (!(($id = $this->uri->rsegments(3, 0)) && ($this->user = User::find_by_id($id)))) {
return redirect_message(array('admin', $this->get_class()), array('_flash_message' => '找不到該筆資料。'));
}
}
$this->add_tab('使用者列表', array('href' => base_url('admin', $this->get_class()), 'index' => 1));
}
示例9: excluirAction
public function excluirAction($user_id = null)
{
if (is_numeric($user_id)) {
$user = User::find_by_id($user_id);
if (!is_null($user)) {
$user->delete();
$this->view->setVar('users', User::all());
}
}
}
开发者ID:brunosantoshx,项目名称:serie-criando-sistema-de-cadastro-e-login,代码行数:10,代码来源:UsuariosController.php
示例10: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
global $USER;
require_once get_config('docroot') . 'lib/view.php';
$configdata = $instance->get('configdata');
// this will make sure to unserialize it for us
$configdata['viewid'] = $instance->get('view');
$view = new View($configdata['viewid']);
$group = $view->get('group');
$result = '';
$artefactid = isset($configdata['artefactid']) ? $configdata['artefactid'] : null;
if ($artefactid) {
$artefact = $instance->get_artefact_instance($configdata['artefactid']);
if (!file_exists($artefact->get_path())) {
return '';
}
$urlbase = get_config('wwwroot');
// edit view doesn't use subdomains, neither do groups
if (get_config('cleanurls') && get_config('cleanurlusersubdomains') && !$editing && empty($group)) {
$viewauthor = new User();
$viewauthor->find_by_id($view->get('owner'));
$viewauthorurlid = $viewauthor->get('urlid');
if ($urlallowed = !is_null($viewauthorurlid) && strlen($viewauthorurlid)) {
$urlbase = profile_url($viewauthor) . '/';
}
}
// Send the current language to the pdf viewer
$language = current_language();
$language = str_replace('_', '-', substr($language, 0, substr_count($language, '_') > 0 ? 5 : 2));
if ($language != 'en' && !file_exists(get_config('docroot') . 'artefact/file/blocktype/pdf/js/pdfjs/web/locale/' . $language . '/viewer.properties')) {
// In case the language file exists as a string with both lower and upper case, eg fr_FR we test for this
$language = substr($language, 0, 2) . '-' . strtoupper(substr($language, 0, 2));
if (!file_exists(get_config('docroot') . 'artefact/file/blocktype/pdf/js/pdfjs/web/locale/' . $language . '/viewer.properties')) {
// In case we fail to find a language of 5 chars, eg pt_BR (Portugese, Brazil) we try the 'parent' pt (Portugese)
$language = substr($language, 0, 2);
if ($language != 'en' && !file_exists(get_config('docroot') . 'artefact/file/blocktype/pdf/js/pdfjs/web/locale/' . $language . '/viewer.properties')) {
$language = 'en-GB';
}
}
}
$result = '<iframe src="' . $urlbase . 'artefact/file/blocktype/pdf/viewer.php?editing=' . $editing . '&ingroup=' . !empty($group) . '&file=' . $artefactid . '&lang=' . $language . '&view=' . $instance->get('view') . '" width="100%" height="500" frameborder="0"></iframe>';
require_once get_config('docroot') . 'artefact/comment/lib.php';
require_once get_config('docroot') . 'lib/view.php';
$view = new View($configdata['viewid']);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing);
}
$smarty = smarty_core();
if ($artefactid) {
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
}
$smarty->assign('html', $result);
return $smarty->fetch('blocktype:pdf:pdfrender.tpl');
}
示例11: init
public static function init()
{
if (isset($_COOKIE['SESSID'])) {
if (UserSession::exists(array('session_id' => $_COOKIE['SESSID']))) {
$session = User::find_by_id(UserSession::find_by_session_id($_COOKIE['SESSID'])->user_id);
session_id($_COOKIE['SESSID']);
self::set($session);
} else {
setcookie("SESSID", "", -1);
self::set(-1);
}
session_start();
}
UserSession::delete_all(array('conditions' => array('expiration < ?', Utils::tps())));
}
示例12: authenticate_user_account
/**
* Attempt to authenticate user
*
* @param object $user As returned from the usr table
* @param string $password The password being used for authentication
* @return bool True/False based on whether the user
* authenticated successfully
* @throws AuthUnknownUserException If the user does not exist
*/
public function authenticate_user_account($user, $password)
{
$this->must_be_ready();
$result = $this->validate_password($password, $user->password, $user->salt);
// If result == 1, password is correct
// If result > 1, password is correct but using old settings, should be changed
if ($result > 1) {
if ($user->passwordchange != 1) {
$userobj = new User();
$userobj->find_by_id($user->id);
$this->change_password($userobj, $password);
$user->password = $userobj->password;
$user->salt = $userobj->salt;
}
}
return $result > 0;
}
示例13: create
public function create($group_id = null)
{
$group = self::load_group($group_id);
if ($this->post) {
$added = false;
foreach ($_POST['users'] as $id) {
$user = User::find_by_id($id);
if ($user) {
$user_group = new UserGroup();
$user_group->user_id = $user->id;
$user_group->group_id = $group->id;
if ($user_group->save()) {
$added = true;
}
}
}
if ($added) {
Site::Flash("notice", "The users have been added to the group");
}
Redirect("admin/groups/{$group->id}");
}
$group_users = array();
foreach ($group->users() as $user) {
$group_users[] = $user->id;
}
$users = array();
$all_users = User::find_all("", "nickname ASC");
foreach ($all_users as $user) {
if (!in_array($user->id, $group_users)) {
$users[] = $user;
}
}
if (count($users) == 0) {
Site::Flash("error", "There are no more users to add.");
Redirect("admin/groups/{$group->id}");
}
$this->assign("users", $users);
$this->assign("group", $group);
$this->title = "Add Users";
$this->render("user_group/create.tpl");
}
示例14: activate
/**
* activate
*
* @return void
* @author Mathew
**/
public function activate($id, $code = false)
{
if ($code !== FALSE) {
$user = User::find_by_activation_code($code);
if (!$user) {
return FALSE;
}
$data = array('activation_code' => NULL, 'active' => 1);
$user->update_attributes($data);
} else {
$user = User::find_by_id($id);
$data = array('activation_code' => NULL, 'active' => 1);
$user->update_attributes($data);
}
if ($user->is_valid()) {
return TRUE;
}
if ($user->is_invalid()) {
return FALSE;
}
}
示例15: filter
function filter($userid = FALSE, $year = FALSE, $month = FALSE)
{
$this->view_data['userlist'] = User::find('all', array('conditions' => array('status = ?', 'active')));
$this->view_data['username'] = User::find_by_id($userid);
$this->view_data['user_id'] = $userid;
$this->view_data['year'] = $year;
$this->view_data['month'] = $month;
$search = "";
$stats_search = "";
if ($userid) {
$search .= "user_id = {$userid} and ";
$stats_search = " AND user_id = {$userid} ";
}
if ($month && $year) {
$search .= "date >= '{$year}-{$month}-01' and date <= '{$year}-{$month}-31'";
} else {
$search .= "date >= '{$year}-01-01' and date <= '{$year}-12-31'";
}
//statistic
$graph_month = $month != 0 ? $month : date('m');
if ($month == 0) {
$lastday_in_month = strtotime($year . "-12-31");
$firstday_in_month = strtotime($year . "-01-01");
$this->view_data['days_in_this_month'] = 12;
$this->view_data['expenses_this_month'] = Expense::count(array('conditions' => 'UNIX_TIMESTAMP(`date`) <= ' . $lastday_in_month . ' and UNIX_TIMESTAMP(`date`) >= ' . $firstday_in_month . $stats_search));
$this->view_data['expenses_owed_this_month'] = Expense::find_by_sql('select sum(value) AS "owed" from expenses where UNIX_TIMESTAMP(`date`) >= "' . $firstday_in_month . '" AND UNIX_TIMESTAMP(`date`) <= "' . $lastday_in_month . '"' . $stats_search);
$this->view_data['expenses_due_this_month_graph'] = Expense::find_by_sql('select sum(value) AS "owed", MONTH(`date`) as `date` from expenses where UNIX_TIMESTAMP(`date`) >= "' . $firstday_in_month . '" AND UNIX_TIMESTAMP(`date`) <= "' . $lastday_in_month . '"' . $stats_search . ' Group By MONTH(`date`)');
} else {
$days_in_this_month = days_in_month($graph_month, $year);
$lastday_in_month = strtotime($year . "-" . $graph_month . "-" . $days_in_this_month);
$firstday_in_month = strtotime($year . "-" . $graph_month . "-01");
$this->view_data['days_in_this_month'] = $days_in_this_month;
$this->view_data['expenses_this_month'] = Expense::count(array('conditions' => 'UNIX_TIMESTAMP(`date`) <= ' . $lastday_in_month . ' and UNIX_TIMESTAMP(`date`) >= ' . $firstday_in_month . $stats_search));
$this->view_data['expenses_owed_this_month'] = Expense::find_by_sql('select sum(value) AS "owed" from expenses where UNIX_TIMESTAMP(`date`) >= "' . $firstday_in_month . '" AND UNIX_TIMESTAMP(`date`) <= "' . $lastday_in_month . '"' . $stats_search);
$this->view_data['expenses_due_this_month_graph'] = Expense::find_by_sql('select sum(value) AS "owed", `date` from expenses where UNIX_TIMESTAMP(`date`) >= "' . $firstday_in_month . '" AND UNIX_TIMESTAMP(`date`) <= "' . $lastday_in_month . '"' . $stats_search . ' Group By `date`');
}
$this->view_data['expenses'] = Expense::find('all', array('conditions' => array("{$search}")));
$this->content_view = 'expenses/all';
}