]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
flickr integration updates
authorGreg Froese <greg.froese@gmail.com>
Fri, 9 Oct 2009 03:23:52 +0000 (03:23 +0000)
committerGreg Froese <greg.froese@gmail.com>
Fri, 9 Oct 2009 03:23:52 +0000 (03:23 +0000)
actions/flickrImportPhotoset.php
actions/flickrSetup.php
lib/flickr.php
pages/flickr/error_log
pages/flickr/importPhotosets.php
start.php
views/default/tidypics/forms/setupFlickr.php

index 315d1009dba95e9fbc1fc09884ba9b25a2d3f524..d28ea85644074946eae302bdee5d1f221deb34e0 100644 (file)
@@ -11,6 +11,7 @@ require_once dirname(dirname(__FILE__)) . "/lib/phpFlickr/phpFlickr.php";
 $f = new phpFlickr("26b2abba37182aca62fe0eb2c7782050");
 
 $set_id = get_input( "set_id" );
+$album_id = get_input( "album_id" );
 $page_pp = get_input( "page" );
 $return_url = get_input( "return_url" );
 $user = get_loggedin_user();
@@ -25,9 +26,6 @@ if( empty( $flickr_id )) {
 // Get the friendly URL of the user's photos
 $photos_url = $f->urls_getUserPhotos( $flickr_id->value );
 $photos = $f->photosets_getPhotos( $set_id, null, null, 10, $page_pp );
-/* TODO:
-* 1. create album if a matching one doesn't exist
-*/
 
 $photos_to_upload = array();
 foreach( $photos["photoset"]["photo"] as $photo ) {
@@ -76,10 +74,7 @@ gatekeeper();
 // Get common variables
 $access_id = (int) get_input("access_id");
 $container_guid = (int) get_input('container_guid', 0);
-$container_guid = 990; //force it to my test album for now
-
-if (!$container_guid)
-       $container_guid == $_SESSION['user']->getGUID();
+$container_guid = intval ($album_id);
 
 $album = get_entity($container_guid);
 
index e272ee141b8d12ed25e6e8f1c9b7eba9397792c2..2a1f82315900c17018a912423ebee7badb1690de 100644 (file)
@@ -6,6 +6,7 @@ require_once dirname(dirname(__FILE__)) . "/lib/phpFlickr/phpFlickr.php";
 $f = new phpFlickr("26b2abba37182aca62fe0eb2c7782050");
 
 $flickr_username = get_input( "flickr_username" );
+$album_id = get_input( "album_id" );
 $return_url = get_input( "return_url" );
 $user = get_loggedin_user();
 
@@ -18,9 +19,14 @@ if( empty( $flickr_username )) {
        if( !empty( $flickr_user["id"] )) {
                create_metadata( $user->guid, "flickr_username", $flickr_username, "text", $user->guid, ACCESS_PUBLIC );
                create_metadata( $user->guid, "flickr_id", $flickr_user["id"], "text", $user->guid, ACCESS_PUBLIC );
+               if( $album_id ) {
+                       create_metadata( $user->guid, "flickr_album_id", $album_id, "text", $user->guid, ACCESS_PUBLIC );
+                       $album = get_entity( $album_id );
+               }
                
                system_message( "Successfully saved Flickr username of $flickr_username" );
                system_message( "flickr user id: $flickr_user[id]" );
+               system_message( "Album saved - $album->title" );
        } else {
                register_error( "Username $flickr_username not found on Flickr" );
        }
index ec54e2867a7e2405e525683baeb833e2bbd1e83b..48872c31f1a34f7d7ee795846dee97273c62460b 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 function flickr_menu() {
-       add_submenu_item( "Flickr Username setup", "/mod/tidypics/pages/flickr/setup.php");
+       add_submenu_item( "Flickr setup", "/mod/tidypics/pages/flickr/setup.php");
        add_submenu_item( "Import Flickr photos", "/mod/tidypics/pages/flickr/importPhotosets.php" );
 }
        
index 7163440526682b4efaa08e49e42eb1b29f20cca1..a55ce1ae7ad57690146cae6bc035bfd6b13abed4 100644 (file)
@@ -21,3 +21,4 @@
 [06-Oct-2009 23:29:22] PHP Fatal error:  Call to undefined function  elgg_view_title() in /home/gfroese/public_html/mod/tidypics/pages/flickr/importPhotosets.php on line 9
 [06-Oct-2009 23:30:08] WARNING: 2009-10-06 23:30:08 (PDT): "require_once(/home/gfroese/public_html/mod/tidypics/views/lib/flickr.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory" in file /home/gfroese/public_html/mod/tidypics/views/default/tidypics/forms/setupFlickr.php (line 2)
 [06-Oct-2009 23:30:08] PHP Fatal error:  require_once() [<a href='function.require'>function.require</a>]: Failed opening required '/home/gfroese/public_html/mod/tidypics/views/lib/flickr.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/gfroese/public_html/mod/tidypics/views/default/tidypics/forms/setupFlickr.php on line 2
+[08-Oct-2009 20:05:02] PHP Parse error:  syntax error, unexpected ')' in /home/gfroese/public_html/mod/tidypics/pages/flickr/importPhotosets.php on line 23
index c9b4416e4576fc2fb4dbaf52e2fe48f554816687..fe241439ed4c719723781670328d64874e1c3cbd 100644 (file)
        $viewer = get_loggedin_user();
        $flickr_username = get_metadata_byname( $viewer->guid, "flickr_username" );
        $flickr_id = get_metadata_byname( $viewer->guid, "flickr_id" );
+       $album_id = get_metadata_byname( $viewer->guid, "flickr_album_id" );
+       
+       if( intval( $album_id->value ) <= 0 ) {
+               register_error( "No album selected.  Please choose and save an album: $album_id->value" );
+               forward( "/mod/tidypics/pages/flickr/setup.php" );
+       }
        
        $photosets = $f->photosets_getList( $flickr_id->value );
        foreach( $photosets["photoset"] as $photoset ) {
@@ -29,7 +35,7 @@
                //create links to import photos 10 at a time
                while( $photoset["photos"] > $count ) {
                        $looper++;
-                       $body .= " <a href='/mod/tidypics/actions/flickrImportPhotoset.php?set_id=$photoset[id]&page=$looper'>$looper</a>";
+                       $body .= " <a href='/mod/tidypics/actions/flickrImportPhotoset.php?set_id=$photoset[id]&page=$looper&album_id=$album_id->value'>$looper</a>";
                        $count = $count + 10;                   
                }
                $body .= "<br />$photoset[photos] images";
index 76daca0664099ddc3f02c2ba5caa4935d63472bb..9648915bdfe095525eee95493bb64c88110155c3 100644 (file)
--- a/start.php
+++ b/start.php
        register_action("tidypics/download", true, $CONFIG->pluginspath . "tidypics/actions/download.php");\r
        register_action("tidypics/addtag", true, $CONFIG->pluginspath . "tidypics/actions/addtag.php");\r
        register_action("tidypics/deletetag", true, $CONFIG->pluginspath . "tidypics/actions/deletetag.php");\r
-       register_action("tidypics/setupFlickr", true, $CONFIG->pluginspath . "tidypics/actions/setupFlickr.php");\r
+       register_action("tidypics/flickrSetup", true, $CONFIG->pluginspath . "tidypics/actions/flickrSetup.php");\r
 \r
 ?>
\ No newline at end of file
index cee94058e27d88e9b5291b1287225702cb92a0ff..8ae7c27bb8876774390e6df12342a937ea8daa1b 100644 (file)
@@ -3,12 +3,37 @@ require_once( dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . "/lib/fli
 
 $user = get_loggedin_user();
 $flickr_username = get_metadata_byname( $user->guid, "flickr_username" );
+$flickr_album_id = get_metadata_byname( $user->guid, "flickr_album_id" );
 
 $action = $vars['url'] . 'action/tidypics/flickrSetup';
 
 $form_body = "<p>";
-$form_body .= "Please enter your Flickr username here:<br /><input style='width: 20%;' type='text' name='flickr_username' value='$flickr_username->value' ' class='input-text' /><br />";
+$form_body .= "Please enter your Flickr username here: <input style='width: 20%;' type='text' name='flickr_username' value='$flickr_username->value' ' class='input-text' /> <br />";
 $form_body .= "<input type='hidden' name='return_url' value='$_SERVER[REQUEST_URI]' />";
+
+$albums = get_entities( "object", "album", $user->guid );
+$options = array( 0 => "Select album" );
+foreach( $albums as $album ) {
+       $title = $album->title;
+       switch( $album->access_id ) {
+               case ACCESS_PRIVATE:
+                       $title .= " (private)";
+                       break;
+               case ACCESS_PUBLIC:
+                       $title .= " (public)";
+                       break;
+               default:
+                       $title .= " (not sure)";
+                       break;
+       }
+       $options[$album->guid] = $title;
+}
+
+$form_body .= "<br />Album to import photos to: ";
+$form_body .= elgg_view('input/pulldown', array('internalname' => 'album_id',
+                                                                                               'options_values' => $options,
+                                                                                               'value' => $flickr_album_id->value ));
+$form_body .= "<br />";
 $form_body .= elgg_view('input/submit', array('value' => elgg_echo("save")));
 
 flickr_menu();