105a80be10408af072a8072f97309cdce8c5ce46
[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  * 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')) || (!isAdmin())) {
42         die();
43 } // END - if
44
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
47
48 // By default show the list...
49 $show = true;
50
51 // Check for 'url_id' element
52 if ((countRequestPost() > 0) && ((!isPostRequestParameterSet('url_id')) || (!is_array(postRequestParameter('url_id'))) || (count(postRequestParameter('url_id')) == 0))) {
53         // Not found so output message
54         loadTemplate('admin_settings_saved', false, '{--ADMIN_SURFBAR_NO_SELECTIONS--}');
55
56         // Abort here
57         return;
58 } // END - if
59
60 // Edit or delete button hit?
61 if (isFormSent('edit')) {
62         // Show entries for editing
63         adminEditEntriesConfirm(
64                 postRequestParameter('url_id'),
65                 'surfbar_urls',
66                 array('url_id', 'url_userid', 'url'),
67                 array('bigintval', 'addMemberSelectionBox', ''),
68                 array('', array(false, true, true, 'url_userid[]'), ''),
69                 false,
70                 'url_id',
71                 'url_userid',
72                 'url_userid'
73         );
74         $show = false;
75 } elseif (isPostRequestParameterSet('do_edit')) {
76         // Change data of entries
77         adminEditEntriesConfirm(
78                 postRequestParameter('url_id'),
79                 'surfbar_urls',
80                 array(),
81                 array(),
82                 array(),
83                 true,
84                 'url_id',
85                 'url_userid',
86                 'url_userid'
87         );
88 } elseif (isPostRequestParameterSet('delete')) {
89         // Show entries for deletion
90         adminDeleteEntriesConfirm(
91         postRequestParameter('url_id'),
92                 'surfbar_urls',
93                 array('url_id', 'url_userid', 'url', 'url_registered'),
94                 array('bigintval', 'generateUserProfileLink', 'generateFrametesterUrl', ''),
95                 array('', '', '', ''),
96                 false,
97                 'url_id',
98                 'url_userid',
99                 'url_userid'
100         );
101         $show = false;
102 } elseif (isPostRequestParameterSet('do_delete')) {
103         // Remove entries from database
104         adminDeleteEntriesConfirm(postRequestParameter('url_id'), 'surfbar_urls', array(), array(), array(), true, 'url_id');
105 } elseif (isFormSent('lock')) {
106         // Un-/lock selected URLs. This does not work for pending URLs
107         adminLockEntriesConfirm(
108                 postRequestParameter('url_id'),
109                 'surfbar_urls',
110                 array('url_id', 'url_userid', 'url', 'url_registered', 'url_status'),
111                 array('bigintval', 'generateUserProfileLink', 'generateFrametesterUrl', '', 'translateSurfbarUrlStatus'),
112                 array('', '', '', '', ''),
113                 false,
114                 'url_id',
115                 'url_userid',
116                 'url_userid'
117         );
118         $show = false;
119 } elseif (isPostRequestParameterSet('do_lock')) {
120         // Un-/lock selected URLs. This does not work for pending URLs
121         adminLockEntriesConfirm(
122                 postRequestParameter('url_id'),
123                 'surfbar_urls',
124                 array(),
125                 array(),
126                 array(),
127                 array('url_status' => array('ACTIVE' => 'LOCKED', 'LOCKED' => 'ACTIVE')),
128                 true,
129                 'url_id',
130                 'url_userid',
131                 'url_userid'
132         );
133 } elseif (isPostRequestParameterSet('undelete')) {
134         // Undelete selected URLs. This does only work for deleted URLs... ;-)
135         adminUndeleteEntriesConfirm(
136                 postRequestParameter('url_id'),
137                 'surfbar_urls',
138                 array('url_id', 'url_userid', 'url', 'url_registered', 'url_status'),
139                 array('bigintval', 'generateUserProfileLink', 'generateFrametesterUrl', '', 'translateSurfbarUrlStatus'),
140                 array('', '', '', '', ''),
141                 false,
142                 'url_id',
143                 'url_userid',
144                 'url_userid'
145         );
146         $show = false;
147 } elseif (isPostRequestParameterSet('do_undelete')) {
148         // Undelete selected URLs. This does only work for deleted URLs... ;-)
149         adminUndeleteEntriesConfirm(
150                 postRequestParameter('url_id'),
151                 'surfbar_urls',
152                 array(),
153                 array(),
154                 array(),
155                 array('url_status' => array('DELETED' => 'ACTIVE')),
156                 true,
157                 'url_id',
158                 'url_userid',
159                 'url_userid'
160         );
161 }
162
163 // Show entries?
164 if ($show === false) return false;
165
166 // List all URLs
167 $result = SQL_QUERY("SELECT
168         `url_id`, `url_userid`, `url`, `url_views_total`, `url_status`,
169         UNIX_TIMESTAMP(`url_registered`) AS `url_registered`,
170         UNIX_TIMESTAMP(`url_last_locked`) AS `url_last_locked`,
171         `url_lock_reason`
172 FROM
173         `{?_MYSQL_PREFIX?}_surfbar_urls`
174 ORDER BY
175         `url_id` ASC", __FILE__, __LINE__);
176
177 // Do we have some URLs left?
178 if (SQL_NUMROWS($result) > 0) {
179         // List all URLs
180         $OUT = '';
181         while ($content = SQL_FETCHARRAY($result)) {
182                 // "Translate"/add content
183                 $content['url_registered']  = generateDateTime($content['url_registered'], 2);
184                 $content['url_last_locked'] = generateDateTime($content['url_last_locked'], 2);
185
186                 // Load row template
187                 $OUT .= loadTemplate('admin_list_surfbar_urls_row', true, $content);
188         } // END - while
189
190         // Load main template
191         loadTemplate('admin_list_surfbar_urls', false, $OUT);
192 } else {
193         // No URLs in surfbar
194         loadTemplate('admin_settings_saved', false, '{--ADMIN_SURFBAR_NO_URLS_FOUND--}');
195 }
196
197 // Free result
198 SQL_FREERESULT($result);
199
200 // [EOF]
201 ?>