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