| 1 | <?
|
|---|
| 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_INC . 'profiles.inc.php' );
|
|---|
| 24 | require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
|
|---|
| 25 |
|
|---|
| 26 | // --------------- page variables and login
|
|---|
| 27 |
|
|---|
| 28 | $_page['name_index'] = 130;
|
|---|
| 29 | $_page['css_name'] = 'mail.css';
|
|---|
| 30 |
|
|---|
| 31 | $logged['member'] = member_auth(0);
|
|---|
| 32 | $memberID = (int)$_COOKIE['memberID'];
|
|---|
| 33 |
|
|---|
| 34 | $_page['extra_js'] = $oTemplConfig -> sMailBoxSortingInit;
|
|---|
| 35 | $_page['js_name'] = 'sort_table.js';
|
|---|
| 36 |
|
|---|
| 37 | // this is dynamic page - send headers to do not cache this page
|
|---|
| 38 | send_headers_page_changed();
|
|---|
| 39 |
|
|---|
| 40 | $_ni = $_page['name_index'];
|
|---|
| 41 |
|
|---|
| 42 | $mode = $_REQUEST['mode'];
|
|---|
| 43 | switch( $mode )
|
|---|
| 44 | {
|
|---|
| 45 | case 'outbox':
|
|---|
| 46 | $_page['header'] = _t( "_OUTBOX_H" );
|
|---|
| 47 | $_page['header_text'] = _t( "_OUTBOX_H1" );
|
|---|
| 48 | $_page_cont[$_ni]['page_main_code'] = PageCodeOutbox();
|
|---|
| 49 | break;
|
|---|
| 50 | case 'inbox':
|
|---|
| 51 | default:
|
|---|
| 52 | $mode = 'inbox';
|
|---|
| 53 | $_page['header'] = _t( "_INBOX_H" );
|
|---|
| 54 | $_page['header_text'] = _t( "_INBOX_H1" );
|
|---|
| 55 | $_page_cont[$_ni]['page_main_code'] = PageCodeInbox();
|
|---|
| 56 | }
|
|---|
| 57 |
|
|---|
| 58 | PageCode();
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 | function PageCodeInbox()
|
|---|
| 63 | {
|
|---|
| 64 | global $memberID;
|
|---|
| 65 | global $site;
|
|---|
| 66 | global $tmpl;
|
|---|
| 67 | global $date_format;
|
|---|
| 68 |
|
|---|
| 69 | if( $_REQUEST['do_delete'] or $_REQUEST['do_mark_new'] or $_REQUEST['do_mark_old'] )
|
|---|
| 70 | {
|
|---|
| 71 | if( $_REQUEST['do_delete'] )
|
|---|
| 72 | $sqlDoQuery = "DELETE FROM `Messages` WHERE";
|
|---|
| 73 |
|
|---|
| 74 | if( $_REQUEST['do_mark_new'] )
|
|---|
| 75 | $sqlDoQuery = "UPDATE `Messages` SET `New`='1' WHERE";
|
|---|
| 76 |
|
|---|
| 77 | if( $_REQUEST['do_mark_old'] )
|
|---|
| 78 | $sqlDoQuery = "UPDATE `Messages` SET `New`='0' WHERE";
|
|---|
| 79 |
|
|---|
| 80 | if( $aMsgs = $_POST['m'] and is_array( $aMsgs ) and !empty( $aMsgs ) )
|
|---|
| 81 | {
|
|---|
| 82 | foreach( $aMsgs as $msgID => $on )
|
|---|
| 83 | {
|
|---|
| 84 | $msgID = (int)$msgID;
|
|---|
| 85 | if( !$msgID or $on != 'on' )
|
|---|
| 86 | continue;
|
|---|
| 87 |
|
|---|
| 88 | db_res( "$sqlDoQuery `ID`=$msgID AND `Recipient` = $memberID" );
|
|---|
| 89 | }
|
|---|
| 90 | }
|
|---|
| 91 | }
|
|---|
| 92 | //echoDbg( $_POST );
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 | $query = "
|
|---|
| 97 | SELECT
|
|---|
| 98 | `Messages`.`ID`,
|
|---|
| 99 | UNIX_TIMESTAMP( `Date` ) AS `timestamp`,
|
|---|
| 100 | DATE_FORMAT(`Date`, '$date_format') AS `Date`,
|
|---|
| 101 | `Sender`,
|
|---|
| 102 | `Profiles`.`NickName` AS `SenderNickName`,
|
|---|
| 103 | `Subject`,
|
|---|
| 104 | `New`
|
|---|
| 105 | FROM `Messages`
|
|---|
| 106 | LEFT JOIN `Profiles` ON
|
|---|
| 107 | `Profiles`.`ID` = `Sender`
|
|---|
| 108 | WHERE `Recipient` = $memberID
|
|---|
| 109 | ORDER BY `Date` DESC
|
|---|
| 110 | ";
|
|---|
| 111 |
|
|---|
| 112 | $rMsgs = db_res( $query );
|
|---|
| 113 |
|
|---|
| 114 | if( !mysql_num_rows( $rMsgs ) )
|
|---|
| 115 | return '<div class="no_result"><div>'._t( "_No messages in Inbox" ).'</div></div>';
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 | // --- get template and replace headers ---
|
|---|
| 119 | $aReplace = array();
|
|---|
| 120 |
|
|---|
| 121 | $aReplace['mailbox_header_img'] = '<img src="'.getTemplateIcon( 'inbox.gif' ) .'" class="mailbox_header_img" />';
|
|---|
| 122 | //$aReplace['summary'] = _t(
|
|---|
| 123 | $aReplace['flag'] = _t( '_Flag' );
|
|---|
| 124 | $aReplace['from'] = _t( '_From' );
|
|---|
| 125 | $aReplace['date'] = _t( '_Date' );
|
|---|
| 126 | $aReplace['subject'] = _t( '_Subject' );
|
|---|
| 127 | $aReplace['click_to_sort'] = _t( '_Click to sort' );
|
|---|
| 128 |
|
|---|
| 129 | $aReplace['actions_l'] = _t( "_Selected messages" ) .':';
|
|---|
| 130 | $aReplace['actions'] = '
|
|---|
| 131 | <input type="submit" class="mailbox_submit" name="do_delete" value="'._t('_Delete').'" onclick="return confirm(\''._t('_are you sure?').'\');" />
|
|---|
| 132 | <input type="submit" class="mailbox_submit" name="do_mark_new" value="'._t( "_Mark as New" ).'" />
|
|---|
| 133 | <input type="submit" class="mailbox_submit" name="do_mark_old" value="'._t( "_Mark as old" ).'" />
|
|---|
| 134 | ';
|
|---|
| 135 |
|
|---|
| 136 | $ret = file_get_contents(BX_DIRECTORY_PATH_ROOT . "templates/tmpl_{$tmpl}/mail_box.html");
|
|---|
| 137 | foreach( $aReplace as $key => $val )
|
|---|
| 138 | $ret = str_replace( "__{$key}__", $val, $ret );
|
|---|
| 139 |
|
|---|
| 140 | $aMyTmpl = preg_split( "/\{\/?InsertRows\}/", $ret );
|
|---|
| 141 | $tmplRow = $aMyTmpl[1];
|
|---|
| 142 | $ret = "{$aMyTmpl[0]}{InsertRows /}{$aMyTmpl[2]}";
|
|---|
| 143 |
|
|---|
| 144 | $InsertRows = '';
|
|---|
| 145 | $tr_class = 'odd';
|
|---|
| 146 | while( $aMsg = mysql_fetch_assoc( $rMsgs ) )
|
|---|
| 147 | {
|
|---|
| 148 | $sSubject = process_line_output( html2txt( $aMsg['Subject'] ));
|
|---|
| 149 |
|
|---|
| 150 | $aReplace = array();
|
|---|
| 151 |
|
|---|
| 152 | $aReplace['tr_class'] = $tr_class;
|
|---|
| 153 | $aReplace['new_add'] = $aMsg['New'] ? 'new' : '';
|
|---|
| 154 |
|
|---|
| 155 | $aReplace['ID'] = $aMsg['ID'];
|
|---|
| 156 | $aReplace['CheckBox'] = '<input type="checkbox" class="td_mailbox_checkbox" id="sel_msg_'.$aMsg['ID'].'" name="m['.$aMsg['ID'].']" value="on" />';
|
|---|
| 157 | $aReplace['Flag'] = '<img class="mailbox_flag_img" src="'.getTemplateIcon( $aMsg['New'] ? 'not_readed.gif' : 'readed.gif' ).'" title="'._t( $aMsg['New'] ? '_New Message' : '_Readed' ).'" />';
|
|---|
| 158 | $aReplace['From'] = '<center><div style="width:45px;">' . get_member_icon($aMsg['Sender']) . "<div class=\"clear_both\"></div><!--{$aMsg['SenderNickName']}--> <a href=\"".getProfileLink($aMsg['Sender'])."\">{$aMsg['SenderNickName']}</a>" . '</center>';
|
|---|
| 159 | $aReplace['Date'] = "<!--{$aMsg['timestamp']}--> {$aMsg['Date']}";
|
|---|
| 160 | $aReplace['Subject'] = "<!--$sSubject--> <a href=\"{$site['url']}messages_inbox.php?message={$aMsg['ID']}\">$sSubject</a>";
|
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 | $sInsertRow = $tmplRow;
|
|---|
| 164 | foreach( $aReplace as $key => $val )
|
|---|
| 165 | $sInsertRow = str_replace( "{{$key}}", $val, $sInsertRow );
|
|---|
| 166 |
|
|---|
| 167 | $sInsertRows .= $sInsertRow;
|
|---|
| 168 | $tr_class = ( $tr_class == 'odd' ? 'even' : 'odd' );
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|
| 171 | $ret = str_replace( "{InsertRows /}", $sInsertRows, $ret );
|
|---|
| 172 |
|
|---|
| 173 | $ret =
|
|---|
| 174 | '<form name="mailbox_form" action="'.$_SERVER['PHP_SELF'].'?mode=inbox" method="post">'.$ret.'</form>';
|
|---|
| 175 |
|
|---|
| 176 | return $ret;
|
|---|
| 177 | }
|
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 | function PageCodeOutbox()
|
|---|
| 181 | {
|
|---|
| 182 | global $memberID;
|
|---|
| 183 | global $site;
|
|---|
| 184 | global $tmpl;
|
|---|
| 185 | global $date_format;
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 | $query = "
|
|---|
| 189 | SELECT
|
|---|
| 190 | `Messages`.`ID`,
|
|---|
| 191 | UNIX_TIMESTAMP( `Date` ) AS `timestamp`,
|
|---|
| 192 | DATE_FORMAT(`Date`, '$date_format') AS `Date`,
|
|---|
| 193 | `Recipient`,
|
|---|
| 194 | `Profiles`.`NickName` AS `RecipientNickName`,
|
|---|
| 195 | `Subject`,
|
|---|
| 196 | `New`
|
|---|
| 197 | FROM `Messages`
|
|---|
| 198 | LEFT JOIN `Profiles` ON
|
|---|
| 199 | `Profiles`.`ID` = `Recipient`
|
|---|
| 200 | WHERE `Sender` = $memberID
|
|---|
| 201 | ORDER BY `Date` DESC
|
|---|
| 202 | ";
|
|---|
| 203 |
|
|---|
| 204 | $rMsgs = db_res( $query );
|
|---|
| 205 |
|
|---|
| 206 | if( !mysql_num_rows( $rMsgs ) )
|
|---|
| 207 | return '<div class="no_result"><div>'._t( "_No messages in Outbox" ).'</div></div>';
|
|---|
| 208 |
|
|---|
| 209 |
|
|---|
| 210 | // --- get template and replace headers ---
|
|---|
| 211 | $aReplace = array();
|
|---|
| 212 |
|
|---|
| 213 | $aReplace['mailbox_header_img'] = '<img src="'.getTemplateIcon( 'outbox.gif' ) .'" class="mailbox_header_img" />';
|
|---|
| 214 | //$aReplace['summary'] = _t(
|
|---|
| 215 | $aReplace['flag'] = _t( '_Flag' );
|
|---|
| 216 | $aReplace['from'] = _t( '_Recipient' );
|
|---|
| 217 | $aReplace['date'] = _t( '_Date' );
|
|---|
| 218 | $aReplace['subject'] = _t( '_Subject' );
|
|---|
| 219 | $aReplace['click_to_sort'] = _t( '_Click to sort' );
|
|---|
| 220 |
|
|---|
| 221 | $aReplace['actions_l'] = '';
|
|---|
| 222 | $aReplace['actions'] = '';
|
|---|
| 223 |
|
|---|
| 224 | $ret = file_get_contents(BX_DIRECTORY_PATH_ROOT . "templates/tmpl_{$tmpl}/mail_box.html");
|
|---|
| 225 | foreach( $aReplace as $key => $val )
|
|---|
| 226 | $ret = str_replace( "__{$key}__", $val, $ret );
|
|---|
| 227 |
|
|---|
| 228 | $aMyTmpl = preg_split( "/\{\/?InsertRows\}/", $ret );
|
|---|
| 229 | $tmplRow = $aMyTmpl[1];
|
|---|
| 230 | $ret = "{$aMyTmpl[0]}{InsertRows /}{$aMyTmpl[2]}";
|
|---|
| 231 |
|
|---|
| 232 | $InsertRows = '';
|
|---|
| 233 | $tr_class = 'odd';
|
|---|
| 234 | while( $aMsg = mysql_fetch_assoc( $rMsgs ) )
|
|---|
| 235 | {
|
|---|
| 236 | $sSubject = process_line_output( html2txt( $aMsg['Subject'] ));
|
|---|
| 237 |
|
|---|
| 238 | $aReplace = array();
|
|---|
| 239 |
|
|---|
| 240 | $aReplace['tr_class'] = $tr_class;
|
|---|
| 241 | $aReplace['new_add'] = $aMsg['New'] ? 'new' : '';
|
|---|
| 242 |
|
|---|
| 243 | $aReplace['ID'] = $aMsg['ID'];
|
|---|
| 244 | $aReplace['CheckBox'] = '';
|
|---|
| 245 | $aReplace['Flag'] = '<img class="mailbox_flag_img" src="'.getTemplateIcon( $aMsg['New'] ? 'not_readed.gif' : 'readed.gif' ).'" title="'._t( $aMsg['New'] ? '_Not Readed' : '_Readed' ).'" />';
|
|---|
| 246 | $aReplace['From'] = '<center><div style="width:45px;">' . get_member_icon($aMsg['Recipient']) . "<div class=\"clear_both\"></div><!--{$aMsg['RecipientNickName']}--> <a href=\"".getProfileLink($aMsg['Recipient'])."\">{$aMsg['RecipientNickName']}</a>" . '</center>';
|
|---|
| 247 | $aReplace['Date'] = "<!--{$aMsg['timestamp']}--> {$aMsg['Date']}";
|
|---|
| 248 | $aReplace['Subject'] = "<!--$sSubject--> <a href=\"{$site['url']}messages_outbox.php?message={$aMsg['ID']}\">$sSubject</a>";
|
|---|
| 249 |
|
|---|
| 250 |
|
|---|
| 251 | $sInsertRow = $tmplRow;
|
|---|
| 252 | foreach( $aReplace as $key => $val )
|
|---|
| 253 | $sInsertRow = str_replace( "{{$key}}", $val, $sInsertRow );
|
|---|
| 254 |
|
|---|
| 255 | $sInsertRows .= $sInsertRow;
|
|---|
| 256 | $tr_class = ( $tr_class == 'odd' ? 'even' : 'odd' );
|
|---|
| 257 | }
|
|---|
| 258 |
|
|---|
| 259 | $ret = str_replace( "{InsertRows /}", $sInsertRows, $ret );
|
|---|
| 260 |
|
|---|
| 261 | return $ret;
|
|---|
| 262 | }
|
|---|
| 263 |
|
|---|
| 264 |
|
|---|
| 265 | ?> |
|---|