3 * Site Mailings Subscription Maintenance page
5 * This page is used to maintain site mailings (currently, just
6 * unsubscribe specific user).
8 * Copyright 1999-2001 (c) VA Linux Systems
9 * Copyright (C) 2010 Alain Peyrat - Alcatel-Lucent
11 * This file is part of FusionForge. FusionForge is free software;
12 * you can redistribute it and/or modify it under the terms of the
13 * GNU General Public License as published by the Free Software
14 * Foundation; either version 2 of the Licence, or (at your option)
17 * FusionForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 require_once '../env.inc.php';
29 require_once $gfcommon.'include/pre.php';
30 require_once $gfwww.'admin/admin_utils.php';
32 session_require_global_perm ('forge_admin');
34 $user_name = getStringFromRequest('user_name');
35 $pattern = getStringFromRequest('pattern');
37 if (getStringFromRequest('submit') && $user_name) {
38 $type = getStringFromRequest('type');
43 Show form for unsubscription type selection
46 site_admin_header(array('title'=>_('Site Mailings Subscription Maintenance')));
49 <h2><?php echo _('Unsubscribe user:'); ?> <?php echo $user_name; ?></h2>
51 <?php echo _('You can unsubscribe user either from admin-initiated sitewide mailings or from all site mailings (admin-initiated and automated mailings, like forum and file release notifications).'); ?>
53 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="post">
54 <input type="hidden" name="user_name" value="<?php echo $user_name?>" />
55 Unsubscription type: <?php echo html_build_select_box_from_arrays(
56 array(_('MAIL'),_('ALL')),
57 array(_('Admin-initiated mailings'),_('All site mailings')),
60 <input type="submit" name="submit" value="<?php echo _('Unsubscribe'); ?>" />
64 site_admin_footer(array());
69 Perform unsubscription
72 $u =& user_get_object_by_name($user_name);
73 if (!$u || !is_object($u)) {
74 exit_error(_('Could Not Get User'),'home');
75 } elseif ($u->isError()) {
76 exit_error($u->getErrorMessage(),'home');
79 if (!$u->unsubscribeFromMailings($type=='ALL' ? 1 : 0)) {
80 exit_error(_('Could not unsubscribe user: ').$u->getErrorMessage(),'home');
83 $feedback .= _('User unsubscribed');
87 site_admin_header(array('title'=>_('Site Mailings Subscription Maintenance')));
92 <?php printf(_('Use field below to find users which match given pattern with the %1$s username, real name, or email address (substring match is preformed, use \'%%\' in the middle of pattern to specify 0 or more arbitrary characters). Click on the username to unsubscribe user from site mailings (new form will appear).'), forge_get_config ('forge_name')); ?>
95 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="post">
96 Pattern: <input type="text" name="pattern" value="<?php echo $pattern; ?>" />
97 <input type="submit" name="submit" value="<?php echo _('Show users matching pattern'); ?>" />
103 $res = db_query_params('SELECT *
105 WHERE lower(user_name) LIKE $1
106 OR lower(realname) LIKE $1
107 OR lower(email) LIKE $1',
108 array (strtolower ("%$pattern%")));
112 $title[]=_('user_id');
113 $title[]=_('User name');
114 $title[]=_('Real name');
116 $title[]=_('Site Mail.');
117 $title[]=_('Comm. Mail.');
119 echo $GLOBALS['HTML']->listTableTop($title);
122 while ($row = db_fetch_array($res)) {
124 <tr '.$GLOBALS['HTML']->boxGetAltRowStyle($i++).'>
126 <td>'.$row['user_id'].'</td>
127 <td><a href="unsubscribe.php?submit=1&user_name='.$row['user_name'].'">'.$row['user_name'].'</a></td>
128 <td>'.$row['realname'].'</td>
129 <td> '.$row['email'].'</td>
130 <td>'.$row['mail_siteupdates'].'</td>
131 <td> '.$row['mail_va'].'</td>
136 echo $GLOBALS['HTML']->listTableBottom();
140 site_admin_footer(array());
144 // c-file-style: "bsd"