Group Membership - Leave Group Function - remove location

Author Message

Paul Wilson

Tuesday 06 March 2007 3:32:17 am

Hi

I'm working on group membership functions - along the lines used in Kristof Cooman's Membership extension.

Basically a user's membership of a group is set by adding an extra location for the user's user object in the relevant user group folder.

I also want users to be able to remove themselves from groups.

For experimental purposes, I achieved this by posting template form data to the (kernel)/content/action.php script as follows:

{def $form_post_url="content/action"}
<form name="locationsform" method="post" action={$form_post_url|ezurl}>
    <input type="hidden" name="ContentNodeID" value="{$node.node_id}" />
    <input type="hidden" name="ContentObjectID" value="{$user_id}" />
    <input type="hidden" name="ViewMode" value="full" />
    <input type="hidden" name="ContentObjectLanguageCode" value="" />
    <input type="hidden" name="LocationIDSelection[]" value="{$current_member_of_user_group_node_id}" title="Remove me from this user group." />
    <input class="button" type="submit" name="RemoveAssignmentButton" value="Leave this Group" title="Remove me from this user group." />
</form>

Which works fine, as long as the current user is an Administrator User. Otherwise I get 'Access Denied -You don't have permission to access this area'.

Is there a way I can set permissions to allow this to work? Or is there some other easier method I've missed?

I'd be pleased to document the solution for everyone if someone can help me out.

Thanks

Claudia Kosny

Tuesday 06 March 2007 11:24:23 am

Hi Paul

I had to give the users permissions for content/manage_locations to get a similar thing working. Just try it out.

Claudia

Paul Wilson

Tuesday 06 March 2007 8:19:50 pm

Big thanks to you Claudia,

That worked like a charm. My reading of the code had taken me in a more ominous-looking (and apparently unneccessary) direction.

Regards

- Paul

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 10:35:32
Script start
Timing: Jan 18 2025 10:35:32
Module start 'layout'
Timing: Jan 18 2025 10:35:32
Module start 'content'
Timing: Jan 18 2025 10:35:33
Module end 'content'
Timing: Jan 18 2025 10:35:33
Script end

Main resources:

Total runtime1.0623 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0072 588.1406152.6406
Module start 'layout' 0.00720.0033 740.781339.4766
Module start 'content' 0.01051.0505 780.2578505.8594
Module end 'content' 1.06100.0013 1,286.117212.1094
Script end 1.0623  1,298.2266 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00420.3998160.0003
Check MTime0.00170.1645160.0001
Mysql Total
Database connection0.00160.153210.0016
Mysqli_queries1.006094.6941570.0176
Looping result0.00060.0583550.0000
Template Total1.013895.420.5069
Template load0.00350.331020.0018
Template processing1.010395.101020.5051
Template load and register function0.00010.007910.0001
states
state_id_array0.00260.244610.0026
state_identifier_array0.00220.210820.0011
Override
Cache load0.00290.2689240.0001
Sytem overhead
Fetch class attribute can translate value0.00080.075020.0004
Fetch class attribute name0.00130.123340.0003
XML
Image XML parsing0.00060.060720.0003
class_abstraction
Instantiating content class attribute0.00000.000950.0000
General
dbfile0.00080.0743160.0000
String conversion0.00000.000740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 12
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs