1<?php
2  /**************************************************************************\
3  * phpGroupWare Email - POP3 Mail Wrapper for Imap Enabled PHP                                  *
4  * http://www.phpgroupware.org/                                          *                               *
5  * -------------------------------------------------------------------------*
6  * This library is part of phpGroupWare (http://www.phpgroupware.org)       *
7  * This library is free software; you can redistribute it and/or modify it  *
8  * under the terms of the GNU Lesser General Public License as published by *
9  * the Free Software Foundation; either version 2.1 of the License,         *
10  * or any later version.                                                    *
11  * This library is distributed in the hope that it will be useful, but      *
12  * WITHOUT ANY WARRANTY; without even the implied warranty of               *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     *
14  * See the GNU Lesser General Public License for more details.              *
15  * You should have received a copy of the GNU Lesser General Public License *
16  * along with this library; if not, write to the Free Software Foundation,  *
17  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA            *
18  \**************************************************************************/
19
20  /* $Id: class.mail_dcom_nntp.inc.php 15464 2004-11-06 16:13:49Z powerstat $ */
21
22	class mail_dcom extends mail_dcom_base
23	{
24		function base64($text)
25		{
26			return imap_base64($text);
27		}
28
29		function close($stream,$flags='')
30		{
31			return imap_close($stream,$flags);
32		}
33
34		function createmailbox($stream,$mailbox)
35		{
36			// N/A for pop3
37			return true;
38		}
39
40		function deletemailbox($stream,$mailbox)
41		{
42			// N/A for pop3
43			return true;
44		}
45
46		function delete($stream,$msg_num,$flags='',$currentfolder='')
47		{
48			return imap_delete($stream,$msg_num);
49		}
50
51		function expunge($stream)
52		{
53			// N/A for pop3
54			return true;
55		}
56
57		function fetchbody($stream,$msgnr,$partnr,$flags='')
58		{
59			return imap_fetchbody($stream,$msgnr,$partnr,$flags);
60		}
61
62		function header($stream,$msg_nr,$fromlength='',$tolength='',$defaulthost='')
63		{
64			return imap_header($stream,$msg_nr,$fromlength,$tolength,$defaulthost);
65		}
66
67		function fetch_raw_mail($stream,$msg_num)
68		{
69			return imap_fetchheader($stream,$msg_num,FT_PREFETCHTEXT);
70		}
71
72		function fetchheader($stream,$msg_num)
73		{
74			return imap_fetchheader($stream,$msg_num);
75		}
76
77		function get_header($stream,$msg_num)
78		{
79			// alias for compatibility with some old code
80			return $this->fetchheader($stream,$msg_num);
81		}
82
83		function fetchstructure($stream,$msg_num,$flags='')
84		{
85			return imap_fetchstructure($stream,$msg_num);
86		}
87
88		function get_body($stream,$msg_num,$flags='')
89		{
90			return imap_body($stream,$msg_num,$flags);
91		}
92
93		function listmailbox($stream,$ref,$pattern)
94		{
95			// N/A for pop3
96			return False;
97		}
98
99		function num_msg($stream) // returns number of messages in the mailbox
100		{
101			return imap_num_msg($stream);
102		}
103
104		function mailboxmsginfo($stream)
105		{
106			return imap_mailboxmsginfo($stream);
107		}
108
109		function mailcopy($stream,$msg_list,$mailbox,$flags)
110		{
111			// N/A for pop3
112			return False;
113		}
114
115		function mail_move($stream,$msg_list,$mailbox)
116		{
117			// N/A for pop3
118			return False;
119		}
120
121		function open($mailbox,$username,$password,$flags='')
122		{
123			return imap_open($mailbox,$username,$password,$flags);
124		}
125
126		function qprint($message)
127		{
128			// return quoted_printable_decode($message);
129			$str = quoted_printable_decode($message);
130			return str_replace("=\n",'',$str);
131		}
132
133		function reopen($stream,$mailbox,$flags='')
134		{
135			// N/A for pop3
136			return False;
137		}
138
139		function sort($stream,$criteria,$reverse='',$options='',$msg_info='')
140		{
141			return imap_sort($stream,$criteria,$reverse,$options);
142		}
143
144		function status($stream,$mailbox,$options)
145		{
146			return imap_status($stream,$mailbox,$options);
147			//return imap_num_recent($stream);
148		}
149
150		function append($stream,$folder='Sent',$header,$body,$flags='')
151		{
152			// N/A for pop3
153			return False;
154		}
155
156		function login($folder='INBOX')
157		{
158			//$debug_logins = True;
159			$debug_logins = False;
160			if($debug_logins)
161			{
162				echo 'CALL TO LOGIN IN CLASS MSG POP3'.'<br />'.'userid='.$GLOBALS['phpgw_info']['user']['preferences']['email']['userid'];
163			}
164
165			error_reporting(error_reporting() - 2);
166			if($folder!='INBOX')
167			{
168				// pop3 has only 1 "folder" - inbox
169				$folder='INBOX';
170			}
171
172			// WORKAROUND FOR BUG IN EMAIL CUSTOM PASSWORDS (PHASED OUT 7/2/01)
173			// $pass = $this->get_email_passwd();
174			// === ISSET CHECK ==
175			if ( (isset($GLOBALS['phpgw_info']['user']['preferences']['email']['userid']))
176				&& ($GLOBALS['phpgw_info']['user']['preferences']['email']['userid'] != '')
177				&& (isset($GLOBALS['phpgw_info']['user']['preferences']['email']['passwd']))
178				&& ($GLOBALS['phpgw_info']['user']['preferences']['email']['passwd'] != '') )
179			{
180				$user = $GLOBALS['phpgw_info']['user']['preferences']['email']['userid'];
181				$pass = $GLOBALS['phpgw_info']['user']['preferences']['email']['passwd'];
182			}
183			else
184			{
185				// problem - invalid or nonexistant info for userid and/or passwd
186				return False;
187			}
188
189			$server_str = $GLOBALS['phpgw']->msg->get_mailsvr_callstr();
190			$mbox = $this->open($server_str.$folder, $user, $pass);
191
192			error_reporting(error_reporting() + 2);
193			return $mbox;
194		}
195
196		function construct_folder_str($folder)
197		{
198			$folder_str = $GLOBALS['phpgw']->msg->get_folder_long($folder);
199			return $folder_str;
200		}
201
202		function deconstruct_folder_str($folder)
203		{
204			$folder_str = $GLOBALS['phpgw']->msg->get_folder_short($folder);
205			return $folder_str;
206		}
207	} // end of class msg
208
209