From ed37c3c3ccfe6b0bc15315fe79d5eef0b441fa9f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 14 Jul 2011 15:38:07 +0000 Subject: [PATCH] Menu system fixes, list_user simplified: - Menu entry 'add_points' has truncated output due to to short VARCHAR - what=list_user and correspondig functions simplified towards XML-rewrite - TODOs.txt updated --- DOCS/TODOs.txt | 18 +-- inc/extensions/ext-menu.php | 14 +- inc/libs/user_functions.php | 133 +++++++----------- inc/modules/admin/admin-inc.php | 4 +- inc/modules/admin/what-list_user.php | 13 +- inc/mysql-connect.php | 2 +- templates/de/html/admin/admin_list_user.tpl | 8 +- .../de/html/admin/admin_list_user_alpha.tpl | 2 +- .../de/html/admin/admin_list_user_pagenav.tpl | 2 +- .../de/html/admin/admin_list_user_sort.tpl | 2 +- .../html/admin/admin_list_user_sort_form.tpl | 15 +- 11 files changed, 86 insertions(+), 127 deletions(-) diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 89adf4e7d6..3095100005 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -54,9 +54,9 @@ ./inc/functions.php:2214: // @TODO Rename column data_type to e.g. mail_status ./inc/gen_sql_patches.php:95:// @TODO Rewrite this to a filter ./inc/install-functions.php:57: // @TODO DEACTIVATED: changeDataInLocalConfigurationFile('OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0); -./inc/language/de.php:1062: // @TODO Rewrite these two constants -./inc/language/de.php:1078: // @TODO Rewrite these three constants -./inc/language/de.php:754:// @TODO Are these constants longer used? +./inc/language/de.php:1065: // @TODO Rewrite these two constants +./inc/language/de.php:1081: // @TODO Rewrite these three constants +./inc/language/de.php:757:// @TODO Are these constants longer used? ./inc/language-functions.php:255: // @TODO These are all valid languages, again hard-coded ./inc/language-functions.php:44:// @TODO Rewrite all language constants to this function. ./inc/language/newsletter_de.php:13: * @TODO This language file is completely out-dated, please do no * @@ -81,10 +81,9 @@ ./inc/libs/task_functions.php:247: // @TODO These can be rewritten to filter ./inc/libs/task_functions.php:51:// @TODO Move all extension-dependent queries into filters ./inc/libs/theme_functions.php:93: // @TODO Can't this be rewritten to an API function? -./inc/libs/user_functions.php:159: // @TODO These two constants are no longer used, maybe we reactivate this code? -./inc/libs/user_functions.php:250:// @TODO Double-check configuration entry here -./inc/libs/user_functions.php:344: // @TODO Make this filter working: $ADDON = runFilterChain('post_login_update', $content); -./inc/libs/user_functions.php:373: // @TODO Make this filter working: $url = runFilterChain('do_login', array('content' => $content, 'addon' => $ADDON)); +./inc/libs/user_functions.php:221:// @TODO Double-check configuration entry here +./inc/libs/user_functions.php:315: // @TODO Make this filter working: $ADDON = runFilterChain('post_login_update', $content); +./inc/libs/user_functions.php:344: // @TODO Make this filter working: $url = runFilterChain('do_login', array('content' => $content, 'addon' => $ADDON)); ./inc/libs/yoomedia_functions.php:114: $response = YOOMEDIA_QUERY_API('out_textmail.php', true); // @TODO Ask Yoo!Media for test script ./inc/load_config.php:75: // @TODO Rewrite them to avoid this else block ./inc/loader/load-extension.php:13: * @TODO Rewrite this whole file * @@ -136,8 +135,8 @@ ./inc/modules/admin/what-list_refs.php:107: // @TODO Try to rewrite some to EL ./inc/modules/admin/what-list_unconfirmed.php:107: // @TODO "Please do not call me directly." Should be rewritten to a nice selection depending on ext-bonus ./inc/modules/admin/what-list_unconfirmed.php:84: // @TODO This constant might be unused? define('__LIST_UNCON_TITLE', '{--ADMIN_LIST_UNCONFIRMED_BONUS_LINKS--}'); -./inc/modules/admin/what-list_user.php:254: // @TODO Rewrite this into a filter -./inc/modules/admin/what-list_user.php:297: // @TODO Rewrite this into a filter +./inc/modules/admin/what-list_user.php:247: // @TODO Rewrite this into a filter +./inc/modules/admin/what-list_user.php:290: // @TODO Rewrite this into a filter ./inc/modules/admin/what-logs.php:64: // @TODO Fix content-type here ./inc/modules/admin/what-logs.php:70: // @TODO Fix content-type here ./inc/modules/admin/what-mem_add.php:124: // @TODO This can be somehow rewritten to a function @@ -313,6 +312,7 @@ ./templates/de/html/admin/admin_list_chk_reg.tpl:1: ./templates/de/html/admin/admin_list_country_del_row.tpl:1: ./templates/de/html/admin/admin_list_country_edit_row.tpl:1: +./templates/de/html/admin/admin_list_user_sort_form.tpl:1: ./templates/de/html/admin/admin_reset_pass_done.tpl:1: ./templates/de/html/admin/admin_send_reset_link.tpl:1: ./templates/de/html/member/member_refback_edit.tpl:1: diff --git a/inc/extensions/ext-menu.php b/inc/extensions/ext-menu.php index bb365bdcbb..c7e9681b92 100644 --- a/inc/extensions/ext-menu.php +++ b/inc/extensions/ext-menu.php @@ -41,10 +41,10 @@ if (!defined('__SECURITY')) { } // END - if // Version number -setThisExtensionVersion('0.0.3'); +setThisExtensionVersion('0.0.4'); // Version history array (add more with , '0.0.1' and so on) -setExtensionVersionHistory(array('0.0.0','0.0.1','0.0.2','0.0.3')); +setExtensionVersionHistory(array('0.0.0','0.0.1','0.0.2','0.0.3', '0.0.4')); switch (getExtensionMode()) { case 'register': // Do stuff when installation is running @@ -95,10 +95,18 @@ switch (getExtensionMode()) { case '0.0.3': // SQL queries for v0.0.3 // Change menu-string - addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `title` = 'Admin-Menü editieren' WHERE `what` = 'adminedit' LIMIT 1"); + addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `title`='Admin-Menü editieren' WHERE `what` = 'adminedit' LIMIT 1"); setExtensionUpdateNotes("Menüpunkt 'Vom Admin editieren' in 'Admin-Menü editieren' bei bereits bestehenden Installationen umändern."); break; + + case '0.0.4': // SQL queries for v0.0.4 + // Change menu-string + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admin_menu` CHANGE `title` `title` VARCHAR(255) NOT NULL DEFAULT ''"); + addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `title`='{OPEN_TEMPLATE}DEFAULT_POINTS{CLOSE_TEMPLATE} gutschreiben' WHERE `what` = 'add_points' LIMIT 1"); + + setExtensionUpdateNotes("VARCHAR(50) ist zu kurz für Linktitel (wegen der dynamischen Anteile)."); + break; } // END - switch break; diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php index b7d06247d8..64a95f39ef 100644 --- a/inc/libs/user_functions.php +++ b/inc/libs/user_functions.php @@ -41,12 +41,9 @@ if (!defined('__SECURITY')) { } // END - if // Add links for selecting some users -function alpha ($sortby, $colspan, $return=false) { - if (!isGetRequestParameterSet('offset')) { - setGetRequestParameter('offset', 0); - } // END - if - $add = '&page=' . getRequestParameter('page').'&offset=' . getRequestParameter('offset'); - foreach (array('mode','status') as $param) { +function alpha ($sortby) { + $add = ''; + foreach (array('page','offset','mode','status') as $param) { if (isGetRequestParameterSet($param)) { $add .= '&' . $param . '=' . getRequestParameter($param); } // END - if @@ -62,13 +59,7 @@ function alpha ($sortby, $colspan, $return=false) { $OUT .= '' . $ltr . ''; } else { // Output link to letter - $OUT .= '' . $ltr . ''; + $OUT .= '' . $ltr . ''; } if ((($counter / getConfig('user_alpha')) == round($counter / getConfig('user_alpha'))) && ($counter > 0)) { @@ -80,23 +71,18 @@ function alpha ($sortby, $colspan, $return=false) { // Prepare content $content = array ( - 'colspan2' => $colspan, 'alpha_selection' => $OUT ); // Load template $OUT = loadTemplate('admin_list_user_alpha', true, $content); - if ($return === true) { - // Return generated code - return $OUT; - } else { - // Output generated code - outputHtml($OUT); - } + + // Return generated code + return $OUT; } // Add links for sorting -function addSortLinks ($letter, $sortby, $colspan, $return=false) { +function addSortLinks ($letter, $sortby) { $OUT = ''; if (!isGetRequestParameterSet('offset')) setGetRequestParameter('offset', 0); if (!isGetRequestParameterSet('page')) setGetRequestParameter('page' , 0); @@ -137,82 +123,67 @@ function addSortLinks ($letter, $sortby, $colspan, $return=false) { } } // END - foreach - // Add list and colspan + // Add output $content['list'] = substr($OUT, 0, -1); - $content['colspan2'] = $colspan; // Load template $OUT = loadTemplate('admin_list_user_sort', true, $content); - // Should we return or output? - if ($return === true) { - // Return code - return $OUT; - } else { - // Output code - outputHtml($OUT); - } + // Return code + return $OUT; } // Add page navigation -function addPageNavigation ($numPages, $offset, $showForm, $colspan, $return=false) { - // @TODO These two constants are no longer used, maybe we reactivate this code? - //if ($showForm === true) { - // // Load form for changing number of lines - // define('__FORM_HEADER', loadTemplate('admin_list_user_sort_form', true)); - // define('__FORM_FOOTER', ' '); - //} else { - // // Empty row - // define('__FORM_HEADER', ' '); - // define('__FORM_FOOTER', ' '); - //} - +function addPageNavigation ($numPages) { + // Start with empty content $OUT = ''; - for ($page = 1; $page <= $numPages; $page++) { - if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) { - $OUT .= '-'; - } else { - if (!isGetRequestParameterSet('letter')) setGetRequestParameter('letter', ''); - if (!isGetRequestParameterSet('sortby')) setGetRequestParameter('sortby', 'userid'); - // Base link - $OUT .= ''; - } + // Add status/mode + foreach (array('mode','status') as $param) { + if (isGetRequestParameterSet($param)) { + $OUT .= '&' . $param . '=' . getRequestParameter($param); + } // END - if + } // END - foreach + + // Letter and so on + $OUT .= '&letter=' . getRequestParameter('letter') . '&sortby=' . getRequestParameter('sortby') . '&page=' . $page . '&offset=' . getConfig('user_limit') . '%}">'; + } - $OUT .= $page; + $OUT .= $page; - if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) { - $OUT .= '-'; - } else { - $OUT .= ''; - } + if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) { + $OUT .= '-'; + } else { + $OUT .= ''; + } - if ($page < $numPages) $OUT .= '|'; - } // END - for + if ($page < $numPages) { + $OUT .= '|'; + } // END - if + } // END - for - // Remember the list and colspan - $content['list'] = $OUT; - $content['colspan2'] = $colspan; + // Add list output + $content['list'] = $OUT; - // Load template - $OUT = loadTemplate('admin_list_user_pagenav', true, $content); - if ($return === true) { - // Return code - return $OUT; - } else { - // Output code - outputHtml($OUT); - } + // Load template + $OUT = loadTemplate('admin_list_user_pagenav', true, $content); + } // END - if + + // Return code + return $OUT; } // Create email link to user's account diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 18f99003fc..b7537c8b60 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -626,9 +626,9 @@ function generateUserProfileLink ($userid, $title = '', $what = 'list_user') { if (($title == '') && (isValidUserId($userid))) { // Set userid as title $title = $userid; - } elseif ($userid == 0) { + } elseif (!isValidUserId($userid)) { // User id zero is invalid - return '' . $userid . ''; + return '' . makeNullToZero($userid) . ''; } if (($title == '0') && ($what == 'list_refs')) { diff --git a/inc/modules/admin/what-list_user.php b/inc/modules/admin/what-list_user.php index 0c86176452..58bc853aa3 100644 --- a/inc/modules/admin/what-list_user.php +++ b/inc/modules/admin/what-list_user.php @@ -45,7 +45,6 @@ addYouAreHereLink('admin', __FILE__); // Init variables $MORE = ''; -$colspan = 4; // Add lock reason? if (isExtensionInstalledAndNewer('user', '0.3.5')) { @@ -238,17 +237,11 @@ LIMIT 1", // Are there some entries? if (!SQL_HASZERONUMS($result_master)) { // We have some (new?) registrations! - $templateContent['colspan2'] = ($colspan + 2); $templateContent['user_count'] = getTotalConfirmedUser(); - // Sorting links - $templateContent['alpha_sort'] = alpha(getRequestParameter('sortby'), ($colspan + 1), true); - $templateContent['sort_links'] = addSortLinks(getRequestParameter('letter'), getRequestParameter('sortby'), ($colspan + 1), true); - $templateContent['page_nav'] = ''; - - if ($numPages > 1) { - $templateContent['page_nav'] = addPageNavigation($numPages, getConfig('user_limit'), true, $colspan, true); - } // END - if + // Sorting links and number of pages + $templateContent['sort_links'] = addSortLinks(getRequestParameter('letter'), getRequestParameter('sortby')); + $templateContent['num_pages'] = $numPages; // Column with nickname when nickname extension is present // @TODO Rewrite this into a filter diff --git a/inc/mysql-connect.php b/inc/mysql-connect.php index 818bdc0c06..8ab0fd974f 100644 --- a/inc/mysql-connect.php +++ b/inc/mysql-connect.php @@ -100,7 +100,7 @@ if ((!isInstalling()) && (!isInstallationPhase())) { // Is it a valid resource? if (SQL_SELECT_DB($GLOBALS['mysql']['dbase'], __FILE__, __LINE__) === true) { - // This is required for extension 'optimize' to work + // Set database name (required for ext-optimize and isSqlTableCreated()) setConfigEntry('__DB_NAME', $GLOBALS['mysql']['dbase']); // Remove MySQL array from namespace diff --git a/templates/de/html/admin/admin_list_user.tpl b/templates/de/html/admin/admin_list_user.tpl index c341708166..883d894667 100644 --- a/templates/de/html/admin/admin_list_user.tpl +++ b/templates/de/html/admin/admin_list_user.tpl @@ -1,14 +1,14 @@
- - $content[alpha_sort] + {%pipe,getRequestParameter,alpha=sortby%} $content[sort_links] - $content[page_nav] + {%pipe,addPageNavigation=$content[num_pages]%} $content[rows] - $content[page_nav] + {%pipe,addPageNavigation=$content[num_pages]%}
+ {%template,AdminListUserTitle%}:
diff --git a/templates/de/html/admin/admin_list_user_alpha.tpl b/templates/de/html/admin/admin_list_user_alpha.tpl index 89082addca..a88ee35cfd 100644 --- a/templates/de/html/admin/admin_list_user_alpha.tpl +++ b/templates/de/html/admin/admin_list_user_alpha.tpl @@ -1,5 +1,5 @@ - + -
diff --git a/templates/de/html/admin/admin_list_user_pagenav.tpl b/templates/de/html/admin/admin_list_user_pagenav.tpl index d823cc8cb1..9fa1c2b889 100644 --- a/templates/de/html/admin/admin_list_user_pagenav.tpl +++ b/templates/de/html/admin/admin_list_user_pagenav.tpl @@ -1,5 +1,5 @@
+ -
diff --git a/templates/de/html/admin/admin_list_user_sort.tpl b/templates/de/html/admin/admin_list_user_sort.tpl index b67e1b5a20..98364b3a62 100644 --- a/templates/de/html/admin/admin_list_user_sort.tpl +++ b/templates/de/html/admin/admin_list_user_sort.tpl @@ -1,5 +1,5 @@
+ - - + -- 2.39.2
- - - - -
- -
-