by
KK » Tue Aug 22, 2017 6:16 pm
@Tanja,
As @trendoman tried to explain, normally it shouldn't be that difficult for clients to get the difference.
However, if you don't agree with that assertion, we can try to normalize things somewhat as follows (thanks to v2.0)
Broadly speaking, there are two points that are bothering you -
1. The same user accounts appear at two different places.
2. The field layout of the accounts are slightly different at both the places.
To fix the first issue, please place the following in your 'addons/kfunctions.php' file -
- Code: Select all
// Exclude non-admins from the listing in users section
if( !$_GET['debug'] ){
$FUNCS->add_event_listener( 'alter_render_vars_content_list_inner', 'my_alter_render_vars', -10 );
}
function my_alter_render_vars( &$templates, $render ){
global $CTX, $FUNCS, $DB, $KUSER;
if( $render=='content_list_inner' ){
$route = $FUNCS->current_route;
if( is_object($route) ){
$tables = K_TBL_USERS .' as u, '. K_TBL_USER_LEVELS .' as lvl';
$where = 'u.access_level = lvl.k_level AND u.access_level >= '.K_ACCESS_LEVEL_AUTHENTICATED_SPECIAL;
if( $route->module=='users' ){
// modify SQL for cms:query within the template to exclude non-admins from core users listing
$fields = 'u.id as id, u.name as name, u.title as title, u.email as email, u.system as is_system, lvl.title as level_str, lvl.k_level as level';
$orderby .= 'u.access_level DESC, u.name ASC';
$sql = 'SELECT ' . $fields . ' FROM ' . $tables . ' WHERE ' . $where . ' ORDER BY ' . $orderby;
$CTX->set( 'k_selected_query', $sql );
}
elseif( $route->module=='pages' && is_object($KUSER) && $KUSER->users_tpl!='' && $route->masterpage==$KUSER->users_tpl ){
$fields = array( 'u.name as name' );
// exclude admins from extended-users listing
$rows = $DB->select( $tables, $fields, $where );
$str_users = '';
foreach( $rows as $r ){
$str_users .= ',' . $r['name'];
}
$exclude = $CTX->get( 'k_selected_exclude', 2 /*global*/ );
$CTX->set( 'k_selected_exclude', $exclude.$str_users, 'global' );
}
}
}
}
And now when you visit the core users section you'll find that it shows only the admin/super-admin/special accounts (i.e. skips all lowest level accounts that are created from the front-end using the extended template).
If for (perhaps debugging) you'd want to see all accounts listed here, add a
&debug=1 to the URL in admin panel and that would remove this filter temporarily.
So now, the accounts are neatly segregated in two places -
1. All admin level accounts are in core
2. All lower level accounts (usually created from front-end) are in the extended users template.
I suppose this should be a reasonable distinction for the client to come to terms with without getting confused. What do you say?
Coming to the second issue (different field layouts), we can normalize that by using <cms:config_form_view> in you extended template.
Following is the full code of your template with the new configuration -
- Code: Select all
<?php require_once( '../couch/cms.php' ); ?>
<cms:template clonable='1' title='MITGLIEDER'>
<!--
If additional fields are required for users, they can be defined here in the usual manner.
-->
<cms:editable name='test_field' label='Test field' type='text' />
<!--
config form GUI
-->
<cms:config_form_view>
<cms:persist
k_publish_date="
<cms:if frm_my_disabled='1'>
0000-00-00 00:00:00
<cms:else/>
<cms:if k_cur_form_mode='edit' && k_page_date!='0000-00-00 00:00:00'>
<cms:show k_page_date />
<cms:else />
<cms:date format='Y-m-d H:i:s' />
</cms:if>
</cms:if>"
_auto_title='1'
/>
<cms:style>
#settings-panel{display: none; }
</cms:style>
<cms:field 'extended_user_id' hide='1' />
<cms:field 'k_page_name' label="<cms:localize 'user_name' />" desc="<cms:localize 'user_name_restrictions' />" order='-7' />
<cms:field 'k_page_title' label="<cms:localize 'display_name' />" order='-6' />
<cms:field 'extended_user_email' label="<cms:localize 'email' />" group='_system_fields_' order='-5' />
<cms:field 'my_disabled' label="<cms:localize 'disabled' />" group='_system_fields_' order='-4'>
<cms:input
type='singlecheck'
id=k_field_input_id
name=k_field_input_name
field_label="<cms:localize 'disabled' />"
value="<cms:if k_page_date='0000-00-00 00:00:00'>1<cms:else />0</cms:if>"
/>
</cms:field>
<cms:field 'extended_user_password' label="<cms:localize 'new_password' />" desc="<cms:localize 'new_password_msg' />" group='_system_fields_' order='-3' />
<cms:field 'extended_user_password_repeat' label="<cms:localize 'repeat_password' />" desc="<cms:localize 'repeat_password_msg' />" group='_system_fields_' order='-2' />
</cms:config_form_view>
</cms:template>
<?php COUCH::invoke(); ?>
Visit the modified template as super-admin for the change to persist.
Coming back to the admin panel, you should see the cloned pages of the extended-user template display their fields as follows -

- b.png (22.64 KiB) Viewed 8152 times
Compare that to how the core user account shows up -

- a.png (22.37 KiB) Viewed 8152 times
Baring a few minor differences, I am sure you'll agree that both look almost the same.
Does this help? Please let me know.