CVS edit link for hadyos

I would to contribute a brand new module called "Facebook Photos" or "fbphotos".

The purpose of this module will be to import publicly available photos from a person's Facebook profile or Fan Page into Drupal. It does so by creating internal tables in the Drupal schema (currently an albums table and a photos table), and then populating these tables with references to the location of the facebook photos. Upon uploading new photos to a person's Facebook profile or fan page, an administrator needs to login to Drupal and click on a 'Synchronise' button - the module will then use Facebook's API to connect to Facebook, and import all photos in local Drupal tables.

A public page will be made visible in drupal, where users can browse photo albums, and the photos in each albums in turn. This functionality is currently available in the following website - http://beta.marhaba.co.nz/albums; however, the website is still in constant development and there is no guarantee that the referenced link will be available for public when this motivation's review is being conducted.

I plan to allow the albums and photos being presented using tradionatial HTML+CSS and using an open source Flash slideshow plugin like dfGallery.

I have started building this functionality after finding no Drupal module allowing such functionality. Most Facebook modules available for Drupal allow for 'each logged in user' to import their own content from Facebook. This module differs by allowing the admin of the website to import their own photos from Facebook and sharing it with all visitors to the website.

I have working code now that successfully works. I am currently polishing it up and at the stage where getting community feedback whilst developing will be useful - hence my application for a CVS account now.

Comments

hadyos’s picture

Component: Miscellaneous » Code
Category: task » feature
Issue tags: -Module review +facebook, +photos, +image import module
StatusFileSize
new61.91 KB

To run this module, you will need the following:

* Add the Facebook Developer application and create a new application
* Facebook API and Secret Key

This module is still in development. There are obvious things that are in my list for tidy up before releasing such as the use of check_plain's where appropriate and appropriate permission attributes. However, the attached module is good enough for use and getting the picture of where the module is heading.

[UPDATE: NEW MODULE ATTACHMENT MADE IN A POST BELOW. ATTACHMENT TO THIS POST IS OUTDATED - DO NOT DOWNLOAD]

avpaderno’s picture

Status: Postponed (maintainer needs more info) » Needs review
Issue tags: +Module review
hadyos’s picture

StatusFileSize
new993.36 KB

Please discard my previous attachment. I have attached the latest source code of my proposed fbphotos module to this posting.

This version is more complete and works end to end at the moment. You can see it in action on the following link: http://beta.marhaba.co.nz/fbalbums.

New to this version of the module is the use of Zen Flash Gallery to display the imported Facebook photos in a funky style.

avpaderno’s picture

Component: Code » Miscellaneous
Category: feature » task
Status: Needs review » Needs work
Issue tags: -facebook, -photos, -image import module +Module review

In Drupal.org CVS the only accepted files are the ones licensed under GPL license v2+; compatible licenses are not accepted.
Files available from third-party sites should not be included in Drupal.org CVS.

hadyos’s picture

Status: Needs work » Needs review
StatusFileSize
new24.17 KB

Attached a new iteration of the Facebook Photos module. New in this iteration

o Removal of any files that are not under the GPL license
o Added README.txt file with instructions on installation
o Added extra functionality to the module to allow display imported Facebook photos in more than one method (e.g. Standard HTML, lightBox, Zen Flash Gallery)

Kindly review the latest attachment please.

matt2000’s picture

I wonder if you could add your css in fbphotos.page.inc instead of using hook_init and adding it on every page load?

hadyos’s picture

StatusFileSize
new19.92 KB

Thanks for the review matt. Whilst reading the Drupal API, it was mentioned that hook_init is usually the place were all the CSS and JS files are included for a given module. However, I do see your point that not all screens of my module require my custom CSS.

I have uploaded a new version of my module with the following changes:

  • Removed css from hook_init and into fbphotos.page.inc as suggested
  • Removed LICENSE.TXT
  • Added 2 x Blocks that show (a) Random 'x' photos from the last imported Facebook album, (b) Random 'x' photos from all imported Facebook albums

I am using this module now on a production site, and it is fairly stable in my opinion. Looking forward to the CVS account and contributing back to Drupal!

avpaderno’s picture

Whilst reading the Drupal API, it was mentioned that hook_init is usually the place were all the CSS and JS files are included for a given module.

The CSS files added in hook_init() are added to all the pages; rather than checking the page being viewed, it is better to add the CSS files in the menu callback for the pages that need those CSS files.

hadyos’s picture

Yip, I have done something similar to that now - although doesn't look as nice :\

matt2000’s picture

I haven't looked real deep to see if this might be handled elsewhere, but at first glance, it looks like there may be unsanitized user-generated URLs being output, for example in the block. User-generated content (including data supplied by Facebook API) should be run through check_plain(), or filter_xss(), or in the case of URLs, l().

Other than that, a visual review of the code shows that hadyos has a good understanding of the Drupal API and best practices, including security considerations, with the possible exception of the above.

IMHO, this can be RTBC once the above is addressed, and someone actually installs the module to ensure that it doesn't obviously break anything.

hadyos’s picture

StatusFileSize
new29.9 KB

Thanks for the review matt.

I agree. My code was fetching rows from the database (populated with Facebook data) and using them 'as-is' in any of the theme functions without any santisation.

I have updated the code as follows:

  • Fetched objects from database are no longer directly used in any of the theming functions.
  • For every database record retrieved, an array is made, and entries in this array are manually assigned with the appropriate check_plain() or check_url() functions

The new version of the code has been tested by me, and look exactly the same as is - except it is a lot more secure now. Only downside of this change is my code now looks a bit 'heavy' :\

Kindly review my code again and approve. It would be a nice Christmas gift to be given a CVS account before the end of the year :)

avpaderno’s picture

Status: Needs review » Needs work

The file LICENSE.txt needs to be removed; Drupal.org CVS doesn't allow to commit that file.

hadyos’s picture

Category: task » feature
Status: Needs work » Needs review
StatusFileSize
new20.25 KB

I have re bundled the fbphotos module again without the LICENSE.txt and attached to post.

avpaderno’s picture

Category: feature » task
bizkut’s picture

nice module! :)

bizkut’s picture

your module uses db_rewrite_sql() which doesn't work with i18n

avpaderno’s picture

Status: Needs review » Needs work
  1. t('Delete album %name', array('%name' => check_plain($album->name))
    

    When the code uses %-placeholders, there is no need to pass the argument to check_plain(), because that is already done by t().

  2. The call to db_rewrite_sql() is not correct; without further arguments, the function takes the query is for the nodes table, which is not true in this case. If there are no modules that implement hook_db_rewrite_sql() to alter the table created by your module, it's probably that calling db_rewrite_sql(), or not doesn't make any differences.
  3. Strings used in the user interface should be in sentence case.
  4. There are functions that don't have the correct name.

Out of the points I reported, the point about the function names is the one that needs to be fixed, to get this application approved.

robino’s picture

I am not a developer but I used your module to test. I run into some issues to display the albums to all other users except me.

the bug in in sites/all/modules/fbphotos/fbphotos.page.inc on line 9 is in:
$result = pager_query(db_rewrite_sql($sql), variable_get('fbphotos_albums_limit', 10), 0);

I changed that into:
$result = pager_query(($sql), variable_get('fbphotos_albums_limit', 10), 0);

And it worked :)

hadyos’s picture

Status: Needs work » Needs review
StatusFileSize
new19.69 KB

Thanks for everyone's comments.

I have uploaded a new version of the module to address all issues that were raised.

@kiamlaluno
* Fixed extra calls to check_plain(). All placeholders passed to the t() function no longer call check_plain
* Removed usage of db_rewrite_sql(). I initially thought that was required to convert {table names} to their prefixed names; that is already handled inherently by Drupal
* All user interface comments now use sentence case. I have stuck to spelling 'Facebook' with a capital F though.
* All function names to me are currently correct and reflect my purpose for them. I have correct $ID tags to all files that I wish to have committed as part of this module.

@robino
* Thanks for raising your issue. I have fixed it as well in this attachment. With that said, I was unsure why you hit your problem and how that code fix made any difference.

jupiterchild’s picture

Installed this today following the VERY good instructions in the readme.txt; very easy to install.

I'm not a developer or coder so I can only relay my experience and mention a couple of issues:

Thumbnails link back to www.example.com/fbalbums/00000000 which fails if Drupal is installed in a sub-directory i.e. www.example.com/cms/fbalbums/00000000

I had issues when synchronising Albums with Facebook. The first synch goes OK but any subsequent synch just hangs. I found I needed to clear my recent cookies and and then the synch works.

Great module.

jupiterchild’s picture

Problem seems to be at line 220 :

$img_link = check_url($base_url . "/fbalbums/{$photo->aid}/photo/{$photo->pid}");

$img_link = check_url($base_url . "/cms/fbalbums/{$photo->aid}/photo/{$photo->pid}");

as a quick fix I added my sub-directory to the path.

avpaderno’s picture

Status: Needs review » Needs work

The code should use url() to obtain the URL.

I am changing the status as per previous comment.

jupiterchild’s picture

Changing line 220

from:

$img_link = check_url($base_url . "/fbalbums/{$photo->aid}/photo/{$photo->pid}");

to:

$img_link = url($base_url . "fbalbums/{$photo->aid}/photo/{$photo->pid}");

fixes the problem for me.

jupiterchild’s picture

Not quite fixed, since this introduces another error:

We are yet to import any photos ;) continues to be displayed in the thumbnail block.

line 227

$content .= "<li>We are yet to import any photos ;)</li>";

I guess I'll leave it to the coders.

jupiterchild’s picture

From a usability point of view it would be useful to be able to control the maximum display size of the original photo. I've been using the default 'html viewer' and since the user has no control over the size of the original Facebook photos invariably some of the photos are quite large, this results in horizontal scroll bars.

I've not had time to install and use the other viewers.

jupiterchild’s picture

@#28 Realised I could do this by theming fbphotos_photo.tpl.php

jupiterchild’s picture

I have used fbphotos over several days and not had any major issues until I installed fbconnect (http://drupal.org/project/fbconnect) module.
Both modules operate OK except when in order to refresh the album contents I use the fbphotos 'Synchronise All' button. I then receive the following error message:

Fatal error: Cannot redeclare class FacebookRestClientException in /home/*******/public_html/*******/cms/sites/all/modules/fbphotos/facebook-client/facebookapi_php5_restlib.php on line 3784

Disabling the fbconnect module fixes the issue (I have tried this several times, just to confirm).

Wasn't sure which issue queue to post this in but since hadyos is wanting reviews I've posted the issue here.

hadyos’s picture

Thanks a lot for your feedback jupiterchild. I'll update the module on the weekend to fix the issues you have raised.

Re @#30, both fbphotos and fbconnect utilise Facebook's PHP API which is causing a conflict when both of them are being used at the same time.

jupiterchild’s picture

@hadyos #31

One other thing I noticed is the thumbnail block only ever selects images in landscape mode. I looked at the code, though not being a coder I was unsure whether this is by design, since the code seems to be selecting images with a greater width than height.

The Facebook PHP API could become an issue since I guess more Facebook / Drupal modules will gradually come on stream.

This is a great module, does exactly what I require, and I personally see no reason not to release it.

hadyos’s picture

@jupiterchild #32

You caught-up on the thumbnail behaviour quite correct. I built this module initially for a website of mine. The portrait thumbnail photos was messing my pixel perfect layout, hence I wanted to always return landscape thumbnails.

As part of the next fix I'll release, I'll make this a configurable item.

Thanks a lot for your feedback - much appreciated. As you can see I have been waiting since October 2009 to try and get it release but I get review feedbacks once a month :) Can't wait myself for it to be on the Drupal module list!

avpaderno’s picture

Status: Needs work » Closed (won't fix)

There have not been replies in the last week. I am marking this application as won't fix.

blaiz’s picture

Subscribe

blaiz’s picture

Hi everyone,

Is this project still alive? I'm looking for a way to import photo albums from a public page to my Drupal website and this module is the only one I could find that can do that.

However, after following the instructions in the README file, I have this error on facebook.com:

Error
An error occurred with [facebook application name]. Please try again later.

API Error Code: 100
API Error Description: Invalid parameter
Error Message: Requires valid next URL.

Has anybody had this error before?

Thanks,

Blaiz

hadyos’s picture

Hey Blaiz,

I was actively working on this project by the CVS approval dragged for too long. Let me know how I can recreate the above error that you are getting and I can try and make a new patch of the module along with fixing your issue.

Always happy to see there is interest for my facebook photos module.

Hady

blaiz’s picture

Hi Hadyos,

I finally got it working, I had to add a next URL on the Facebook application, then add it on my profile and synchronize. It works really well, all the albums are here, I added lightbox, that's really cool.

I really hope it can become a hosted module on Drupal and receive updates because we really need such a module.

However there are some functionalities that we need also. We would like to customize the title of the photo albums. I changed the name from "Album - " to "Photo album: ", by directly changing it in the files but I think it would be cool to be able to do it through a GUI. Another nice feature would be to use the album title in the URL, and make URLs more customizable in general (e.g. instead of /fbalbums/14546451468, it would be cool to have /san-francisco-photos/north-beach).

I will look into it, see how hard it could be to implement that, but I have never worked on a module source code before so I don't know if I'll be able to do it myself.

Thanks

blaiz’s picture

Ok I finally got working what I wanted to do.

The name of the album is now appended in the URL. I used a pathauto function to do that and it works pretty well. That's a bit better for SEO. You need the pathauto module installed and enabled to use this function.
Here is the code, in the fbphotos.page.inc file, after line 17:

    $album['link']        = check_url($base_url . "/fbalbums/{$album_src->aid}");
	
	// Append the title of the album in the URL
	module_load_include('inc', 'pathauto', 'pathauto');
	if (module_exists('pathauto') && function_exists('pathauto_cleanstring')) { 
		$album['link'] .= '/'.pathauto_cleanstring("{$album_src->name}");
	}
		  
    $album['name']        = check_plain($album_src->name);

and you get a URL like youwebsite.com/fbalbums/987646749648_1894651/your-album-title-inserted-here

jazzitup’s picture

@blaiz: can you confirm an issue with FBConnect and this module?

@hadyos: did you try to host this module at drupal.org?

blaiz’s picture

I'm not using the FBConnect module.

dobbler’s picture

Hi,

I have this all working but I'm at a loss as to how to display the galleries on the frontend?!?

Am I just missing something glaringly obvious?

Many thanks and great module!

Regards,

Rob.

(Maybe this isn't the place to post this?)

dobbler’s picture

Oops! I found it! It was glaringly obvious!

hadyos’s picture

Component: Miscellaneous » miscellaneous

hey all,

thanks for everyone's interest in the module. I have tried to apply for this module to be accepted in drupal.org as you can see in this thread. the time taken to review every iteration of my code took too much time and i eventually got busy with other work.

i'm currently working on another drupal module, and will try and give applying for this module into drupal.org another shot!

blaiz’s picture

awesome!

Good luck

steviesky’s picture

Category: task » support
Status: Closed (won't fix) » Active

Hi Hadyos,

What a great module and something that is really necessary in the drupal module arsenal. All the sites i am going to do want to have there photos on there site aswell and i cant understand why this is not being accepted. Is there any site or place that people can email to try and enforce the module acceptors to take notice.

Great work,
Steve

arianek’s picture

Status: Active » Postponed

Hi. Please read all the following and the links provided as this is very important information about your CVS Application:

Drupal.org has moved from CVS to Git! This is a very significant change for the Drupal community and for your application. Please read the following documentation on how this affects and benefits you and the application process:
Migrating from CVS Applications to (Git) Full Project Applications

  • The status of this application will be put to "postponed" and by following the instructions in the above link, you will be able to reopen it.
  • Or if your application has been "needs work" for more than 5 weeks, your application will be marked as "closed (won't fix)". You can still reopen it, by reading the instructions above.
avpaderno’s picture

Category: support » task
Status: Postponed » Closed (won't fix)

The user who applied for the CVS account didn't reply from April 2010, and on May 14 the application has been closed. Since then, the OP has not uploaded new versions of the code, even if he got reports about what should be changed.

I am closing this application.