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