本文整理汇总了PHP中Users::getByIdsLoaded方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::getByIdsLoaded方法的具体用法?PHP Users::getByIdsLoaded怎么用?PHP Users::getByIdsLoaded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Users
的用法示例。
在下文中一共展示了Users::getByIdsLoaded方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
function write()
{
global $current_user;
/* @var $current_user CurrentUser */
$uid = isset(Request::$post['id']) ? Request::$post['id'] : $current_user->id;
if (!$uid) {
throw new Exception('illegal user id');
}
if ($current_user->id != $uid) {
if ($current_user->getRole() >= User::ROLE_BIBER) {
$editing_user = Users::getByIdsLoaded(array($uid));
$editing_user = isset($editing_user[$uid]) ? $editing_user[$uid] : false;
}
} else {
$editing_user = $current_user;
}
$current_user->can_throw('users_edit', $editing_user);
foreach ($this->ruleNames as $name => $rule) {
foreach ($this->typeNames as $typename => $type) {
if (isset(Request::$post[$name][$typename])) {
$editing_user->setNotifyRule($rule, $type, true);
} else {
$editing_user->setNotifyRule($rule, $type, false);
}
}
}
$editing_user->save();
}
示例2: get_likes
function get_likes($params, &$data)
{
$ids = $_POST['ids'];
$to_check = array();
foreach ($ids as $event_id) {
if (is_numeric($event_id) && $event_id > 0) {
$to_check[$event_id] = $event_id;
}
}
if (count($to_check)) {
$res = Database::sql2array('SELECT `user_id`,`event_id` FROM `event_likes` WHERE `event_id` IN (' . implode(',', $to_check) . ')');
$uids = array();
foreach ($res as $row) {
$uids[$row['user_id']] = $row['user_id'];
}
if (count($uids)) {
$users = Users::getByIdsLoaded(array_keys($uids));
foreach ($res as $row) {
if (isset($users[$row['user_id']])) {
$data['likes'][$row['event_id']][$row['user_id']] = array('nickname' => $users[$row['user_id']]->data['nickname'], 'id' => $users[$row['user_id']]->data['id']);
if (CurrentUser::$id == $row['user_id']) {
$data['self'][$row['event_id']] = $row['user_id'];
}
}
}
}
}
foreach ($to_check as $event_id) {
if (!isset($data['likes'][$event_id])) {
$data['likes'][$event_id] = array();
}
}
$data['owner'] = CurrentUser::$id;
return $data;
}
示例3: getUsers
function getUsers($ids) {
$users = Users::getByIdsLoaded($ids);
$out = array();
/* @var $user User */
$i = 0;
if (is_array($users))
foreach ($users as $user) {
$out[$user->id] = array(
'id' => $user->id,
'picture' => $user->getAvatar(),
'nickname' => $user->getNickName(),
);
}
if (is_array($ids))
foreach ($ids as $id) {
if (!isset($out[$id])) {
$out[$id] = array(
'id' => $id,
'picture' => Config::need('www_path') . '/static/upload/avatars/default.jpg',
'nickname' => 'аноним',
);
}
}
return $out;
}
示例4: getCommentUsers
function getCommentUsers($ids)
{
$users = Users::getByIdsLoaded($ids);
$out = array();
/* @var $user User */
if (is_array($users)) {
foreach ($users as $user) {
$out[] = $user->getListData();
}
}
return $out;
}
示例5: _list
function _list($opts)
{
$data = array();
$has_paging = !isset($opts['no_paging']);
$show_sortings = isset($opts['show_sortings']);
$per_page = isset($opts['per_page']) ? $opts['per_page'] : 10;
$per_page = min(100, max(1, (int) $per_page));
$cond = new Conditions();
$cond->setSorting(array('time' => array('order' => 'desc', 'title' => 'по дате')), array('time' => array('order' => 'desc', 'title' => 'по дате')));
$cond->setPaging(100000, $per_page);
$where = array('parent_id=0');
if (isset($opts['where'])) {
foreach ($opts['where'] as $w) {
$where[] = $w;
}
}
$order = $cond->getSortingField() . ' ' . $cond->getSortingOrderSQL();
$limit = $cond->getLimit();
$query = 'SELECT * FROM `comments`
WHERE (' . implode(' AND ', $where) . ')
ORDER BY ' . $order . ' LIMIT ' . $limit . '';
$comments = Database::sql2array($query, 'id');
$pids = array();
$uids = array();
foreach ($comments as $comment) {
$pids[$comment['id']] = $comment['id'];
$uids[$comment['user_id']] = $comment['user_id'];
}
if (count($pids)) {
$query = 'SELECT * FROM `comments` WHERE `thread` IN (' . implode(',', $pids) . ') ORDER BY `thread`,`id`';
$nextlevel = Database::sql2array($query, 'id');
$comments += $nextlevel;
foreach ($comments as $comment) {
$uids[$comment['user_id']] = $comment['user_id'];
}
if (count($uids)) {
$users = Users::getByIdsLoaded($uids);
} else {
$users = array();
}
foreach ($comments as &$comment) {
if (!isset($users[$comment['user_id']])) {
continue;
}
$comment['user'] = $users[$comment['user_id']];
$parents[$comment['parent_id']][$comment['id']] = $comment;
uasort($parents[$comment['parent_id']], 'x_sort_comment');
}
$comments = $this->build_tree($parents, 0);
}
return $comments;
}
示例6: _list
function _list($ids, $opts = array(), $limit = false) {
$users = Users::getByIdsLoaded($ids);
$out = array();
/* @var $user User */
$i = 0;
if (is_array($users))
foreach ($users as $user) {
if ($limit && ++$i > $limit)
return $out;
$out[] = $user->getListData();
}
return $out;
}
示例7: _item
function _item($row)
{
$out = array();
$usrs = array();
$out['review'] = array('user_id' => $row['user_id'], 'time' => date('Y-m-d H:i', $row['time']), 'mark' => isset($row['mark']) ? $row['mark'] : 0, 'body' => isset($row['body']) ? $row['body'] : '', 'likesCount' => isset($row['likesCount']) ? (int) $row['likesCount'] : 0);
$usrs[$row['user_id']] = $row['user_id'];
if (count($usrs)) {
$users = Users::getByIdsLoaded($usrs);
foreach ($users as $user) {
$out['users'][] = $user->getListData();
}
}
return $out;
}
示例8: _list
function _list($ids, $opts = array(), $limit = false)
{
$users = Users::getByIdsLoaded($ids);
$out = array();
/* @var $user User */
$i = 0;
if (is_array($users)) {
foreach ($users as $user) {
if ($limit && ++$i > $limit) {
return $out;
}
$out[] = array('id' => $user->id, 'picture' => $user->getAvatar(), 'nickname' => $user->getNickName());
}
}
return $out;
}
示例9: _list
function _list($opts = array())
{
$has_paging = !isset($opts['no_paging']);
$show_sortings = isset($opts['show_sortings']);
$per_page = isset($opts['per_page']) ? $opts['per_page'] : 10;
$per_page = min(100, max(1, (int) $per_page));
$cond = new Conditions();
$cond->setSorting(array('created' => array('order' => 'desc', 'title' => 'по дате')));
$cond->setPaging(100000, $per_page);
$where = array('1');
if (isset($opts['where'])) {
foreach ($opts['where'] as $w) {
$where[] = $w;
}
}
$order = $cond->getSortingField() . ' ' . $cond->getSortingOrderSQL();
$limit = $cond->getLimit();
$query = 'SELECT SQL_CALC_FOUND_ROWS P. * , GROUP_CONCAT( T.title ) AS tags, GROUP_CONCAT( PT.tag_id ) AS tags_indexes
FROM `publications` P
LEFT JOIN `publications_tags` PT ON PT.publication_id = P.id
LEFT JOIN `tags` T ON T.id = PT.tag_id
WHERE (' . implode(' AND ', $where) . ')
GROUP BY P.id
ORDER BY ' . $order . ' LIMIT ' . $limit . '';
$publications = Database::sql2array($query, 'id');
foreach ($publications as $publication) {
$uids[$publication['user_id']] = $publication['user_id'];
}
$users = Users::getByIdsLoaded($uids);
foreach ($publications as &$publication) {
$publication['user'] = isset($users[$publication['user_id']]) ? $users[$publication['user_id']]->data : array();
}
$cond->setPaging(Database::sql2single('SELECT FOUND_ROWS()'), $per_page);
$data['publications'] = $publications;
$data['conditions'] = $cond->getConditions();
if (!$show_sortings) {
foreach ($data['conditions'] as $key => $group) {
if ($group['mode'] == 'sorting') {
unset($data['conditions'][$key]);
}
}
}
return $data;
}
示例10: getSubscriptions
function getSubscriptions()
{
global $current_user;
$user = Users::getByIdsLoaded(array($this->params['user_id']));
$user = isset($user[$this->params['user_id']]) ? $user[$this->params['user_id']] : $current_user;
/* @var $user User */
$subscriptions = $user->getSubscriptions();
$this->data['subscriptions'] = $subscriptions;
$this->data['user'] = $user->getListData();
$this->data['user']['unused_points'] = $user->getPoints();
$this->data['subscriptions']['active'] = $user->isSubscriptionEnabled() ? '1' : 0;
$this->data['subscriptions']['end'] = $user->getSubscriptionEnd() ? date('Y/m/d H:i:s ', $user->getSubscriptionEnd()) : 0;
}
示例11: getThreadList
function getThreadList() {
global $current_user;
$query = 'SELECT * FROM `users_messages_index` UMI
RIGHT JOIN `users_messages` UM ON UM.id = UMI.message_id
WHERE `id_recipient`=' . $current_user->id;
$messages = Database::sql2array($query);
// загрузили все сообщения вообще
// для каждого треда выбираем последнее сообщение
$messages_prepared = array();
$uids = array();
foreach ($messages as &$message) {
if (!isset($messages_prepared[$message['thread_id']])) {
$messages_prepared[$message['thread_id']]['newest']['time'] = 0;
$messages_prepared[$message['thread_id']]['oldest']['time'] = time() + 10000;
}
if ($messages_prepared[$message['thread_id']]['newest']['time'] < $message['time']) {
$messages_prepared[$message['thread_id']]['newest'] = $message;
$messages_prepared[$message['thread_id']]['subject'] = $message['subject'];
$messages_prepared[$message['thread_id']]['html'] = $message['html'];
}
if ($message['is_new'])
$messages_prepared[$message['thread_id']]['is_new'] = 1;
if ($messages_prepared[$message['thread_id']]['oldest']['time'] > $message['time'])
$messages_prepared[$message['thread_id']]['oldest'] = $message['time'];
$messages_prepared[$message['thread_id']]['members'][$message['id_recipient']] = $message['id_recipient'];
$messages_prepared[$message['thread_id']]['members'][$message['id_author']] = $message['id_author'];
$messages_prepared[$message['thread_id']]['thread_id'] = $message['thread_id'];
}
foreach ($messages_prepared as $thread_id => &$mess) {
$mess['oldest'] = date('Y/m/d H:i:s', $mess['oldest']);
$tmpmess = $mess['newest'];
$tmpmess['oldest'] = $mess['oldest'];
$tmpmess['newest'] = date('Y/m/d H:i:s', $mess['newest']['time']);
$tmpmess['subject'] = $mess['subject'];
$tmpmess['is_new'] = isset($mess['is_new']) ? 1 : 0;
foreach ($mess['members'] as $uid) {
if ($current_user->id != $uid)
$tmpmess['members'][] = array(
'id' => $uid
);
$uids[$uid] = $uid;
}
$out[] = $tmpmess;
}
$users = Users::getByIdsLoaded($uids);
foreach ($users as $user) {
$this->data['users'][$user->id] = array(
'id' => $user->id,
'picture' => $user->getAvatar(),
'nickname' => $user->getNickName(),
);
}
$this->data['messages'] = $out;
}
示例12: getStatUsers
function getStatUsers($uids)
{
if (!count($uids)) {
return array();
}
$users = Users::getByIdsLoaded($uids);
$out = array();
foreach ($users as $user) {
$out[] = $user->getListData();
}
foreach ($out as &$r) {
$r['path'] = Config::need('www_path') . '/admin/users/stat/' . $r['id'];
}
return $out;
}
示例13: getThreadList
function getThreadList($notifications = false)
{
global $current_user;
$out = array();
if ($notifications) {
$query = 'SELECT * FROM `users_messages_index` UMI
RIGHT JOIN `users_messages` UM ON UM.id = UMI.message_id
WHERE `id_recipient`=' . $current_user->id . ' AND `id_author`=0 AND `is_deleted`=0';
} else {
$query = 'SELECT * FROM `users_messages_index` UMI
RIGHT JOIN `users_messages` UM ON UM.id = UMI.message_id
WHERE `id_recipient`=' . $current_user->id . ' AND `id_author`<>0 AND `is_deleted`=0';
}
$messages = Database::sql2array($query);
// загрузили все сообщения вообще
// для каждого треда выбираем последнее сообщение
$messages_prepared = array();
$uids = array();
$thread_ids = array();
foreach ($messages as &$message) {
$tr[$message['thread_id']] = $message['id_author'];
$uids[$message['id_author']] = $message['id_author'];
$thread_ids[$message['thread_id']] = $message['thread_id'];
if (!isset($messages_prepared[$message['thread_id']])) {
$messages_prepared[$message['thread_id']]['newest']['time'] = 0;
$messages_prepared[$message['thread_id']]['oldest']['time'] = time() + 10000;
}
if ($messages_prepared[$message['thread_id']]['newest']['time'] < $message['time']) {
$messages_prepared[$message['thread_id']]['newest'] = $message;
$messages_prepared[$message['thread_id']]['html'] = $message['html'];
}
if ($message['is_new']) {
$messages_prepared[$message['thread_id']]['is_new'] = 1;
}
if ($messages_prepared[$message['thread_id']]['oldest']['time'] > $message['time']) {
$messages_prepared[$message['thread_id']]['oldest'] = $message['time'];
$messages_prepared[$message['thread_id']]['subject'] = $message['subject'];
}
$messages_prepared[$message['thread_id']]['thread_id'] = $message['thread_id'];
}
foreach ($messages_prepared as $thread_id => &$mess) {
$mess['oldest'] = date('Y/m/d H:i:s', $mess['oldest']);
$tmpmess = $mess['newest'];
$tmpmess['oldest'] = $mess['oldest'];
$tmpmess['newest'] = date('Y/m/d H:i:s', $mess['newest']['time']);
$tmpmess['timestamp'] = $mess['newest']['time'];
$tmpmess['time'] = date('Y/m/d H:i:s', $tmpmess['time']);
$tmpmess['subject'] = $mess['subject'];
$tmpmess['is_new'] = isset($mess['is_new']) ? 1 : 0;
$out[$tmpmess['thread_id']] = $tmpmess;
}
// all people from threads
if (count($thread_ids)) {
if ($notifications) {
$query = 'SELECT `thread_id`,`id_recipient`,`type` FROM`users_messages_index` WHERE `thread_id` IN (' . implode(',', $thread_ids) . ')
AND `id_recipient`=' . $current_user->id;
} else {
$query = 'SELECT `thread_id`,`id_recipient`,`type` FROM`users_messages_index` WHERE `thread_id` IN (' . implode(',', $thread_ids) . ')';
}
$parts = Database::sql2array($query);
foreach ($parts as &$p) {
if (isset($out[$p['thread_id']])) {
if ($tr[$p['thread_id']] != $current_user->id) {
$out[$p['thread_id']]['members'][$tr[$p['thread_id']]] = array('user_id' => $tr[$p['thread_id']]);
}
if ($p['id_recipient'] != $current_user->id) {
$out[$p['thread_id']]['members'][$p['id_recipient']] = array('user_id' => $p['id_recipient']);
}
$uids[$p['id_recipient']] = $p['id_recipient'];
}
}
}
$users = Users::getByIdsLoaded($uids);
foreach ($users as $user) {
$this->data['users'][$user->id] = $user->getListData();
}
uasort($out, 'sort_by_newest_time');
$this->data['messages'] = $out;
}
示例14: getLog
//.........这里部分代码省略.........
$tmp[] = array('book_id' => $new_relation_id);
}
$values['old_relations'] = $tmp;
} else {
if ($field == 'deleted_relations') {
foreach ($v[1] as $new_relation_id) {
$book_ids[$new_relation_id] = $new_relation_id;
$tmp[] = array('book_id' => $new_relation_id);
}
$values['deleted_relations'] = $tmp;
} else {
$values[] = array('name' => $field, 'old' => $v[0], 'new' => $v[1]);
}
}
}
} else {
if ($row['target_type'] == BiberLog::TargetType_person) {
if ($field == 'new_relations') {
foreach ($v[1] as $new_relation_id) {
$person_ids[$new_relation_id] = (int) $new_relation_id;
$tmp[] = array('author_id' => $new_relation_id);
}
$values['new_relations'] = $tmp;
} else {
if ($field == 'old_relations') {
foreach ($v[1] as $new_relation_id) {
$person_ids[$new_relation_id] = (int) $new_relation_id;
$tmp[] = array('author_id' => $new_relation_id);
}
$values['old_relations'] = $tmp;
} else {
if ($field == 'deleted_relations') {
foreach ($v[1] as $new_relation_id) {
$person_ids[$new_relation_id] = (int) $new_relation_id;
$tmp[] = array('author_id' => $new_relation_id);
}
$values['deleted_relations'] = $tmp;
} else {
$values[] = array('name' => $field, 'old' => $v[0], 'new' => $v[1]);
}
}
}
} else {
if ($row['target_type'] == BiberLog::TargetType_magazine) {
$values[] = array('name' => $field, 'old' => $v[0], 'new' => $v[1]);
} else {
if ($row['target_type'] == BiberLog::TargetType_serie) {
if ($field == 'id_book') {
$book_id_s = $v[0] ? $v[0] : $v[1];
if ($book_id_s) {
$book_ids[$book_id_s] = $book_id_s;
}
continue;
}
$values[] = array('name' => $field, 'old' => $v[0], 'new' => $v[1]);
}
}
}
}
}
if (in_array($row['target_type'], array(BiberLog::TargetType_book))) {
$book_ids[$row['id_target']] = $row['id_target'];
$book_id = $row['id_target'];
}
if (in_array($row['target_type'], array(BiberLog::TargetType_person))) {
$person_ids[(int) $row['id_target']] = (int) $row['id_target'];
$person_id = $row['id_target'];
}
if (in_array($row['target_type'], array(BiberLog::TargetType_serie))) {
$serie_id = $row['id_target'];
$serie_ids[$row['id_target']] = $row['id_target'];
}
if (in_array($row['target_type'], array(BiberLog::TargetType_magazine))) {
$magazine_id = $row['id_target'];
$magazine_ids[$row['id_target']] = $row['id_target'];
}
$this->data['logs'][] = array('id' => $row['id'], 'book_id' => max($book_id, $book_id_s), 'author_id' => $person_id, 'serie_id' => $serie_id, 'time' => date('Y/m/d H:i:s', $row['time']), 'action' => BiberLog::$actionTypes[$row['action_type']], 'id_user' => $row['id_user'], 'values' => $values, 'applied' => $row['undo'] ? 0 : 1);
}
$users = Users::getByIdsLoaded($uids);
foreach ($users as $user) {
$this->data['users'][$user->id] = $user->getListData();
}
if (count($serie_ids)) {
$query = 'SELECT id,name,title FROM `series` WHERE `id` IN(' . implode(',', $serie_ids) . ')';
$out = Database::sql2array($query);
foreach ($out as &$r) {
$r['path'] = Config::need('www_path') . '/s/' . $r['id'];
}
$this->data['series'] = $out;
}
if (count($book_ids)) {
$this->data['books'] = $this->getLogBooks($book_ids);
}
if (count($person_ids)) {
$this->data['authors'] = $this->getLogPersons($person_ids);
}
foreach (Config::$langRus as $code => $title) {
$this->data['lang_codes'][] = array('id' => Config::$langs[$code], 'code' => $code, 'title' => $title);
}
}
示例15: loadReviews
function loadReviews()
{
if ($this->reviewsLoaded) {
return false;
}
$query = 'SELECT `id_user`,`comment`,`time`,`rate` FROM `reviews` WHERE `id_target`=' . $this->id . ' AND `target_type`=' . self::REVIEW_TYPE_BOOK;
$reviews = Database::sql2array($query);
$uids = array();
foreach ($reviews as $review) {
$uids[] = $review['id_user'];
}
if ($uids) {
$users = Users::getByIdsLoaded($uids);
}
global $current_user;
/* @var $current_user CurrentUser */
foreach ($reviews as &$review) {
if (isset($users[$review['id_user']])) {
$review['nickname'] = $users[$review['id_user']]->getProperty('nickname', 'аноним');
$review['picture'] = $users[$review['id_user']]->getProperty('picture') ? $users[$review['id_user']]->id . '.jpg' : 'default.jpg';
} else {
$review['nickname'] = 'аноним';
$review['picture'] = 'default.jpg';
}
}
$this->reviews = $reviews;
$this->reviewsLoaded = true;
}