Index: extensions/LCAS/trunk/admin/LCAS_admin.php
===================================================================
--- extensions/LCAS/trunk/admin/LCAS_admin.php	(revision 10270)
+++ extensions/LCAS/trunk/admin/LCAS_admin.php	(revision 10549)
@@ -9,6 +9,8 @@
 check_status(ACCESS_ADMINISTRATOR);
 
-if (!defined('LCAS_PATH')) define('LCAS_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
-if (!defined('LCAS_PATH_ABS')) define('LCAS_PATH_ABS' ,  dirname(__FILE__).'/');
+if (!defined('LCAS_PATH'))
+ define('LCAS_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
+if (!defined('LCAS_PATH_ABS'))
+ define('LCAS_PATH_ABS' ,  dirname(__FILE__).'/');
 
 //ini_set('error_reporting', E_ALL);
@@ -30,145 +32,160 @@
 $version = $plugin['version'];
 
-	if (isset($_POST['submit']) and isset($_POST['LCAS_Option']) and isset($_POST['LCAS_Mail']))
+if (isset($_POST['submit'])
+ and isset($_POST['LCAS_Option'])
+ and isset($_POST['LCAS_Mail']))
+{
+
+/* General configuration settings */
+  $_POST['LCAS_MailText'] = str_replace('\"', '"', str_replace("\'", "'",
+   str_replace("\\\\", "\\", $_POST['LCAS_MailText'])));
+  
+  $newconf_LCAS= array(
+    $_POST['LCAS_Option'],
+    $_POST['LCAS_Mail'],
+    $_POST['LCAS_MailText']);
+
+  $conf['LoginCaseAccentsSensitivity'] = serialize($newconf_LCAS);
+
+  $query = '
+    UPDATE '.CONFIG_TABLE.'
+    SET value="'.addslashes($conf['LoginCaseAccentsSensitivity']).'"
+    WHERE param="LoginCaseAccentsSensitivity"
+    LIMIT 1
+    ;';
+  
+  pwg_query($query);
+
+  array_push($page['infos'], l10n('LCAS_save_config'));
+}
+
+$conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']);
+
+if (isset($conf_LCAS[0]))
+{
+  $case_ins = ($conf_LCAS[0] == '1' or $conf_LCAS[0] == '3');
+  $acc_ins = ($conf_LCAS[0] == '2' or $conf_LCAS[0] == '3');
+
+  if ($case_ins or $acc_ins)
   {
 
-/* General configuration settings */
-		$_POST['LCAS_MailText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['LCAS_MailText'])));
-    
-    $newconf_LCAS= array(
-      $_POST['LCAS_Option'],
-      $_POST['LCAS_Mail'],
-      $_POST['LCAS_MailText']);
-
-    $conf['LoginCaseAccentsSensitivity'] = serialize($newconf_LCAS);
-
-		$query = '
-	  	UPDATE '.CONFIG_TABLE.'
-	  	SET value="'.addslashes($conf['LoginCaseAccentsSensitivity']).'"
-	  	WHERE param="LoginCaseAccentsSensitivity"
-	  	LIMIT 1
-	  	;';
-		
-		pwg_query($query);
-
-    array_push($page['infos'], l10n('LCAS_save_config'));
-  }
-
-	$conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']);
-  
-  if (isset($conf_LCAS[0]))
-  {
-    $case_ins = ($conf_LCAS[0] == '1' or $conf_LCAS[0] == '3');
-    $acc_ins = ($conf_LCAS[0] == '2' or $conf_LCAS[0] == '3');
-
-    if ($case_ins or $acc_ins)
+// +-----------------------------------------------------------------------+
+// |                               user list                               |
+// +-----------------------------------------------------------------------+
+
+    $page['all_users'] = LCAS_get_user_list($conf_LCAS[0]);
+
+// +-----------------------------------------------------------------------+
+// |                           initialization                              |
+// +-----------------------------------------------------------------------+
+
+    $lcas_UserToUpdate = -1;
+    if ((isset($_POST['UserToUpdate'])) && ($_POST['UserToUpdate'] != -1)) {
+      $lcas_UserToUpdate = $_POST['UserToUpdate'];
+      
+      if ((isset($_POST['user-'.$lcas_UserToUpdate])) &&
+       ($_POST['user-'.$lcas_UserToUpdate] != '')) {
+
+        // Check if username already exists
+        $lcas_previous_compare_user =
+         LCAS_change_case($_POST['user-'.$lcas_UserToUpdate], $conf_LCAS[0]);
+
+        $LCAS_users = array();
+
+        // This is a dirty request - Works fine for small number of users
+        // but could be unoptimized for large number of users
+        $query = '
+          SELECT '.$conf['user_fields']['username'].' AS username
+          FROM '.USERS_TABLE.';';
+        
+        $res = pwg_query($query);
+        while ($r = pwg_db_fetch_assoc($res))
+        {
+          $LCAS_users[$r['username']] =
+           LCAS_change_case($r['username'], $conf_LCAS[0]);
+        }
+          
+        $users_found = array_keys($LCAS_users, $lcas_previous_compare_user);
+
+        if (count($users_found) < 1)
+        {
+          // Get old username before update -
+          // Useful for user notification if is set
+          $query ='
+            SELECT username
+            FROM '.USERS_TABLE.'
+            WHERE id = '.$lcas_UserToUpdate.'
+          ;';
+
+          $data = pwg_db_fetch_assoc(pwg_query($query));
+
+          // Username update
+          $query = '
+            UPDATE '.USERS_TABLE.'
+            SET username="'.addslashes($_POST['user-'.$lcas_UserToUpdate]).'"
+            WHERE id='.$lcas_UserToUpdate.'
+            LIMIT 1
+            ;';
+
+          pwg_query($query);
+
+          if (isset($conf_LCAS[1]) and $conf_LCAS[1] == 'true')
+          {
+            LCAS_SendMail($lcas_UserToUpdate, $data['username'],
+             $_POST['user-'.$lcas_UserToUpdate]);
+          }
+
+          // Reloading conflict table content
+          $page['all_users'] = LCAS_get_user_list($conf_LCAS[0]);
+          array_push($page['infos'],
+           l10n('LCAS_Info_userlist_username_renamed'));
+        }
+        else
+        {
+          // Username already exists
+          array_push(
+            $page['errors'],
+            l10n('LCAS_Err_Userlist_New_Username_Exists').
+             '<br>"'.$lcas_previous_compare_user.'"'
+          );
+        }
+      }
+      else {
+        // Username is empty
+        array_push($page['errors'],
+         l10n('LCAS_Err_Userlist_Empty_New_Username'));
+      }
+    }
+
+// +-----------------------------------------------------------------------+
+// |                               user list                               |
+// +-----------------------------------------------------------------------+
+
+    $lcas_previous_compare_user = '';
+    $visible_user_list          = array();
+    foreach ($page['all_users'] as $local_user)
     {
-
-// +-----------------------------------------------------------------------+
-// |                               user list                               |
-// +-----------------------------------------------------------------------+
-
-      $page['all_users'] = LCAS_get_user_list($conf_LCAS[0]);
-
-// +-----------------------------------------------------------------------+
-// |                           initialization                              |
-// +-----------------------------------------------------------------------+
-
-      $lcas_UserToUpdate = -1;
-      if ((isset($_POST['UserToUpdate'])) && ($_POST['UserToUpdate'] != -1)) {
-        $lcas_UserToUpdate = $_POST['UserToUpdate'];
-        
-        if ((isset($_POST['user-'.$lcas_UserToUpdate])) && ($_POST['user-'.$lcas_UserToUpdate] != '')) {
-
-          // Check if username already exists
-        	$lcas_previous_compare_user = LCAS_change_case($_POST['user-'.$lcas_UserToUpdate], $conf_LCAS[0]);
-
-          $LCAS_users = array();
-
-          // This is a dirty request - Works fine for small number of users but could be unoptimized for large number of users
-          $query = '
-            SELECT '.$conf['user_fields']['username'].' AS username
-            FROM '.USERS_TABLE.';';
-          
-          $res = pwg_query($query);
-          while ($r = pwg_db_fetch_assoc($res))
-          {
-            $LCAS_users[$r['username']] = LCAS_change_case($r['username'], $conf_LCAS[0]);
-          }
-            
-          $users_found = array_keys($LCAS_users, $lcas_previous_compare_user);
-
-          if (count($users_found) < 1)
-          {
-            // Get old username before update - Usefull for user notification if is set
-            $query ='
-              SELECT username
-              FROM '.USERS_TABLE.'
-              WHERE id = '.$lcas_UserToUpdate.'
-            ;';
-
-            $data = pwg_db_fetch_assoc(pwg_query($query));
-  
-            // Username update
-            $query = '
-              UPDATE '.USERS_TABLE.'
-              SET username="'.addslashes($_POST['user-'.$lcas_UserToUpdate]).'"
-              WHERE id='.$lcas_UserToUpdate.'
-              LIMIT 1
-              ;';
-
-            pwg_query($query);
-
-            if (isset($conf_LCAS[1]) and $conf_LCAS[1] == 'true')
-            {
-              LCAS_SendMail($lcas_UserToUpdate, $data['username'], $_POST['user-'.$lcas_UserToUpdate]);
-            }
-
-            // Reloading conflict table content
-            $page['all_users'] = LCAS_get_user_list($conf_LCAS[0]);
-            array_push($page['infos'], l10n('LCAS_Info_userlist_username_renamed'));
-          }
-          else
-          {
-            // Username already exists
-            array_push($page['errors'], l10n('LCAS_Err_Userlist_New_Username_Exists').'<br>"'.$lcas_previous_compare_user.'"');
-          }
-        }
-        else {
-          // Username is empty
-          array_push($page['errors'], l10n('LCAS_Err_Userlist_Empty_New_Username'));
-        }
-      }
-
-// +-----------------------------------------------------------------------+
-// |                               user list                               |
-// +-----------------------------------------------------------------------+
-
-      $lcas_previous_compare_user = '';
-      $visible_user_list          = array();
-      foreach ($page['all_users'] as $local_user)
-      {
-        if ($lcas_previous_compare_user != $local_user['transformed']) {
-          $display = 'orange';
-          $lcas_previous_compare_user = $local_user['transformed'];
-        }
-        else {
-          $display = '';
-        }
-
-        $template->append(
-          'users',
-          array(
-            'ID'          => $local_user['id'],
-            'USERNAME'    => stripslashes($local_user['username']),
-            'COMPARE'     => stripslashes($local_user['transformed']),
-            'EMAIL'       => get_email_address_as_display_text($local_user['email']),
-            'DISPLAY'     => $display,
-          )
-        );
-      }
-      
+      if ($lcas_previous_compare_user != $local_user['transformed']) {
+        $display = 'orange';
+        $lcas_previous_compare_user = $local_user['transformed'];
+      }
+      else {
+        $display = '';
+      }
+
+      $template->append(
+        'users',
+        array(
+          'ID'          => $local_user['id'],
+          'USERNAME'    => stripslashes($local_user['username']),
+          'COMPARE'     => stripslashes($local_user['transformed']),
+          'EMAIL'       =>
+           get_email_address_as_display_text($local_user['email']),
+          'DISPLAY'     => $display,
+        )
+      );
     }
   }
+}
 
 
@@ -176,16 +193,16 @@
 // |                           templates init                              |
 // +-----------------------------------------------------------------------+
-  $template->assign(
-    array(
-    'LCAS_VERSION'                  => $version,
-    'LCAS_PATH'                     => LCAS_PATH,
-    'PHPWG_VERSION'                 => PHPWG_VERSION,
-    'LCAS_PATH_ABS'                 => LCAS_PATH_ABS,
-		'LCAS_Option'                   => $conf_LCAS[0],
-		'LCAS_MAIL_TRUE'                => $conf_LCAS[1] == 'true'  ? 'checked = "checked"' : '' ,
-		'LCAS_MAIL_FALSE'               => $conf_LCAS[1] == 'false' ? 'checked = "checked"' : '' ,
-    'LCAS_MAILTEXT'                 => $conf_LCAS[2]
-    )
-  );
+$template->assign(
+  array(
+  'LCAS_VERSION'    => $version,
+  'LCAS_PATH'       => LCAS_PATH,
+  'PHPWG_VERSION'   => PHPWG_VERSION,
+  'LCAS_PATH_ABS'   => LCAS_PATH_ABS,
+  'LCAS_Option'     => $conf_LCAS[0],
+  'LCAS_MAIL_TRUE'  => $conf_LCAS[1] == 'true'  ? 'checked = "checked"' : '' ,
+  'LCAS_MAIL_FALSE' => $conf_LCAS[1] == 'false' ? 'checked = "checked"' : '' ,
+  'LCAS_MAILTEXT'   => $conf_LCAS[2]
+  )
+);
 
 
@@ -193,18 +210,19 @@
 // |                             errors display                            |
 // +-----------------------------------------------------------------------+
-  if (isset ($errors) and count($errors) != 0)
+if (isset ($errors) and count($errors) != 0)
+{
+  $template->assign('errors',array());
+  foreach ($errors as $error)
   {
-	  $template->assign('errors',array());
-	  foreach ($errors as $error)
-	  {
-		  array_push($page['errors'], $error);
-		}
-	}  
+    array_push($page['errors'], $error);
+  }
+}  
 
 // +-----------------------------------------------------------------------+
 // |                           templates display                           |
 // +-----------------------------------------------------------------------+
-  $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/global.tpl');
-  $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
+$template->set_filename('plugin_admin_content',
+ dirname(__FILE__) . '/template/global.tpl');
+$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
 
 ?>
