3 * GForge User's Diary Page
5 * Copyright 1999-2001 (c) VA Linux Systems
7 * This file is part of GForge.
9 * GForge is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * GForge 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
20 * along with GForge; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 require_once('../env.inc.php');
26 require_once $gfcommon.'include/pre.php';
27 require_once $gfwww.'include/vote_function.php';
29 if (!$sys_use_diary) {
30 exit_error (_('The diary feature is not enabled.')) ;
33 if (!session_loggedin()) {
39 $u =& session_get_user();
40 $diary_id = getIntFromRequest('diary_id');
42 if (getStringFromRequest('submit')) {
43 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
44 exit_form_double_submit();
47 $summary = getStringFromRequest('summary');
48 $details = getStringFromRequest('details');
50 if (getStringFromRequest('is_public')) {
56 //make changes to the database
57 if (getStringFromRequest('update')) {
58 //updating an existing diary entry
59 $res=db_query_params ('UPDATE user_diary SET summary=$1,details=$2,is_public=$3
60 WHERE user_id=$4 AND id=$5',
61 array(htmlspecialchars($summary) ,
62 htmlspecialchars($details) ,
66 if ($res && db_affected_rows($res) > 0) {
67 $feedback .= _('Diary Updated');
69 form_release_key(getStringFromRequest("form_key"));
71 $feedback .= _('Nothing Updated');
73 } else if (getStringFromRequest('add')) {
74 //inserting a new diary entry
77 $res=db_query_params ('INSERT INTO user_diary (user_id,date_posted,summary,details,is_public) VALUES
81 htmlspecialchars($summary) ,
82 htmlspecialchars($details) ,
84 if ($res && db_affected_rows($res) > 0) {
85 $feedback .= _('Item Added');
88 //send an email if users are monitoring
91 $result=db_query_params ('SELECT users.email from user_diary_monitor,users
92 WHERE user_diary_monitor.user_id=users.user_id
93 AND user_diary_monitor.monitored_user=$1',
94 array(user_getid() ));
95 $rows=db_numrows($result);
99 $tolist=implode(util_result_column_to_array($result),', ');
101 $to = ''; // send to noreply@
102 $subject = sprintf (_("[%s User Notes: %s] %s"),
103 forge_get_config ('forge_name'),
105 stripslashes($summary)) ;
106 $body = util_line_wrap(stripslashes($details)) ;
109 ______________________________________________________________________
110 You are receiving this email because you elected to monitor this user.
111 To stop monitoring this user, login to %s and visit the following link:
115 forge_get_config ('forge_name'),
116 util_make_url ("/developer/monitor.php?diary_user=". user_getid())) ;
118 util_send_message($to, $subject, $body, $to, $tolist);
120 $feedback .= " ".sprintf(ngettext("email sent to %s monitoring user",
121 "email sent to %s monitoring users",
125 $feedback .= " "._("email not sent - no one monitoring") ;
132 //don't send an email to monitoring users
133 //since this is a private note
136 form_release_key(getStringFromRequest("form_key"));
137 $feedback .= _('Error Adding Item');
150 $res=db_query_params ('SELECT * FROM user_diary WHERE user_id=$1 AND id=$2',
153 if (!$res || db_numrows($res) < 1) {
154 $feedback .= _('Entry not found or does not belong to you');
156 $info_str=_('Add A New Entry');
159 $info_str=_('Update An Entry');
160 $_summary=db_result($res,0,'summary');
161 $_details=db_result($res,0,'details');
162 $_is_public=db_result($res,0,'is_public');
163 $_diary_id=db_result($res,0,'id');
167 $info_str=_('Add A New Entry');
171 echo site_user_header(array('title'=>_('My Diary And Notes')));
172 echo '<h1>' . _('My Diary And Notes') . '</h1>';
175 <h2>'. $info_str .'</h2>
177 <form action="'. getStringFromServer('PHP_SELF') .'" method="post">
178 <input type="hidden" name="form_key" value="'.form_generate_key().'"/>
179 <input type="hidden" name="'. $proc_str .'" value="1" />
180 <input type="hidden" name="diary_id" value="'. $_diary_id .'" />
182 <tr><td colspan="2"><strong>'._('Summary').':</strong><br />
183 <input type="text" name="summary" size="45" maxlength="60" value="'. $_summary .'" />
186 <tr><td colspan="2"><strong>'._('Details').':</strong><br />
187 <textarea name="details" rows="15" cols="60">'. $_details .'</textarea>
191 <input type="submit" name="submit" value="'._('SUBMIT ONLY ONCE').'" />
192 <input type="checkbox" name="is_public" value="1" '. (($_is_public)?'checked="checked"':'') .' /> '._('Is Public').'
194 <p>'._('If marked as public, your entry will be mailed to any monitoring users when it is first submitted.').'
202 echo $HTML->boxTop(_('Existing Diary And Note Entries'));
206 $result=db_query_params ('SELECT * FROM user_diary WHERE user_id=$1 ORDER BY id DESC',
207 array(user_getid() ));
208 $rows=db_numrows($result);
209 if (!$result || $rows < 1) {
211 <strong>'._('You Have No Diary Entries').'</strong>';
214 echo ' </td></tr>';
215 for ($i=0; $i<$rows; $i++) {
217 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'><td><a href="'. getStringFromServer('PHP_SELF') .'?diary_id='.
218 db_result($result,$i,'id').'">'.db_result($result,$i,'summary').'</a></td>'.
219 '<td>'. date(_('Y-m-d H:i'), db_result($result,$i,'date_posted')).'</td></tr>';
222 <tr><td colspan="2" class="tablecontent">';
225 echo $HTML->boxBottom();
227 echo site_user_footer(array());