A lot while() conditions rewritten to SQL_FETCHARRAY(), see bug #107, @TODO tags...
[mailer.git] / inc / modules / admin / what-config_home.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 09/22/2004 *
4  * ================                             Last change: 09/22/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-config_home.php                             *
8  * -------------------------------------------------------------------- *
9  * Short description : Set "home" page                                  *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : "Home"-Seite festlegen                           *
12  * -------------------------------------------------------------------- *
13  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 }
39
40 // Add description as navigation point
41 ADD_DESCR("admin", __FILE__);
42
43 // Init "sub" value
44 $sub = "";
45 if (REQUEST_ISSET_GET(('sub'))) $sub = REQUEST_GET('sub');
46
47 switch ($sub)
48 {
49 case "settings": // Settings related to the index page
50         if (IS_FORM_SENT()) {
51                 // Save settings
52                 ADMIN_SAVE_SETTINGS_POST();
53                 OUTPUT_HTML("<a href=\"{!URL!}/modules.php?module=admin&amp;what=config_home&amp;sub=settings\">{--ADMIN_CONTINUE_TO_CONFIG--}</a>");
54         } else {
55                 // Prepare data for the template
56                 $content = array_fill(-1, 60, "");
57                 $content[getConfig('index_delay')] = " selected=\"selected\"";
58
59                 define('__INDEX_COOKIE_SELECTION', CREATE_TIME_SELECTIONS(getConfig('index_cookie'), "index_cookie", "YMWD"));
60                 LOAD_TEMPLATE("admin_config_home_settings", false, $content);
61         }
62         break;
63
64 case "target": // Set which what-file will be placed in home-page (only modules.php?module=index)
65         if (REQUEST_ISSET_GET(('home'))) {
66                 // Set new home
67                 UPDATE_CONFIG("index_home", REQUEST_GET(('home')));
68         } // END - if
69
70         // Load all what menu points
71         $result = SQL_QUERY("SELECT id, what, title
72 FROM `{!_MYSQL_PREFIX!}_guest_menu`
73 WHERE `action`='main' AND `what` != '' AND `what` IS NOT NULL AND `locked`='N'
74 ORDER BY `sort` ASC", __FILE__, __LINE__);
75
76         // Init variables
77         $SW = 2;
78         $OUT = "";
79
80         // Process all entries
81         while ($content = SQL_FETCHARRAY($result)) {
82                 // Link for setting 'what' as new "home"
83                 $LINK = "<a href=\"{!URL!}/modules.php?module=admin&amp;what=config_home&amp;sub=target&amp;home=".$content['what']."\">{--_IS_NEW_HOME--}</a>";
84
85                 // Is this current home?
86                 if ($content['what'] == getConfig('index_home')) {
87                         // Is current home
88                         $LINK = "<div class=\"admin_note\">{!_IS_CURRENT_HOME!}</div>";
89                         $content['title'] = "<div class=\"admin_note\">".$content['title']."</div>";
90                 } // END - if
91
92                 // Prepare content
93                 $content['sw'] = $SW;
94                 $content['link'] = $LINK;
95
96                 // Load row template
97                 $OUT .= LOAD_TEMPLATE("admin_config_home_row", true, $content);
98
99                 // Switch color
100                 $SW = 3 - $SW;
101         } // END - while
102
103         // Free memory
104         SQL_FREERESULT($result);
105         define('__HOME_ROWS', $OUT);
106
107         // Load template
108         LOAD_TEMPLATE("admin_config_home");
109         break;
110
111 default: // Output selection table
112         LOAD_TEMPLATE("admin_config_home_main");
113         break;
114
115 }
116
117 //
118 ?>