]> git.mxchange.org Git - mailer.git/blobdiff - inc/fix_menu.php
Rewrote some parts:
[mailer.git] / inc / fix_menu.php
index b50b07fe9dc3e800e3b6062c2f34e185c1e167a6..8c6288b7f41976bc6f6cb4e7ffeb7eb0409125a4 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 10/22/2009 *
- * ===============                              Last change: 10/22/2009 *
+ * Mailer v0.2.1-FINAL                                Start: 10/22/2009 *
+ * ===================                          Last change: 10/22/2009 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : fix_menu.php                                     *
  * $Date::                                                            $ *
  * $Tag:: 0.2.1-FINAL                                                 $ *
  * $Author::                                                          $ *
- * Needs to be in all Files and every File needs "svn propset           *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * For more information visit: http://www.mxchange.org                  *
+ * Copyright (c) 2009 - 2013 by Mailer Developer Team                   *
+ * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  * it under the terms of the GNU General Public License as published by *
@@ -44,14 +43,14 @@ if (!defined('__SECURITY')) {
 // Get all menus
 foreach (array('guest','member','admin') as $menu) {
        // Query it
-       $result = SQL_QUERY_ESC("SELECT `action`, `what` FROM `{?_MYSQL_PREFIX?}_%s_menu` ORDER BY `action` ASC, `what` ASC",
+       $result = sqlQueryEscaped("SELECT `action`, `what` FROM `{?_MYSQL_PREFIX?}_%s_menu` ORDER BY `action` ASC,`what` ASC",
                array($menu), __FILE__, __LINE__);
 
        // Init array
        $menus = array();
 
        // Load all entries
-       while ($entry = SQL_FETCHARRAY($result)) {
+       while ($entry = sqlFetchArray($result)) {
                // Is the menu entry set?
                if (!isset($menus['menu'][$entry['action']][$entry['what']])) {
                        // Not found
@@ -60,43 +59,54 @@ foreach (array('guest','member','admin') as $menu) {
                        // Double entry, so get count
                        if (is_null($entry['what'])) {
                                // Main menu
-                               $entries = countSumTotalData($entry['action'], $menu . '_menu', 'action', 'action', true, " AND `what` IS NULL");
+                               $entries = countSumTotalData($entry['action'], $menu . '_menu', 'action', 'action', TRUE, ' AND `what` IS NULL');
                        } else {
                                // Sub menu
-                               $entries = countSumTotalData($entry['action'], $menu . '_menu', 'action', 'action', true, sprintf(" AND `what`='%s'", $entry['what']));
+                               $entries = countSumTotalData($entry['action'], $menu . '_menu', 'action', 'action', TRUE, sprintf(" AND `what`='%s'", $entry['what']));
                        }
-                       //* DEBUG: */ print 'menu='.$menu.',action='.$entry['action'].',what='.$entry['what'].',entries='.$entries.'<br />';
+                       //* DEBUG: */ debugOutput('menu='.$menu.',action='.$entry['action'].',what='.$entry['what'].',entries='.$entries);
 
                        // Only remove if we have at least 2 entries from same menu
                        if ($entries > 1) {
                                // Remove all except one
                                if (is_null($entry['what'])) {
                                        // Main menu is double
-                                       SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `what` IS NULL LIMIT %s",
-                                               array($menu, $entry['action'], ($entries - 1)), __FILE__, __LINE__);
+                                       sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `what` IS NULL LIMIT %s",
+                                               array(
+                                                       $menu,
+                                                       $entry['action'],
+                                                       ($entries - 1)
+                                               ), __FILE__, __LINE__);
                                } else {
                                        // Sub menu is double
-                                       SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `what`='%s' LIMIT %s",
-                                               array($menu, $entry['action'], $entry['what'], ($entries - 1)), __FILE__, __LINE__);
+                                       sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `what`='%s' LIMIT %s",
+                                               array(
+                                                       $menu,
+                                                       $entry['action'],
+                                                       $entry['what'],
+                                                       ($entries - 1)
+                                               ), __FILE__, __LINE__);
                                }
                        } // END - if
                }
        } // END - while
 
        // Free result
-       SQL_FREERESULT($result);
+       sqlFreeResult($result);
+
+       // Init sqls
+       initSqls();
 
        // Now insert our unqiue key for action-what combination
-       SQL_QUERY_ESC("ALTER TABLE `{?_MYSQL_PREFIX?}_%s_menu` DROP KEY `action_what`",
-               array($menu), __FILE__, __LINE__);
-       SQL_QUERY_ESC("ALTER TABLE `{?_MYSQL_PREFIX?}_%s_menu` ADD UNIQUE `action_what` (`action` , `what`)",
-               array($menu), __FILE__, __LINE__);
+       addSql(sprintf('ALTER TABLE `{?_MYSQL_PREFIX?}_%s_menu` DROP INDEX `action_what`', $menu));
+       addSql(sprintf('ALTER TABLE `{?_MYSQL_PREFIX?}_%s_menu` ADD UNIQUE INDEX `action_what` (`action`, `what`)', $menu));
 
        // Now insert our unqiue key for what
-       SQL_QUERY_ESC("ALTER TABLE `{?_MYSQL_PREFIX?}_%s_menu` DROP KEY `what`",
-               array($menu), __FILE__, __LINE__);
-       SQL_QUERY_ESC("ALTER TABLE `{?_MYSQL_PREFIX?}_%s_menu` ADD UNIQUE `what` (`what`)",
-               array($menu), __FILE__, __LINE__);
+       addSql(sprintf('ALTER TABLE `{?_MYSQL_PREFIX?}_%s_menu` DROP INDEX `what`', $menu));
+       addSql(sprintf('ALTER TABLE `{?_MYSQL_PREFIX?}_%s_menu` ADD UNIQUE INDEX `what` (`what`)', $menu));
+
+       // And run all
+       runFilterChain('run_sqls');
 } // END - foreach
 
 // [EOF]