Some language strings fixed, renamed. Copyright notice updated
[mailer.git] / inc / modules / member / what-themes.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 03/20/2005 *
4  * ===================                          Last change: 03/20/2005 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-themes.php                                  *
8  * -------------------------------------------------------------------- *
9  * Short description : Theme selection for members                      *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Design-Auswahl fuer Mitglieder                   *
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 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://www.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 (!isMember()) {
42         redirectToIndexMemberOnlyModule();
43 }
44
45 // Add description as navigation point
46 addYouAreHereLink('member', __FILE__);
47
48 if ((!isExtensionActive('theme')) && (!isAdmin())) {
49         loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('theme'));
50         return;
51 } // END - if
52
53 if (isPostRequestParameterSet('member_theme')) {
54         // Save theme to member's profile
55         SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `curr_theme`='%s' WHERE `userid`=%s LIMIT 1",
56                 array(postRequestParameter('member_theme'), getMemberId()), __FILE__, __LINE__);
57
58         // Set new theme for guests
59         $newTheme = SQL_ESCAPE(postRequestParameter('member_theme'));
60
61         // Change to new theme
62         setTheme($newTheme);
63
64         // Theme saved!
65         loadTemplate('admin_settings_saved', false, '{--MEMBER_THEME_SAVED--}');
66 } // END - if
67
68 // Initialize array
69 $THEMES = array(
70         'theme_unix'    => array(), // Unix name from filesystem
71         'theme_name'    => array(), // Title
72         'theme_author'  => array(), // Theme author's name
73         'theme_email'   => array(), // Author's email address
74         'theme_url'     => array(), // URL were you can download it from
75         'theme_version' => array(), // Version number of theme
76 );
77
78 // Read directory "themes"
79 $includes = getArrayFromDirectory('theme/', '', false, true, array('css', 'images'));
80
81 // Walk through all entries and add it
82 foreach ($includes as $inc) {
83         // Get directory from it
84         $dir = basename(dirname($inc));
85
86         // Is the theme active, then include it
87         if (isThemeActive($dir)) {
88                 // Found a valid directory so let's load it's theme.php file
89                 loadInclude($inc);
90
91                 // Add found theme to array
92                 $THEMES['theme_unix'][]    = $dir;
93                 $THEMES['theme_name'][]    = $GLOBALS['theme_data']['name'];
94                 $THEMES['theme_author'][]  = $GLOBALS['theme_data']['author'];
95                 $THEMES['theme_email'][]   = $GLOBALS['theme_data']['email'];
96                 $THEMES['theme_url'][]     = $GLOBALS['theme_data']['url'];
97                 $THEMES['theme_version'][] = $GLOBALS['theme_data']['version'];
98         } // END - if
99 } // END - while
100
101 // Remove last theme data
102 unset($GLOBALS['theme_data']);
103
104 // Sort array by Uni* name
105 array_pk_sort($THEMES, array('theme_name'));
106
107 // Generate output lines for the template
108 $OUT = '';
109 foreach ($THEMES['theme_unix'] as $key => $unix) {
110         $default = '';
111         if (getCurrentTheme() == $unix) {
112                 $default = ' checked="checked"';
113         } // END - if
114
115         // Prepare content
116         $content = array(
117                 'unix'          => $unix,
118                 'default'       => $default,
119                 'theme_name'    => $THEMES['theme_name'][$key],
120                 'theme_email'   => $THEMES['theme_email'][$key],
121                 'theme_author'  => $THEMES['theme_author'][$key],
122                 'theme_url'     => $THEMES['theme_url'][$key],
123                 'theme_version' => $THEMES['theme_version'][$key]
124         );
125
126         // Load row template
127         $OUT .= loadTemplate('member_themes_row', true, $content);
128 } // END - foreach
129
130 if (empty($OUT)) {
131         // No themes found???
132         $OUT = '<tr>
133   <td colspan="5" class="bottom" height="80">
134     ' . loadTemplate('admin_settings_saved', true, '{--MEMBER_NO_THEMES_FOUND--}') . '
135   </td>
136 </tr>';
137 } // END - if
138
139 // Load template
140 loadTemplate('member_themes', false, $OUT);
141
142 // [EOF]
143 ?>