source: trunk/mail.php

Last change on this file was 2, checked in by george, 14 years ago
  • Přidáno: Trunk revize 13719.
File size: 9.4 KB
Line 
1<?php
2
3 /***************************************************************************
4 * Dolphin Smart Community Builder
5 * -----------------
6 * begin : Mon Mar 23 2006
7 * copyright : (C) 2006 BoonEx Group
8 * website : http://www.boonex.com/
9 * This file is part of Dolphin - Smart Community Builder
10 *
11 * Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
12 * http://creativecommons.org/licenses/by/3.0/
13 *
14 * Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the Creative Commons Attribution 3.0 License for more details.
17 * You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
18 * see license.txt file; if not, write to marketing@boonex.com
19 ***************************************************************************/
20
21 require_once( 'inc/header.inc.php' );
22 require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
23 require_once( BX_DIRECTORY_PATH_ROOT . 'templates/tmpl_' . $tmpl . '/scripts/BxTemplMailBox.php');
24
25 $iProfileId = getLoggedId();
26
27 $aProfile = getProfileInfo($iProfileId);
28
29 // init some needed parameters ;
30
31 $sOutputHtml = null;
32 $sComposedPage = null;
33
34 // define message id (for view mode) ;
35 $iMessageID = ( isset($_GET['messageID']) ) ? (int) $_GET['messageID'] : 0;
36
37 // define the message status such as : read, unread ;
38 $iMessageStatus = ( isset($_GET['status']) and $_GET['status'] == 'read' ) ? 0 : 1 ;
39
40 // define the recipient ID ;
41 $vRecipientID = ( isset($_GET['recipient_id']) ) ? $_GET['recipient_id'] : null;
42
43 // contain message's subject ;
44 $sMessageSubject = ( isset($_POST['subject']) ) ? process_db_input($_POST['subject'], BX_TAGS_STRIP) : null;
45
46 // contain messages' body ;
47 $sMessageBody = ( isset($_POST['message']) ) ? process_db_input( nl2br( urldecode($_POST['message']) ), BX_TAGS_VALIDATE) : null;
48
49 // contain all receivied messages id separeted by comma ;
50 $sMessagesList = isset( $_GET['messages'] ) ? $_GET['messages'] : null;
51
52 // contain query from js for autocomplete;
53 $sAutoCompleteQ = (isset($_GET['q'])) ? process_db_input($_GET['q'], BX_TAGS_STRIP) : null;
54
55 // try to segregate received messages list;
56 if ( $sMessagesList )
57 {
58 // array : contain all received messages id ;
59 $aMessagesList = array();
60 $aMessagesList = explode(',', $sMessagesList);
61 }
62
63 // contain some needed settings for the MailBox's object ;
64 $aMailBoxSettings = array
65 (
66 // logged member's ID ;
67 'member_id' => ($iProfileId || $aProfile['Role'] & BX_DOL_ROLE_ADMIN) ? $iProfileId : 0,
68
69 // message recipient's ID ;
70 'recipient_id' => ($vRecipientID) ? (int) $vRecipientID : 0,
71
72 // mailbox mode such as : inbox, outbox, trash ;
73 'mailbox_mode' => (isset($_GET['mode'])) ? $_GET['mode'] : 'inbox',
74
75 // type of message's sort ;
76 'sort_mode' => (isset($_GET['sorting'])) ? $_GET['sorting'] : 'date_desc',
77
78 // contain number of current page ;
79 'page' => (isset($_GET['page'])) ? (int) $_GET['page']: 0,
80
81 // contain per page number for current page ;
82 'per_page' => (isset($_GET['per_page'])) ? (int) $_GET['per_page']: 0,
83
84 // contain type of needed type of contacts (friends, faves ...)
85 'contacts_mode' => (isset($_GET['contacts_mode'])) ? $_GET['contacts_mode'] : null,
86
87 // contain number of current contacts page ;
88 'contacts_page' => (isset($_GET['contacts_page'])) ? (int) $_GET['contacts_page'] : 0,
89
90 // contain number of needed message ;
91 'messageID' => (isset($_GET['messageID'])) ? (int) $_GET['messageID'] : 0,
92 );
93
94 // contain all needed settings for compose message ;
95 $aComposeSettings = array
96 (
97 // allow to send message to phisical recipient's email ;
98 'send_copy' => ( isset($_GET['copy_message']) ) ? true : false ,
99
100 // allow to send message to phisical sender's email;
101 'send_copy_to_me' => ( isset($_GET['copy_message_to_me']) ) ? true : false ,
102
103 // allow to send notification to the recipient's email ;
104 'notification' => ( isset($_GET['notify']) ) ? true : false ,
105 );
106
107 // define the type of message (greet, mail ...) ;
108 if ( isset($_GET['messages_types']) )
109 $aMailBoxSettings['messages_types'] = $_GET['messages_types'];
110
111 // ** swith the compose page;
112 switch($aMailBoxSettings['mailbox_mode'])
113 {
114 case 'inbox' :
115 case 'outbox' :
116 case 'trash' :
117 $sComposedPage = 'mail_page';
118 break;
119 case 'compose' :
120 $sComposedPage = 'mail_page_compose';
121 break;
122 case 'view_message' :
123 $sComposedPage = 'mail_page_view';
124 break;
125 default :
126 $sComposedPage = 'mail_page';
127 }
128
129 // create BxTemplMailBox object
130 $oMailBox = new BxTemplMailBox( $sComposedPage, $aMailBoxSettings );
131
132 // for ajax requests processing ;
133 if ( isset($_GET['ajax_mode']) and isset($_GET['action']) )
134 {
135 // contain all the available callback functions ;
136 $aCallbackFunctions = array( 'genMessagesRows', 'genArchiveMessages', 'getInboxMessagesCount' );
137
138 switch($_GET['action'])
139 {
140 case 'sort' :
141 case 'paginate' :
142 case 'get_page' :
143 $sOutputHtml = $oMailBox -> genMessagesRows();
144 break;
145
146 // mark all the received messages ;
147 case 'mark' :
148 // mark message with received mode ;
149 if ( is_array($aMessagesList) and !empty($aMessagesList) )
150 {
151 foreach( $aMessagesList AS $iKey )
152 {
153 $iMessageID = (int) $iKey;
154 if ( $iMessageID )
155 $oMailBox -> setMarkMessage($iMessageID, $iMessageStatus);
156 }
157
158 $sOutputHtml = 'ok';
159 }
160 break;
161
162 // delete all the received messages ;
163 case 'delete' :
164 if ( is_array($aMessagesList ) and !empty($aMessagesList) )
165 {
166 foreach( $aMessagesList AS $iKey )
167 {
168 $iMessageID = (int) $iKey;
169 if ( $iMessageID )
170 $oMailBox -> setTrashedMessage($iMessageID);
171 }
172 }
173 break;
174
175 // restore all the deleted messages from trash;
176 case 'restore' :
177 if ( is_array($aMessagesList) and !empty($aMessagesList) )
178 {
179 foreach( $aMessagesList AS $iKey )
180 {
181 $iMessageID = (int) $iKey;
182 if ( $iMessageID )
183 $oMailBox -> setRestoredMessage($iMessageID);
184 }
185 }
186 break;
187
188 // will return count of inbox messages ;
189 case 'get_messages_count' :
190 $iMessageCount = $oMailBox -> getInboxMessagesCount();
191 $sResponceText = ( $iMessageCount ) ? ' (' . $iMessageCount . ') ' : null;
192 $sOutputHtml = $sResponceText;
193 break;
194
195 // will return all the arhive's message list ;
196 case 'archives_paginate' :
197 $sOutputHtml = $oMailBox -> genArchiveMessages();
198 break;
199
200 // will return message's replay window;
201 case 'reply_message' :
202 if ( $iMessageID and $vRecipientID )
203 {
204 $vRecipientID = (int) $vRecipientID;
205 $sOutputHtml = $oMailBox -> genReplayMessage($vRecipientID, $iMessageID);
206 }
207 break;
208
209 case 'compose_mail' :
210 if ( $sMessageSubject and $sMessageBody and $vRecipientID)
211 $sOutputHtml = $oMailBox -> sendMessage($sMessageSubject, $sMessageBody, $vRecipientID, $aComposeSettings);
212 else
213 $sOutputHtml = _t_err( '_please_fill_next_fields_first' );
214 break;
215 case 'auto_complete' :
216 if ( $sAutoCompleteQ )
217 $sOutputHtml = $oMailBox -> getAutoCompleteList($sAutoCompleteQ);
218 break;
219 case 'get_thumbnail' :
220 $iRecipientID = getId($vRecipientID);
221 if ( $iRecipientID )
222 $sOutputHtml = get_member_thumbnail($iRecipientID, 'none');
223 break;
224 }
225
226 // try to define the callback function name ;
227 if ( isset($_GET['callback_function']) and in_array($_GET['callback_function'], $aCallbackFunctions) )
228 {
229 if (method_exists($oMailBox, $_GET['callback_function']))
230 $sOutputHtml = $oMailBox -> $_GET['callback_function']();
231 }
232
233 echo $sOutputHtml;
234 exit;
235 }
236
237 // ** prepare to output page in normal mode ;
238
239 $_page['name_index'] = 7;
240
241 $_page['header'] = _t( "_Mailbox" );
242 $_page['header_text'] = _t( "_Mailbox" );
243
244 $GLOBALS['oTopMenu'] -> setCustomSubIconUrl( getTemplateIcon('bx_mymail.png') );
245
246 $_page['css_name'] = 'mail.css';
247 $_page['js_name'] = 'mail_box.js';
248
249 $_page['extra_js'] = $oTemplConfig -> sTinyMceEditorCompactJS;
250
251 $_ni = $_page['name_index'];
252
253 if ( $aMailBoxSettings['member_id'] ) {
254 $sOutputHtml = $oMailBox -> getCode();
255 }
256 else {
257 login_form( _t( "_LOGIN_OBSOLETE" ), 0, false );
258 }
259
260 $_page_cont[$_ni]['page_main_code'] = $sOutputHtml;
261
262 PageCode();
263
264?>
Note: See TracBrowser for help on using the repository browser.