aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Froese <greg.froese@gmail.com>2009-10-09 03:23:52 +0000
committerGreg Froese <greg.froese@gmail.com>2009-10-09 03:23:52 +0000
commit71b4d8c3c3343455552a76756e5aaacd82034c4e (patch)
tree6fa9ed22a82a1815d63412bbab236283ed1bac62
parent9aa79bc38829f164bacc6b522278d0098b597933 (diff)
downloadelgg-71b4d8c3c3343455552a76756e5aaacd82034c4e.tar.gz
elgg-71b4d8c3c3343455552a76756e5aaacd82034c4e.tar.bz2
flickr integration updates
-rw-r--r--actions/flickrImportPhotoset.php9
-rw-r--r--actions/flickrSetup.php6
-rw-r--r--lib/flickr.php2
-rw-r--r--pages/flickr/error_log1
-rw-r--r--pages/flickr/importPhotosets.php8
-rw-r--r--start.php2
-rw-r--r--views/default/tidypics/forms/setupFlickr.php27
7 files changed, 44 insertions, 11 deletions
diff --git a/actions/flickrImportPhotoset.php b/actions/flickrImportPhotoset.php
index 315d1009d..d28ea8564 100644
--- a/actions/flickrImportPhotoset.php
+++ b/actions/flickrImportPhotoset.php
@@ -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);
diff --git a/actions/flickrSetup.php b/actions/flickrSetup.php
index e272ee141..2a1f82315 100644
--- a/actions/flickrSetup.php
+++ b/actions/flickrSetup.php
@@ -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" );
}
diff --git a/lib/flickr.php b/lib/flickr.php
index ec54e2867..48872c31f 100644
--- a/lib/flickr.php
+++ b/lib/flickr.php
@@ -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" );
}
diff --git a/pages/flickr/error_log b/pages/flickr/error_log
index 716344052..a55ce1ae7 100644
--- a/pages/flickr/error_log
+++ b/pages/flickr/error_log
@@ -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
diff --git a/pages/flickr/importPhotosets.php b/pages/flickr/importPhotosets.php
index c9b4416e4..fe241439e 100644
--- a/pages/flickr/importPhotosets.php
+++ b/pages/flickr/importPhotosets.php
@@ -18,6 +18,12 @@
$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";
diff --git a/start.php b/start.php
index 76daca066..9648915bd 100644
--- a/start.php
+++ b/start.php
@@ -458,6 +458,6 @@
register_action("tidypics/download", true, $CONFIG->pluginspath . "tidypics/actions/download.php");
register_action("tidypics/addtag", true, $CONFIG->pluginspath . "tidypics/actions/addtag.php");
register_action("tidypics/deletetag", true, $CONFIG->pluginspath . "tidypics/actions/deletetag.php");
- register_action("tidypics/setupFlickr", true, $CONFIG->pluginspath . "tidypics/actions/setupFlickr.php");
+ register_action("tidypics/flickrSetup", true, $CONFIG->pluginspath . "tidypics/actions/flickrSetup.php");
?> \ No newline at end of file
diff --git a/views/default/tidypics/forms/setupFlickr.php b/views/default/tidypics/forms/setupFlickr.php
index cee94058e..8ae7c27bb 100644
--- a/views/default/tidypics/forms/setupFlickr.php
+++ b/views/default/tidypics/forms/setupFlickr.php
@@ -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();