Mod: User Categories Mod: User Categories
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Mod: User Categories

Started by vortac, October 03, 2006, 03:56:56 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

vortac

I downloaded Coppermine last week to setup a family and friends photo site (it's getting too big to manage with Dave James' album script).  I was surprised to find that Coppermine does not have support for user owned categories.  I really need this functionality and from searching the forums, it seems like a lot of other users want it too.  So I put together this patch.  It adds the following features:

- A new selection box, "Category owner", is added to the Administrator category page allowing administrators to assign ownership to categories.
- The category page is now accessible to registered users, who are allowed to fully manipulate (move, delete, edit) the categories which they own.
- Support for nesting of categories owned by different users (e.g. "Family" category owned by user "Son", "Family->Dad" category owned by user "Dad", "Family ->Mom" owned by "Mom" etc.)
- Users can create subcategories and albums in their categories.
- xp_publish has been modified to allow users to create albums and upload directly into categories which they own.
- Users can also upload via the web form into albums under their categories.
- All albums within a user's owned categories can be modified by the user, including movement between user owned categories.
- Albums can now be moved to and from the User Gallery.
- This patch should make it easier to add real permissions (unix style, acl, etc) since the diffs highlight many (all?) of the critical points for permissions.

Caveat emptor:
- This is a first cut (aka alpha code).
- Seems to work well for me, but ymmv (translation: the usual disclaimer, I take no responsibility for this patch breaking your site or causing your server to burst into flames).
- If anyone is interested in trying this out, I'd like to hear feedback about bugs/issues/etc.
- If anyone familiar with the Coppermine code could take a look, that would be great.
- I have no idea whatsoever how this will or will not work with bridging.

Bugs/Known issues:
- User category view and movement can be confusing if a user's categories are not positionally contiguous within each hierarchy level.  Solution is probably a constraint enforcing positional grouping of user categories.
- I used a couple of negative constants for convenience in some of the code/queries.  These should probably be replaced with nulls or something.
- There is a query that uses UNION, which is only supported in mysql 4+.
- There are some other queries that would be nicer using UNION, but I generally tried to avoid it since this system seems to support mysql 3.x.
- Categories which a user does not own are displayed in the selects using "optgroups".  Any better ideas for this?  Leaving them out entirely makes the menus confusing in terms of hierarchy.
- A non-admin user can move a category he owns at the root level into another category he owns, however he cannot move it back to the root level, since the root level is owned by Administrator.  Solution is probably to either not allow this, or to keep track of if a user owned category was ever at the root level, and allow users to move such categories back.
- Others I can't recall or don't know about now.

Installation:

Download and unzip the patch into your toplevel cpg directory (e.g. cpg149), and run this command: "patch -p1 < patch-cpg149-usrcat".  No database modifications are required as this patch uses the existing and seemingly unused "owner_id" field in the categories table.  Log on as administrator and add some new categories owned by users.  To get a "My Categories" menu item for users, add the following line to $template_user_admin_menu in your theme:

<td class="admin_menu"><a href="catmgr.php" title="Create, manage, and delete categories">My categories</a></td>

- Eric

vortac

This incremental patch fixes the following bugs/issues in the user categories mod:

- The "EDIT FILES" button next to the albums now works in user categories.
- In some cases the "DELETE", "PROPERTIES", "EDIT FILES" buttons were displayed to Guests (although they did not have permissions if they clicked these options).  This has been fixed.
- Eliminated unnecessary DB queries when Guests load index.php.

Installation:

AFTER having installed the initial user categories patch, download and unzip this patch into your cpg directory.  Then do "patch -p1 < patch-cpg149-usrcat-inc1".

djpvx

i'm very newbie, but can you tell me, how to patch it?

vortac

Hi there, can you provide more information about your setup?  Do you have shell access to your account (ssh for example), or are you only able to modify files on the server via FTP?  Since you must have read the installation instructions in the previous posts, which cover the case where you have shell access, I'll assume the latter.  I'll also assume your local machine is windows based, which means it does not come with a "patch" utility.

What you probably need to do is first install a windows patch utility, such as http://gnuwin32.sourceforge.net/packages/patch.htm.  Then, download and unzip cpg149.  Next, download and unzip the patches into this cpg149 directory.  In the cpg149 directory, issue the patch commands exactly as stated in the previous posts, and in that order.  Finally, upload the patched cpg149 tree to your server.

Beyond that, you'll need to provide more information.

- Eric

Quote from: djpvx on October 05, 2006, 09:25:37 PM
i'm very newbie, but can you tell me, how to patch it?

djpvx

i can access my files via ftp only. :-\

Little_rU

Hi!

First of all thanks a lot for this great hack, this is what I was looking for a long time.

But I have an installation problem. I've successfully applied both patches and administrator can now assign owner to a category but I don't see how this user (owner) can do something with it (any new menu etc). And when owner tries to open catmgr.php page it says "You don't have permission to access this page."

Where can I find this $template_user_admin_menu where as I understand I have to put a link to this category management page ?

Bazzah

This mod sounds like exactly what I need, but I can not get it to work either. I too am a bit of a newbie when it comes to php and sql. I have followed your instructions to the letter. I downloaded that patching utility you suggested (Im on a windows machine, and trying to install the mod via ftp) but when running the patch, it comes up with errors each time it attempts to patch.

can't find file to patch at input line 4
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -ru cpg149-ORIG/albmgr.php cpg149/albmgr.php
|--- cpg149-ORIG/albmgr.php     2006-09-26 19:34:27.000000000 -0400
|+++ cpg149/albmgr.php  2006-10-02 14:19:38.000000000 -0400
--------------------------
File to patch:

Piotras

This is what i was looking for.  Worked great thx alot.   :) ;)

Piotras

Found a bug.

After allowing a user to create albums i specific category it adds the album to the user categories not to the specified category.


codegirl42

this is EXACTLY what i've been looking for for a long time....but...for some reason....i produce errors when i try to patch

I have shell access....

these are the errors that I get:

patching file albmgr.php
Hunk #1 FAILED at 51.
Hunk #2 FAILED at 337.
Hunk #3 FAILED at 360.
3 out of 3 hunks FAILED -- saving rejects to file albmgr.php.rej
patching file catmgr.php
Hunk #1 FAILED at 26.
Hunk #2 FAILED at 51.
Hunk #3 FAILED at 64.
Hunk #4 FAILED at 105.
Hunk #5 FAILED at 209.
Hunk #6 FAILED at 233.
Hunk #7 FAILED at 257.
Hunk #8 FAILED at 306.
Hunk #9 FAILED at 321.
Hunk #10 FAILED at 361.
Hunk #11 FAILED at 400.
Hunk #12 FAILED at 421.
Hunk #13 FAILED at 517.
Hunk #14 FAILED at 532.
Hunk #15 FAILED at 582.
15 out of 15 hunks FAILED -- saving rejects to file catmgr.php.rej
patching file db_input.php
Hunk #1 FAILED at 197.
1 out of 1 hunk FAILED -- saving rejects to file db_input.php.rej
patching file delete.php
Hunk #1 FAILED at 148.
Hunk #2 FAILED at 282.
2 out of 2 hunks FAILED -- saving rejects to file delete.php.rej
patching file include/functions.inc.php
Hunk #1 FAILED at 2995.
1 out of 1 hunk FAILED -- saving rejects to file include/functions.inc.php.rej
patching file index.php
Hunk #1 FAILED at 536.
Hunk #2 FAILED at 547.
Hunk #3 FAILED at 695.
Hunk #4 FAILED at 705.
Hunk #5 FAILED at 862.
5 out of 5 hunks FAILED -- saving rejects to file index.php.rej
patching file lang/english.php
Hunk #1 FAILED at 398.
Hunk #2 FAILED at 565.
Hunk #3 FAILED at 576.
Hunk #4 FAILED at 1378.
Hunk #5 FAILED at 2110.
5 out of 5 hunks FAILED -- saving rejects to file lang/english.php.rej
patching file modifyalb.php
Hunk #1 FAILED at 58.
Hunk #2 FAILED at 131.
Hunk #3 FAILED at 148.
Hunk #4 FAILED at 428.
Hunk #5 FAILED at 448.
Hunk #6 FAILED at 463.
6 out of 6 hunks FAILED -- saving rejects to file modifyalb.php.rej
patching file picmgr.php
Hunk #1 FAILED at 85.
1 out of 1 hunk FAILED -- saving rejects to file picmgr.php.rej
patching file upload.php
Hunk #1 FAILED at 839.
Hunk #2 FAILED at 2209.
2 out of 2 hunks FAILED -- saving rejects to file upload.php.rej
patching file xp_publish.php
Hunk #1 FAILED at 173.
Hunk #2 FAILED at 200.
Hunk #3 FAILED at 236.
Hunk #4 FAILED at 627.
Hunk #5 FAILED at 644.
Hunk #6 FAILED at 673.
Hunk #7 FAILED at 718.
7 out of 7 hunks FAILED -- saving rejects to file xp_publish.php.rej

codegirl42

forgot to mention that this is a unix server

codegirl42

i implemented this manually...but was curious to know if there was a way that users could add sub-categories/albums to ANY ADMIN CREATED CATEGORY except USER albums. This would be great. I have a website in which i create a main category such as "FORD" and I would like users to create sub-categories and albums of their own such as: "2006 FOCUS"....

but the way this is setup, admin has to give OWNERSHIP in order for the user to create subcategories...I wish there was a way that EVERYONE could own ALL categories.

I hope this makes sense....

Thanks for any help

MrOrange

I can't figure out that patch thing either on Win XP.

Can someone give a quick run down of how to read the patch file?

I take it this tells us what file to modify, and the the lines to change?

diff -ru cpg149-ORIG/catmgr.php cpg149/catmgr.php
--- cpg149-ORIG/catmgr.php 2006-09-26 19:34:27.000000000 -0400
+++ cpg149/catmgr.php 2006-10-02 15:08:15.000000000 -0400
@@ -26,7 +26,7 @@


Any help would be appreciated.

codegirl42

Quote from: MrOrange on November 12, 2006, 12:02:54 PM
I can't figure out that patch thing either on Win XP.

Can someone give a quick run down of how to read the patch file?

I take it this tells us what file to modify, and the the lines to change?

diff -ru cpg149-ORIG/catmgr.php cpg149/catmgr.php
--- cpg149-ORIG/catmgr.php 2006-09-26 19:34:27.000000000 -0400
+++ cpg149/catmgr.php 2006-10-02 15:08:15.000000000 -0400
@@ -26,7 +26,7 @@


Any help would be appreciated.

might sound dumb, but i just followed the '+'s and '-'s in patching it manually. if you look at what you posted....the file that it's editing is "catmgr.php" first....so then the line that would be REMOVED would begin with a single '-' and the line that it is replaced with, begins with a single '+'.

MrOrange

Quote from: codegirl42 on November 12, 2006, 06:08:15 PM
might sound dumb, but i just followed the '+'s and '-'s in patching it manually. if you look at what you posted....the file that it's editing is "catmgr.php" first....so then the line that would be REMOVED would begin with a single '-' and the line that it is replaced with, begins with a single '+'.

ahh awesome! thank you!

vortac

Hi, sorry for the poor response latency, I've actually been using a different photo gallery lately.  I don't know why you are having such problems with patch.  Are you using cpg 1.4.9?  A different version, or a version that has other mods may cause problems.  It's also possible that you're in the wrong directory, which affects which -p option you need to use (-p1, -p2, etc).  But you have the right idea regarding how patch works with "+" and "-", although it is tedious to do by hand.

As for the subcategory part of your post, that should work if you've added:

<td class="admin_menu"><a href="catmgr.php" title="Create, manage, and delete categories">My categories</a></td>

to your "$template_user_admin_menu" in the template, as described in the first post.  To test this immediately, you can just enter "catmgr.php" directly into the url after the "/" and you should see the option for users to create subcategories in categories they own (if memory serves, it's been a couple of months since I've looked at this).

- Eric

Quote from: codegirl42 on November 12, 2006, 12:33:06 AM
i implemented this manually...but was curious to know if there was a way that users could add sub-categories/albums to ANY ADMIN CREATED CATEGORY except USER albums. This would be great. I have a website in which i create a main category such as "FORD" and I would like users to create sub-categories and albums of their own such as: "2006 FOCUS"....

but the way this is setup, admin has to give OWNERSHIP in order for the user to create subcategories...I wish there was a way that EVERYONE could own ALL categories.

I hope this makes sense....

Thanks for any help

codegirl42

Quote from: vortac on November 14, 2006, 04:24:53 AM
Hi, sorry for the poor response latency, I've actually been using a different photo gallery lately.  I don't know why you are having such problems with patch.  Are you using cpg 1.4.9?  A different version, or a version that has other mods may cause problems.  It's also possible that you're in the wrong directory, which affects which -p option you need to use (-p1, -p2, etc).  But you have the right idea regarding how patch works with "+" and "-", although it is tedious to do by hand.

As for the subcategory part of your post, that should work if you've added:

<td class="admin_menu"><a href="catmgr.php" title="Create, manage, and delete categories">My categories</a></td>

to your "$template_user_admin_menu" in the template, as described in the first post.  To test this immediately, you can just enter "catmgr.php" directly into the url after the "/" and you should see the option for users to create subcategories in categories they own (if memory serves, it's been a couple of months since I've looked at this).

- Eric


thanks for the post Eric!

But what i would like is for them NOT to have to own the category in order to create albums in it...you know what i mean?

vortac

OK, I know what you mean now.  If you only want this for one or two parent categories, you should be able to easily hack it in the code by hard coding the category id in each conditional that checks the category permission.  Just go through the patch diff and you should see every such point.  A less hacky approach would be to add a database column for each category allowing this, or actually add a table for real permissions.

- Eric

Quote from: codegirl42 on November 14, 2006, 04:42:20 AM
thanks for the post Eric!

But what i would like is for them NOT to have to own the category in order to create albums in it...you know what i mean?

JCphotog

This looks great.  It's all a bit beyond me.  But sort of like codegirl42 I'd love the opportunity to allow my users the ability to move their albums or create their albums in categories other than the user gallery cat.  Great work. 

webberz

This is exactly what I am looking for! I wish I can get it installed.  I can't locate version 1.4.9 only the lastest coppermine 1.4.10 and this gives errors.  I expect because the files being updated have been changed in 1.4.10.  I would use 1.4.9 instead if I can get it, even though it may have security problems.  Or can you provide a updated patch for 1.4.10.  thanks