4 * Copyright (C) 2016-2017 Jerry Padgett <sjpadgett@gmail.com>
6 * LICENSE: This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * @author Jerry Padgett <sjpadgett@gmail.com>
21 * @link http://www.open-emr.org
25 if( isset( $_SESSION['pid'] ) && isset( $_SESSION['patient_portal_onsite_two'] ) ){
26 $owner = $_SESSION['pid'];
28 $fake_register_globals=false;
29 $sanitize_all_escapes=true;
30 require_once ( dirname( __FILE__
) . "/../../interface/globals.php" );
34 $sanitize_all_escapes = true;
35 $fake_register_globals = false;
36 require_once ( dirname( __FILE__
) . "/../../interface/globals.php" );
37 if( ! isset( $_SESSION['authUserID'] ) ){
38 $landingpage = "index.php";
39 header( 'Location: ' . $landingpage );
44 require_once (dirname( __FILE__
) . "/../lib/portal_mail.inc");
45 require_once("$srcdir/pnotes.inc");
47 $task = $_POST ['task'];
51 $noteid = $_POST ['noteid'] ?
$_POST ['noteid'] : 0;
52 $reply_noteid = $_POST ['replyid'] ?
$_POST ['replyid'] : 0;
53 $owner = isset($_POST ['owner']) ?
$_POST ['owner'] : $_SESSION ['pid'];
54 $note = $_POST ['inputBody'];
55 $title = $_POST ['title'];
56 $sid=(int)$_POST ['sender_id'];
57 $sn=$_POST ['sender_name'];
58 $rid=(int)$_POST ['recipient_id'];
59 $rn=$_POST ['recipient_name'];
65 addPnote($rid, $note,1,1,$title ,$sn,'','New');
66 updatePortalMailMessageStatus ( $noteid, 'Forwarded' );
72 // each user has their own copy of message
73 sendMail ( $owner, $note, $title, $header, $noteid,$sid,$sn,$rid,$rn,'New' );
74 sendMail ( $rid, $note, $title, $header, $noteid,$sid,$sn,$rid,$rn,'New',$reply_noteid );
80 sendMail ( $owner, $note, $title, $header, $noteid,$sid,$sn,$rid,$rn,'Reply','' );
81 sendMail ( $rid, $note, $title, $header, $noteid,$sid,$sn,$rid,$rn,'New',$reply_noteid );
87 updatePortalMailMessageStatus ( $noteid, 'Delete' );
94 updatePortalMailMessageStatus ( $noteid, 'Read' );
97 echo 'missing note id';
103 $result = getMails($owner,'inbox','','');
104 echo json_encode($result);
112 $result = getMails($owner,'sent','','');
113 echo json_encode($result);
121 $result = getMails($owner,'all','','');
122 echo json_encode($result);
130 $result = getMails($owner,'deleted','','');
131 echo json_encode($result);
137 if(isset($_REQUEST["submit"]))
138 header("Location: {$_REQUEST["submit
"]}");