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