Skip to content

Commit

Permalink
Fixed #18886: New users only viewable by Administrator until validated
Browse files Browse the repository at this point in the history
Added an unactivated user dashboard to allow activation and removal from
the adminitration interface if for some reason, the user does not click
on the activation link
  • Loading branch information
dpobel committed Dec 12, 2011
1 parent c5aea81 commit cc4d809
Show file tree
Hide file tree
Showing 8 changed files with 397 additions and 0 deletions.
22 changes: 22 additions & 0 deletions design/admin2/stylesheets/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,28 @@ table.list th, table.special th
vertical-align: middle;
}

table.list label
{
font-weight:normal;
}

table.list th a
{
text-decoration:none;
}

table.list .sort-asc a
{
padding-right:1.5em;
background:url(../images/icons-sprite.png) no-repeat right -270px;
}

table.list .sort-desc a
{
padding-right:1.5em;
background:url(../images/icons-sprite.png) no-repeat right -250px;
}

table.special th
{
border-top: 1px solid #ccc;
Expand Down
1 change: 1 addition & 0 deletions design/admin2/templates/parts/user/menu.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
{include uri='design:parts/ini_menu.tpl' ini_section='Leftmenu_user' i18n_hash=hash(
'access_controll', 'Access control'|i18n( 'design/admin/parts/user/menu' ),
'roles_and_policies', 'Roles and policies'|i18n( 'design/admin/parts/user/menu' ),
'unactivated', 'Unactivated users'|i18n( 'design/admin/parts/user/menu' ),

This comment has been minimized.

Copy link
@arnebratt

arnebratt Dec 12, 2011

This link appears for my admin user. However, a different user with user/activation policy access does not see it. This user does however have access to the user/unactivated module.

This comment has been minimized.

Copy link
@dpobel

dpobel Dec 12, 2011

Author Contributor

Thanks for the report, this has been fixed in ae6edc5

)}

{/if}
Expand Down
138 changes: 138 additions & 0 deletions design/standard/templates/user/unactivated.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{* DO NOT EDIT THIS FILE! Use an override template instead. *}
{def $uri = $module.functions.unactivated.uri}
<form name="activations" method="post" action={$uri|ezurl}>

{if and( is_set( $success_activate ), is_set( $errors_activate ) )}
{if $success_activate}
<div class="message-feedback">
<h2>{'The following users have been successfully activated:'|i18n( 'design/admin/user/activations' )}</h2>
<ul>
{foreach $success_activate as $userid}
{def $object = fetch( content, object, hash( 'object_id', $userid ) )}
{if $object.status|eq( 1 )}
<li><a href={$object.main_node.url_alias|ezurl}>{$object.name|wash}</a></li>
{else}
<li>{$object.name|wash}</li>
{/if}
{undef $object}
{/foreach}
</ul>
</div>
{/if}
{if $errors_activate}
<div class="message-error">
<h2>{'Some users have not been activated'|i18n( 'design/admin/user/activations' )}</h2>
</div>
{/if}
{elseif and( is_set( $success_remove ), is_set( $errors_remove ) )}
{if $success_remove}
<div class="message-feedback">
<h2>{'The following unactivated users have been successfully removed:'|i18n( 'design/admin/user/activations' )}</h2>
<ul>
{foreach $success_remove as $name}
<li>{$name|wash}</li>
{/foreach}
</ul>
</div>
{/if}
{if $errors_remove}
<div class="message-error">
<h2>{'Some users have not been removed'|i18n( 'design/admin/user/activations' )}</h2>
</div>
{/if}
{/if}



<div class="context-block">
{* DESIGN: Header START *}<div class="box-header"><div class="box-ml">
<h1 class="context-title">{'Unactivated users (%users_count)'|i18n( 'design/admin/user',, hash( '%users_count', $unactivated_count ) )}</h1>
{* DESIGN: Mainline *}<div class="header-mainline"></div>

{* DESIGN: Header END *}</div></div>

{* DESIGN: Content START *}<div class="box-ml"><div class="box-mr"><div class="box-content">

{* Items per page selector. *}
<div class="context-toolbar">
<div class="button-left">
<p class="table-preferences">
{switch match=$number_of_items}
{case match=25}
<a href={concat( '/user/preferences/set/', $limit_preference, '/1' )|ezurl}>10</a>
<span class="current">25</span>
<a href={concat( '/user/preferences/set/', $limit_preference, '/3' )|ezurl}>50</a>
{/case}

{case match=50}
<a href={concat( '/user/preferences/set/', $limit_preference, '/1' )|ezurl}>10</a>
<a href={concat( '/user/preferences/set/', $limit_preference, '/2' )|ezurl}>25</a>
<span class="current">50</span>
{/case}

{case}
<span class="current">10</span>
<a href={concat( '/user/preferences/set/', $limit_preference, '/2' )|ezurl}>25</a>
<a href={concat( '/user/preferences/set/', $limit_preference, '/3' )|ezurl}>50</a>
{/case}

{/switch}
</p>
</div>
<div class="float-break"></div>
</div>

{if $unactivated_count}
<table class="list" cellspacing="0">
<tr>
<th class="tight"><img src={'toggle-button-16x16.gif'|ezimage} width="16" height="16" alt="{'Toggle selection'|i18n( 'design/admin/user' )}" onclick="ezjs_toggleCheckboxes( document.activations, 'DeleteIDArray[]' ); return false;"/></th>
<th{cond( $sort_field|eq( 'time' ), concat( ' class="sort-', $sort_order, '"' ), '' )}><a href={concat(
$uri, '/time/', cond( and( $sort_field|eq( 'time' ), $sort_order|eq( 'asc' ) ), 'desc', 'asc' ) )|ezurl}>{'Registration date'|i18n( 'design/admin/user' )}</a></th>
<th>{'Name'|i18n( 'design/admin/user' )}</th>
<th{cond( $sort_field|eq( 'login' ), concat( ' class="sort-', $sort_order, '"' ), '' )}><a href={concat(
$uri, '/login/', cond( and( $sort_field|eq( 'login' ), $sort_order|eq( 'asc' ) ), 'desc', 'asc' ) )|ezurl}>{'Login'|i18n( 'design/admin/user' )}</a></th>
<th{cond( $sort_field|eq( 'email' ), concat( ' class="sort-', $sort_order, '"' ), '' )}><a href={concat(
$uri, '/email/', cond( and( $sort_field|eq( 'email' ), $sort_order|eq( 'asc' ) ), 'desc', 'asc' ) )|ezurl}>{'E-mail'|i18n( 'design/admin/user' )}</a></th>
</tr>
{foreach $unactivated_users as $user sequence array( 'bglight', 'bgdark' ) as $style}
<tr class="{$style}">
<td><input type="checkbox" name="DeleteIDArray[]" id="delete-{$user.contentobject_id}" value="{$user.contentobject_id}" /></td>
<td><label for="delete-{$user.contentobject_id}">{$user.account_key.time|l10n( 'shortdatetime' )}</label></td>
<td><label for="delete-{$user.contentobject_id}">{$user.contentobject.name|wash()}</label></td>
<td><label for="delete-{$user.contentobject_id}">{$user.login|wash()}</label></td>
<td><label for="delete-{$user.contentobject_id}">{$user.email|wash()}</label></td>
</tr>
{/foreach}

</table>

<div class="context-toolbar">
{include name=navigator
uri='design:navigator/google.tpl'
page_uri=concat( '/user/unactivated/', $sort_field, '/', $sort_order )
item_count=$unactivated_count
view_parameters=$view_parameters
item_limit=$number_of_items}
</div>
{else}
<div class="block">
<p>{'There are no unactivated users'|i18n( 'design/admin2/user/activations' )}</p>
</div>
{/if}

{* DESIGN: Content END *}</div></div></div>

{if $unactivated_count}
<div class="controlbar">
{* DESIGN: Control bar START *}<div class="box-bc"><div class="box-ml">
<div class="block">
<input class="button" type="submit" name="ActivateButton" value="{'Activate selected users'|i18n( 'design/admin/user' )}" title="{'Activate selected users.'|i18n( 'design/admin/user' )}" />
<input class="button" type="submit" name="RemoveButton" value="{'Remove selected users'|i18n( 'design/admin/user' )}" title="{'Remove selected users.'|i18n( 'design/admin/user' )}" />
</div>
{* DESIGN: Control bar END *}</div></div>
</div>
{/if}

</div>
</form>
{undef $uri}
36 changes: 36 additions & 0 deletions kernel/classes/datatypes/ezuser/ezuser.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ static function definition()
'keys' => array( 'contentobject_id' ),
'sort' => array( 'contentobject_id' => 'asc' ),
'function_attributes' => array( 'contentobject' => 'contentObject',
'account_key' => 'accountKey',
'groups' => 'groups',
'has_stored_login' => 'hasStoredLogin',
'original_password' => 'originalPassword',
Expand Down Expand Up @@ -286,6 +287,31 @@ static function fetchByEmail( $email, $asObject = true )
$asObject );
}

/**
* Return an array of unactivated eZUser object
*
* @param array|false|null An associative array of sorting conditions,
* if set to false ignores settings in $def, if set to null uses
* settingss in $def.
* @param int $limit
* @param int $offset
* @return array( eZUser )
*/
static public function fetchUnactivated( $sort = false, $limit = 10, $offset = 0 )
{
$accountDef = eZUserAccountKey::definition();

return eZPersistentObject::fetchObjectList(
eZUser::definition(), null, null, $sort,
array(
'limit' => $limit,
'offset' => $offset
),
true, false, null, array( $accountDef['name'] ),
" WHERE contentobject_id = user_id"
);
}

/*!
\static
\return a list of the logged in users.
Expand Down Expand Up @@ -2305,6 +2331,16 @@ function contentObject()
return null;
}

/**
* Returns the eZUserAccountKey associated with this user
*
* @return eZUserAccountKey
*/
public function accountKey()
{
return eZUserAccountKey::fetchByUserID( $this->ContentObjectID );
}

/*!
Returns true if it's a real user which is logged in. False if the user
is the default user or the fallback buildtin user.
Expand Down
16 changes: 16 additions & 0 deletions kernel/classes/datatypes/ezuser/ezuseraccountkey.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ static function fetchByKey( $hashKey )
true );
}

/**
* Return the eZUserAccountKey object associated to a user id
*
* @param int $userID
* @return eZUserAccountKey
*/
static public function fetchByUserID( $userID )
{
return eZPersistentObject::fetchObject(
eZUserAccountKey::definition(),
null,
array( 'user_id' => $userID ),
true
);
}

/*!
Remove account keys belonging to user \a $userID
*/
Expand Down
17 changes: 17 additions & 0 deletions kernel/user/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,22 @@
'default_navigation_part' => 'ezmynavigationpart',
'params' => array( ) );

$ViewList['unactivated'] = array(
'functions' => array( 'activation' ),
'script' => 'unactivated.php',
'ui_context' => 'administration',
'default_navigation_part' => 'ezusernavigationpart',
'unordered_params' => array( 'offset' => 'Offset' ),
'single_post_actions' => array(
'ActivateButton' => 'ActivateUsers',
'RemoveButton' => 'RemoveUsers'
),
'post_action_parameters' => array(
'ActivateUsers' => array( 'UserIDs' => 'DeleteIDArray' ),
'RemoveUsers' => array( 'UserIDs' => 'DeleteIDArray' ),
),
'params' => array( 'SortField', 'SortOrder' ),
);

$SiteAccess = array(
'name'=> 'SiteAccess',
Expand All @@ -122,5 +138,6 @@
$FunctionList['preferences'] = array();
$FunctionList['register'] = array();
$FunctionList['selfedit'] = array();
$FunctionList['activation'] = array();

?>
Loading

0 comments on commit cc4d809

Please sign in to comment.