Forums / Developer / Moving user under a group during activation [SOLVED]

Moving user under a group during activation [SOLVED]

Author Message

Lo' F.

Monday 30 May 2011 8:40:32 am

Hello everybody!

When new users register themselves, they have to wait for the administrator to activate their account (...removed the email activation feature).

But I would like to add a shortcut which will allow the administrator to move its website's users under a group he wants them to belong, directly from the user setting page.

For this I added a new block with a simple select field recalling the list of available users groups in the setting.tpl (design/admin2/templates/user/).

<div class="block">
<label>{'Move this user under a users group'|i18n( 'design/admin/user/setting' )}:</label>
{def $users_groups=fetch('content', 'list', hash('parent_node_id', 199))}
<select name="users_groups">
<option value="">{'Please select'|i18n( 'design/admin/user/setting' )}</option>
{foreach $users_groups as $group}
<option value="{$group.node_id}">{$group.name}</option>
{/foreach}
</select>
</div>

Technically when he ticks the checkbox, selects the desired group and clicks ok, the user will be active and located under its new group node.

I guess, in order to accomplish this, the file I would need to alter is kernel/user/activate.php, right?

Since I have had unpleasant experiences with kernel files, playing with it freaks me out a bit.

Found something on the subject http://ezpedia.org/snippet/php_snippet_moving_a_node. Do I need to integrate a functionality like that in that activate.php file?

Thanks a lot!

loredanaebook.it

Lo' F.

Monday 30 May 2011 10:15:31 am

Well, it's done! With or without reply, this forum turns to be always lucky to me!

First of all the right file wasn't activate.php (which is instead related to email activation, I suppose) but setting.php under kernel/user/.

In setting.tpl I also added an hidden field through which pass over the user node id needing to be moved.

<input type="hidden" name="user_node" value="{$user[contentobject][main_node_id]}" />

And in the setting.php file, the rest of the game..

if ( $http->hasPostVariable( "UpdateSettingButton" ) )
{
    ...
    if ( $http->hasPostVariable( 'user_node' ) )
    {
        $userNode = $http->postVariable( 'user_node' );
    }
    if ( $http->hasPostVariable( 'users_groups' ) )
    {
        $usersGroup = $http->postVariable( 'users_groups' );
    }
...

... within the eZOperationHandler else statement..

else
    {
        eZUserOperationCollection:: ...

        eZContentObjectTreeNodeOperations::move( $userNode, $usersGroup );
    }

 

loredanaebook.it

Nicolas Pastorino

Tuesday 31 May 2011 12:24:20 am

Hi Lo' F !

I like the fact that the eZ Community forums are your lucky charm :)

About your solution : it seems fully functional, but it kinda hacks the kernel files, making any future upgrade a bit boring. How about an ajax based solution ? You could keep the template you updated, but simply handle the action through Ajax. This will have you create your own backend, using ezjscore for instance, but will keep your install future-proof.

Cheers !

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Marko Žmak

Tuesday 31 May 2011 2:08:21 am

Hi Lo, there's already a way in eZP to this and it's done like this:

<form action="{'content/action'|ezurl(no)}" method="post">
<input type="hidden" name="ContentNodeID" value="id_of_node_you_want_to_move">
<input type="hidden" name="NewParentNode" value="id_of_parent_node_where_you_want_to_move_it_to">
<input type="hidden" name="ViewMode" value="redirectback">
<input type="submit" name="MoveNodeAction" value="Move user to another group">
</form>

so you don't have to hack the kernel.

Does this help?

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

eZ debug

Timing: Jan 18 2025 00:59:21
Script start
Timing: Jan 18 2025 00:59:21
Module start 'content'
Timing: Jan 18 2025 00:59:22
Module end 'content'
Timing: Jan 18 2025 00:59:22
Script end

Main resources:

Total runtime1.0917 sec
Peak memory usage4,096.0000 KB
Database Queries201

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0068 587.8594180.8203
Module start 'content' 0.00680.9262 768.6797620.9219
Module end 'content' 0.93300.1587 1,389.6016341.3672
Script end 1.0917  1,730.9688 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00430.3917210.0002
Check MTime0.00170.1548210.0001
Mysql Total
Database connection0.00110.100310.0011
Mysqli_queries1.000591.64542010.0050
Looping result0.00220.20001990.0000
Template Total1.060897.220.5304
Template load0.00240.215420.0012
Template processing1.058496.946820.5292
Template load and register function0.00010.010410.0001
states
state_id_array0.00080.077210.0008
state_identifier_array0.00130.116120.0006
Override
Cache load0.00190.1776390.0000
Sytem overhead
Fetch class attribute can translate value0.00130.122040.0003
Fetch class attribute name0.00140.131470.0002
XML
Image XML parsing0.00280.259540.0007
class_abstraction
Instantiating content class attribute0.00000.002980.0000
General
dbfile0.00700.6393410.0002
String conversion0.00000.000530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 28
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs