Quick question - should this module work for anonymous users? I can get it to work for a user but not for an anonymous user, even when both are permissioned for 'manage own favorites'.
Thanks
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | favorites.delete_cookies_favorites.patch | 1.11 KB | kemsnake |
Comments
Comment #1
anea02 commentedOK, I think I have answered my own question and the answer is 'no'. I had a quick look at the module code and everything is linked backed to the user ID. Would it be a huge amount of work to support anonymous users as well? This module is the only module I can find that can stand a chance of helping me (aside from the lack of anonymous support it is a perfect match for my needs) because it can store any page within the site as a favourite (views, panels etc.)
Thanks
Comment #2
jusyjim commentedI would be willing to contribute $ to the developer for adding support for anonymous usage as well as ajax refresh of favorites.
Comment #3
mpavel commentedHi there,
I've made some changes to the code to allow unregistered visitors to add pages to their favorites.
The changes to the code are quite simple. Here's how it works:
1. Unregistered visitor clicks 'Add to favorites'
2. If a cookie 'favsuid' already exists, use it as the user id and run the DELETE/INSERT queries
3. Else create the cookie with the value of 'time()' and run the queries
4. Unregistered visitor clicks 'Remove from favorites'
5. Basically do step 2, 3 again but just DELETE favorite where userid = 'favsuid' cookie
The updated code tries not to interfeere with the original and basically just has checks if the userid is set or not ...
Also, if the visitor registers and logs in on the website he won't see his Favorites links anymore - but he can add more as a logged in user. When he logs out he'll see the original Favorites again.
Hope all this makes sense.
Here is the content of 'favorites.module.php'
Comment #4
doitDave commentedThere would be several ways to implement this for anonymous users. Be it cookie or session based or even with an individual password to identify...hey, wait a second: The latter already exists (see user/register)... and the first two also do: Check "menu > bookmarks" in your browser...
Haha, okay, caught me. That was nasty kidding. Apologies. But without kidding, it all ends up in re-inventing the wheel. Session or cookie based implementations, in the end, all necessarily mean to store something client-sided, i.e. in the browser. But why would you while literally every browser, even good old Lynx, already provides bookmarks. So let's see what this module is intended for: Provide platform and browser independent bookmarks. Those who do not want to register with your site, will use del.icio.us, digg etc. Those who don't bother, well, are no longer anonymous.
TL; DR: I think this is really no feature that would make any sense at all. Correct me, if I missed something (and feel free to re-open in such a case).
Comment #5
savel commentedHere is the simple scenario:
I need to build a simple basket for some content type. I.e. to let he/she mark some of 200 offers as "interesting" and then mail list to administrator via simple form.
So it's important to have favorites for guest users.
Comment #6
doitDave commentedOk, you have a point. So let's reopen it. But I can't promise anything right now. For one thing I'm deeply caught in other projects. And for the other, if at all, this would have to work is the $_SESSION variable or cookies. I will think about it ocasionally.
If, of course, anyone else is willing to take it, feel free to provide solid patch (against the current dev branch, please).
Comment #7
doitDave commentedI have now implemented an abstraction layer for the CRUD internals. It distinguishes between registered users and guests and operates with cookies instead of DB entries for the latter ones.
I have tested it working so far, with and without JS. Before it goes into a new release, please test it.
It will be in the next dev snapshot of July 1st, 2013. Enjoy!
Comment #9
System Lord commented7.x-2.x dev
Anonymous user: "You do not have permission to remove this favorite."
Anonymous user can save pages/links now but they cannot delete them.
Comment #10
System Lord commentedThis module is ideal for my site. Actually it's exactly what I need. I will pay $$ to have it fixed.
Comment #11
System Lord commented#9 - same problem with 7.x-2.0-beta1.
Comment #12
kemsnake commentedpatch for #9. added some checks. patch for 7.x-2.0-beta1
Comment #13
kemsnake commentedclean code from #12