Permalink
Browse files

add flickr_users_path_aliases_is_available

  • Loading branch information...
1 parent 2b8fb19 commit dda264af66ee2276032e2bcbf9f740cc4e66d809 straup committed Dec 2, 2011
Showing with 22 additions and 1 deletion.
  1. +1 −1 www/account_path_aliases.php
  2. +21 −0 www/include/lib_flickr_users_path_aliases.php
@@ -27,7 +27,7 @@
$ok = 0;
}
- if (($ok) && (flickr_users_path_aliases_get_by_alias($new_alias))){
+ if (($ok) && (flickr_users_path_aliases_is_available($new_alias))){
$GLOBALS['smarty']->assign("error", "alias taken");
$ok = 0;
}
@@ -1,5 +1,7 @@
<?php
+ loadlib("flickr_api");
+
#################################################################
function flickr_users_path_aliases_get_by_alias($alias){
@@ -37,6 +39,25 @@ function flickr_users_path_aliases_for_user(&$user){
#################################################################
+ function flickr_users_path_aliases_is_available($alias){
+
+ if (flickr_users_path_aliases_get_by_alias($alias)){
+ return 0;
+ }
+
+ $method = "flickr.urls.lookupUser";
+ $url = "http://www.flickr.com/photos/{$alias}";
+
+ $args = array(
+ 'url' => $url,
+ );
+
+ $rsp = flickr_api_call($method, $args);
+ return ($rsp['ok']) ? 0 : 1;
+ }
+
+ #################################################################
+
function flickr_users_path_aliases_create(&$user, $alias){
$rsp = flickr_users_path_aliases_for_user($user);

0 comments on commit dda264a

Please sign in to comment.