New Module: Favourites

Glooper

Joined: 2005-09-21
Posts: 225
Posted: Thu, 2010-04-08 02:45

Please Download from Gallery Modules

A simple module that will put a star by each photo... which you can click to add to your favourites. You can then click "view" to view your favourites photos.. and then save this list which will e-mail the site owner and the viewer a url to see the favourites again.

There's configuration screen that allows you to set the e-mail address of the site owner (probably you) and the from e-mail address for all e-mails coming from the site.

This module is kind of like a lightbox feature. I've built it so that wedding photographers can share an album to a client who can then choose there favourites and inform the photographer.

For security reasons I'd recommend that you only use this module for registered users. (there's a checkbox in the configuration...)... otherwise an automated system maybe able to make use of the e-mail facility to send spam, Alternatively you could extend this module to include a captcha or something.

Anyway.. let me know if you have any problems.. only tried this on two systems so there maybe some teething problems.

Can one of the admins as well create me a documentation page to put the documentation for this module in? Cheers :)

Ben

Benjamin Albert Smith - Photography
Pikitia - New Zealand Photography

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Thu, 2010-04-08 03:12

Just a quick creation of the page:
http://codex.gallery2.org/Gallery3:Modules:favorites http://codex.gallery2.org/Gallery3:Modules:favourites
It ( docs) needs work and I will test the module in time.
Thanks for your contribution!

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
mamouneyya

Joined: 2009-11-02
Posts: 337
Posted: Thu, 2010-04-08 10:19

It's nice, but the graphics are terrible :P!
For now, one issue for me: When you go to your Favorites album, an annoying warning will be shown on the top saying that the album is not writable.

Thanks :)

 
mamouneyya

Joined: 2009-11-02
Posts: 337
Posted: Thu, 2010-04-08 10:29

Another issues:
(1) You cannot add/remove video to/from the favorite unless you open it.
(2) The buttons don't get flipped in RTL mode (i.e. with Arabic interface.)

 
mamouneyya

Joined: 2009-11-02
Posts: 337
Posted: Thu, 2010-04-08 13:09

For the RTL issue, these will do the job:

/* RTL support */
.rtl .icon-f {
   right: 0;
   left: auto;
   }
.rtl #f-view-link {
   float: left;
   }
.rtl #f-view-link a {
   left: 0;
   right: auto;
   }
.rtl #f-save-link {
   float: left;
   }
.rtl #f-save-link a {
   left: 0;
   right: auto;
   }
 
TAZattitude

Joined: 2009-04-27
Posts: 74
Posted: Thu, 2010-04-08 12:45

Great mod!!! Been looking forward to seeing this one for G3.

A few features I would like to see.

1) Optional email or not when favorites are saved. Though this is a great idea, in my case, I would rather just let registered members save without the admin getting emailed

2) To have the following optional as far as saving them in favorites goes
- Have the star show up next to photos
- Have the star show up next to the albums only (I personally would only use this option)
- Have the star show up next to both of the above

3) Both favorites and favourites version

Of course, like mentioned above,to fix the "Favourites album is not writable". I've changed permissions to 777, but the message still comes up.

Thanks again!

 
Glooper

Joined: 2005-09-21
Posts: 225
Posted: Fri, 2010-04-09 00:25

You can easily create your own graphics for this.. just change favourites/images/faves.png... :P

I'm not sure what to do about the "Favourites album is not writable" message. The message is correct as it's not writable (it doesn't actually exist!).. If I pretend that it's writable then the "add photos" and "add an album" menu items will appear though not work properly! I'll have a think to see if there's a way round it.. ...I think those messages only appear when you are logged in as an administrator.

I will add those options now TAZ.. :)

Ben

Benjamin Albert Smith - Photography
Pikitia - New Zealand Photography

 
Glooper

Joined: 2005-09-21
Posts: 225
Posted: Sun, 2010-10-10 00:48

OK.. kinda got rid of the annoying message.. you just have to ignore the add to menu options! :) If you do use them it will probably add to the main album.

Added those additional options.

and sorted out support for movies.

I didn't change favourites to favorites... You should be able to use the language options to change that anyway..:)...

Ben

Benjamin Albert Smith - Photography
Pikitia - New Zealand Photography

 
rWatcher
rWatcher's picture

Joined: 2005-09-06
Posts: 722
Posted: Fri, 2010-04-09 03:34
Glooper wrote:
OK.. kinda got rid of the annoying message.. you just have to ignore the add to menu options! :) If you do use them it will probably add to the main album.

I didn't thoroughly test this, but it looks like if you edit the index function in controllers/favourites.php to look like this, then the menu's go away:

    $template = new Theme_View("page.html", "collection", "favourites");
    $template->set_global("page", $page);
    $template->set_global("page_title", null);
    $template->set_global("max_pages", $max_pages);
    $template->set_global("page_size", $page_size);
    //$template->set_global("item", $album);
    $template->set_global("children", $album->viewable()->children($page_size, $offset));
    $template->set_global("children_count", $children_count);
    //$template->set_global("parents", $album->parents());
    $template->content = new View("dynamic.html");

    print $template;
 
Glooper

Joined: 2005-09-21
Posts: 225
Posted: Fri, 2010-04-09 06:15

ah cool.
I'm away for the next week but will try it out when I get back and release a new version

Ben

Benjamin Albert Smith - Photography
Pikitia - New Zealand Photography

 
mamouneyya

Joined: 2009-11-02
Posts: 337
Posted: Fri, 2010-04-09 08:46

And it will be nice if you added the RTL support to the css file, too.

 
Glooper

Joined: 2005-09-21
Posts: 225
Posted: Fri, 2010-04-09 09:29

Actually.. I'm not really sure where RTL support really lies? Shouldn't it be something that is in the theme rather than in a module? I don't really want to increase the size of the css. I'll check out the policy elsewhere in g3...
IMHO Rather than having a css file that copes with both ltr and rtl, I think it would be better to provide 2 different css files that are switched over depending on a global setting... or something similar.

Ben

Benjamin Albert Smith - Photography
Pikitia - New Zealand Photography

 
mamouneyya

Joined: 2009-11-02
Posts: 337
Posted: Fri, 2010-04-09 09:34

The theme makers don't know about every module made for G3, so they write RTL support for their theme components. The module developers should write the required RTL support for anything else in their modules. I completely understand that you don't want to increase the file size, making it heavy to load, but I do think that we're talking about some essential support here, rather than improvement/luxury.

 
Glooper

Joined: 2005-09-21
Posts: 225
Posted: Fri, 2010-04-09 10:03

@floriddave - Cheers for adding the documentation. I've just finished updating it with more stuff. :)

@mamouneyya - I'll sort something out when I stick in the other fix.

Benjamin Albert Smith - Photography
Pikitia - New Zealand Photography

 
mamouneyya

Joined: 2009-11-02
Posts: 337
Posted: Fri, 2010-04-09 11:57

Thanks.
By the way, Both 'Item view only' and 'Both views' in the admin interface are not translatable.

 
TAZattitude

Joined: 2009-04-27
Posts: 74
Posted: Sat, 2010-04-10 00:50

Thanks for the add-ons Glooper!!
I see that you can make the changes to show if albums, items, or both can be chosen from the admin, but I don't see where they show up on the actual 'front end' of the program. The 'stars' still show up on the items only.

Thanks again!

 
TAZattitude

Joined: 2009-04-27
Posts: 74
Posted: Tue, 2010-04-13 10:31

Glooper,
Just wondering if you had a chance to sort out the album-item-or both issue?

Seems no matter which selection you choose from the "Please choose where a user can select their favourites" on the admin panel, the only choice given to the user is to add an "item" to their favorites (the "Both views" and "Album view only" does not seem to be working).
Thanks!

 
Glooper

Joined: 2005-09-21
Posts: 225
Posted: Wed, 2010-04-14 03:12

Not yet. Might have some time tomorrow to sort it out though. :)

Ben

Benjamin Albert Smith - Photography
Pikitia - New Zealand Photography

 
TAZattitude

Joined: 2009-04-27
Posts: 74
Posted: Wed, 2010-04-14 10:22

That would be great...thanks!

 
Glooper

Joined: 2005-09-21
Posts: 225
Posted: Thu, 2010-04-15 00:09

Taz.. Just sat in front of my development machine, to sort this issue out.. tried it on my install here first.. and it works fine?...

Maybe there's a miss understanding on how this should work. Currently it works as follows... When in album view.. the toggle stars only appear when viewing an entire album. whereas in the item view the toggle star appears when viewing a single item, and both means it will appear in both album and item view. Is this what you meant? or did you mean something else?

Ben

Benjamin Albert Smith - Photography
Pikitia - New Zealand Photography

 
Glooper

Joined: 2005-09-21
Posts: 225
Posted: Sat, 2010-04-17 22:26

Added both the RTL stuff and the rWatcher fixes.

Cheers
Ben

Benjamin Albert Smith - Photography
Pikitia - New Zealand Photography

 
TAZattitude

Joined: 2009-04-27
Posts: 74
Posted: Thu, 2010-04-15 00:41

Aaaah, I see what you mean. You have it set to be able to add anything "within" an album to favourites...along with the actual item.

Anyway you could have it so the toggle stars can be clicked on the actual "album"?

Something like this...
Each once of these I would consider an individual "album"
Then once you go within each of the album, these would be the 'item' choice.
Probably no need to add the toggle star on the 'resized' item?!

So in other words, if you could move the ability to add the toggle starts one level "up" on both the album and the item favourites, would be great!!

Thanks again!
Scott

 
Glooper

Joined: 2005-09-21
Posts: 225
Posted: Thu, 2010-04-15 07:38

So rather than having favourite photos... you would only have favourite albums.. ?

I dont really understand why you'd want to do that? Or perhaps I'm still missing something!

Can be easily done.. I'll do it tomorrow morning.

Ben

Benjamin Albert Smith - Photography
Pikitia - New Zealand Photography

 
TAZattitude

Joined: 2009-04-27
Posts: 74
Posted: Thu, 2010-04-15 10:25

Glooper..Yes, that is correct.
The reason is, because my Gallery is basically 'paint jobs', so when a user saves an 'album', they are saving an album consisting of approx 15 pics of the same paint job. So it's not the ability to save individual pics that are important (at least to me), but the paint job (which is the individual album).
I have 1600 different 'albums' each consisting of pics of one paint job.

Even if you could just change the toggle star from 'within the album' to the individual album (which is one level up), that would be great. So you can leave the individual resized pic as an option in the admin.
This way, I guess you wouldn't even have to change the admin.

To satisfy all scenarios, it would be neat if you could select any of the three from the admin panel
-individual albums
-items within the alums (already have)
-resized items (already have)

Gallery2 "Favourites" module was set up like this where everything could be listed in your favourites. I don't think there was a choice where you could select what would get the 'toggle' icon though from the admin though

One other request would be a selection from admin that 'no' email is involved. They could just bookmark their favorites without the user (or admin) getting emailed.

Thank you very much for your time!

 
TAZattitude

Joined: 2009-04-27
Posts: 74
Posted: Thu, 2010-04-15 11:00
Quote:
One other request would be a selection from admin that 'no' email is involved. They could just bookmark their favorites without the user (or admin) getting emailed.

To add to this, if it's selected from admin not to email when a user clicks on 'Save', it can just bring up a prompt that reads. "Bookmark this page now!"... or something like that.
Or unless the jobs get saved in the database and are there when the user logs in. If so, the prompt could read "These are now saved on your Favourites list!"

I wasn't for sure if it's setup to use cookies or saved in the database.

Thanks again,
Scott

 
Glooper

Joined: 2005-09-21
Posts: 225
Posted: Sun, 2010-10-10 00:47

It uses cookies.. but I not sure how long they will last before they expire... AS such the url that is e-mailed contains the ID's of all the favourites within the url. I'm not going to change this module to use a database and using bookmarks is pain in the arse as it works differently for all browser and most newer browser don't support it (for security reasons). So.. I'm afraid you'll have to stick with the e-mail solution..

However I have put in your other request.. you can now select albums or items or both to be favourites.

Also changed some wording here and there and added some validation on the e-mail.

Ben

Benjamin Albert Smith - Photography
Pikitia - New Zealand Photography

 
TAZattitude

Joined: 2009-04-27
Posts: 74
Posted: Mon, 2010-04-19 10:44

Thanks so much Glooper. I'll install it later and check it out.
Very nice module that's a 'must have' on my website.

I appreciate your time!

Thanks!
Scott

 
pete2010

Joined: 2010-10-04
Posts: 19
Posted: Wed, 2010-10-06 06:05

Dave, is the Favourites module available for download? The download link on the Favourites page takes me to your post here, and the link in your post takes me back to the Favourites page!

Peter

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2010-10-06 06:24

2 posts up..

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
carlstreeter

Joined: 2010-10-06
Posts: 29
Posted: Thu, 2010-10-07 16:43

Hi Glooper. Just played with your module a bit. Here are my "it would be cool if's".

It would be cool if the "favorite" status were persistent. Maybe using a custom tag? Like {username}_favorite or something?

It would also be cool if, on the "view favorites" page, there were a way to download full sized versions of all of your favorites, like the downloadalbum module, for your favorites "album".

One of the things I need out of my gallery is a way to manage the contents on my LCD photo frame. The GUI part of the favorites module is pretty slick, and could be very useful for this, if the settings were persistent, and I could download the contents.

Thoughts?

 
Glooper

Joined: 2005-09-21
Posts: 225
Posted: Thu, 2010-10-07 16:51

Glad your finding this module useful. I'm afraid I won't get a chance to add any more features to this module for a long time. However the persistence is possible now. If you use the e-mail feature to e-mail yourself your favourites list then each time you click on the link in the email it will show that exact favourite list.

Ben

Benjamin Albert Smith - Photography
Pikitia - New Zealand Photography

 
carlstreeter

Joined: 2010-10-06
Posts: 29
Posted: Thu, 2010-10-07 17:56

I thought about this a little more, and it seems like what I want is different enough from your module that it feels like a new module.

My current plan is to create a new module, based on yours (especially your GUI), that ditches the email send/receive, and replaces the favorite/defavorite logic with tags.

Thanks for the great module. Even though it isn't *quite* what I need, it's pretty close. Oh, and your photography is awesome. ;)

 
jusie

Joined: 2007-06-21
Posts: 48
Posted: Sat, 2010-10-09 19:17

I've just added this module to my gallery, configured it and tested... After I've filled in the e-mail form and hit Submit, the pop up tells me

{"result":"success","location":"\/g3\/index.php\/favourites"}

I assume there should be a proper message instead? Did I miss out on any steps? Do I need to add variables and text to Gallery's language file or something?

Second question - When you send your favourites list to someone, the form contains a comment field but the standard e-mail text doesn't include that comment - What variable can I use in the e-mail template to include the comment?

 
Glooper

Joined: 2005-09-21
Posts: 225
Posted: Sat, 2010-10-09 19:38

It's probably a bug. I've not tested since G3 came out of beta. Will try and fix later.

I believe the variable is %comments to include the comment.

Ben

Benjamin Albert Smith - Photography
Pikitia - New Zealand Photography

 
jusie

Joined: 2007-06-21
Posts: 48
Posted: Sat, 2010-10-09 19:57

Thanks for your quick response! Yes, %comments works in the e-mail. I'd tried %comment but that didn't work.

It would be awesome if you could look into the success message issue at some point. I'm loving the module.

 
Glooper

Joined: 2005-09-21
Posts: 225
Posted: Sun, 2010-10-10 00:46
 
krzyzphoto

Joined: 2010-11-19
Posts: 11
Posted: Wed, 2010-11-24 17:45

Thanks for the great module, one question. I have it set up to send emails to the site owner and a copy to the favorite client, but it only sends to the client and not the site owner. Any suggestions?

 
Serge D
Serge D's picture

Joined: 2009-06-11
Posts: 2466
Posted: Thu, 2011-01-20 18:32

Any chance to retool/redesign elements layout so that operations would be confined to some comon areas - menu or sidebar?
All these nice stars dancing around the page could make design odd...

View page does not work for me within Wind theme, what could be a problem?

Edit: Ok, problem with view of favorite items is in dynamic.html.php. there is $title variable which is not initialized by the module. it would cause php to fail in strict error mode.

Glooper, you have to write docs on how you have done it. it would help other people a lot when it comes to dynamic pages

 
Timmy Likes to Click

Joined: 2011-02-09
Posts: 5
Posted: Wed, 2011-02-16 23:20

One thing we just came across today.

Issue:
We had a user try to navigate to page two of our favourites. On page two see a duplication of images that were on page one of favourites.

I know that all the favourites are displayed on one page, but can the page navigation at the bottom be dropped? It confused one of our users today.

[img]http://www.blackhillsbadlands.com/bhphotos/bhm01.png[/img]

[img]http://www.blackhillsbadlands.com/bhphotos/bhm02.png[/img]

All in all GREAT MODULE!

Few additional questions / suggestions:

Is there an admin function to see all the favorite lists that were saved and emailed? Also, a way delete or clear out all saved favorite lists?

 
photomanz

Joined: 2010-04-09
Posts: 97
Posted: Thu, 2011-03-24 00:36

Comment moved to troubleshooting forum.

 
Maerin

Joined: 2010-01-27
Posts: 29
Posted: Tue, 2011-06-14 19:07

As many others I like this module very much but wanted to really save the users favourites instead of emailing it. As I'm just a learning-by-doing-coding-newbie I had to keep it simple.
Because I don't use the url-field of a user I thought it would be a good candidate to (mis)use this url-attribute for storing the favourites url which is normally emailed.

1) I choose for saving the favourites url every time a photo is selected or deselected. So it's auto saving.
In favourites/controllers/favourites.php I added to the function "toggle_favourites"

$user = ORM::factory("user")->where("name", "=", identity::active_user()->name)->find();
$user->url = $favourites->getUrl();
$user->save();

so the function looks now like this:

public function toggle_favourites($id){
  $favourites = Favourites::getOrCreate();
  $infavour = $favourites ->toggle($id);

  $user = ORM::factory("user")->where("name", "=", identity::active_user()->name)->find();
  $user->url = $favourites->getUrl();
  $user->save();

  $title = $infavour?t("Remove from favourites"):t("Add to favourites");
  json::reply(array("result" => "success",
                    "favourite" => $infavour,
                    "hasfavourites" => $favourites->hasFavourites(),
                    "title" => (string)$title));
}

2) I added an new user_login event to load a saved url when a user logs in.
In favourites/helpers/favourites_event.php I added to following function

   static function user_login($user) {
  
	if ($user->url) {
          $favourites = Favourites::getOrCreate();
          $favourites->clear();
          $array = explode("/",substr($user->url, strrpos($user->url, "view") + 5));

	    if (!empty($array[0])) {
              foreach($array as $i=>$item){
              $favourites->toggle($item);
              }
	    }

	  // url::redirect(item::root()->abs_url()) = G3 home page
	  // url::redirect($user->url)              = Favourites page
	  url::redirect(item::root()->abs_url());	  
    }
  }

That's all !

3) Optional: If you are not interested in emailing the link you can get rid of the "save" star in the favourites pseudo album by commenting out the five "f-save-link" lines in the favourites/css/favourites.css.

Any comments are welcome.

 
dgfphoto99

Joined: 2009-04-15
Posts: 121
Posted: Thu, 2011-06-16 15:07

I tried to enter this code into the docs mentioned but got a white page.

Any help where these lines should go would help someone who is not a very good programmer but like the mods!!

Thanks

DGF

 
Maerin

Joined: 2010-01-27
Posts: 29
Posted: Fri, 2011-06-17 11:28

DGF,

I did a clean install of the favourites module and copy/paste the code as I decribed in my post. It works without a problem.

The only thing I can think of is that you added the "static function user_login" code exactly at the end of the favourites_event.php. Then you get a white page. With "adding" I meant adding as a new function, so just before the last curly brace "}" which marks the end of the "class favourites_event_Core".

 
exrace

Joined: 2006-01-02
Posts: 26
Posted: Thu, 2011-08-25 00:42

For some reason the Module "favourites" admin doesn't show up under any of the menus.
When you try to go to /admin/favourites manually I get an error page.
The advanced settings does show 4 favourites values which you can edit.
The module works fine in the albums.

What could be missing here?
I am running latest Gallery 3.02 code.

 
krikman

Joined: 2011-02-22
Posts: 24
Posted: Fri, 2012-05-25 08:55

For all users of this excellent module I present more shiny icons:
http://www.marktim.ru/files/regular/faves.png

Hope I don't break any copyrights. $)

http://photo.marktim.ru

 
melph

Joined: 2009-02-14
Posts: 12
Posted: Fri, 2012-06-29 14:29

Loves this plugin, almost does what I need.

I have added the mod by Maerin, but had to comment out the redirect at the bottom of the new user_login function otherwise after logging in, the login floating box would just become populated with loads of data. If one was to select back on the browser, this then would show the user as logged in. However, not a problem as like I say, have commented out.

I would really like the ability for users to email themselves their lightbox - we often have people coming to us with requests for images across a large array of sub galleries, so receiving an email with the images in would save us allot of time. BUT...

..... it doesnt email? (note, this didnt work on a clean install so nothing to do with mod)

Is there meant to be a Success message once an email has been sent?

At the mioment, I fill in the name and email and comments field, hit save but nothing happens other than the message box closing.

I know my webhost had issues with webmail, so I have installed the php mailer to make sure (and have tested all ok using contact form)

Any ideas or suggestions?

Best wishes

Mark

 
melph

Joined: 2009-02-14
Posts: 12
Posted: Fri, 2012-06-29 17:26

Hi

So I now know this module uses php mail function. This is the problem as my web host has disabled this function and won't allow it(I have had many battles over this).

Any suggestions on how to get this to work with phpmailer?

Many thdnks

 
SKiD1

Joined: 2008-04-25
Posts: 3
Posted: Sat, 2013-04-13 20:49

Hi,
thanx for handy plugin:-)
I would like to include to e-mail list of filenames which I could import to Lightroom using Photo List Importer plugin. Is it possible to do it somehow? Thank you