More rewrites to make use of (cached) wrapper functions
[mailer.git] / inc / modules / admin / what-config_register.php
index c4bf6bc8379ae5d6bcb1a137fe4dcfa06242b2a8..0d65e88d6fb481cb28e3dfab614f1c61413a358c 100644 (file)
@@ -18,6 +18,7 @@
  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
 // Some security stuff...
 if ((!defined('__SECURITY')) || (!isAdmin())) {
        die();
-}
+} // END - if
 
 // Add description as navigation point
 addMenuDescription('admin', __FILE__);
 
 // Do we want to save changes?
 if (isFormSent()) {
-       foreach (postRequestElement('sel') as $id => $value) {
-               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_must_register` SET field_required='%s' WHERE `id`=%s AND field_required != '%s' LIMIT 1",
-               array($value, bigintval($id), $value),__FILE__, __LINE__);
-       }
-       loadTemplate('admin_settings_saved', false, getMessage('REGISTER_ADMIN_CHANGES_SAVED'));
-}
+       // Begin counting
+       $cnt = 0;
+
+       // Update all entries
+       foreach (postRequestParameter('sel') as $id => $value) {
+               // Update database
+               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_must_register` SET `field_required`='%s' WHERE `id`=%s AND `field_required` != '%s' LIMIT 1",
+                       array($value, bigintval($id), $value),__FILE__, __LINE__);
+
+               // Get affected rows
+               $cnt += SQL_AFFECTEDROWS();
+       } // END - foreach
+
+       // Output message for updated entries
+       loadTemplate('admin_settings_saved', false, getMaskedMessage('REGISTER_ADMIN_CHANGES_SAVED', $cnt));
+} // END - if
 
 // List all register values
-$result = SQL_QUERY("SELECT id, field_name, field_required FROM `{?_MYSQL_PREFIX?}_must_register` ORDER BY `id`", __FILE__, __LINE__);
-$OUT = ''; $SW = 2;
+$result = SQL_QUERY("SELECT `id`, `field_name`, `field_required` FROM `{?_MYSQL_PREFIX?}_must_register` ORDER BY `id` ASC", __FILE__, __LINE__);
+$OUT = '';
 while ($content = SQL_FETCHARRAY($result)) {
        // Get language string
-       $content['field_name'] =  getMessage(strtoupper($content['field_name']));
+       $content['field_name'] = '{--' . strtoupper($content['field_name']) . '--}';
 
        // Add more data
-       $content['sw']        = $SW;
-       $content['selection'] = addSelectionBox('yn', $content['field_required'], "sel[".$content['id']."]");
+       $content['selection'] = addSelectionBox('yn', $content['field_required'], 'sel[' . $content['id'] . ']');
 
        // @TODO Move this HTML code into a template
-       $OUT .= "<tr>
-  <td align=\"center\" class=\"switch_sw".$content['sw']." bottom right\">".$content['id']."</td>
-  <td class=\"switch_sw".$content['sw']." bottom right\">&nbsp;&nbsp;".$content['field_name']."</td>
-  <td align=\"center\" class=\"switch_sw".$content['sw']." bottom right\">
-    ".$content['selection']."
-  </td>
-</tr>\n";
-
-       // Switch color
-       $SW = 3 - $SW;
-}
+       $OUT .= loadTemplate('admin_config_register_row', true, $content);
+} // END - while
 
 // Free memory
 SQL_FREERESULT($result);