4995716159eaaaba921c858f5e9fd7a407cc658b
[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  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
21  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
42         die();
43 } elseif (!isMember()) {
44         redirectToIndexMemberOnlyModule();
45 }
46
47 // Add description as navigation point
48 addMenuDescription('member', __FILE__);
49
50 if ((!isExtensionActive('theme')) && (!isAdmin())) {
51         loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('theme'));
52         return;
53 } // END - if
54
55 if (isPostRequestParameterSet('member_theme')) {
56         // Save theme to member's profile
57         SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `curr_theme`='%s' WHERE `userid`=%s LIMIT 1",
58                 array(postRequestParameter('member_theme'), getMemberId()), __FILE__, __LINE__);
59
60         // Set new theme for guests
61         $newTheme = SQL_ESCAPE(postRequestParameter('member_theme'));
62
63         // Change to new theme
64         setTheme($newTheme);
65
66         // Theme saved!
67         loadTemplate('admin_settings_saved', false, getMessage('MEMBER_THEME_SAVED'));
68 } // END - if
69
70 // Initialize array
71 $THEMES = array(
72         'theme_unix'   => array(), // Unix name from filesystem
73         'theme_name'   => array(), // Title
74         'theme_author' => array(), // Theme author's name
75         'theme_email'  => array(), // Author's email address
76         'theme_url'    => array(), // URL were you can download it from
77         'theme_version'    => array(), // Version number of theme
78 );
79
80 // Read directory "themes"
81 $includes = getArrayFromDirectory('theme/', '', false, true, array('css', 'images'));
82
83 // Walk through all entries and add it
84 foreach ($includes as $inc) {
85         // Get directory from it
86         $dir = basename(dirname($inc));
87
88         // Is the theme active, then include it
89         if (isThemeActive($dir)) {
90                 // Found a valid directory so let's load it's theme.php file
91                 loadInclude($inc);
92
93                 // Add found theme to array
94                 $THEMES['theme_unix'][]    = $dir;
95                 $THEMES['theme_name'][]    = $GLOBALS['theme_data']['name'];
96                 $THEMES['theme_author'][]  = $GLOBALS['theme_data']['author'];
97                 $THEMES['theme_email'][]   = $GLOBALS['theme_data']['email'];
98                 $THEMES['theme_url'][]     = $GLOBALS['theme_data']['url'];
99                 $THEMES['theme_version'][] = $GLOBALS['theme_data']['version'];
100         } // END - if
101 } // END - while
102
103 // Remove last theme data
104 unset($GLOBALS['theme_data']);
105
106 // Sort array by Uni* name
107 array_pk_sort($THEMES, array('theme_name'));
108
109 // Generate output lines for the template
110 $OUT = ''; $SW = 2;
111 foreach ($THEMES['theme_unix'] as $key => $unix) {
112         $default = '';
113         if (getCurrentTheme() == $unix) $default = ' selected="selected"';
114
115         // Add row
116         $OUT .= "<tr>
117   <td class=\"switch_sw".$SW." bottom right\" align=\"center\" height=\"30\">
118     <input type=\"radio\" name=\"member_theme\" class=\"member_normal\" value=\"".$unix."\"".$default." />
119   </td>
120   <td class=\"switch_sw".$SW." bottom right\" align=\"center\">".$THEMES['theme_name'][$key]."</td>
121   <td class=\"switch_sw".$SW." bottom right\" align=\"center\">
122     <a href=\"mailto:".$THEMES['theme_email'][$key]."?Subject=[Theme:] ".$THEMES['theme_name'][$key]." (".$unix.")'.'\">".$THEMES['theme_author'][$key]."</a>
123   </td>
124   <td class=\"switch_sw".$SW." bottom right\" align=\"center\">
125     <a href=\"".generateDerefererUrl($THEMES['theme_url'][$key])."\" target=\"_blank\">".$THEMES['theme_url'][$key]."</a>
126   </td>
127   <td class=\"switch_sw".$SW." bottom\" align=\"center\">v".$THEMES['theme_version'][$key]."</td>
128 </tr>\n";
129         $SW = 3 - $SW;
130 } // END - foreach
131
132 if (empty($OUT)) {
133         // No themes found???
134         $OUT = "<tr>
135   <td colspan=\"5\" class=\"bottom\" height=\"80\">
136     ".loadTemplate('admin_settings_saved', true, getMessage('MEMBER_NO_THEMES_FOUND'))."
137   </td>
138 </tr>\n";
139 } // END - if
140
141 // Load template
142 loadTemplate('member_themes', false, $OUT);
143
144 // [EOF]
145 ?>