本文整理汇总了PHP中Users::getById方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::getById方法的具体用法?PHP Users::getById怎么用?PHP Users::getById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Users
的用法示例。
在下文中一共展示了Users::getById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateData
function generateData()
{
global $current_user;
// мини блок с меню пользователя и его инфо
// если страница user/id и это не наша страница - рисуем чужого пользователя
$id = Request::get(0, false);
if (!$id) {
return false;
}
if ($id == $current_user->id) {
return false;
} else {
$user = Users::getById($id);
}
/* @var $user User */
/* @var $current_user CurrentUser */
// выдаем данные по пользователю
$this->data['profile']['id'] = $user->id;
// можно добавить в друзья?
if (in_array($user->id, $current_user->getFollowing())) {
$this->data['profile']['following'] = 1;
} else {
$this->data['profile']['following'] = 0;
}
}
示例2: generateData
function generateData()
{
global $current_user;
// мини блок с меню пользователя и его инфо
// если страница user/id и это не наша страница - рисуем чужого пользователя
if (Request::$pageName == 'user') {
$id = Request::get(0, false);
} else {
$id = $current_user->id;
}
if ($id && $id == $current_user->id) {
$user = $current_user;
} else {
if ($id) {
$user = Users::getById($id);
}
}
if (!$id) {
return false;
}
/* @var $user User */
$this->data['profile']['id'] = $user->id;
$this->data['profile']['nickname'] = $user->getProperty('nickname');
$this->data['profile']['rolename'] = $user->getRoleName();
$this->data['profile']['picture'] = $user->getProperty('picture') ? $user->id . '.jpg' : 'default.jpg';
}
示例3: BasePage
function BasePage()
{
@session_start();
if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc() || ini_get('magic_quotes_sybase')) {
foreach ($_GET as $k => $v) {
$_GET[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v);
}
foreach ($_POST as $k => $v) {
$_POST[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v);
}
foreach ($_REQUEST as $k => $v) {
$_REQUEST[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v);
}
foreach ($_COOKIE as $k => $v) {
$_COOKIE[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v);
}
}
// set site variable
$s = new Sites();
$this->site = $s->get();
$this->smarty = new Smarty();
$this->smarty->template_dir = WWW_DIR . 'views/templates/' . $this->template_dir;
$this->smarty->compile_dir = SMARTY_DIR . 'templates_c/';
$this->smarty->config_dir = SMARTY_DIR . 'configs/';
$this->smarty->cache_dir = SMARTY_DIR . 'cache/';
$this->smarty->error_reporting = E_ALL - E_NOTICE;
$this->smarty->assign('site', $this->site);
$this->smarty->assign('page', $this);
if (isset($_SERVER["SERVER_NAME"])) {
$this->serverurl = (isset($_SERVER["HTTPS"]) ? "https://" : "http://") . $_SERVER["SERVER_NAME"] . ($_SERVER["SERVER_PORT"] != "80" ? ":" . $_SERVER["SERVER_PORT"] : "") . WWW_TOP . '/';
$this->smarty->assign('serverroot', $this->serverurl);
}
$this->page = isset($_GET['page']) ? $_GET['page'] : 'content';
$users = new Users();
if ($users->isLoggedIn()) {
$this->userdata = $users->getById($users->currentUserId());
$this->userdata["categoryexclusions"] = $users->getCategoryExclusion($users->currentUserId());
//update lastlogin every 15 mins
if (strtotime($this->userdata['now']) - 900 > strtotime($this->userdata['lastlogin'])) {
$users->updateSiteAccessed($this->userdata['ID']);
}
$this->smarty->assign('userdata', $this->userdata);
$this->smarty->assign('loggedin', "true");
$sab = new SABnzbd($this);
if ($sab->integrated !== false && $sab->url != '' && $sab->apikey != '') {
$this->smarty->assign('sabintegrated', $sab->integrated);
$this->smarty->assign('sabapikeytype', $sab->apikeytype);
}
if ($this->userdata["role"] == Users::ROLE_ADMIN) {
$this->smarty->assign('isadmin', "true");
}
$this->floodCheck(true, $this->userdata["role"]);
} else {
$this->smarty->assign('isadmin', "false");
$this->smarty->assign('loggedin', "false");
$this->floodCheck(false, "");
}
}
示例4: defaultAction
public function defaultAction()
{
$users = new Users();
$account = $users->getById(Auth::getUserId());
if ($account === false) {
$this->doesNotExist();
return;
}
$this->view->assign('account', $account);
}
示例5: notifyNewInbox
public static function notifyNewInbox($user_ids, $id_sender)
{
global $current_user;
$sender = Users::getById($id_sender);
/* @var $sender User */
$subject = 'Новое письмо!';
if (isset($user_ids[$current_user->id])) {
unset($user_ids[$current_user->id]);
}
/* @var $book Book */
$message = 'Новое личное сообщение от пользователя <a href="' . Config::need('www_path') . '/user/' . $sender->id . '">' . $sender->getNickName() . '</a>';
self::send($user_ids, $subject, $message, UserNotify::UN_NEW_MESSAGE, $only_email = true);
}
示例6: set
function set()
{
global $current_user;
$this->data['success'] = 1;
if (!$current_user->authorized) {
$this->error('Auth');
return;
}
/* @var $current_user User */
$id_user = false;
if (isset($_POST['id_user'])) {
if (!$current_user->can('ocr_edit')) {
$this->error('You must be biber to do that');
return;
} else {
$id_user = (int) $_POST['id_user'];
}
}
$_POST['status'] = isset($_POST['status']) ? $_POST['status'] : -1;
$_POST['state'] = isset($_POST['state']) ? $_POST['state'] : -1;
$id_user = $id_user ? $id_user : $current_user->id;
$id_book = max(0, (int) $_POST['id_book']);
if (!is_numeric($_POST['status'])) {
foreach (Ocr::$statuses as $s) {
if ($s['name'] == $_POST['status']) {
$_POST['status'] = $s['id'];
}
}
}
if (!is_numeric($_POST['state'])) {
foreach (Ocr::$states as $s) {
if ($s['name'] == $_POST['state']) {
$_POST['state'] = $s['id'];
}
}
}
$user = Users::getById($id_user);
/*@var $user User*/
$user->load();
$status = max(-1, (int) $_POST['status']);
$state = max(-1, (int) $_POST['state']);
try {
Ocr::setStatus($id_user, $id_book, $status, $state);
} catch (Exception $e) {
$this->error($e->getMessage());
}
if ($state == Ocr::STATE_APPROVED) {
$user->gainActionPoints('ocr_add', $id_book, BiberLog::TargetType_book);
}
}
示例7: setStatus
public static function setStatus($id_user, $id_book, $status, $state)
{
global $current_user;
$book = Books::getInstance()->getByIdLoaded($id_book);
/* @var $book Book */
if ($book->getQuality() >= BOOK::BOOK_QUALITY_BEST) {
throw new Exception('book quality is best, you cant fix states');
}
if (!isset(self::$statuses[$status])) {
throw new Exception('no status #' . $status);
}
if (!isset(self::$states[$state])) {
throw new Exception('no status #' . $state);
}
$can_comment = false;
if ($state > 0) {
$query = 'SELECT `time` FROM `ocr` WHERE `id_book`=' . $id_book . ' AND `id_user`=' . $id_user . ' AND `status`=' . $status . ' AND `state`=' . $state;
$last_time = Database::sql2single($query);
if (time() - $last_time > 24 * 60 * 60) {
$can_comment = true;
}
}
if ($state == 0 && $status !== 0) {
// delete
$query = 'DELETE FROM `ocr` WHERE `id_book`=' . $id_book . ' AND `id_user`=' . $id_user . ' AND `status`=' . $status . '';
} else {
// upsert
$query = 'INSERT INTO `ocr` SET `id_book`=' . $id_book . ', `id_user`=' . $id_user . ', `status`=' . $status . ',`state`=' . $state . ',`time`=' . time() . '
ON DUPLICATE KEY UPDATE
`time`=' . time() . ', `state`=' . $state;
}
if (!Database::query($query, false)) {
throw new Exception('Duplicating #book ' . $id_book . ' #status' . $status . ' #state' . $state);
}
if ($state == 0) {
$comment = 'User ' . $current_user->id . ' drop status ' . $status . ' state ' . $state . ' user_id ' . $id_user;
} else {
$comment = 'User ' . $current_user->id . ' set status ' . $status . ' state ' . $state . ' user_id ' . $id_user;
}
$comUser = Users::getById($id_user);
/* @var $comUser User */
if ($can_comment && ($part = self::getMessagePart($status, $state))) {
$comment = mb_strtolower($part, 'UTF-8') . ' книгу';
MongoDatabase::addSimpleComment(BiberLog::TargetType_book, $id_book, $id_user, $comment);
}
}
示例8: generateProfile
function generateProfile()
{
global $current_user;
/* @var $current_user CurrentUser */
/* @var $user User */
$user = $current_user->id === $this->id ? $current_user : Users::getById($this->id);
$this->data['profile'] = $user->getXMLInfo();
$this->data['profile']['role'] = $user->getRole();
$this->data['profile']['lang'] = $user->getLanguage();
$this->data['profile']['city_id'] = $user->getProperty('city_id');
$this->data['profile']['city'] = Database::sql2single('SELECT `name` FROM `lib_city` WHERE `id`=' . $user->getProperty('city_id'));
$this->data['profile']['picture'] = $user->getProperty('picture') ? $user->id . '.jpg' : 'default.jpg';
$this->data['profile']['rolename'] = $user->getRoleName();
$this->data['profile']['bday'] = $user->getBday(date('d-m-Y'), 'd-m-Y');
$this->data['profile']['bdays'] = $user->getBday('неизвестно', 'd.m.Y');
// additional
$this->data['profile']['link_fb'] = $user->getPropertySerialized('link_fb');
$this->data['profile']['link_vk'] = $user->getPropertySerialized('link_vk');
$this->data['profile']['link_tw'] = $user->getPropertySerialized('link_tw');
$this->data['profile']['link_lj'] = $user->getPropertySerialized('link_lj');
}
示例9: removeFriend
function removeFriend()
{
$id = max(0, (int) $_POST['id']);
$current_user = new CurrentUser();
if ($current_user->authorized) {
if ($current_user->id != $id) {
$user_following = $current_user->getFollowing();
$friend = Users::getById($id);
/* @var $friend User */
$friend_followers = $friend->getFollowers();
if (isset($user_following[$id])) {
unset($user_following[$id]);
}
if (isset($friend_followers[$current_user->id])) {
unset($friend_followers[$current_user->id]);
}
$current_user->setFollowing($user_following);
$friend->setFollowers($friend_followers);
$friend->save();
$current_user->save();
}
}
}
示例10: update
}
function update($bind, $where = NULL)
{
return $this->_db->update($this->_table, $bind, $where);
}
function delete($where = NULL)
{
return $this->_db->delete($this->_table, $where);
}
function getTableName()
{
return $this->_table;
}
}
class Users extends Table
{
// 针对于Users表的操作
function getById($id)
{
$sql = 'SELECT * FROM ' . $this->_table . ' WHERE id=' . $id;
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
return $row;
}
}
$bind = array('username' => 'Rose', 'password' => 'ben', 'age' => 29, 'sex' => 1);
$db = new Mysql('localhost', 'root', 'root', 'test');
$users = new Users($db);
//$users->insert ( $bind );
print_r($users->getById(152));
示例11: getProfile
function getProfile($edit = false)
{
global $current_user;
/* @var $current_user CurrentUser */
/* @var $user User */
$user = $current_user->id === $this->id ? $current_user : Users::getById($this->id);
if ($edit && $user->id != $current_user->id) {
$current_user->can_throw('users_edit', $user);
}
if ($edit) {
foreach (Users::$rolenames as $id => $role) {
$this->data['roles'][] = array('id' => $id, 'title' => $role);
}
}
try {
$user->load();
} catch (Exception $e) {
throw new Exception('Пользователя не существует');
}
if ($user->loaded) {
} else {
return;
}
$this->data['profile'] = $user->getXMLInfo();
$this->data['profile']['role'] = $user->getRole();
$this->data['profile']['lang'] = $user->getLanguage();
$this->data['profile']['city_id'] = $user->getProperty('city_id');
$this->data['profile']['picture'] = $user->getAvatar();
$this->data['profile']['rolename'] = $user->getRoleName();
$this->data['profile']['bday'] = $user->getBday(date('d-m-Y'), 'd-m-Y');
$this->data['profile']['path'] = $user->getUrl();
$this->data['profile']['path_edit'] = $user->getUrl() . '/edit';
$this->data['profile']['bdays'] = $user->getBday('неизвестно', 'd.m.Y');
// additional
$this->data['profile']['link_fb'] = $user->getPropertySerialized('link_fb');
$this->data['profile']['link_vk'] = $user->getPropertySerialized('link_vk');
$this->data['profile']['link_tw'] = $user->getPropertySerialized('link_tw');
$this->data['profile']['link_lj'] = $user->getPropertySerialized('link_lj');
$this->data['profile']['quote'] = $user->getPropertySerialized('quote');
$this->data['profile']['about'] = $user->getPropertySerialized('about');
$this->data['profile']['change_nickname'] = $user->checkNickChanging();
// $this->data['profile']['path_message'] = Config::need('www_path').'/me/messages?to='.$user->id;
$this->data['profile']['path_message'] = Config::need('www_path') . '/user/' . $user->getNickName() . '/contact';
$this->data['profile']['path_edit_notifications'] = Config::need('www_path') . '/user/me/edit_notifications';
$this->data['profile']['path_stat'] = Config::need('www_path') . '/admin/users/stat/' . $user->id;
}
示例12: getListData
function getListData()
{
$user = Users::getById($this->data['user_id']);
$out = array('id' => $this->id, 'title' => $this->getTitle(), 'anons' => $this->getAnons(), 'path' => $this->getUrl(), 'comment_count' => $this->getCommentCount(), 'image' => $this->getImage(), 'path' => Config::need('www_path') . '/blog/' . $user->data['nick'] . '/' . $this->id, 'path_edit' => Config::need('www_path') . '/blog/' . $user->data['nick'] . '/' . $this->id . '/edit');
return $out;
}
示例13: getProfile
function getProfile($edit = false)
{
global $current_user;
/* @var $current_user CurrentUser */
/* @var $user User */
$user = $current_user->id === $this->id ? $current_user : Users::getById($this->id);
if ($edit && $user->id != $current_user->id) {
Error::CheckThrowAuth(User::ROLE_SITE_ADMIN);
}
if ($edit) {
foreach (Users::$rolenames as $id => $role) {
$this->data['roles'][] = array('id' => $id, 'title' => $role);
}
}
$this->data['profile'] = $user->getXMLInfo();
$this->data['profile']['role'] = $user->getRole();
$this->data['profile']['nickname'] = $user->getNickName();
$this->data['profile']['lang'] = $user->getLanguage();
$this->data['profile']['city_id'] = $user->getProperty('city_id');
$this->data['profile']['city'] = Database::sql2single('SELECT `name` FROM `lib_city` WHERE `id`=' . (int) $user->getProperty('city_id'));
$this->data['profile']['picture'] = $user->getAvatar();
$this->data['profile']['rolename'] = $user->getRoleName();
$this->data['profile']['bday'] = $user->getBday(date('d-m-Y'), 'd-m-Y');
$this->data['profile']['path'] = $user->getUrl();
$this->data['profile']['path_edit'] = $user->getUrl() . '/edit';
$this->data['profile']['bdays'] = $user->getBday('неизвестно', 'd.m.Y');
// additional
$this->data['profile']['link_fb'] = $user->getPropertySerialized('link_fb');
$this->data['profile']['link_vk'] = $user->getPropertySerialized('link_vk');
$this->data['profile']['link_tw'] = $user->getPropertySerialized('link_tw');
$this->data['profile']['link_lj'] = $user->getPropertySerialized('link_lj');
$this->data['profile']['quote'] = $user->getPropertySerialized('quote');
$this->data['profile']['about'] = $user->getPropertySerialized('about');
// $this->data['profile']['path_message'] = Config::need('www_path').'/me/messages?to='.$user->id;
$this->data['profile']['path_message'] = Config::need('www_path') . '/user/' . $user->getNickName() . '/contact';
}
示例14: getProfile
function getProfile($edit = false)
{
global $current_user;
/* @var $current_user CurrentUser */
/* @var $user User */
$user = $current_user->id === $this->id ? $current_user : Users::getById($this->id);
if ($edit && $user->id != $current_user->id) {
$current_user->can_throw('users_edit', $user);
}
foreach (Users::$rolenames as $id => $role) {
$this->data['roles'][] = array('id' => $id, 'title' => $role);
}
try {
$user->load();
} catch (Exception $e) {
throw new Exception('Пользователя не существует');
}
if ($user->loaded) {
} else {
return;
}
$this->data['user'] = $user->getListData();
/*
Если
1. У юзера нет друзей / фоловеров
2. Не добавил ни одной книжки
3. Не добавил в любимые ни одного объекта
*/
$this->data['user']['role'] = $user->getRole();
$this->data['user']['id_city'] = $user->getProperty('id_city');
$this->data['user']['city'] = Database::sql2single('SELECT `name` FROM `lib_city` WHERE `id`=' . (int) $user->getProperty('id_city'));
$this->data['user']['id_country'] = $user->getProperty('id_country');
$this->data['user']['country'] = Database::sql2single('SELECT `name` FROM `lib_country` WHERE `id`=' . (int) $user->getProperty('id_country'));
$this->data['user']['id_region'] = $user->getProperty('id_region');
$this->data['user']['region'] = Database::sql2single('SELECT `name` FROM `lib_region` WHERE `id`=' . (int) $user->getProperty('id_region'));
$this->data['user']['id_street'] = $user->getProperty('id_street');
$this->data['user']['street'] = Database::sql2single('SELECT `name` FROM `lib_street` WHERE `id`=' . (int) $user->getProperty('id_street'));
$this->data['user']['picture'] = $user->getAvatar();
$this->data['user']['rolename'] = $user->getRoleName();
$bdayunix = max(0, strtotime($user->getBday()));
if (!$edit) {
$this->data['user']['bday'] = date('d M Y г.', $bdayunix);
$en = array('/JAN/isU', '/FEB/isU', '/MAR/isU', '/APR/isU', '/MAY/isU', '/JUN/isU', '/JUL/isU', '/AUG/isU', '/SEP/isU', '/OCT/isU', '/NOV/isU', '/DEC/isU');
$ru = array('января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря');
$this->data['user']['bday'] = preg_replace($en, $ru, $this->data['user']['bday']);
} else {
$this->data['user']['bday'] = date('Y-d-m', $bdayunix);
}
$this->data['user']['path'] = $user->getUrl();
$this->data['user']['path_edit'] = $user->getUrl() . '/edit';
// additional
}
示例15: push
public function push($walls_disabled = array())
{
global $current_user;
if (!$this->canPushed) {
return;
}
$eventId = false;
// ревью обновляем
if ($this->data['type'] == self::EVENT_BOOKS_REVIEW_ADD || $this->data['type'] == self::EVENT_BOOKS_RATE_ADD) {
// ищем старую
$eventId = MongoDatabase::findReviewEvent($current_user->id, $this->data['bid']);
if ($eventId) {
// есть старая? нужно удалить запись на стене со ссылкой на старую запись со всех стен
MongoDatabase::deleteWallItemsByEventId($eventId);
MongoDatabase::updateEvent($eventId, $this->data);
}
}
// а если был такой эвент недавно, с тем же типом
// то обновляем эфент, добавляя туда объекты
if (in_array($this->data['type'], self::$eventsMultTypes)) {
// находим эвент с таким типом
$additionalCriteria = array();
if ($this->data['type'] == self::EVENT_BOOKS_ADD_SHELF) {
$additionalCriteria['shelf_id'] = $this->data['shelf_id'];
}
list($eventId, $data) = MongoDatabase::findLastEventByType($this->data['user_id'], $this->data['type'], $additionalCriteria);
if ($eventId) {
// нашли эвент!
$old_time = isset($data['time']) ? $data['time'] : time();
foreach ($this->data as $field => $value) {
if (!isset($data[$field])) {
$data[$field] = $value;
}
if (is_array($value)) {
foreach ($value as $val) {
if (is_array($data[$field])) {
$data[$field][$val] = $val;
}
}
}
}
$data['time'] = $old_time;
MongoDatabase::deleteWallItemsByEventId($eventId);
MongoDatabase::updateEvent($eventId, $data);
}
}
$eventDbId = 0;
if (!$eventId) {
$eventId = MongoDatabase::addEvent($this->data);
$query = 'INSERT INTO `events` SET `mongoid`=' . Database::escape($eventId);
Database::query($query, false);
$eventDbId = Database::lastInsertId();
if (!$eventDbId) {
throw new Exception('cant push event id to database');
}
}
if ($eventId) {
$user = Users::getById($this->data['user_id']);
/* @var $user User */
$followerIds = $user->getFollowers();
$followerIds[$user->id] = $user->id;
foreach ($walls_disabled as $id) {
if (isset($followerIds[$id])) {
unset($followerIds[$id]);
}
}
MongoDatabase::pushEvents($this->data['user_id'], $followerIds, $eventId, $this->data['time']);
}
return $eventDbId;
}