From: Roland Häder Date: Wed, 30 Jun 2010 11:18:36 +0000 (+0000) Subject: Some templates renamed, fixed of double-init of extension notes: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=56d013d98342508c517a61a84c39e5cebe83641e;p=mailer.git Some templates renamed, fixed of double-init of extension notes: - Some templates renamed, new naming convention says that _ext_ is a shortcut for _extension_ and therefore it is outdated. - Double-initialization of extension notes while displaying them in task fixed - In same place, counting of SQL queries fixed - TODOs.txt updated --- diff --git a/.gitattributes b/.gitattributes index ab89fa767c..4e2830af17 100644 --- a/.gitattributes +++ b/.gitattributes @@ -724,6 +724,7 @@ templates/de/emails/admin/admin_autopurge_unconfirmed.tpl -text templates/de/emails/admin/admin_del_surfbar_urls.tpl -text templates/de/emails/admin/admin_edit_surfbar_urls.tpl -text templates/de/emails/admin/admin_ext_deactivated.tpl -text +templates/de/emails/admin/admin_extension_deactivated.tpl -text templates/de/emails/admin/admin_holiday_deactivated.tpl -text templates/de/emails/admin/admin_holiday_request.tpl -text templates/de/emails/admin/admin_holiday_unlock.tpl -text @@ -1050,6 +1051,10 @@ templates/de/html/admin/admin_ext_notes.tpl -text templates/de/html/admin/admin_ext_reg_form.tpl -text templates/de/html/admin/admin_ext_sql_row.tpl -text templates/de/html/admin/admin_ext_sql_table.tpl -text +templates/de/html/admin/admin_extension_notes.tpl -text +templates/de/html/admin/admin_extension_reg_form.tpl -text +templates/de/html/admin/admin_extension_sql_row.tpl -text +templates/de/html/admin/admin_extension_sql_table.tpl -text templates/de/html/admin/admin_extensions.tpl -text templates/de/html/admin/admin_extensions_delete.tpl -text templates/de/html/admin/admin_extensions_delete_row.tpl -text diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index c794be08b0..8776ad3ec8 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -39,8 +39,8 @@ ./inc/extensions/ext-yoomedia.php:123: // @TODO Can this be moved into a database table? ./inc/extensions/ext-yoomedia.php:56:// @TODO Only deprecated when 'ext-network' is ready! setExtensionDeprecated('Y'); ./inc/extensions-functions.php:143: // @TODO Do we still need this? setExtensionUpdateNotes(''); -./inc/extensions-functions.php:428:// @TODO Change from ext_id to ext_name (not just even the variable! ;-) ) -./inc/extensions-functions.php:544: // @TODO Extension is loaded, what next? +./inc/extensions-functions.php:425:// @TODO Change from ext_id to ext_name (not just even the variable! ;-) ) +./inc/extensions-functions.php:541: // @TODO Extension is loaded, what next? ./inc/functions.php:115: // @TODO Extension 'msg' does not exist ./inc/functions.php:1482: // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ? ./inc/functions.php:1505: // @TODO Rewrite this old lost code to a template @@ -229,6 +229,11 @@ ./templates/de/html/surfbar/surfbar_frame_textlinks.tpl:5: ### ### DEPRECATION FOLLOWS: ### ### ./inc/modules/admin/admin-inc.php:439:// @DEPRECATED +./templates/de/emails/admin/admin_ext_deactivated.tpl:1: +./templates/de/html/admin/admin_ext_notes.tpl:1: +./templates/de/html/admin/admin_ext_reg_form.tpl:1: +./templates/de/html/admin/admin_ext_sql_row.tpl:1: +./templates/de/html/admin/admin_ext_sql_table.tpl:1: ### ### template-warnings.log follows: ### ### Warning: Not parsing JavaScript templates/de/html/js/js_order_send.tpl. Warning: Not parsing JavaScript templates/de/html/js/js_cookies_disabled.tpl. diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index af6f615564..f1df6010e5 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -241,13 +241,13 @@ function registerExtension ($ext_name, $taskId, $dry_run = false, $logout = true // And run possible updates //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currentExtension=' . getCurrentExtensionName()); $history = getExtensionVersionHistory(); - foreach ($history as $ver) { - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . getCurrentExtensionName() . ', ext_ver=' . $ver); + foreach ($history as $ext_ver) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . getCurrentExtensionName() . ', ext_ver=' . $ext_ver); // Load extension in update mode - loadExtension(getCurrentExtensionName(), 'update', $ver, isExtensionDryRun()); + loadExtension(getCurrentExtensionName(), 'update', $ext_ver, isExtensionDryRun()); // Add update notes to our output - addExtensionNotes($ver); + addExtensionNotes($ext_ver); } // END - foreach // Does this extension depends on an outstanding update of another update? @@ -385,9 +385,6 @@ function registerExtension ($ext_name, $taskId, $dry_run = false, $logout = true } elseif (isExtensionDryRun() === true) { // In "dry-run" mode do always return a true $ret = true; - - // Re-init queries and notes - initExtensionNotes(); } else { // Extension has been removed for updates, so all is fine! $ret = true; @@ -738,40 +735,48 @@ function addExtensionVerboseSqlTable ($title = '', $dashed = '', $switch = false // Do we have queries? if ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y')) { - // Get all SQLs - foreach (getExtensionSqls() as $sqls) { - // New array format is recursive - foreach ($sqls as $idx => $sql) { - // Trim out spaces - $sql = trim($sql); - - // Output command if set - if (!empty($sql)) { - // Prepare output for template - $content = array( - 'i' => ($idx+1), - 'sql' => $sql - ); - - // Load row template - $OUT .= loadTemplate('admin_ext_sql_row', true, $content); - } // END - if + // Do we have entries? + if (countExtensionSqls() > 0) { + // Init counter + $idx = 0; + // Get all SQLs + foreach (getExtensionSqls() as $sqls) { + // New array format is recursive + foreach ($sqls as $sql) { + // Trim out spaces + $sql = trim($sql); + + // Output command if set + if (!empty($sql)) { + // Prepare output for template + $content = array( + 'i' => ($idx + 1), + 'sql' => $sql + ); + + // Load row template + $OUT .= loadTemplate('admin_extension_sql_row', true, $content); + + // Count up + $idx++; + } // END - if + } // END - foreach } // END - foreach - } // END - foreach - // Prepare content for template - $content = array( - 'width' => $width, - 'dashed' => $dashed, - 'title' => $title, - 'rows' => $OUT - ); + // Prepare content for template + $content = array( + 'width' => $width, + 'dashed' => $dashed, + 'title' => $title, + 'rows' => $OUT + ); - // Load main template - $OUT = loadTemplate('admin_ext_sql_table', true, $content); - } elseif ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y')) { - // No addional SQL commands to run - $OUT = loadTemplate('admin_settings_saved', true, '{--ADMIN_NO_ADDITIONAL_SQLS--}'); + // Load main template + $OUT = loadTemplate('admin_extension_sql_table', true, $content); + } else { + // No addional SQL commands to run + $OUT = loadTemplate('admin_settings_saved', true, '{--ADMIN_NO_ADDITIONAL_SQLS--}'); + } } // END - if // Return output @@ -915,7 +920,7 @@ function doDeactivateExtension($ext_name) { // Notify the admin sendAdminNotification( '{--ADMIN_EXTENSION_DEACTIVATED_SUBJECT--}', - 'admin_ext_deactivated', + 'admin_extension_deactivated', array('ext_name' => $ext_name) ); } // END - if @@ -1109,38 +1114,39 @@ function determineTaskIdBySubject ($subject) { } // Add updates notes for given version -function addExtensionNotes ($ver) { +function addExtensionNotes ($ext_ver) { // Init notes/content - $out = ''; $content = array(); + $out = ''; + $content = array(); // Is do we have verbose output enabled? if ((!isExtensionActive('sql_patches')) || (getConfig('verbose_sql') == 'Y')) { // Update notes found? - if (isExtensionUpdateNoteSet($ver)) { + if (isExtensionUpdateNoteSet($ext_ver)) { // Update notes found $content = array( - 'ver' => $ver, - 'notes' => getExtensionUpdateNotes($ver) + 'ver' => $ext_ver, + 'notes' => getExtensionUpdateNotes($ext_ver) ); // Reset them - setExtensionUpdateNotes('', $ver); - } elseif (($ver == '0.0') || ($ver == '0.0.0')) { + setExtensionUpdateNotes('', $ext_ver); + } elseif (in_array($ext_ver, array('0.0', '0.0.0'))) { // Initial release $content = array( - 'ver' => $ver, + 'ver' => $ext_ver, 'notes' => '{--INITIAL_RELEASE--}' ); } else { // No update notes found! $content = array( - 'ver' => $ver, + 'ver' => $ext_ver, 'notes' => '{--NO_UPDATE_NOTES--}' ); } // Load template - $out = loadTemplate('admin_EXTENSION_notes', true, $content); + $out = loadTemplate('admin_extension_notes', true, $content); } // END - if // Add the notes @@ -1196,8 +1202,8 @@ function isExtensionAlwaysActive () { } // Setter for EXT_VERSION flag -function setThisExtensionVersion ($version) { - $GLOBALS['ext_version'][getCurrentExtensionName()] = (string) $version; +function setThisExtensionVersion ($ext_version) { + $GLOBALS['ext_version'][getCurrentExtensionName()] = (string) $ext_version; } // Getter for EXT_VERSION flag @@ -1399,8 +1405,8 @@ function getExtensionReportsFailure () { } // Setter for EXT_VER_HISTORY flag -function setExtensionVersionHistory ($verHistory) { - $GLOBALS['ext_ver_history'][getCurrentExtensionName()] = (array) $verHistory; +function setExtensionVersionHistory ($versionHistory) { + $GLOBALS['ext_ver_history'][getCurrentExtensionName()] = (array) $versionHistory; } // Getter for EXT_VER_HISTORY array @@ -1409,33 +1415,41 @@ function getExtensionVersionHistory () { } // Setter for EXT_UPDATE_NOTES -function setExtensionUpdateNotes ($updateNotes, $ver='') { +function setExtensionUpdateNotes ($updateNotes, $ext_ver = '') { // . '/' . getCurrentExtensionVersion() - //* DEBUG: */ debug_report_bug(__FUNCTION__.':' . getCurrentExtensionName() . '/' . getExtensionMode() . '/' . $ver . '=' . $updateNotes); - if (empty($ver)) { + //* DEBUG: */ debug_report_bug(__FUNCTION__.':' . getCurrentExtensionName() . '/' . getExtensionMode() . '/' . $ext_ver . '=' . $updateNotes); + if (empty($ext_ver)) { $GLOBALS['ext_update_notes'][getCurrentExtensionName()][getCurrentExtensionVersion()] = (string) $updateNotes; } else { - $GLOBALS['ext_update_notes'][getCurrentExtensionName()][$ver] = (string) $updateNotes; + $GLOBALS['ext_update_notes'][getCurrentExtensionName()][$ext_ver] = (string) $updateNotes; } } // Getter for EXT_UPDATE_NOTES -function getExtensionUpdateNotes ($ver) { - return $GLOBALS['ext_update_notes'][getCurrentExtensionName()][$ver]; +function getExtensionUpdateNotes ($ext_ver) { + return $GLOBALS['ext_update_notes'][getCurrentExtensionName()][$ext_ver]; } // Checks if ext_update_notes is set -function isExtensionUpdateNoteSet ($ver) { - return isset($GLOBALS['ext_update_notes'][getCurrentExtensionName()][$ver]); +function isExtensionUpdateNoteSet ($ext_ver) { + return isset($GLOBALS['ext_update_notes'][getCurrentExtensionName()][$ext_ver]); } // Init extension notice function initExtensionNotes () { + // Is it already initialized? + if (isset($GLOBALS['ext_notes'][getCurrentExtensionName()])) { + // This is mostly not wanted, so please report it + debug_report_bug(__FUNCTION__, __LINE__, 'ext_notes already set for extension ' . getCurrentExtensionName()); + } // END - if + + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getCurrentExtensionName()=' . getCurrentExtensionName()); $GLOBALS['ext_notes'][getCurrentExtensionName()] = ''; } // Append extension notice function appendExtensionNotes ($notes) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getCurrentExtensionName()=' . getCurrentExtensionName() . ', notes()=' . strlen($notes)); $GLOBALS['ext_notes'][getCurrentExtensionName()] .= (string) trim($notes); } @@ -1446,17 +1460,18 @@ function getExtensionNotes () { // Setter for current extension name function setCurrentExtensionName ($ext_name) { - $GLOBALS['curr_EXTENSION_name'] = (string) trim($ext_name); + $GLOBALS['curr_extension_name'] = (string) trim($ext_name); } // Getter for current extension name function getCurrentExtensionName () { - if (isset($GLOBALS['curr_EXTENSION_name'])) { - return $GLOBALS['curr_EXTENSION_name']; + if (!isset($GLOBALS['curr_extension_name'])) { + // Not set! + debug_report_bug(__FUNCTION__, __LINE__, 'curr_extension_name not initialized. Please execute initExtensionSqls() before calling this function.'); } // END - if - // Not set! - debug_report_bug(__FUNCTION__.": curr_EXTENSION_name not initialized. Please execute initExtensionSqls() before calling this function."); + // Return it + return $GLOBALS['curr_extension_name']; } // Init SQLs array for current extension @@ -1491,6 +1506,20 @@ function getExtensionSqls () { return $GLOBALS['ext_sqls'][getCurrentExtensionName()]; } +// Count SQLs for current extension +function countExtensionSqls () { + // Output debug backtrace if not found (SHOULD NOT HAPPEN!) + if (!isset($GLOBALS['ext_sqls'][getCurrentExtensionName()])) { + // Not found, should not happen + debug_report_bug(__FUNCTION__, __LINE__, sprintf("ext_sqls is empty, current extension: %s", + getCurrentExtensionName() + )); + } // END - if + + // Count them all + return count($GLOBALS['ext_sqls'][getCurrentExtensionName()]); +} + // Removes SQLs for current extension function unsetExtensionSqls () { unset($GLOBALS['ext_sqls'][getCurrentExtensionName()]); diff --git a/inc/extensions/ext-online.php b/inc/extensions/ext-online.php index 45051d6892..08e7edc0c1 100644 --- a/inc/extensions/ext-online.php +++ b/inc/extensions/ext-online.php @@ -65,9 +65,9 @@ switch (getExtensionMode()) { `is_member` ENUM('Y','N') NOT NULL DEFAULT 'N', `timestamp` VARCHAR(10) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), -KEY (`userid`), -KEY (`refid`), -KEY `admin_member` (`is_admin`,`is_member`) +INDEX (`userid`), +INDEX (`refid`), +INDEX `admin_member` (`is_admin`, `is_member`) ) TYPE={?_TABLE_TYPE?}"); addAdminMenuSql('misc','usr_online','Online-Statistik','Eine Liste von derzeit "Online" Usern. Doppelte Einträge könnte auf mangelnden Cookie-Support des Browsers oder auf einen Spider hindeuten.', 1); break; @@ -93,8 +93,7 @@ KEY `admin_member` (`is_admin`,`is_member`) break; case 'update': // Update an extension - switch (getCurrentExtensionVersion()) - { + switch (getCurrentExtensionVersion()) { case '0.0.1': // SQL queries for v0.0.1 // Update notes (these will be set as task text!) setExtensionUpdateNotes("Fehler Unknown column 'visibled' in 'field list' behoben."); diff --git a/inc/modules/admin/overview-inc.php b/inc/modules/admin/overview-inc.php index 2a02b281d6..ecd876f699 100644 --- a/inc/modules/admin/overview-inc.php +++ b/inc/modules/admin/overview-inc.php @@ -284,7 +284,7 @@ LIMIT 1", SQL_FREERESULT($result_lines); if ($lines == '0') { // New extension found - $OUT .= loadTemplate('admin_ext_reg_form', true, array( + $OUT .= loadTemplate('admin_extension_reg_form', true, array( 'id' => bigintval($id), 'ext_name' => $ext_name )); diff --git a/templates/de/emails/admin/admin_ext_deactivated.tpl b/templates/de/emails/admin/admin_ext_deactivated.tpl index 3ece3e3327..11f5d85d80 100644 --- a/templates/de/emails/admin/admin_ext_deactivated.tpl +++ b/templates/de/emails/admin/admin_ext_deactivated.tpl @@ -1,10 +1 @@ -Hallo Administrator, - -es wurde soeben die Erweiterung $content[ext_name] automatisch deaktiviert, da sie als veraltet markiert ist. - -Bitte deinstallieren Sie bald diese Erweiterung. Sie wird von mxchange.org nicht mehr unterstützt. - -Mit freundlichen Grüßen, - Ihr {?MAIN_TITLE?} Team - -{?URL?}/login.php ({?WEBMASTER?}) + diff --git a/templates/de/emails/admin/admin_extension_deactivated.tpl b/templates/de/emails/admin/admin_extension_deactivated.tpl new file mode 100644 index 0000000000..3ece3e3327 --- /dev/null +++ b/templates/de/emails/admin/admin_extension_deactivated.tpl @@ -0,0 +1,10 @@ +Hallo Administrator, + +es wurde soeben die Erweiterung $content[ext_name] automatisch deaktiviert, da sie als veraltet markiert ist. + +Bitte deinstallieren Sie bald diese Erweiterung. Sie wird von mxchange.org nicht mehr unterstützt. + +Mit freundlichen Grüßen, + Ihr {?MAIN_TITLE?} Team + +{?URL?}/login.php ({?WEBMASTER?}) diff --git a/templates/de/html/admin/admin_ext_notes.tpl b/templates/de/html/admin/admin_ext_notes.tpl index ca76eba979..11f5d85d80 100644 --- a/templates/de/html/admin/admin_ext_notes.tpl +++ b/templates/de/html/admin/admin_ext_notes.tpl @@ -1,4 +1 @@ -
- v$content[ver]:
- $content[notes] -
+ diff --git a/templates/de/html/admin/admin_ext_reg_form.tpl b/templates/de/html/admin/admin_ext_reg_form.tpl index 44d772e387..11f5d85d80 100644 --- a/templates/de/html/admin/admin_ext_reg_form.tpl +++ b/templates/de/html/admin/admin_ext_reg_form.tpl @@ -1,4 +1 @@ - -
- -
+ diff --git a/templates/de/html/admin/admin_ext_sql_row.tpl b/templates/de/html/admin/admin_ext_sql_row.tpl index 8f979715cb..11f5d85d80 100644 --- a/templates/de/html/admin/admin_ext_sql_row.tpl +++ b/templates/de/html/admin/admin_ext_sql_row.tpl @@ -1,6 +1 @@ - - $content[i]. - - $content[sql] - - + diff --git a/templates/de/html/admin/admin_ext_sql_table.tpl b/templates/de/html/admin/admin_ext_sql_table.tpl index e7dd9b54bd..11f5d85d80 100644 --- a/templates/de/html/admin/admin_ext_sql_table.tpl +++ b/templates/de/html/admin/admin_ext_sql_table.tpl @@ -1,10 +1 @@ -
- - - - -$content[rows] -
- $content[title]: -
-
+ diff --git a/templates/de/html/admin/admin_extension_notes.tpl b/templates/de/html/admin/admin_extension_notes.tpl new file mode 100644 index 0000000000..ca76eba979 --- /dev/null +++ b/templates/de/html/admin/admin_extension_notes.tpl @@ -0,0 +1,4 @@ +
+ v$content[ver]:
+ $content[notes] +
diff --git a/templates/de/html/admin/admin_extension_reg_form.tpl b/templates/de/html/admin/admin_extension_reg_form.tpl new file mode 100644 index 0000000000..44d772e387 --- /dev/null +++ b/templates/de/html/admin/admin_extension_reg_form.tpl @@ -0,0 +1,4 @@ + +
+ +
diff --git a/templates/de/html/admin/admin_extension_sql_row.tpl b/templates/de/html/admin/admin_extension_sql_row.tpl new file mode 100644 index 0000000000..8f979715cb --- /dev/null +++ b/templates/de/html/admin/admin_extension_sql_row.tpl @@ -0,0 +1,6 @@ + + $content[i]. + + $content[sql] + + diff --git a/templates/de/html/admin/admin_extension_sql_table.tpl b/templates/de/html/admin/admin_extension_sql_table.tpl new file mode 100644 index 0000000000..e7dd9b54bd --- /dev/null +++ b/templates/de/html/admin/admin_extension_sql_table.tpl @@ -0,0 +1,10 @@ +
+ + + + +$content[rows] +
+ $content[title]: +
+