]> git.mxchange.org Git - mailer.git/blob - inc/modules/admin/what-mem_add.php
- Rewrites to use more the userid than the actual email address when sending
[mailer.git] / inc / modules / admin / what-mem_add.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 09/28/2003 *
4  * ===================                          Last change: 12/13/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-mem_add.php                                 *
8  * -------------------------------------------------------------------- *
9  * Short desciption : Add new menu for your members                     *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Fuegen Sie einen weiteren Menuepunkt zum Mit-    *
12  *                     Mitgliedsmenue hinzu                             *
13  * -------------------------------------------------------------------- *
14  * $Revision::                                                        $ *
15  * $Date::                                                            $ *
16  * $Tag:: 0.2.1-FINAL                                                 $ *
17  * $Author::                                                          $ *
18  * -------------------------------------------------------------------- *
19  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
20  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
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')) || (!isAdmin())) {
41         die();
42 } // END - if
43
44 // Add desciption as navigation point
45 addYouAreHereLink('admin', __FILE__);
46
47 // Check if the admin has entered title and what-php file name...
48 if ((!isPostRequestParameterSet('title')) && (isFormSent())) {
49         unsetPostRequestParameter('ok');
50 } // END - if
51
52 if (!isFormSent()) {
53         // Create arrays
54         $menus  = array();
55         $titles = array();
56         $below  = array();
57
58         // Get all available main menus
59         $result = SQL_QUERY("SELECT `action`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE (`what`='' OR `what` IS NULL) ORDER BY `sort` ASC",
60                 __FILE__, __LINE__);
61         if (!SQL_HASZERONUMS($result)) {
62                 // Read menu structure
63                 // @TODO Cant this be rewritten?
64                 while ($content = SQL_FETCHARRAY($result)) {
65                         // Menu actions
66                         $menus[] = $content['action'];
67
68                         // Menu titles
69                         $titles[] = $content['title'];
70
71                         // Below this menu point should the new be added so we simply increase the sort value by 1 :-)
72                         $below[] = $content['sort'] + 1;
73                 } // END - if
74
75                 // Free memory
76                 SQL_FREERESULT($result);
77
78                 // Remove double eintries
79                 // @TODO This can be somehow rewritten to a function
80                 $prev = '';
81                 $dmy  = $menus;
82                 $dmy2 = $titles;
83                 $dmy3 = $below;
84                 foreach ($menus as $key => $value) {
85                         if ($value == $prev) {
86                                 // Remove entries
87                                 unset($dmy[$key]);
88                                 unset($dmy2[$key]);
89                                 unset($dmy3[$key]);
90                         } else {
91                                 $prev = $value;
92                         }
93                 } // END - foreach
94
95                 // Prepare variables
96                 $menus = $dmy; $titles = $dmy2; $below = $dmy3;
97
98                 // Load sub menus :)
99                 foreach ($menus as $key_main => $value_main) {
100                         $result = SQL_QUERY_ESC("SELECT `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='%s' AND `what` != '' ORDER BY `sort` ASC",
101                                 array($value_main), __FILE__, __LINE__);
102                         if (!SQL_HASZERONUMS($result)) {
103                                 // Initialize arrays
104                                 $menus[$value_main] = array();
105                                 $titles[$value_main] = array();
106                                 $below[$value_main] = array();
107
108                                 // Read menu structure
109                                 while ($content = SQL_FETCHARRAY($result)) {
110                                         // Menu actions
111                                         $menus[$value_main][] = $content['what'];
112
113                                         // Menu titles
114                                         $titles[$value_main][] = $content['title'];
115
116                                         // Below this menu point should the new be added so we simply increase the sort value by 1 :-)
117                                         $below[$value_main][] = $content['sort'] + 1;
118                                 } // END - while
119
120                                 // Free memory
121                                 SQL_FREERESULT($result);
122
123                                 // Remove double eintries
124                                 // @TODO This can be somehow rewritten to a function
125                                 $prev = ''; $dmy = $menus[$value_main]; $dmy2 = $titles[$value_main]; $dmy3 = $below[$value_main];
126                                 foreach ($menus[$value_main] as $key => $value) {
127                                         if ($value == $prev) {
128                                                 unset($dmy[$key]);
129                                                 unset($dmy2[$key]);
130                                                 unset($dmy3[$key]);
131                                         } else {
132                                                 $prev = $value;
133                                         }
134                                 } // END - foreach
135
136                                 // Transfer variables into array
137                                 $menus[$value_main]  = $dmy;
138                                 $titles[$value_main] = $dmy2;
139                                 $below[$value_main]  = $dmy3;
140                         } // END - if
141                 } // END - foreach
142         } // END - if
143
144         $OUT = '<select class="form_select" name="sort" size="1">
145       <option value="">{--ADMIN_IS_FIRST_MENU--}</option>';
146         foreach ($below as $key => $m) {
147                 if (is_array($m)) {
148                         foreach ($m as $key2 => $m2) {
149                                 $OUT .= '<option value="' . $m2 . '">' . $titles[$key][$key2];
150                                 foreach ($menus as $k => $v) {
151                                         if (($v == $key) && (!is_array($v))) {
152                                                 $OUT .= ' (' . $titles[$k] . ')';
153                                         } // END - if
154                                 } // END - foreach
155                                 $OUT .= '</option>';
156                         } // END - foreach
157                 } else {
158                         $OUT .= '<option value="' . $m . '">' . $titles[$key] . '</option>';
159                 }
160         }
161         $OUT .= '</select>';
162
163         // Prepare selection boxes for template
164         $content['below_selection']  = $OUT;
165         $content['what_selection']   = adminAddMenuSelectionBox('member', 'what'  , 'name');
166         $content['action_selection'] = adminAddMenuSelectionBox('member', 'action', 'menu');
167
168         // Display form
169         loadTemplate('admin_add_member_menu', false, $content);
170 } elseif (!isDemoModeActive()) {
171         // Insert new menu entry
172         if (isPostRequestParameterSet('menu')) {
173                 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('%s','%s','%s','%s','%s','%s')",
174                         array(
175                                 postRequestParameter('menu'),
176                                 postRequestParameter('name'),
177                                 postRequestParameter('title'),
178                                 postRequestParameter('visible'),
179                                 postRequestParameter('active'),
180                                 bigintval(postRequestParameter('sort')),
181                         ), __FILE__, __LINE__);
182         } else {
183                 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_member_menu` (`action`,`title`,`visible`,`locked`,`sort`) VALUES ('%s','%s','%s','%s','%s')",
184                         array(
185                                 postRequestParameter('name'),
186                                 postRequestParameter('title'),
187                                 postRequestParameter('visible'),
188                                 postRequestParameter('active'),
189                                 bigintval(postRequestParameter('sort')),
190                         ), __FILE__, __LINE__);
191         }
192         displayMessage('{--SETTINGS_SAVED');
193 } else {
194         // Demo mode!
195         displayMessage('{--SETTINGS_NOT_SAVED--}');
196 }
197
198 // [EOF]
199 ?>