From 7e1e705f8ba79c7579a1c433ad6cf3488a4e349b Mon Sep 17 00:00:00 2001 From: patdenice Date: Wed, 5 Mar 2008 17:54:32 +0000 Subject: user_list.tpl goes smarty. Correction in plugins update and delete options. git-svn-id: http://piwigo.org/svn/trunk@2253 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/plugins.php | 62 ++++---- admin/user_list.php | 293 ++++++++---------------------------- template/yoga/admin/user_list.tpl | 302 +++++++++++++++++--------------------- 3 files changed, 233 insertions(+), 424 deletions(-) diff --git a/admin/plugins.php b/admin/plugins.php index d40158b33..a4260513b 100644 --- a/admin/plugins.php +++ b/admin/plugins.php @@ -34,6 +34,34 @@ check_status(ACCESS_ADMINISTRATOR); $my_base_url = PHPWG_ROOT_PATH.'admin.php?page=plugins'; +// +-----------------------------------------------------------------------+ +// | Sections definitions | +// +-----------------------------------------------------------------------+ +if (empty($_GET['section'])) +{ + $page['section'] = 'list'; +} +else +{ + $page['section'] = $_GET['section']; +} + +$tab_link = $my_base_url . '&section='; + +// TabSheet +$tabsheet = new tabsheet(); +// TabSheet initialization +$tabsheet->add('list', l10n('plugins_tab_list'), $tab_link.'list'); +$tabsheet->add('update', l10n('plugins_tab_update'), $tab_link.'update'); +$tabsheet->add('new', l10n('plugins_tab_new'), $tab_link.'new'); +// TabSheet selection +$tabsheet->select($page['section']); +// Assign tabsheet to template +$tabsheet->assign(); + +$my_base_url .= '§ion=' . $page['section']; + + // +-----------------------------------------------------------------------+ // | perform requested actions | // +-----------------------------------------------------------------------+ @@ -153,7 +181,11 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id="' . $plugin_id . '"'; break; case 'delete': - if (!deltree(PHPWG_PLUGINS_PATH . $plugin_id)) + if (!empty($crt_db_plugin)) + { + array_push($errors, 'CANNOT delete - PLUGIN IS INSTALLED'); + } + elseif (!deltree(PHPWG_PLUGINS_PATH . $plugin_id)) { send_to_trash(PHPWG_PLUGINS_PATH . $plugin_id); } @@ -176,34 +208,6 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id="' . $plugin_id . '"'; } -// +-----------------------------------------------------------------------+ -// | Sections definitions | -// +-----------------------------------------------------------------------+ -if (empty($_GET['section'])) -{ - $page['section'] = 'list'; -} -else -{ - $page['section'] = $_GET['section']; -} - -$tab_link = $my_base_url . '&section='; - -// TabSheet -$tabsheet = new tabsheet(); -// TabSheet initialization -$tabsheet->add('list', l10n('plugins_tab_list'), $tab_link.'list'); -$tabsheet->add('update', l10n('plugins_tab_update'), $tab_link.'update'); -$tabsheet->add('new', l10n('plugins_tab_new'), $tab_link.'new'); -// TabSheet selection -$tabsheet->select($page['section']); -// Assign tabsheet to template -$tabsheet->assign(); - -$my_base_url .= '§ion=' . $page['section']; - - // +-----------------------------------------------------------------------+ // | start template output | // +-----------------------------------------------------------------------+ diff --git a/admin/user_list.php b/admin/user_list.php index 6e648101f..3b7194594 100644 --- a/admin/user_list.php +++ b/admin/user_list.php @@ -450,7 +450,7 @@ DELETE FROM '.USER_GROUP_TABLE.' // | groups list | // +-----------------------------------------------------------------------+ -$groups = array(); +$groups[-1] = '------------'; $query = ' SELECT id, name @@ -481,7 +481,7 @@ else $start = 0; } -$template->assign_vars( +$template->assign( array( 'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=user_list', @@ -490,93 +490,42 @@ $template->assign_vars( 'F_FILTER_ACTION' => PHPWG_ROOT_PATH.'admin.php' )); -if (isset($_GET['id'])) -{ - $template->assign_block_vars('session', array('ID' => $_GET['id'])); -} - // Hide radio-button if not allow to assign adviser if ($conf['allow_adviser']) { - $template->assign_block_vars('adviser', array()); + $template->assign('adviser', true); } -foreach ($page['order_by_items'] as $item => $label) +// Filter status options +$status_options[-1] = '------------'; +foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) { - $selected = (isset($_GET['order_by']) and $_GET['order_by'] == $item) ? - 'selected="selected"' : ''; - $template->assign_block_vars( - 'order_by', - array( - 'VALUE' => $item, - 'CONTENT' => $label, - 'SELECTED' => $selected - )); + $status_options[$status] = l10n('user_status_'.$status); } +$template->assign('status_options', $status_options); +$template->assign('status_selected', + isset($_GET['status']) ? $_GET['status'] : ''); -foreach ($page['direction_items'] as $item => $label) -{ - $selected = (isset($_GET['direction']) and $_GET['direction'] == $item) ? - 'selected="selected"' : ''; - $template->assign_block_vars( - 'direction', - array( - 'VALUE' => $item, - 'CONTENT' => $label, - 'SELECTED' => $selected - )); -} +// Filter group options +$template->assign('group_options', $groups); +$template->assign('group_selected', + isset($_GET['group']) ? $_GET['group'] : ''); -$blockname = 'group_option'; +// Filter order options +$template->assign('order_options', $page['order_by_items']); +$template->assign('order_selected', + isset($_GET['order_by']) ? $_GET['order_by'] : ''); -$template->assign_block_vars( - $blockname, - array( - 'VALUE'=> -1, - 'CONTENT' => '------------', - 'SELECTED' => '' - )); +// Filter direction options +$template->assign('direction_options', $page['direction_items']); +$template->assign('direction_selected', + isset($_GET['direction']) ? $_GET['direction'] : ''); -foreach ($groups as $group_id => $group_name) -{ - $selected = (isset($_GET['group']) and $_GET['group'] == $group_id) ? - 'selected="selected"' : ''; - $template->assign_block_vars( - $blockname, - array( - 'VALUE' => $group_id, - 'CONTENT' => $group_name, - 'SELECTED' => $selected - )); -} - -$blockname = 'status_option'; - -$template->assign_block_vars( - $blockname, - array( - 'VALUE'=> -1, - 'CONTENT' => '------------', - 'SELECTED' => '' - )); - -foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) -{ - $selected = (isset($_GET['status']) and $_GET['status'] == $status) ? - 'selected="selected"' : ''; - $template->assign_block_vars( - $blockname, - array( - 'VALUE' => $status, - 'CONTENT' => l10n('user_status_'.$status), - 'SELECTED' => $selected - )); -} if (isset($_POST['pref_submit'])) { // echo '
'; print_r($_POST); echo '
'; - $template->assign_vars( + $template->assign( array( 'ADVISER_YES' => 'true' == (isset($_POST['adviser']) and $_POST['adviser']) ? 'checked="checked"' : '', 'ADVISER_NO' => 'false' == (isset($_POST['adviser']) and $_POST['adviser']) ? 'checked="checked"' : '', @@ -587,22 +536,28 @@ if (isset($_POST['pref_submit'])) 'RECENT_PERIOD' => $_POST['recent_period'], 'EXPAND_YES' => 'true' == $_POST['expand'] ? 'checked="checked"' : '', 'EXPAND_NO' => 'false' == $_POST['expand'] ? 'checked="checked"' : '', - 'SHOW_NB_COMMENTS_YES' => - 'true' == $_POST['show_nb_comments'] ? 'checked="checked"' : '', - 'SHOW_NB_COMMENTS_NO' => - 'false' == $_POST['show_nb_comments'] ? 'checked="checked"' : '', - 'SHOW_NB_HITS_YES' => - 'true' == $_POST['show_nb_hits'] ? 'checked="checked"' : '', - 'SHOW_NB_HITS_NO' => - 'false' == $_POST['show_nb_hits'] ? 'checked="checked"' : '', + 'SHOW_NB_COMMENTS_YES' => 'true' == $_POST['show_nb_comments'] ? 'checked="checked"' : '', + 'SHOW_NB_COMMENTS_NO' => 'false' == $_POST['show_nb_comments'] ? 'checked="checked"' : '', + 'SHOW_NB_HITS_YES' => 'true' == $_POST['show_nb_hits'] ? 'checked="checked"' : '', + 'SHOW_NB_HITS_NO' => 'false' == $_POST['show_nb_hits'] ? 'checked="checked"' : '', 'ENABLED_HIGH_YES' => 'true' == $_POST['enabled_high'] ? 'checked="checked"' : '', 'ENABLED_HIGH_NO' => 'false' == $_POST['enabled_high'] ? 'checked="checked"' : '', + + 'STATUS_ACTION_SET' => 'set' == $_POST['status_action'] ? 'checked="checked"' : '', + 'LEVEL_ACTION_SET' => 'set' == $_POST['level_action'] ? 'checked="checked"' : '', + 'NB_IMAGE_LINE_ACTION_SET' => 'set' == $_POST['nb_image_line_action'] ? 'checked="checked"' : '', + 'NB_LINE_PAGE_ACTION_SET' => 'set' == $_POST['nb_line_page_action'] ? 'checked="checked"' : '', + 'TEMPLATE_ACTION_SET' => 'set' == $_POST['template_action'] ? 'checked="checked"' : '', + 'LANGUAGE_ACTION_SET' => 'set' == $_POST['language_action'] ? 'checked="checked"' : '', + 'RECENT_PERIOD_ACTION_SET' => 'set' == $_POST['recent_period_action'] ? 'checked="checked"' : '', + 'MAXWIDTH_ACTION_SET' => 'set' == $_POST['maxwidth_action'] ? 'checked="checked"' : '', + 'MAXHEIGHT_ACTION_SET' => 'set' == $_POST['maxheight_action'] ? 'checked="checked"' : '', )); } else { $default_user = get_default_user_info(true); - $template->assign_vars( + $template->assign( array( 'NB_IMAGE_LINE' => $default_user['nb_image_line'], 'NB_LINE_PAGE' => $default_user['nb_line_page'], @@ -612,162 +567,45 @@ else )); } -$blockname = 'template_option'; +// Template Options +$template->assign('template_options', get_pwg_themes()); +$template->assign('template_selected', + isset($_POST['pref_submit']) ? $_POST['template'] : get_default_template()); -foreach (get_pwg_themes() as $pwg_template) -{ - if (isset($_POST['pref_submit'])) - { - $selected = $_POST['template']==$pwg_template ? 'selected="selected"' : ''; - } - else if (get_default_template() == $pwg_template) - { - $selected = 'selected="selected"'; - } - else - { - $selected = ''; - } - - $template->assign_block_vars( - $blockname, - array( - 'VALUE'=> $pwg_template, - 'CONTENT' => $pwg_template, - 'SELECTED' => $selected - )); -} - -$blockname = 'language_option'; - -foreach (get_languages() as $language_code => $language_name) -{ - if (isset($_POST['pref_submit'])) - { - $selected = $_POST['language']==$language_code ? 'selected="selected"':''; - } - else if (get_default_language() == $language_code) - { - $selected = 'selected="selected"'; - } - else - { - $selected = ''; - } - - $template->assign_block_vars( - $blockname, - array( - 'VALUE'=> $language_code, - 'CONTENT' => $language_name, - 'SELECTED' => $selected - )); -} - -$blockname = 'pref_status_option'; +// Language options +$template->assign('language_options', get_languages()); +$template->assign('language_selected', + isset($_POST['pref_submit']) ? $_POST['language'] : get_default_language()); +// Status options foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) { - if (isset($_POST['pref_submit'])) - { - $selected = $_POST['status'] == $status ? 'selected="selected"' : ''; - } - else if ('normal' == $status) - { - $selected = 'selected="selected"'; - } - else - { - $selected = ''; - } - // Only status <= can be assign if (is_autorize_status(get_access_type_status($status))) { - $template->assign_block_vars( - $blockname, - array( - 'VALUE' => $status, - 'CONTENT' => l10n('user_status_'.$status), - 'SELECTED' => $selected - )); + $pref_status_options[$status] = l10n('user_status_'.$status); } } +$template->assign('pref_status_options', $pref_status_options); +$template->assign('pref_status_selected', + isset($_POST['pref_submit']) ? $_POST['status'] : 'normal'); -// associate -$blockname = 'associate_option'; +// associate and dissociate options +$template->assign('association_options', $groups); +$template->assign('associate_selected', + isset($_POST['pref_submit']) ? $_POST['associate'] : ''); +$template->assign('dissociate_selected', + isset($_POST['pref_submit']) ? $_POST['dissociate'] : ''); -$template->assign_block_vars( - $blockname, - array( - 'VALUE'=> -1, - 'CONTENT' => '------------', - 'SELECTED' => '' - )); - -foreach ($groups as $group_id => $group_name) -{ - if (isset($_POST['pref_submit'])) - { - $selected = $_POST['associate'] == $group_id ? 'selected="selected"' : ''; - } - else - { - $selected = ''; - } - - $template->assign_block_vars( - $blockname, - array( - 'VALUE' => $group_id, - 'CONTENT' => $group_name, - 'SELECTED' => $selected - )); -} - -// dissociate -$blockname = 'dissociate_option'; - -$template->assign_block_vars( - $blockname, - array( - 'VALUE'=> -1, - 'CONTENT' => '------------', - 'SELECTED' => '' - )); - -foreach ($groups as $group_id => $group_name) -{ - if (isset($_POST['pref_submit'])) - { - $selected = $_POST['dissociate'] == $group_id ? 'selected="selected"' : ''; - } - else - { - $selected = ''; - } - - $template->assign_block_vars( - $blockname, - array( - 'VALUE' => $group_id, - 'CONTENT' => $group_name, - 'SELECTED' => $selected - )); -} // user level options -$blockname = 'level_option'; foreach ($conf['available_permission_levels'] as $level) { - $template->assign_block_vars( - $blockname, - array( - 'VALUE' => $level, - 'CONTENT' => l10n( sprintf('Level %d', $level) ), - 'SELECTED' => $level==$default_user['level'] ? 'selected="selected"' : '', - )); + $level_options[$level] = l10n(sprintf('Level %d', $level)); } +$template->assign('level_options', $level_options); +$template->assign('level_selected', + isset($_POST['pref_submit']) ? $_POST['level'] : $default_user['level']); // +-----------------------------------------------------------------------+ // | navigation bar | @@ -782,7 +620,7 @@ $navbar = create_navigation_bar( $conf['users_page'] ); -$template->assign_vars(array('NAVBAR' => $navbar)); +$template->assign('NAVBAR', $navbar); // +-----------------------------------------------------------------------+ // | user list | @@ -840,10 +678,9 @@ foreach ($visible_user_list as $num => $local_user) (isset($local_user['enabled_high']) and ($local_user['enabled_high'] == 'true')) ? l10n('is_high_enabled') : l10n('is_high_disabled'); - $template->assign_block_vars( - 'user', + $template->append( + 'users', array( - 'CLASS' => ($num % 2 == 1) ? 'row2' : 'row1', 'ID' => $local_user['id'], 'CHECKED' => $checked, 'U_PROFILE' => $profile_url.$local_user['id'], @@ -861,7 +698,7 @@ foreach ($visible_user_list as $num => $local_user) 'PROPERTIES' => implode( ', ', $properties), ) ); - trigger_action('loc_assign_block_var_local_user_list', $local_user); + trigger_action('loc_append_user_list', $local_user); } // +-----------------------------------------------------------------------+ diff --git a/template/yoga/admin/user_list.tpl b/template/yoga/admin/user_list.tpl index 594ab9670..ffb0d651e 100644 --- a/template/yoga/admin/user_list.tpl +++ b/template/yoga/admin/user_list.tpl @@ -1,173 +1,147 @@ - +{* $Id$ *}
-

{lang:title_liste_users}

+

{'title_liste_users'|@translate}

-
+
- {lang:Add a user} - - - - + {'Add a user'|@translate} + + + +
-
+
- {lang:Filter} + {'Filter'|@translate} - + - +
-
+ - - - - - - - - - + + + + + + {foreach from=$cpl_title_user item=title} + + {/foreach} + - - - - - - - - - - - + {foreach from=$users item=user name=users_loop} + + + + + + + + {foreach from=$cpl_user[$smarty.foreach.users_loop.index] item=data} + + {/foreach} + {'permissions'|@translate} + {'Profile'|@translate} + {foreach from=$cpl_link_user[$smarty.foreach.users_loop.index] item=data} + {$data} + {/foreach} + - + {/foreach}
 {lang:Username}{lang:user_status}{lang:Email address}{lang:Groups}{lang:properties}{cpl_title_user.CAPTION}{lang:actions}{'Username'|@translate}{'user_status'|@translate}{'Email address'|@translate}{'Groups'|@translate}{'properties'|@translate}{$title}{'actions'|@translate}
{user.STATUS}{user.EMAIL}{user.GROUPS}{user.PROPERTIES}{user.cpl_user.DATA}
{$user.STATUS}{$user.EMAIL}{$user.GROUPS}{$user.PROPERTIES}{$data} - {lang:permissions} - {lang:Profile} - - {user.cpl_link_user.DATA} - -
- + - +{* delete the selected users ? *}
- {lang:Deletions} - - + {'Deletions'|@translate} + +
- {lang:Status} + {'Status'|@translate} - + - + {if isset($adviser)} - + - + {/if}
{lang:Status}{'Status'|@translate} - - + +
{lang:adviser}{'adviser'|@translate} - - / {lang:set to} - - + + / {'set to'|@translate} + +
- +{* form to set properties for many users at once *}
- {lang:Groups} + {'Groups'|@translate} - + - + @@ -175,31 +149,29 @@ - +{* Properties *}
- {lang:properties} + {'properties'|@translate}
{lang:associate to group}{'associate to group'|@translate} - + {html_options name=associate options=$association_options selected=$associate_selected}
{lang:dissociate from group}{'dissociate from group'|@translate} - + {html_options name=dissociate options=$association_options selected=$dissociate_selected}
- + - + @@ -208,118 +180,114 @@ - +{* preference *}
- {lang:Preferences} + {'Preferences'|@translate}
{lang:enabled_high}{'enabled_high'|@translate} - - / {lang:set to} - - + + / {'set to'|@translate} + +
{lang:Privacy level}{'Privacy level'|@translate} - - + +
- + - + - + - + - + - + - + - + - + - + @@ -329,14 +297,14 @@

- {lang:target} - - + {'target'|@translate} + +

- - + +

-- cgit v1.2.3
{lang:nb_image_per_row}{'nb_image_per_row'|@translate} - - + + + size="3" maxlength="2" type="text" name="nb_image_line" value="{$NB_IMAGE_LINE}" />
{lang:nb_row_per_page}{'nb_row_per_page'|@translate} - - + + + size="3" maxlength="2" type="text" name="nb_line_page" value="{$NB_LINE_PAGE}" />
{lang:theme}{'theme'|@translate} - - + +
{lang:language}{'language'|@translate} - - + +
{lang:recent_period}{'recent_period'|@translate} - - + + + type="text" size="3" maxlength="2" name="recent_period" value="{$RECENT_PERIOD}" />
{lang:auto_expand}{'auto_expand'|@translate} - - / {lang:set to} - - + + / {'set to'|@translate} + +
{lang:show_nb_comments}{'show_nb_comments'|@translate} - - / {lang:set to} - - + + / {'set to'|@translate} + +
{lang:show_nb_hits}{'show_nb_hits'|@translate} - - / {lang:set to} - - + + / {'set to'|@translate} + +
{lang:maxwidth}{'maxwidth'|@translate} - - - + + + + type="text" size="4" maxlength="4" name="maxwidth" value="{$MAXWIDTH}" />
{lang:maxheight}{'maxheight'|@translate} - - - + + + + type="text" size="4" maxlength="4" name="maxheight" value="{$MAXHEIGHT}" />