5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
7 * Copyright 2014, Franck Villaume - TrivialDev
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 require_once '../env.inc.php';
26 require_once $gfcommon.'include/pre.php';
30 if (!forge_get_config('use_diary')) {
31 exit_disabled('home');
34 if (!session_loggedin()) {
38 User obviously has to be logged in to monitor
40 $diary_user = getStringFromRequest('diary_user');
43 First check to see if they are already monitoring
44 If they are, unmonitor by deleting row.
45 If they are NOT, then insert a row into the db
48 site_user_header(array('title'=>_('Monitor a User')));
50 $result = db_query_params ('SELECT * FROM user_diary_monitor WHERE user_id=$1 AND monitored_user=$2;',
53 if (!$result || db_numrows($result) < 1) {
55 User is not already monitoring thread, so
56 insert a row so monitoring can begin
58 $result = db_query_params ('INSERT INTO user_diary_monitor (monitored_user,user_id) VALUES ($1,$2)',
63 echo $HTML->error_msg(_('Error inserting into user_diary_monitor'));
65 echo $HTML->feedback(_('User is now being monitored'));
66 echo '<p>' . _("You will now be emailed this user's diary entries.") . '</p>';
67 echo '<p>' . _('To turn off monitoring, simply click the <strong>Monitor user</strong> link again.') . '</p>';
71 $result = db_query_params ('DELETE FROM user_diary_monitor WHERE user_id=$1 AND monitored_user=$2',
74 echo $HTML->feedback(_('Monitoring Stopped'));
75 echo _('You will not receive any more emails from this user');
80 $HTML->header(array('title'=>_('Error: Choose a User To Monitor First')));