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.
26 require_once('../env.inc.php');
27 require_once $gfcommon.'include/pre.php';
28 require_once $gfwww.'include/vote_function.php';
30 if (!forge_get_config('use_diary')) {
34 if (!session_loggedin()) {
38 $u = session_get_user();
39 $diary_id = getIntFromRequest('diary_id');
41 if (getStringFromRequest('submit')) {
42 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
43 exit_form_double_submit('my');
46 $summary = getHtmlStringFromRequest('summary');
47 $details = getHtmlTextFromRequest('details');
48 $is_public = getIntFromRequest('is_public', 0);
50 //make changes to the database
51 if (getStringFromRequest('update')) {
52 //updating an existing diary entry
53 $res=db_query_params ('UPDATE user_diary SET summary=$1,details=$2,is_public=$3
54 WHERE user_id=$4 AND id=$5',
60 if ($res && db_affected_rows($res) > 0) {
61 $feedback .= _('Diary Updated');
63 form_release_key(getStringFromRequest("form_key"));
65 $feedback .= _('Nothing Updated');
67 } else if (getStringFromRequest('add')) {
68 //inserting a new diary entry
69 $res=db_query_params ('INSERT INTO user_diary (user_id,date_posted,summary,details,is_public) VALUES
76 if ($res && db_affected_rows($res) > 0) {
77 $feedback .= _('Item Added');
80 //send an email if users are monitoring
81 $result=db_query_params ('SELECT users.email from user_diary_monitor,users
82 WHERE user_diary_monitor.user_id=users.user_id
83 AND user_diary_monitor.monitored_user=$1',
84 array(user_getid() ));
85 $rows=db_numrows($result);
89 $tolist=implode(util_result_column_to_array($result),', ');
91 $to = ''; // send to noreply@
92 $subject = sprintf (_("[%s User Notes: %s] %s"),
93 forge_get_config ('forge_name'),
96 $sanitizer = new TextSanitizer();
98 if (strstr($body,'<br/>') || strstr($body,'<br />')) {
99 $body = preg_replace("/[\n\r]/", '', $body);
101 $body = $sanitizer->convertNeededTagsForEmail($body);
102 $body = strip_tags($body);
103 $body = $sanitizer->convertExtendedCharsForEmail($body);
107 ______________________________________________________________________
108 You are receiving this email because you elected to monitor this user.
109 To stop monitoring this user, visit the following link:
111 $body .= util_make_url("/developer/monitor.php?diary_user=".user_getid());
113 util_send_message($to, $subject, $body, $to, $tolist);
115 $feedback .= " ".sprintf(ngettext("email sent to %s monitoring user",
116 "email sent to %s monitoring users",
120 $feedback .= " "._("email not sent - no one monitoring") ;
127 //don't send an email to monitoring users
128 //since this is a private note
131 form_release_key(getStringFromRequest("form_key"));
132 $error_msg .= _('Error Adding Item: '). db_error();
144 $res=db_query_params('SELECT * FROM user_diary WHERE user_id=$1 AND id=$2',
147 if (!$res || db_numrows($res) < 1) {
148 $feedback .= _('Entry not found or does not belong to you');
150 $info_str=_('Add A New Entry');
153 $info_str=_('Update An Entry');
154 $_summary=db_result($res,0,'summary');
155 $_details=db_result($res,0,'details');
156 $_is_public=db_result($res,0,'is_public');
157 $_diary_id=db_result($res,0,'id');
161 $info_str=_('Add A New Entry');
165 site_user_header(array('title'=>_('My Diary And Notes')));
167 $params['name'] = "details";
168 $params['body'] = $_details;
169 $params['height'] = "350";
170 $params['width'] = "100%";
171 $params['content'] = '<textarea name="details" rows="10" cols="60">'.$_details.'</textarea>';
172 $params['user_id'] = $u->getID();
173 plugin_hook_by_reference("text_editor", $params);
176 <h2>'. $info_str .'</h2>
178 <form action="'. getStringFromServer('PHP_SELF') .'" method="post">
179 <input type="hidden" name="form_key" value="'.form_generate_key().'"/>
180 <input type="hidden" name="'. $proc_str .'" value="1" />
181 <input type="hidden" name="diary_id" value="'. $_diary_id .'" />
182 <table class="fullwidth">
183 <tr><td colspan="2"><strong>'._('Summary').':</strong><br />
184 <input type="text" name="summary" size="60" maxlength="60" value="'. $_summary .'" />
187 <tr><td colspan="2"><strong>'._('Details').':</strong><br />'.
188 $params['content'].'</td></tr>
191 <input type="submit" name="submit" value="'._('Submit').'" />
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'));
203 echo '</p><table class="fullwidth">';
204 $result=db_query_params ('SELECT * FROM user_diary WHERE user_id=$1 ORDER BY id DESC',
205 array(user_getid() ));
206 $rows=db_numrows($result);
207 if (!$result || $rows < 1) {
209 <strong>'._('You Have No Diary Entries').'</strong>';
212 for ($i=0; $i<$rows; $i++) {
213 $date = relative_date(db_result($result,$i,'date_posted'));
214 $public = db_result($result,$i,'is_public')? '(public)':'(private)';
216 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'><td><a href="'. getStringFromServer('PHP_SELF') .'?diary_id='.
217 db_result($result,$i,'id').'">'.db_result($result,$i,'summary').'</a></td>'.
218 '<td>'. $date .'</td>'.
219 '<td>'. $public .'</td>'.
224 echo $HTML->boxBottom();
226 site_user_footer(array());