function flickr_photos_places_for_user(&$user, &$place, $more = array()) { $defaults = array('viewer_id' => 0); $more = array_merge($defaults, $more); $more['enforce_geoperms'] = 1; if (!flickr_places_is_valid_placetype($place['place_type'])) { return not_okay("not a valid placetype"); } $query = array("user_id" => $user['id'], $place['place_type'] => $place['woeid']); if (isset($more['geocontext'])) { $query['geocontext'] = $more['geocontext']; } return flickr_photos_search($query, $more); }
public function flickr_photos(\Drupal\user\UserInterface $user = NULL) { global $pager_page_array, $pager_total, $pager_total_items; // Set this to something else if you want multiple pagers. $element = 0; $pager_page_array[$element] = empty($_GET['page']) ? 0 : (int) $_GET['page']; if ($user === NULL) { // @FIXME // Could not extract the default value because it is either indeterminate, or // not scalar. You'll need to provide a default value in // config/install/flickr.settings.yml and config/schema/flickr.schema.yml. $nsid = \Drupal::config('flickr.settings')->get('flickr_default_userid'); if (!$nsid) { drupal_set_message(t('No default Flickr user id has been set.')); return FALSE; } $uid = 0; } else { $account = $user; if ($account->flickr['nsid']) { $nsid = $account->flickr['nsid']; } else { drupal_set_message(t('%user does not have a Flickr account', ['%user' => $account->name]), 'error'); return FALSE; } $uid = $account->uid; } $nsid = flickr_user_find_by_identifier($nsid); $photos = flickr_photos_search($nsid, $pager_page_array[$element] + 1); if (!$photos) { drupal_set_message(t('No accessible photos found for Flickr %userid', ['%userid' => $nsid]), 'warning'); return FALSE; } // Set pager information we just acquired. $pager_total[$element] = $photos['pages']; $pager_total_items[$element] = $photos['total']; // @FIXME // theme() has been renamed to _theme() and should NEVER be called directly. // Calling _theme() directly can alter the expected output and potentially // introduce security issues (see https://www.drupal.org/node/2195739). You // should use renderable arrays instead. // // // @see https://www.drupal.org/node/2195739 // return theme('flickr_photos', array('uid' => $uid, 'photos' => $photos)); }