summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStein Magne Bjorklund2017-06-20 21:51:58 (GMT)
committerStein Magne Bjorklund2017-06-21 00:32:14 (GMT)
commitabbd7fc3d7b298f6f0d86e198c80ba34b49d1767 (patch)
treec314c81b0599831c68e84d5a0a2e97c6ea5d0c5b
parentf4249b4e529e603be75cecc0bdb328eef8b8a69a (diff)
Issue #1490012 by steinmb: Refactor variable names.
Make the code clearer if we are passing user name or user id.
-rw-r--r--includes/media_flickr.utilities.inc27
1 files changed, 21 insertions, 6 deletions
diff --git a/includes/media_flickr.utilities.inc b/includes/media_flickr.utilities.inc
index f16fb5b..9096d18 100644
--- a/includes/media_flickr.utilities.inc
+++ b/includes/media_flickr.utilities.inc
@@ -199,26 +199,40 @@ function _media_flickr_photoset_exists($photoset_id) {
}
}
-function _media_flickr_get_user_id($user_id) {
- $info = _media_flickr_sets_request('flickr.people.getInfo', array('user_id' => $user_id));
+/**
+ * Find user ID based on Flickr user name.
+ *
+ * @param $user_name
+ *
+ * @return mixed
+ */
+function _media_flickr_get_user_id($user_name) {
+ $info = _media_flickr_sets_request('flickr.people.getInfo', array('user_id' => $user_name));
if ($info && ($info['@attributes']['stat'] != 'fail')) {
- return $user_id;
+ return $user_name;
}
elseif ($info['err']['@attributes']['code'] == 1) {
// See if we were passed a username instead.
- $info = _media_flickr_sets_request('flickr.people.findByUsername', array('username' => $user_id));
+ $info = _media_flickr_sets_request('flickr.people.findByUsername', array('username' => $user_name));
if ($info && $info['@attributes']['stat'] != 'fail') {
return $info['user']['@attributes']['id'];
}
}
}
+/**
+ * @param $parts
+ *
+ * @return string
+ */
function _media_flickr_build_uri($parts) {
if (isset($parts['u'])) {
- $user_id = _media_flickr_get_user_id($parts['u']);
- $parts['u'] = isset($user_id) ? $user_id : $parts['u'];
+ $user_name = $parts['u'];
+ $user_id = _media_flickr_get_user_id($user_name);
+ $parts['u'] = isset($user_id) ? $user_id : $parts['u'];
}
+
if (isset($parts['u'])) {
if (isset($parts['p'])) {
$uri = file_stream_wrapper_uri_normalize('flickr://u/' . $parts['u'] . "/p/" . $parts['p']);
@@ -233,6 +247,7 @@ function _media_flickr_build_uri($parts) {
}
}
}
+
if (isset($parts['search'])) {
return file_stream_wrapper_uri_normalize('flickr://search/' . $parts['search']);
}