本文整理汇总了PHP中users_get_by_id函数的典型用法代码示例。如果您正苦于以下问题:PHP users_get_by_id函数的具体用法?PHP users_get_by_id怎么用?PHP users_get_by_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了users_get_by_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: flickr_faves_add_fave
function flickr_faves_add_fave(&$viewer, &$photo, $date_faved = 0)
{
if (!$date_faved) {
$date_faved = time();
}
$cluster_id = $viewer['cluster_id'];
$fave = array('user_id' => $viewer['id'], 'photo_id' => $photo['id'], 'owner_id' => $photo['user_id'], 'date_faved' => $date_faved);
$insert = array();
foreach ($fave as $k => $v) {
$insert[$k] = AddSlashes($v);
}
$rsp = db_insert_users($cluster_id, 'FlickrFaves', $insert);
if (!$rsp['ok'] && $rsp['error_code'] != 1062) {
return $rsp;
}
# now update the photo owner side of things
$owner = users_get_by_id($photo['user_id']);
$cluster_id = $owner['cluster_id'];
$fave = array('user_id' => $owner['id'], 'photo_id' => $photo['id'], 'viewer_id' => $viewer['id']);
$insert = array();
foreach ($fave as $k => $v) {
$insert[$k] = AddSlashes($v);
}
$rsp = db_insert_users($cluster_id, 'FlickrFavesUsers', $insert);
if (!$rsp['ok'] && $rsp['error_code'] != 1062) {
return $rsp;
}
# TO DO: index/update the photo in solr and insert $viewer['id']
# into the faved_by column (20111123/straup)
return okay();
}
示例2: api_dots_dotsForUser
function api_dots_dotsForUser()
{
// these keys not important
$skipKeys = array("details", "details_json", "index_on", "details_listview", "type_of_co");
$u = request_str('user');
$owner = users_get_by_id($u);
$output = array();
if ($owner) {
$dots = dots_get_dots_for_user($owner);
// please say there is a better way
if ($dots) {
foreach ($dots as &$row) {
$a = array();
foreach ($row as $k => $v) {
if (!in_array($k, $skipKeys)) {
$a[$k] = $v;
}
}
$output[] = $a;
}
}
}
if (count($output)) {
api_output_ok($output);
} else {
api_output_error();
}
}
示例3: login_check_login
function login_check_login()
{
if (!$GLOBALS['cfg']['enable_feature_signin']) {
return 0;
}
if ($GLOBALS['cfg']['user']['id']) {
return 1;
}
$auth_cookie = login_get_cookie($GLOBALS['cfg']['auth_cookie_name']);
if (!$auth_cookie) {
return 0;
}
$auth_cookie = crypto_decrypt($auth_cookie, $GLOBALS['cfg']['crypto_cookie_secret']);
list($user_id, $password) = explode(':', $auth_cookie, 2);
if (!$user_id) {
return 0;
}
$user = users_get_by_id($user_id);
if (!$user) {
return 0;
}
if ($user['deleted']) {
return 0;
}
if ($user['password'] !== $password) {
return 0;
}
$GLOBALS['cfg']['user'] = $user;
return 1;
}
示例4: _get_nsid
function _get_nsid($flickr_user, $more = array())
{
# TO DO: put this all in a function somewhere and
# call/queue it when a user signs up...
# As db_main:Users
$user = users_get_by_id($flickr_user['user_id']);
if (!$user) {
return;
}
$method = 'flickr.people.getInfo';
$args = array('user_id' => $flickr_user['nsid']);
$ret = flickr_api_call($method, $args);
if (!$ret['ok']) {
dumper($args);
dumper($ret);
return;
}
$rsp = $ret['rsp']['person'];
$path_alias = $rsp['path_alias'];
$username = $rsp['username']['_content'];
echo "[{$user['id']}] path alias: {$path_alias} screen name: {$username}\n";
if ($path_alias != $flickr_user['path_alias']) {
$update = array('path_alias' => $path_alias);
$rsp = flickr_users_update_user($flickr_user, $update);
echo "[{$user['id']}] update path alias: {$rsp['ok']}\n";
# just let this fail silently if there's a duplicate
flickr_users_path_aliases_create($user, $path_alias);
}
if ($username != $user['username']) {
$update = array('username' => $username);
$rsp = users_update_user($user, $update);
echo "[{$user['id']}] update username: {$rsp['ok']}\n";
}
}
示例5: export_cache_root_for_sheet
function export_cache_root_for_sheet(&$sheet)
{
$user = users_get_by_id($sheet['user_id']);
$user_root = export_cache_root_for_user($user);
$sheet_root = _export_cache_explode_id($sheet['id']);
$parts = array($user_root, $sheet_root);
return implode(DIRECTORY_SEPARATOR, $parts);
}
示例6: set_path_alias
function set_path_alias($flickr_user, $more = array())
{
if ($flickr_user['path_alias'] == '') {
return;
}
$user = users_get_by_id($flickr_user['user_id']);
flickr_users_path_aliases_create($user, $flickr_user['path_alias']);
}
示例7: flickr_backups_users
function flickr_backups_users()
{
$sql = "SELECT DISTINCT(user_id) FROM FlickrBackups";
$rsp = db_fetch($sql);
$users = array();
foreach ($rsp['rows'] as $row) {
$users[] = users_get_by_id($row['user_id']);
}
return $users;
}
示例8: flickr_contacts_get_contact
function flickr_contacts_get_contact($user_id, $contact_id)
{
$user = users_get_by_id($user_id);
$cluster_id = $user['cluster_id'];
$enc_user = AddSlashes($user_id);
$enc_contact = AddSlashes($contact_id);
$sql = "SELECT * FROM FlickrContacts WHERE user_id='{$enc_user}' AND contact_id='{$enc_contact}'";
$rsp = db_fetch_users($cluster_id, $sql);
return db_single($rsp);
}
示例9: api_auth_oauth2_has_auth
function api_auth_oauth2_has_auth(&$method, $key_row = null)
{
$access_token = api_auth_oauth2_get_access_token($method);
if (!$access_token) {
return array('ok' => 0, 'error' => 'Required access token missing', 'error_code' => 400);
}
$token_row = api_oauth2_access_tokens_get_by_token($access_token);
if (!$token_row) {
return array('ok' => 0, 'error' => 'Invalid access token', 'error_code' => 400);
}
if ($token_row['disabled']) {
return array('ok' => 0, 'error' => 'Access token is disabled', 'error_code' => 502);
}
if ($token_row['expires'] && $token_row['expires'] < time()) {
return array('ok' => 0, 'error' => 'Access token has expired', 'error_code' => 400);
}
# I find it singularly annoying that we have to do this here
# but OAuth gets what [redacted] wants. See also: notes in
# lib_api.php around ln 65 (20121026/straup)
$key_row = api_keys_get_by_id($token_row['api_key_id']);
$rsp = api_keys_utils_is_valid_key($key_row);
if (!$rsp['ok']) {
return $rsp;
}
if (isset($method['requires_perms'])) {
if ($token_row['perms'] < $method['requires_perms']) {
$perms_map = api_oauth2_access_tokens_permissions_map();
$required = $perms_map[$method['requires_perms']];
return array('ok' => 0, 'error' => "Insufficient permissions, method requires a token with '{$required}' permissions", 'error_code' => 403);
}
}
# Ensure user-iness - this may seem like a no-brainer until you think
# about how the site itself uses the API in the absence of a logged-in
# user (20130508/straup)
$ensure_user = 1;
$user = null;
if (!$token_row['user_id'] && $key_row && features_is_enabled("api_oauth2_tokens_null_users")) {
$key_role_id = $key_row['role_id'];
$roles_map = api_keys_roles_map('string keys');
$valid_roles = $GLOBALS['cfg']['api_oauth2_tokens_null_users_allowed_roles'];
$valid_roles_ids = array();
foreach ($valid_roles as $role) {
$valid_roles_ids[] = $roles_map[$role];
}
$ensure_user = $key_role_id && in_array($key_role_id, $valid_roles_ids) ? 0 : 1;
}
if ($ensure_user) {
$user = users_get_by_id($token_row['user_id']);
if (!$user || $user['deleted']) {
return array('ok' => 0, 'error' => 'Not a valid user', 'error_code' => 400);
}
}
#
return array('ok' => 1, 'access_token' => $token_row, 'api_key' => $key_row, 'user' => $user);
}
示例10: foursquare_urls_checkin
function foursquare_urls_checkin(&$checkin)
{
# see the way I named foursquare checkin IDs 'checkin_id'
# yeah, that was awesome... (20120219/straup)
if (!$checkin['checkin_id']) {
return;
}
$user = users_get_by_id($checkin['user_id']);
$fsq_user = foursquare_users_get_by_user_id($user['id']);
# Note the lack of a trailing slash, which is apparently
# important in foursquare land...
return "http://www.foursquare.com/user/{$fsq_user['foursquare_id']}/checkin/{$checkin['checkin_id']}";
}
示例11: flickr_geobookmarks_import_for_nsid
function flickr_geobookmarks_import_for_nsid($nsid, $more = array())
{
$flickr_user = flickr_users_get_by_nsid($nsid);
$user = users_get_by_id($flickr_user['user_id']);
if (!$user) {
return not_okay("Not a valid user");
}
$flickr_user = flickr_users_get_by_user_id($user['id']);
$method = 'flickr.people.geoBookmarks.getList';
$args = array('auth_token' => $flickr_user['auth_token']);
$rsp = flickr_api_call($method, $args);
if (!$rsp['ok']) {
return $rsp;
}
if (!$rsp['rsp']['bookmarks']['count']) {
return okay();
}
$bookmarks = array();
# mark everything as private for now since none of that stuff
# got turned on before I left, sad face... (20120217/straup)
$geo_perms = flickr_geo_permissions_map("string keys");
$geo_private = $geo_perms['private'];
foreach ($rsp['rsp']['bookmarks']['bookmark'] as $bm) {
$bm['user_id'] = $user['id'];
$bm['name'] = $bm['label'];
$bm['geocontext'] = $bm['context'];
$bm['geoperms'] = $geo_private;
$bm['woeid'] = 0;
unset($bm['label']);
unset($bm['pretty_name']);
unset($bm['context']);
$geo_method = 'flickr.places.findByLatLon';
$geo_args = array('lat' => $bm['latitude'], 'lon' => $bm['longitude'], 'accuracy' => $bm['accuracy']);
$geo_rsp = flickr_api_call($geo_method, $geo_args);
if ($geo_rsp['ok']) {
# I still miss xpath...
$bm['woeid'] = $geo_rsp['rsp']['places']['place'][0]['woeid'];
}
$bookmarks[] = $bm;
}
$rsp = flickr_geobookmarks_purge_for_user($user);
if (!$rsp['ok']) {
return $rsp;
}
$count = 0;
foreach ($bookmarks as $bm) {
$rsp = flickr_geobookmarks_add($bm);
$count += $rsp['ok'];
}
return okay(array('count_imported' => $count));
}
示例12: flickr_geobookmarks_add
function flickr_geobookmarks_add($bookmark)
{
$user = users_get_by_id($bookmark['user_id']);
$cluster_id = $user['cluster_id'];
$insert = array();
foreach ($bookmark as $k => $v) {
$insert[$k] = AddSlashes($v);
}
$rsp = db_insert_users($cluster_id, 'FlickrGeoBookmarks', $insert);
if ($rsp['ok']) {
$rsp['bookmark'] = $bookmark;
}
return $rsp;
}
示例13: dots_search_extras_create
function dots_search_extras_create($data)
{
# unique ID/key is (dot_id, name, value)
$user = users_get_by_id($data['user_id']);
$hash = array();
foreach ($data as $_key => $_value) {
$hash[$key] = AddSlashes($value);
}
$rsp = db_insert('DotsSearchExtras', $hash);
if ($rsp['ok']) {
$rsp['data'] = $data;
dots_search_facets_add($data['name'], $data['value']);
}
return $rsp;
}
示例14: flickr_contacts_import_for_nsid
function flickr_contacts_import_for_nsid($nsid, $more = array())
{
$flickr_user = flickr_users_get_by_nsid($nsid);
$user = users_get_by_id($flickr_user['user_id']);
if (!$user) {
return array('ok' => 0, 'error' => 'not a valid user');
}
$method = 'flickr.contacts.getList';
$count_contacts = 0;
$args = array('auth_token' => $flickr_user['auth_token'], 'per_page' => 100, 'page' => 1);
$pages = null;
while (!isset($pages) || $pages >= $args['page']) {
$rsp = flickr_api_call($method, $args);
if (!$rsp) {
return array('ok' => 0, 'error' => 'The Flickr API is wigging out...');
}
if (!isset($pages)) {
$pages = $rsp['rsp']['contacts']['pages'];
}
$contacts = $rsp['rsp']['contacts']['contact'];
if (!is_array($contacts)) {
return array('ok' => 0, 'error' => 'The Flickr API did not return any contacts');
}
foreach ($contacts as $contact) {
$contact_nsid = $contact['nsid'];
$contact_username = $contact['username'];
$flickr_contact = flickr_users_get_by_nsid($contact_nsid);
if (!$flickr_contact) {
$password = random_string(32);
$user_contact = users_create_user(array("username" => $contact_username, "email" => "{$contact_username}@donotsend-flickr.com", "password" => $password));
#
$method = 'flickr.people.getInfo';
$args = array('user_id' => $contact_nsid);
$rsp = flickr_api_call($method, $args);
$path_alias = $rsp['ok'] ? $rsp['rsp']['person']['path_alias'] : '';
#
$flickr_contact = flickr_users_create_user(array('user_id' => $user_contact['id'], 'nsid' => $contact_nsid, 'path_alias' => $path_alias));
}
$rel = flickr_contacts_calculate_relationship($contact);
# echo "{$contact_username} : {$rel} ({$contact['friend']} {$contact['family']})\n";
$insert = array('user_id' => $user['id'], 'contact_id' => $flickr_contact['user_id'], 'rel' => $rel);
$contact = flickr_contacts_add_contact($insert);
$count_contacts++;
}
$args['page'] += 1;
}
return array('ok' => 1, 'count_imported' => $count_contacts);
}
示例15: passwords_validate_password_for_user
function passwords_validate_password_for_user($password, &$user, $more = array())
{
$defaults = array('ensure_bcrypt' => 1);
$more = array_merge($defaults, $more);
$enc_password = $user['password'];
$is_bcrypt = substr($enc_password, 0, 4) == '$2a$' ? 1 : 0;
$validate_more = array('use_bcrypt' => $is_bcrypt);
$is_ok = passwords_validate_password($password, $enc_password, $validate_more);
if ($is_ok && !$is_bcrypt && $more['ensure_bcrypt'] && $GLOBALS['passwords_canhas_bcrypt']) {
# note the pass-by-ref above
if (users_update_password($user, $password)) {
$user = users_get_by_id($user['id']);
}
}
return $is_ok;
}