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