]> git.mxchange.org Git - mailer.git/blob - inc/modules/admin/what-list_surfbar_urls.php
New wrapper functions introduced, some one-line parameter monsters killed:
[mailer.git] / inc / modules / admin / what-list_surfbar_urls.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 08/31/2008 *
4  * ===================                          Last change: 08/31/2008 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-list_surfbar_urls.php                       *
8  * -------------------------------------------------------------------- *
9  * Short description : List all URLs in surfbar and sync from mail pool *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Alle URLs in Surfbar auflisten und syncen        *
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')) || (!isAdmin())) {
40         die();
41 } // END - if
42
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
45
46 // By default show the list...
47 $show = true;
48
49 // Check for 'url_id' element
50 if ((countRequestPost() > 0) && ((!isPostRequestParameterSet('url_id')) || (!is_array(postRequestParameter('url_id'))) || (count(postRequestParameter('url_id')) == 0))) {
51         // Not found so output message
52         loadTemplate('admin_settings_saved', false, '{--ADMIN_SURFBAR_NO_SELECTIONS--}');
53
54         // Abort here
55         return;
56 } // END - if
57
58 // Edit or delete button hit?
59 if (isFormSent('edit')) {
60         // Show entries for editing
61         adminEditEntriesConfirm(
62                 postRequestParameter('url_id'),
63                 'surfbar_urls',
64                 array(
65                         'url_id',
66                         'url_userid',
67                         'url'
68                 ),
69                 array(
70                         'bigintval',
71                         'addMemberSelectionBox',
72                         ''
73                 ),
74                 array(
75                         '',
76                         array(
77                                 false,
78                                 true,
79                                 true,
80                                 'url_userid[]'
81                         ),
82                         ''
83                 ),
84                 false,
85                 'url_id',
86                 'url_userid',
87                 'url_userid'
88         );
89         $show = false;
90 } elseif (isPostRequestParameterSet('do_edit')) {
91         // Change data of entries
92         adminEditEntriesConfirm(
93                 postRequestParameter('url_id'),
94                 'surfbar_urls',
95                 array(),
96                 array(),
97                 array(),
98                 true,
99                 'url_id',
100                 'url_userid',
101                 'url_userid'
102         );
103 } elseif (isPostRequestParameterSet('delete')) {
104         // Show entries for deletion
105         adminDeleteEntriesConfirm(
106         postRequestParameter('url_id'),
107                 'surfbar_urls',
108                 array(
109                         'url_id',
110                         'url_userid',
111                         'url',
112                         'url_registered'
113                 ),
114                 array(
115                         'bigintval',
116                         'generateUserProfileLink',
117                         'generateFrametesterUrl',
118                         ''
119                 ),
120                 array(
121                         '',
122                         '',
123                         '',
124                         ''
125                 ),
126                 false,
127                 'url_id',
128                 'url_userid',
129                 'url_userid'
130         );
131         $show = false;
132 } elseif (isPostRequestParameterSet('do_delete')) {
133         // Remove entries from database
134         adminDeleteEntriesConfirm(
135                 postRequestParameter('url_id'),
136                 'surfbar_urls',
137                 array(),
138                 array(),
139                 array(),
140                 true,
141                 'url_id'
142         );
143 } elseif (isFormSent('lock')) {
144         // Un-/lock selected URLs. This does not work for pending URLs
145         adminLockEntriesConfirm(
146                 postRequestParameter('url_id'),
147                 'surfbar_urls',
148                 array(
149                         'url_id',
150                         'url_userid',
151                         'url',
152                         'url_registered',
153                         'url_status'
154                 ),
155                 array(
156                         'bigintval',
157                         'generateUserProfileLink',
158                         'generateFrametesterUrl',
159                         '',
160                         'translateSurfbarUrlStatus'
161                 ),
162                 array(
163                         '',
164                         '',
165                         '',
166                         '',
167                         ''
168                 ),
169                 false,
170                 'url_id',
171                 'url_userid',
172                 'url_userid'
173         );
174         $show = false;
175 } elseif (isPostRequestParameterSet('do_lock')) {
176         // Un-/lock selected URLs. This does not work for pending URLs
177         adminLockEntriesConfirm(
178                 postRequestParameter('url_id'),
179                 'surfbar_urls',
180                 array(),
181                 array(),
182                 array(),
183                 array(
184                         'url_status' => array(
185                                 'ACTIVE' => 'LOCKED',
186                                 'LOCKED' => 'ACTIVE'
187                         )
188                 ),
189                 true,
190                 'url_id',
191                 'url_userid',
192                 'url_userid'
193         );
194 } elseif (isPostRequestParameterSet('undelete')) {
195         // Undelete selected URLs. This does only work for deleted URLs... ;-)
196         adminUndeleteEntriesConfirm(
197                 postRequestParameter('url_id'),
198                 'surfbar_urls',
199                 array(
200                         'url_id',
201                         'url_userid',
202                         'url',
203                         'url_registered',
204                         'url_status'
205                 ),
206                 array(
207                         'bigintval',
208                         'generateUserProfileLink',
209                         'generateFrametesterUrl',
210                         '',
211                         'translateSurfbarUrlStatus'
212                 ),
213                 array(
214                         '',
215                         '',
216                         '',
217                         '',
218                         ''
219                 ),
220                 false,
221                 'url_id',
222                 'url_userid',
223                 'url_userid'
224         );
225         $show = false;
226 } elseif (isPostRequestParameterSet('do_undelete')) {
227         // Undelete selected URLs. This does only work for deleted URLs... ;-)
228         adminUndeleteEntriesConfirm(
229                 postRequestParameter('url_id'),
230                 'surfbar_urls',
231                 array(),
232                 array(),
233                 array(),
234                 array(
235                         'url_status' => array(
236                                 'DELETED' => 'ACTIVE'
237                         )
238                 ),
239                 true,
240                 'url_id',
241                 'url_userid',
242                 'url_userid'
243         );
244 }
245
246 // Show entries?
247 if ($show === false) return false;
248
249 // List all URLs
250 $result = SQL_QUERY("SELECT
251         `url_id`, `url_userid`, `url`, `url_views_total`, `url_status`,
252         UNIX_TIMESTAMP(`url_registered`) AS `url_registered`,
253         UNIX_TIMESTAMP(`url_last_locked`) AS `url_last_locked`,
254         `url_lock_reason`
255 FROM
256         `{?_MYSQL_PREFIX?}_surfbar_urls`
257 ORDER BY
258         `url_id` ASC", __FILE__, __LINE__);
259
260 // Do we have some URLs left?
261 if (!SQL_HASZERONUMS($result)) {
262         // List all URLs
263         $OUT = '';
264         while ($content = SQL_FETCHARRAY($result)) {
265                 // "Translate"/add content
266                 $content['url_registered']  = generateDateTime($content['url_registered'], 2);
267                 $content['url_last_locked'] = generateDateTime($content['url_last_locked'], 2);
268
269                 // Load row template
270                 $OUT .= loadTemplate('admin_list_surfbar_urls_row', true, $content);
271         } // END - while
272
273         // Load main template
274         loadTemplate('admin_list_surfbar_urls', false, $OUT);
275 } else {
276         // No URLs in surfbar
277         loadTemplate('admin_settings_saved', false, '{--ADMIN_SURFBAR_NO_URLS_FOUND--}');
278 }
279
280 // Free result
281 SQL_FREERESULT($result);
282
283 // [EOF]
284 ?>