Renamed all SQL-related functions to camel-case notation
[mailer.git] / inc / loader / load-points_data.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 07/31/2011 *
4  * ===================                          Last change: 07/31/2011 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : load-points_data.php                             *
8  * -------------------------------------------------------------------- *
9  * Short description : Load more cache files                            *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Mehr Cache-Dateien nachladen                     *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2013 by Mailer Developer Team                   *
20  * For more information visit: http://mxchange.org                      *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         die();
41 } elseif (isInstallationPhase()) {
42         // Do not run in installation phase
43         return FALSE;
44 } elseif (!isExtensionInstalledAndNewer('sql_patches', '0.8.0')) {
45         // Is not installed or recent enough
46         return FALSE;
47 }
48
49 // Let's start with the admins table...
50 if (($GLOBALS['cache_instance']->loadCacheFile('points_data')) && ($GLOBALS['cache_instance']->extensionVersionMatches('sql_patches'))) {
51         // Load cache
52         $GLOBALS['cache_array']['points_data'] = $GLOBALS['cache_instance']->getArrayFromCache();
53
54         // Is there cache?
55         if (!isset($GLOBALS['cache_array']['points_data']['subject'])) {
56                 // Try to remove the cache file
57                 $GLOBALS['cache_instance']->removeCacheFile();
58
59                 // Not found, so better abort here
60                 reportBug(__FILE__, __LINE__, 'points_data has been generated, but does not contain "subject". Please try to reload to fix this.');
61         } // END - if
62
63         // Init temporary array
64         $pointsData = array();
65
66         // Rewrite all to subject
67         foreach ($GLOBALS['cache_array']['points_data']['subject'] as $key => $subject) {
68                 // Re-add key with subject
69                 foreach ($GLOBALS['cache_array']['points_data'] as $key2 => $array) {
70                         // Is key2 not 'subject'?
71                         if ($key2 != 'subject') {
72                                 // Then Add it
73                                 $pointsData[$subject][$key2] = $GLOBALS['cache_array']['points_data'][$key2][$key];
74                         } // END - if
75                 } // END - foreach
76         } // END - foreach
77
78         // Set the array back and remove temporary
79         $GLOBALS['cache_array']['points_data'] = $pointsData;
80         unset($pointsData);
81 } elseif ((isHtmlOutputMode()) && (isExtensionInstalledAndNewer('sql_patches', '0.8.6'))) {
82         // Create cache file
83         $GLOBALS['cache_instance']->init();
84
85         // Query the database about this
86         $result = sqlQuery('SELECT * FROM `{?_MYSQL_PREFIX?}_points_data` ORDER BY `id` ASC', __FILE__, __LINE__);
87         while ($dummy = sqlFetchArray($result)) {
88                 // Save row
89                 $GLOBALS['cache_instance']->addRow($dummy);
90         } // END - while
91
92         // Free memory
93         sqlFreeResult($result);
94
95         // Close cache
96         $GLOBALS['cache_instance']->storeExtensionVersion('sql_patches');
97         $GLOBALS['cache_instance']->finalize();
98 }
99
100 // [EOF]
101 ?>