Dragonfly CMS v9 ⇒ Coppermine ⇒ Coppermine Favorites Album ⇒ Community Forums ⇒ CPG Dragonfly™ CMS
Forum Index Modules & Blocks Coppermine

Coppermine Favorites Album Reply to topic


Looking for ideas on the simplest / most straightforward way to make the existing Favorites Album work in a meaningful way.

[ Currently you can click the Add to Favorites Album button at the bottom of Pic-Info eg. here. There is also a Remove option. Images can be revisited via the Favorites Album entry in the text menu spanning the top of the coppermine main page. But this only works for the duration of your session and from the same computer that you Fav'd them from. This is because Favorites are stored in a dedicated Session Cookie. ]

I guess I could just create a new db file to dump the Favorites cookie in and then reload on next session. But wonder if anyone with more knowledge could offer a more rational approach which might still be easy / straightforward to implement?

An sql file with image links indexed by userid?

TIA!

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4


This should do it
CREATE TABLE cms_cpg_favorites ( pid INT NOT NULL, user_id INT NOT NULL, PRIMARY KEY (pid, user_id) );
And when add/remove just insert/delete entry from the table

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Fedora 25 / Apache 2.4.27 / MariaDB 10.1.26 / PHP 7.1.10 / Mercurial

Last edited by DJ Maze on Thu Jul 14, 2016 4:15 pm; edited 2 times in total


I embedded your idea in v10.
Take a look if this satisfies your idea.
code.google.com/p/drag...p;name=v10

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Fedora 25 / Apache 2.4.27 / MariaDB 10.1.26 / PHP 7.1.10 / Mercurial


Looks great! Thanks!!! 👏

Will backport it shortly.

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4


Still working through the backport, but I think you might want to limit access to 'Add to Favorites' to members.

I'd had to do this previously, but now it will all accumulate under Anonymous presumably.

I just added USER_ID && to the existing condition on line 332 in v10 of modules/coppermine/displayimage.php. if (USER_ID && $CONFIG['picinfo_display_favorites']) { // layingback - disable if not user

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4


Seems to work fine from initial tests.

Will work on a Your_Account block to display Favorites, and then place on live site.

Thanks again!

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4


Found a bug. 😞 But not yours. 😀 A latent bug from DF 9.0 when Favorites display was added to the bottom of the main coppermine index page.

When I enabled Favpics in coppermine Admin [ .../favpics,3 ] no Favorites where displayed, and a divide by zero reported - a result of a LIMIT 0 clause on the SQL Select query.

At the end of modules/coppermine/index.php
case 'favpics': require_once('includes/coppermine/favorites.inc'); $count = count(coppermine_get_favorites()); if ($count > 0) { display_thumbnails('favpics', '', '', 1, $count, $thumbrows, false); } break; }
But the 5th & 6th params to display_thumbnails() are the $thumbcols and $thumbrows which set out the area to be populated. So need to be exactly the same as for earlier cases, ie.
display_thumbnails('favpics', '', '', 1, $CONFIG['thumbcols'], $thumbrows, false);

A count of FAVPICS has always been there for the 5th param since DF9.0 but as Favorites rarely lasted through >1 Session was never obvious, I guess.

The count and the call to coppermine_get_favorites is still required for the $count > 0 test.

BTW <br />'s are lost from the Preview when posting from the posting.html page, although it is fine on the final Submit. But seems to not be a problem if you post from Quick Reply instead.

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4


Can I suggest a small enhancement to includes/coppermine/favorites.inc please?

I wrote a Your Account block to display a user's Latest n Favorites. But - of course - it always displayed the favourites of the logged in user instead.

If function coppermine_get_favorites call were changed to coppermine_get_favorites($userid = '')
and the SQL SELECT changed to $qr = $db->sql_query("SELECT pid FROM {$CONFIG['TABLE_FAVORITES']} WHERE user_id = ".($userid ? $userid : is_user()));
it would be possible to call the routine with another user's id to get any user's favourites.

[ I think all the other references to $user_id in that function remain unchanged as they refer to the logged in user. ]

TIA!

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4


Sounds good but it has issues.
It will only work for logged in users to see another user his favorites.
Also, when the other user has no favorites it shows yours.

Better would be to write a new function: coppermine_get_user_favorites($user_id)

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Fedora 25 / Apache 2.4.27 / MariaDB 10.1.26 / PHP 7.1.10 / Mercurial

Last edited by DJ Maze on Mon Mar 02, 2015 2:44 pm; edited 1 time in total


You are probably right.

I had not noticed because a) I didn't want them to show if requesting users wasn't logged in Smile And my YA Block was already coded with a if (count) { ... } statement Wink

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4


Also "Latest n Favorites" is in doubt.
There is no column in the table when the entry is added.
Should it order by picture post time then?

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Fedora 25 / Apache 2.4.27 / MariaDB 10.1.26 / PHP 7.1.10 / Mercurial


I think I convinced myself that it did this. But I guess it is just the display routine that is sorting the thumbnails. So if enough images are present the SELECT LIMIT could be passing a set of n images which weren't the last.

So yes. But it's not a big issue - it is Sooo much better than what it was! Smile

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4


Hmmm. We still seem to have a bit of a problem with Favpics.
  1. User's Gallery display for a specific member coppermine/cat=1000{n}/ displays the favs of the logged in user
  2. Overall User's Gallery display coppermine/cat=1/ also displays the favs of the logged in user, which doesn't really fit.

I'm thinking the only solution is to remove favpics from the Coppermine main page display - that's to say I shouldn't configure it in Admin > coppermine > main page.

The issue: Whether using my enhancement or your better coppermine_get_user_favorites($user_id), neither will solve the case 'favpics' statement in coppermine/index.php. Because the actual display is done by display_thumbnails() which has no concept of user_id other than the current $userinfo one. Looks like major disruption of code to include, so probably not worth it.

I can leave favpics out of my coppermine configuration, but I don't know how you feel about DF as a whole when favpics,3 is in the default config for coppermine. So at a minimum you may want to drop /'favpics, 3' modules/coppermine/cpg_inst.php

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4

All times are UTC


Jump to: