]> git.mxchange.org Git - mailer.git/blob - inc/modules/admin/what-mem_add.php
Email templates added when member edits his/her URLs
[mailer.git] / inc / modules / admin / what-mem_add.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    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  *                                                                      *
15  * -------------------------------------------------------------------- *
16  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
17  * For more information visit: http://www.mxchange.org                  *
18  *                                                                      *
19  * This program is free software; you can redistribute it and/or modify *
20  * it under the terms of the GNU General Public License as published by *
21  * the Free Software Foundation; either version 2 of the License, or    *
22  * (at your option) any later version.                                  *
23  *                                                                      *
24  * This program is distributed in the hope that it will be useful,      *
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
27  * GNU General Public License for more details.                         *
28  *                                                                      *
29  * You should have received a copy of the GNU General Public License    *
30  * along with this program; if not, write to the Free Software          *
31  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
32  * MA  02110-1301  USA                                                  *
33  ************************************************************************/
34
35 // Some security stuff...
36 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38         require($INC);
39 }
40
41 // Add desciption as navigation point
42 ADD_DESCR("admin", __FILE__);
43
44 // Check if the admin has entered title and what-php file name...
45 if ((empty($_POST['title'])) && (isset($_POST['ok'])))
46 {
47         unset($_POST['ok']);
48 }
49
50 if (!isset($_POST['ok']))
51 {
52         // Create arrays
53         $menus = array(); $titles = array(); $below = array();
54
55         // Get all available main menus
56         $result = SQL_QUERY("SELECT action, title, sort FROM "._MYSQL_PREFIX."_member_menu WHERE (what='' OR what IS NULL) ORDER BY sort", __FILE__, __LINE__);
57         if (SQL_NUMROWS($result) > 0)
58         {
59                 // Read menu structure
60                 while (list($act, $title, $sort) = SQL_FETCHROW($result))
61                 {
62                         // Menu actions
63                         $menus[] = $act;
64
65                         // Menu titles
66                         $titles[] = $title;
67
68                         // Below this menu point should the new be added so we simply increase the sort value by 1 :-)
69                         $below[] = $sort + 1;
70                 }
71
72                 // Free memory
73                 SQL_FREERESULT($result);
74
75                 // Remove double eintries
76                 $prev = ""; $dmy = $menus; $dmy2 = $titles; $dmy3 = $below;
77                 foreach ($menus as $key => $value)
78                 {
79                         if ($value == $prev)
80                         {
81                                 // Remove entries
82                                 unset($dmy[$key]);
83                                 unset($dmy2[$key]);
84                                 unset($dmy3[$key]);
85                         }
86                          else
87                         {
88                                 $prev = $value;
89                         }
90                 }
91                 $menus = $dmy; $titles = $dmy2; $below = $dmy3;
92                 // Load sub menus :)
93                 foreach ($menus as $key_main => $value_main)
94                 {
95                         $result = SQL_QUERY_ESC("SELECT what, title, sort FROM "._MYSQL_PREFIX."_member_menu WHERE action='%s' AND what != '' ORDER BY sort",
96                          array($value_main), __FILE__, __LINE__);
97                         if (SQL_NUMROWS($result) > 0)
98                         {
99                                 // Initialize arrays
100                                 $menus[$value_main] = array();
101                                 $titles[$value_main] = array();
102                                 $below[$value_main] = array();
103
104                                 // Read menu structure
105                                 while (list($act, $title, $sort) = SQL_FETCHROW($result))
106                                 {
107                                         // Menu actions
108                                         $menus[$value_main][] = $act;
109
110                                         // Menu titles
111                                         $titles[$value_main][] = $title;
112
113                                         // Below this menu point should the new be added so we simply increase the sort value by 1 :-)
114                                         $below[$value_main][] = $sort + 1;
115                                 }
116
117                                 // Free memory
118                                 SQL_FREERESULT($result);
119
120                                 // Remove double eintries
121                                 $prev = ""; $dmy = $menus[$value_main]; $dmy2 = $titles[$value_main]; $dmy3 = $below[$value_main];
122                                 foreach ($menus[$value_main] as $key => $value)
123                                 {
124                                         if ($value == $prev)
125                                         {
126                                                 unset($dmy[$key]);
127                                                 unset($dmy2[$key]);
128                                                 unset($dmy3[$key]);
129                                         }
130                                          else
131                                         {
132                                                 $prev = $value;
133                                         }
134                                 }
135                                 $menus[$value_main] = $dmy; $titles[$value_main] = $dmy2; $below[$value_main] = $dmy3;
136                         }
137                 }
138         }
139
140         $OUT = "<SELECT class=\"admin_select\" name=\"sort\" size=\"1\">
141       <OPTION value=\"\">".IS_FIRST_MENU."</OPTION>";
142         foreach ($below as $key => $m)
143         {
144                 if (is_array($m))
145                 {
146                         foreach ($m as $key2 => $m2)
147                         {
148                                 $OUT .= "      <OPTION value=\"".$m2."\">".$titles[$key][$key2];
149                                 foreach ($menus as $k => $v)
150                                 {
151                                         if (($v == $key) && (!is_array($v)))
152                                         {
153                                                 $OUT .= " (".$titles[$k].")";
154                                         }
155                                 }
156                                 $OUT .= "</OPTION>\n";
157                         }
158                 }
159                  else
160                 {
161                         $OUT .= "      <OPTION value=\"".$m."\">".$titles[$key]."</OPTION>\n";
162                 }
163         }
164         $OUT .= "</SELECT>";
165
166         define('__BELOW_SELECTION' , $OUT);
167         define('__WHAT_SELECTION'  , ADMIN_MAKE_MENU_SELECTION("member", "what", "name"));
168         define('__ACTION_SELECTION', ADMIN_MAKE_MENU_SELECTION("member", "action", "menu"));
169
170         // Display form
171         LOAD_TEMPLATE("admin_member_add");
172 }
173  elseif (!IS_DEMO())
174 {
175         // Insert new menu entry
176         if (!empty($_POST['menu']))
177         {
178                 $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_member_menu (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('%s','%s','%s','%s','%s','%s')",
179  array(
180         $_POST['menu'],
181         $_POST['name'],
182         $_POST['title'],
183         $_POST['visible'],
184         $_POST['active'],
185         bigintval($_POST['sort']),
186 ), __FILE__, __LINE__);
187         }
188          else
189         {
190                 $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_member_menu (`action`,`title`,`visible`,`locked`,`sort`) VALUES ('%s','%s','%s','%s','%s')",
191  array(
192         $_POST['name'],
193         $_POST['title'],
194         $_POST['visible'],
195         $_POST['active'],
196         bigintval($_POST['sort']),
197 ), __FILE__, __LINE__);
198         }
199         LOAD_TEMPLATE("admin_settings_saved", false, SAVING_DONE);
200 }
201  else
202 {
203         // Demo mode!
204         LOAD_TEMPLATE("admin_settings_saved", false, SETTINGS_NOT_SAVED);
205 }
206
207 //
208 ?>