5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright (C) 2010 Alain Peyrat - Alcatel-Lucent
7 * Copyright 2011, 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';
27 require_once $gfwww.'include/vote_function.php';
29 if (!forge_get_config('use_diary')) {
33 if (!session_loggedin()) {
37 $u = session_get_user();
38 $diary_id = getIntFromRequest('diary_id');
40 if (getStringFromRequest('submit')) {
41 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
42 exit_form_double_submit('my');
45 $summary = getHtmlStringFromRequest('summary');
46 $details = getHtmlTextFromRequest('details');
47 $is_public = getIntFromRequest('is_public', 0);
49 //make changes to the database
50 if (getStringFromRequest('update')) {
51 //updating an existing diary entry
52 $res=db_query_params ('UPDATE user_diary SET summary=$1,details=$2,is_public=$3
53 WHERE user_id=$4 AND id=$5',
59 if ($res && db_affected_rows($res) > 0) {
60 $feedback .= _('Diary Updated');
62 form_release_key(getStringFromRequest("form_key"));
64 $feedback .= _('Nothing Updated');
66 } else if (getStringFromRequest('add')) {
67 //inserting a new diary entry
68 $res=db_query_params ('INSERT INTO user_diary (user_id,date_posted,summary,details,is_public) VALUES
75 if ($res && db_affected_rows($res) > 0) {
76 $feedback .= _('Item Added');
79 //send an email if users are monitoring
80 $result=db_query_params ('SELECT users.email from user_diary_monitor,users
81 WHERE user_diary_monitor.user_id=users.user_id
82 AND user_diary_monitor.monitored_user=$1',
83 array(user_getid() ));
84 $rows=db_numrows($result);
88 $tolist=implode(util_result_column_to_array($result),', ');
90 $to = ''; // send to noreply@
91 $subject = sprintf (_("[%s User Notes: %s] %s"),
92 forge_get_config ('forge_name'),
95 $sanitizer = new TextSanitizer();
97 if (strstr($body,'<br/>') || strstr($body,'<br />')) {
98 $body = preg_replace("/[\n\r]/", '', $body);
100 $body = $sanitizer->convertNeededTagsForEmail($body);
101 $body = strip_tags($body);
102 $body = $sanitizer->convertExtendedCharsForEmail($body);
106 ______________________________________________________________________
107 You are receiving this email because you elected to monitor this user.
108 To stop monitoring this user, visit the following link:
110 $body .= util_make_url("/developer/monitor.php?diary_user=".user_getid());
112 util_send_message($to, $subject, $body, $to, $tolist);
114 $feedback .= " ".sprintf(ngettext("email sent to %s monitoring user",
115 "email sent to %s monitoring users",
119 $feedback .= " "._("email not sent - no one monitoring") ;
126 //don't send an email to monitoring users
127 //since this is a private note
130 form_release_key(getStringFromRequest("form_key"));
131 $error_msg .= _('Error Adding Item: '). db_error();
143 $res=db_query_params('SELECT * FROM user_diary WHERE user_id=$1 AND id=$2',
146 if (!$res || db_numrows($res) < 1) {
147 $feedback .= _('Entry not found or does not belong to you');
149 $info_str=_('Add A New Entry');
152 $info_str=_('Update An Entry');
153 $_summary=db_result($res,0,'summary');
154 $_details=db_result($res,0,'details');
155 $_is_public=db_result($res,0,'is_public');
156 $_diary_id=db_result($res,0,'id');
160 $info_str=_('Add A New Entry');
164 site_user_header(array('title'=>_('My Diary And Notes')));
166 $params['name'] = "details";
167 $params['body'] = $_details;
168 $params['height'] = "350";
169 $params['width'] = "100%";
170 $params['content'] = '<textarea name="details" rows="10" cols="60">'.$_details.'</textarea>';
171 $params['user_id'] = $u->getID();
172 plugin_hook_by_reference("text_editor", $params);
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 .'" />
181 <table class="fullwidth">
182 <tr><td colspan="2"><strong>'._('Summary').':</strong><br />
183 <input type="text" name="summary" size="60" maxlength="60" value="'. $_summary .'" />
186 <tr><td colspan="2"><strong>'._('Details').':</strong><br />'.
187 $params['content'].'</td></tr>
190 <input type="submit" name="submit" value="'._('Submit').'" />
191 <input type="checkbox" name="is_public" value="1" '. (($_is_public)?'checked="checked"':'') .' /> '._('Is Public').'
193 <p>'._('If marked as public, your entry will be mailed to any monitoring users when it is first submitted.').'
201 echo $HTML->boxTop(_('Existing Diary And Note Entries'));
202 echo '</p><table class="fullwidth">';
203 $result=db_query_params ('SELECT * FROM user_diary WHERE user_id=$1 ORDER BY id DESC',
204 array(user_getid() ));
205 $rows=db_numrows($result);
206 if (!$result || $rows < 1) {
208 <strong>'._('You Have No Diary Entries').'</strong>';
211 for ($i=0; $i<$rows; $i++) {
212 $date = relative_date(db_result($result,$i,'date_posted'));
213 $public = db_result($result,$i,'is_public')? '(public)':'(private)';
215 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'><td><a href="'. getStringFromServer('PHP_SELF') .'?diary_id='.
216 db_result($result,$i,'id').'">'.db_result($result,$i,'summary').'</a></td>'.
217 '<td>'. $date .'</td>'.
218 '<td>'. $public .'</td>'.
223 echo $HTML->boxBottom();
225 site_user_footer(array());