Code style changed, ext-user continued:
[mailer.git] / inc / modules / admin / what-theme_edit.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 02/12/2004 *
4  * ===================                          Last change: 02/12/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-theme_edit.php                              *
8  * -------------------------------------------------------------------- *
9  * Short description :                                                  *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  :                                                  *
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 - 2012 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')) || (!isAdmin())) {
40         die();
41 } // END - if
42
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
45
46 // Check for selected themes
47 if (ifPostContainsSelections()) {
48         $OUT = '';
49         foreach (postRequestElement('sel') as $id => $sel) {
50                 $sql = '';
51                 // Shall I de-/activate or delete themes?
52                 if (isPostRequestElementSet('status')) {
53                         // Change status
54                         if (postRequestElement('active', $id) == 'Y') {
55                                 $sql = "UPDATE `{?_MYSQL_PREFIX?}_themes` SET `theme_active`='N' WHERE `id`=%s LIMIT 1";
56                         } else {
57                                 $sql = "UPDATE `{?_MYSQL_PREFIX?}_themes` SET `theme_active`='Y' WHERE `id`=%s LIMIT 1";
58                         }
59                         $OUT = '{--ADMIN_THEMES_UPDATED--}';
60                 } elseif (isFormSent('delete')) {
61                         // Delete themes
62                         $sql = "DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_themes` WHERE `id`=%s LIMIT 1";
63                         $OUT = '{--ADMIN_THEMES_DELETED--}';
64                 }
65
66                 // Run SQL command?
67                 if (!empty($sql)) {
68                         // Run it
69                         $result = SQL_QUERY_ESC($sql, array(bigintval($id)), __FILE__, __LINE__);
70
71                         // Rebuild cache
72                         rebuildCache('themes', 'them');
73                 } // END - if
74         } // END - foreach
75
76         // Output generated?
77         if (empty($OUT)) $OUT = '{--ADMIN_THEME_NO_OUTPUT--}';
78 } elseif (isGetRequestElementSet('default_theme')) {
79         // Escape string from input
80         $postData['default_theme'] = getRequestElement('default_theme');
81
82         // Set session
83         setMailerTheme($postData['default_theme']);
84
85         // Set it in config and current theme as well
86         setConfigEntry('default_theme', $postData['default_theme']);
87
88         // Save theme
89         adminSaveSettings($postData);
90 }
91
92 // Init rows
93 $OUT = ''; 
94
95 // Switch to testing mode
96 $GLOBALS['theme_mode'] = 'test';
97
98 $result = SQL_QUERY("SELECT
99         `id`,
100         `theme_path`,
101         `theme_active`,
102         `theme_ver` AS `theme_version`,
103         `theme_name`
104 FROM
105         `{?_MYSQL_PREFIX?}_themes`
106 ORDER BY
107         `theme_path` ASC", __FILE__, __LINE__);
108
109 if (!SQL_HASZERONUMS($result)) {
110         while ($content = SQL_FETCHARRAY($result)) {
111                 // Construct IFN
112                 $inc = sprintf("theme/%s/theme.php", $content['theme_path']);
113
114                 // Load theme in test mode
115                 loadInclude($inc);
116
117                 // Copy data from theme to content
118                 $content['theme_url'] = $GLOBALS['theme_data']['url'];
119
120                 // Is the loaded theme name != current theme name?
121                 $content['link'] = $content['theme_path'];
122                 if ($content['theme_path'] != getCurrentTheme()) {
123                         $content['link'] = '<a href="{%url=modules.php?module=admin&amp;what=theme_edit&amp;default_theme=' . $content['theme_path'] . '%}" title="{--ADMIN_SET_AS_NEW_THEME--}">' . $content['theme_path'] . '</a>';
124                 } // END - if
125
126                 // Prepare data for the row template
127                 $content['email'] = '<a href="mailto:' . $GLOBALS['theme_data']['email'] . '?Subject=[Theme:] ' . $GLOBALS['theme_data']['name'] . ' (' . $content['theme_path'] . ')\>' . $GLOBALS['theme_data']['author'] . '</a>';
128
129                 // Load row template and switch color
130                 $OUT .= loadTemplate('admin_edit_theme_row', TRUE, $content);
131         } // END - while
132
133         // Free memory
134         SQL_FREERESULT($result);
135 } else {
136         // No themes found???
137         $OUT .= '<tr>
138   <td colspan="7" class="bottom" height="60">
139     ' . displayMessage('{--ADMIN_NO_THEMES_FOUND--}', TRUE) . '
140   </td>
141 </tr>';
142 }
143
144 // Load template
145 loadTemplate('admin_edit_theme', FALSE, $OUT);
146
147 // [EOF]
148 ?>