<?vsp 
--  
--  $Id: forward.vsp,v 1.2 2006/08/15 19:30:34 source Exp $
--  
--  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
--  project.
--  
--  Copyright (C) 1998-2006 OpenLink Software
--  
--  This project is free software; you can redistribute it and/or modify it
--  under the terms of the GNU General Public License as published by the
--  Free Software Foundation; only version 2 of the License, dated June 1991.
--  
--  This program is distributed in the hope that it will be useful, but
--  WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
--  General Public License for more details.
--  
--  You should have received a copy of the GNU General Public License along
--  with this program; if not, write to the Free Software Foundation, Inc.,
--  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--  
--  
 http_rewrite(); http_header('Content-type: text/vnd.wap.wml\r\n');
 declare _mm_bcc, _mm_body, _mm_cc, _mm_fld, _mm_from, _mm_own, _mm_rec_date, _mm_snd_time, _mm_subj, _mm_to varchar;
 declare _mm_id, _mm_is_readed varchar;

   declare _user_name, _login_ok varchar;
        declare _login_ok varchar;
  declare _sid, _msg_id, _start, _list varchar;
  declare _msg_idd integer;

  _sid := '';
  _sid := get_keyword('SESS', params);
   _msg_id := get_keyword('MSG_ID', params);
   _start := get_keyword('START', params);
   _list := get_keyword('LIST', params);

   _msg_idd := atoi(_msg_id);

   _login_ok := 'NO';

 if (_sid  <> '') {
  for select _username from wapsession where sid = _sid  do
  {
   _login_ok := 'YES';
   _user_name := _username;
   update wapsession set _time_last_active = datestring ( now() ) where  sid = _sid;
  }
  }else{
    _login_ok := 'NO';

  }

        declare cr cursor for select MM_ID, MM_FROM, MM_TO, MM_SUBJ, MM_BODY from MAIL_MESSAGE where MM_OWN = _user_name and MM_ID = _msg_idd;
        open cr;
 fetch cr into  _mm_id, _mm_from, _mm_to, _mm_subj, _mm_body;

if  (_login_ok = 'YES')
{ http_rewrite(); http_header('Content-type: text/vnd.wap.wml\r\n');
?><?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">


<wml>
<card id="compose" title="Write Mail">
  <do type="accept" label="Done">
   <go href="#action_menu"/>
  </do>
    <p>
 To:<input name="to" title="To:" value="<?=_mm_from?>" tabindex="2" maxlength="100" /><br/>
 Subj:<input name="subj" value="RE:<?=_mm_subj?>" tabindex="2" maxlength="100" />
 Write Msg:<input name="msg_body" value="$msg_body" tabindex="3" maxlength="500" /><br/>
    </p>
</card>

<card id="action_menu">
  <do type="options" label="Main Menu">
   <go href="checkmail.vsp?SESS=<?=_sid?>&amp;LIST=1"/>
  </do>
 <p><a href="send.vsp?SESS=<?=_sid?>&amp;TO=$(to:e)&amp;MSG=$(msg_body:e)&amp;SUBJ=$(subj:e)&amp;ACTION=REPLY&amp;MSG_ID=<?=_msg_id?>" title="Send">Send</a></p>
 <p><a href="#save_now" title="Save">Save Draft</a></p>
 <p><a href="#cancel" title="Cancel">Cancel</a></p>
</card>
</wml>
<?vsp
}else{ http_rewrite(); http_header('Content-type: text/vnd.wap.wml\r\n');
?><?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">


<wml>
  <card id="P1" title="Wrong" >
    <p mode="nowrap">
   Wrong Login
    </p>
  </card>
</wml>
<?vsp
}
?>


