[geeklog-cvs] geeklog: Use COM_showMessageText (for feature request #0001369)

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sun Aug 28 11:08:57 EDT 2011


changeset 8374:653f483ffb35
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/653f483ffb35
user: Dirk Haun <dirk at haun-online.de>
date: Thu Jun 23 18:28:21 2011 +0200
description:
Use COM_showMessageText (for feature request #0001369)

diffstat:

 public_html/admin/database.php    |  19 +++-------
 public_html/admin/group.php       |  66 ++++++++++++++++----------------------
 public_html/admin/plugins.php     |   9 ++--
 public_html/admin/story.php       |  48 +++++++++++-----------------
 public_html/admin/syndication.php |  19 ++--------
 public_html/admin/topic.php       |  26 ++++----------
 public_html/admin/trackback.php   |  15 ++------
 7 files changed, 74 insertions(+), 128 deletions(-)

diffs (truncated from 417 to 300 lines):

diff -r 9bd9657e05f3 -r 653f483ffb35 public_html/admin/database.php
--- a/public_html/admin/database.php	Thu Jun 23 16:05:56 2011 +0200
+++ b/public_html/admin/database.php	Thu Jun 23 18:28:21 2011 +0200
@@ -221,11 +221,9 @@
                                     $listoptions, $form_arr);
         $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
     } else {
-        $retval .= COM_startBlock($LANG08[06], '',
-                            COM_getBlockTemplate('_msg_block', 'header'));
-        $retval .= $LANG_DB_BACKUP['no_access'];
+        $retval .= COM_showMessageText($LANG_DB_BACKUP['no_access'],
+                                       $LANG08[06]);
         COM_errorLog($_CONF['backup_path'] . ' is not writable.', 1);
-        $retval .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
     }
 
     return $retval;
@@ -282,19 +280,14 @@
                 COM_errorLog("Command used for mysqldump: $log_command", 1);
             }
         } else {
-            $retval .= COM_startBlock($LANG08[06], '',
-                                COM_getBlockTemplate('_msg_block', 'header'));
-            $retval .= $LANG_DB_BACKUP['not_found'];
-            $retval .= COM_endBlock(COM_getBlockTemplate('_msg_block',
-                                                         'footer'));
+            $retval .= COM_showMessageText($LANG_DB_BACKUP['not_found'],
+                                           $LANG08[06]);
             COM_errorLog('Backup Error: Bad path, mysqldump does not exist or open_basedir restriction in effect.', 1);
             COM_errorLog("Command used for mysqldump: $log_command", 1);
         }
     } else {
-        $retval .= COM_startBlock($MESSAGE[30], '',
-                            COM_getBlockTemplate('_msg_block', 'header'));
-        $retval .= $LANG_DB_BACKUP['path_not_found'];
-        $retval .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
+        $retval .= COM_showMessageText($LANG_DB_BACKUP['path_not_found'],
+                                       $MESSAGE[30]);
         COM_errorLog("Backup directory '" . $_CONF['backup_path'] . "' does not exist or is not a directory", 1);
     }
 
diff -r 9bd9657e05f3 -r 653f483ffb35 public_html/admin/group.php
--- a/public_html/admin/group.php	Thu Jun 23 16:05:56 2011 +0200
+++ b/public_html/admin/group.php	Thu Jun 23 18:28:21 2011 +0200
@@ -2,13 +2,13 @@
 
 /* Reminder: always indent with 4 spaces (no tabs). */
 // +---------------------------------------------------------------------------+
-// | Geeklog 1.7                                                               |
+// | Geeklog 1.8                                                               |
 // +---------------------------------------------------------------------------+
 // | group.php                                                                 |
 // |                                                                           |
 // | Geeklog group administration page.                                        |
 // +---------------------------------------------------------------------------+
-// | Copyright (C) 2000-2010 by the following authors:                         |
+// | Copyright (C) 2000-2011 by the following authors:                         |
 // |                                                                           |
 // | Authors: Tony Bibbs        - tony AT tonybibbs DOT com                    |
 // |          Mark Limburg      - mlimburg AT users DOT sourceforge DOT net    |
@@ -86,20 +86,18 @@
     $retval = '';
 
     $thisUsersGroups = SEC_getUserGroups();
-    if (! empty($grp_id) &&
-        ($grp_id > 0) &&
-        !in_array($grp_id, $thisUsersGroups) &&
-        !SEC_groupIsRemoteUserAndHaveAccess($grp_id, $thisUsersGroups)) {
-        $retval .= COM_startBlock($LANG_ACCESS['groupeditor'], '',
-                           COM_getBlockTemplate('_msg_block', 'header'));
+    if (!empty($grp_id) && ($grp_id > 0) &&
+            !in_array($grp_id, $thisUsersGroups) &&
+            !SEC_groupIsRemoteUserAndHaveAccess($grp_id, $thisUsersGroups)) {
         if (!SEC_inGroup('Root') && (DB_getItem($_TABLES['groups'],
                 'grp_name', "grp_id = $grp_id") == 'Root')) {
-            $retval .= $LANG_ACCESS['canteditroot'];
+            $retval .= COM_showMessageText($LANG_ACCESS['canteditroot'],
+                                           $LANG_ACCESS['groupeditor']);
             COM_accessLog("User {$_USER['username']} tried to edit the Root group with insufficient privileges.");
         } else {
-            $retval .= $LANG_ACCESS['canteditgroup'];
+            $retval .= COM_showMessageText($LANG_ACCESS['canteditgroup'],
+                                           $LANG_ACCESS['groupeditor']);
         }
-        $retval .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
 
         return $retval;
     }
@@ -560,13 +558,11 @@
         if ($g_id > 0) {
             if (empty($grp_id) || ($grp_id != $g_id)) {
                 // there already is a group with that name - complain
-                $retval .= COM_siteHeader ('menu', $LANG_ACCESS['groupeditor']);
-                $retval .= COM_startBlock ($LANG_ACCESS['groupexists'], '',
-                           COM_getBlockTemplate ('_msg_block', 'header'));
-                $retval .= $LANG_ACCESS['groupexistsmsg'];
-                $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
-                $retval .= editgroup ($grp_id);
-                $retval .= COM_siteFooter ();
+                $retval .= COM_siteHeader('menu', $LANG_ACCESS['groupeditor'])
+                        . COM_showMessageText($LANG_ACCESS['groupexistsmsg'],
+                                              $LANG_ACCESS['groupexists'])
+                        . editgroup($grp_id)
+                        . COM_siteFooter();
 
                 return $retval;
             }
@@ -685,13 +681,11 @@
             return COM_refresh($_CONF['site_admin_url'] . '/group.php?msg=49');
         }
     } else {
-        $retval .= COM_siteHeader ('menu', $LANG_ACCESS['groupeditor']);
-        $retval .= COM_startBlock ($LANG_ACCESS['missingfields'], '',
-                           COM_getBlockTemplate ('_msg_block', 'header'));
-        $retval .= $LANG_ACCESS['missingfieldsmsg'];
-        $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
-        $retval .= editgroup ($grp_id);
-        $retval .= COM_siteFooter ();
+        $retval .= COM_siteHeader('menu', $LANG_ACCESS['groupeditor'])
+                . COM_showMessageText($LANG_ACCESS['missingfieldsmsg'],
+                                      $LANG_ACCESS['missingfields'])
+                . editgroup($grp_id)
+                . COM_siteFooter();
 
         return $retval;
     }
@@ -749,14 +743,11 @@
     $retval = '';
 
     $thisUsersGroups = SEC_getUserGroups ();
-    if (!empty ($grp_id) &&
-        ($grp_id > 0) &&
-        !in_array ($grp_id, $thisUsersGroups) &&
-        !SEC_groupIsRemoteUserAndHaveAccess( $grp_id, $thisUsersGroups)) {
-        $retval .= COM_startBlock ($LANG_ACCESS['usergroupadmin'], '',
-                           COM_getBlockTemplate ('_msg_block', 'header'));
-        $retval .= $LANG_ACCESS['cantlistgroup'];
-        $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
+    if (!empty ($grp_id) && ($grp_id > 0) &&
+            !in_array($grp_id, $thisUsersGroups) &&
+            !SEC_groupIsRemoteUserAndHaveAccess($grp_id, $thisUsersGroups)) {
+        $retval .= COM_showMessageText($LANG_ACCESS['cantlistgroup'],
+                                       $LANG_ACCESS['usergroupadmin']);
 
         return $retval;
     }
@@ -1014,15 +1005,14 @@
                 !SEC_groupIsRemoteUserAndHaveAccess($group, $thisUsersGroups))
             || (($grp_name == 'All Users') ||
                 ($grp_name == 'Logged-in Users'))) {
-        $retval .= COM_startBlock($LANG_ACCESS['usergroupadmin'], '',
-                                  COM_getBlockTemplate('_msg_block', 'header'));
         if (!SEC_inGroup('Root') && ($grp_name == 'Root')) {
-            $retval .= $LANG_ACCESS['canteditroot'];
+            $retval .= COM_showMessageText($LANG_ACCESS['canteditroot'],
+                                           $LANG_ACCESS['usergroupadmin']);
             COM_accessLog("User {$_USER['username']} tried to edit the Root group with insufficient privileges.");
         } else {
-            $retval .= $LANG_ACCESS['canteditgroup'];
+            $retval .= COM_showMessageText($LANG_ACCESS['canteditgroup'],
+                                           $LANG_ACCESS['usergroupadmin']);
         }
-        $retval .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
 
         return $retval;
     }
diff -r 9bd9657e05f3 -r 653f483ffb35 public_html/admin/plugins.php
--- a/public_html/admin/plugins.php	Thu Jun 23 16:05:56 2011 +0200
+++ b/public_html/admin/plugins.php	Thu Jun 23 18:28:21 2011 +0200
@@ -76,6 +76,7 @@
 *
 * @param    string  $pi_name    Plugin name
 * @return   string              HTML for plugin editor form or error message
+* @todo     FIXME   Move that COM_errorLog message to the language files ...
 *
 */
 function plugin_info_installed($pi_name)
@@ -94,11 +95,9 @@
     if (DB_numRows($result) <> 1) {
         // Serious problem, we got a pi_name that doesn't exist
         // or returned more than one row
-        $retval .= COM_startBlock ($LANG32[13], '',
-                            COM_getBlockTemplate ('_msg_block', 'header'));
-        $retval .= COM_errorLog ('Error in editing plugin ' . $pi_name
-                . '. Either the plugin does not exist or there is more than one row with with same pi_name.  Bailing out to prevent trouble.');
-        $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
+        $msg = COM_errorLog('Error in editing plugin ' . $pi_name
+             . '. Either the plugin does not exist or there is more than one row with with same pi_name.  Bailing out to prevent trouble.');
+        $retval .= COM_showMessageText($msg, $LANG32[13]);
 
         return $retval;
     }
diff -r 9bd9657e05f3 -r 653f483ffb35 public_html/admin/story.php
--- a/public_html/admin/story.php	Thu Jun 23 16:05:56 2011 +0200
+++ b/public_html/admin/story.php	Thu Jun 23 18:28:21 2011 +0200
@@ -253,11 +253,8 @@
         $_CONF['hour_mode'] = 12;
     }
 
-    if (!empty ($errormsg)) {
-        $display .= COM_startBlock($LANG24[25], '',
-                            COM_getBlockTemplate ('_msg_block', 'header'));
-        $display .= $errormsg;
-        $display .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
+    if (!empty($errormsg)) {
+        $display .= COM_showMessageText($errormsg, $LANG24[25]);
     }
 
     if (!empty ($currenttopic)) {
@@ -288,47 +285,40 @@
         if ($_CONF['maximagesperarticle'] > 0) {
             $errors = $story->insertImages();
             if (count($errors) > 0) {
-                $display .= COM_startBlock($LANG24[54], '',
-                                COM_getBlockTemplate('_msg_block', 'header'));
-                $display .= $LANG24[55] . LB . '<ul>' . LB;
+                $msg = $LANG24[55] . LB . '<ul>' . LB;
                 foreach ($errors as $err) {
-                    $display .= '<li>' . $err . '</li>' . LB;
+                    $msg .= '<li>' . $err . '</li>' . LB;
                 }
-                $display .= '</ul>' . LB;
-                $display .= COM_endBlock(COM_getBlockTemplate('_msg_block',
-                                                              'footer'));
+                $msg .= '</ul>' . LB;
+                $display .= COM_showMessageText($msg, $LANG24[54]);
             }
         }
     } else {
         $result = $story->loadFromDatabase($sid, $mode);
     }
 
-    if( ($result == STORY_PERMISSION_DENIED) || ($result == STORY_NO_ACCESS_PARAMS) )
-    {
-        $display .= COM_startBlock($LANG_ACCESS['accessdenied'], '',
-                                COM_getBlockTemplate ('_msg_block', 'header'));
-        $display .= $LANG24[42];
-        $display .= COM_endBlock(COM_getBlockTemplate ('_msg_block', 'footer'));
+    if (($result == STORY_PERMISSION_DENIED) ||
+            ($result == STORY_NO_ACCESS_PARAMS)) {
+        $display .= COM_showMessageText($LANG24[42],
+                                        $LANG_ACCESS['accessdenied']);
         COM_accessLog("User {$_USER['username']} tried to illegally access story $sid.");
         return $display;
-    } elseif( ($result == STORY_EDIT_DENIED) || ($result == STORY_EXISTING_NO_EDIT_PERMISSION) ) {
-        $display .= COM_startBlock($LANG_ACCESS['accessdenied'], '',
-                                COM_getBlockTemplate ('_msg_block', 'header'));
-        $display .= $LANG24[41];
-        $display .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
+    } elseif (($result == STORY_EDIT_DENIED) ||
+            ($result == STORY_EXISTING_NO_EDIT_PERMISSION)) {
+        $display .= COM_showMessageText($LANG24[41],
+                                        $LANG_ACCESS['accessdenied']);
         $display .= STORY_renderArticle ($story, 'p');
         COM_accessLog("User {$_USER['username']} tried to illegally edit story $sid.");
         return $display;
-    } elseif( $result == STORY_INVALID_SID ) {
-        if( $mode == 'editsubmission' )
-        {
+    } elseif ($result == STORY_INVALID_SID) {
+        if ($mode == 'editsubmission') {
             // that submission doesn't seem to be there any more (may have been
             // handled by another Admin) - take us back to the moderation page
-            return COM_refresh( $_CONF['site_admin_url'] . '/moderation.php' );
+            return COM_refresh($_CONF['site_admin_url'] . '/moderation.php');
         } else {
-            return COM_refresh( $_CONF['site_admin_url'] . '/story.php' );
+            return COM_refresh($_CONF['site_admin_url'] . '/story.php');
         }
-    } elseif( $result == STORY_DUPLICATE_SID) {
+    } elseif ($result == STORY_DUPLICATE_SID) {
         $display .= COM_showMessageText($LANG24[24]);
     }
 
diff -r 9bd9657e05f3 -r 653f483ffb35 public_html/admin/syndication.php
--- a/public_html/admin/syndication.php	Thu Jun 23 16:05:56 2011 +0200
+++ b/public_html/admin/syndication.php	Thu Jun 23 18:28:21 2011 +0200
@@ -2,13 +2,13 @@
 
 /* Reminder: always indent with 4 spaces (no tabs). */
 // +---------------------------------------------------------------------------+
-// | Geeklog 1.6                                                               |
+// | Geeklog 1.8                                                               |
 // +---------------------------------------------------------------------------+
 // | syndication.php                                                           |
 // |                                                                           |
 // | Geeklog content syndication administration                                |
 // +---------------------------------------------------------------------------+
-// | Copyright (C) 2003-2010 by the following authors:                         |
+// | Copyright (C) 2003-2011 by the following authors:                         |
 // |                                                                           |
 // | Authors: Dirk Haun         - dirk AT haun-online DOT de                   |
 // |          Michael Jervis    - mike AT fuckingbrit DOT com                  |
@@ -516,10 +516,7 @@
     if (empty ($A['title']) || empty ($A['description']) ||
             empty ($A['filename'])) {
         $retval = COM_siteHeader ('menu', $LANG33[38])
-                . COM_startBlock ($LANG33[38], '',
-                        COM_getBlockTemplate ('_msg_block', 'header'))
-                . $LANG33[39]



More information about the geeklog-cvs mailing list