| 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'] = 45;
|
|---|
| 29 | $_page['css_name'] = 'compose.css';
|
|---|
| 30 |
|
|---|
| 31 | $logged['member'] = member_auth(0);
|
|---|
| 32 | $memberID = (int)$_COOKIE['memberID'];
|
|---|
| 33 |
|
|---|
| 34 | $_page['header'] = 'Messages';
|
|---|
| 35 | $_page['header_text'] = _t( "_INBOX_H1" );
|
|---|
| 36 |
|
|---|
| 37 | // this is dynamic page - send headers to do not cache this page
|
|---|
| 38 | send_headers_page_changed();
|
|---|
| 39 |
|
|---|
| 40 | $preview_length = 45;
|
|---|
| 41 |
|
|---|
| 42 | // --------------- page components
|
|---|
| 43 |
|
|---|
| 44 | $_ni = $_page['name_index'];
|
|---|
| 45 |
|
|---|
| 46 | if( $_GET['action'] == 'delete' )
|
|---|
| 47 | {
|
|---|
| 48 | $mes_id = (int)$_GET['message'];
|
|---|
| 49 | $delete_query = "DELETE FROM `Messages` WHERE `ID` = '$mes_id' AND `Recipient`='$memberID' LIMIT 1";
|
|---|
| 50 | db_res($delete_query);
|
|---|
| 51 | if(mysql_affected_rows($GLOBALS['MySQL']->link) > 0)
|
|---|
| 52 | $_page_cont[$_ni]['page_main_code'] = DesignBoxContent( '', _t( '_Message successfully deleted' ), $oTemplConfig -> PageMessagesInboxMessageDeleted_db_num );
|
|---|
| 53 | else
|
|---|
| 54 | $_page_cont[$_ni]['page_main_code'] = MsgBox(_t('_Access denied'));
|
|---|
| 55 | }
|
|---|
| 56 | elseif($_GET['message'] != 0)
|
|---|
| 57 | {
|
|---|
| 58 | $_page_cont[$_ni]['page_main_code'] = DesignBoxContent( '', PageCompPageMainCode(), $oTemplConfig -> PageMessagesInboxMainCode_db_num );
|
|---|
| 59 | db_res("UPDATE `Messages` SET `New` = '0' WHERE `ID` = '" . (int)$_GET['message'] . "' AND `Recipient`='$memberID' LIMIT 1");
|
|---|
| 60 | }
|
|---|
| 61 | else
|
|---|
| 62 | {
|
|---|
| 63 | echo '<script type="text/javascript">location.href=\'mail.php?mode=inbox\';</script>';
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | // --------------- [END] page components
|
|---|
| 67 |
|
|---|
| 68 | PageCode();
|
|---|
| 69 |
|
|---|
| 70 | // --------------- page components functions
|
|---|
| 71 |
|
|---|
| 72 | /**
|
|---|
| 73 | * page code function
|
|---|
| 74 | */
|
|---|
| 75 | function PageCompPageMainCode()
|
|---|
| 76 | {
|
|---|
| 77 | global $site;
|
|---|
| 78 | global $short_date_format;
|
|---|
| 79 | global $memberID;
|
|---|
| 80 |
|
|---|
| 81 | $messageID = (int)$_GET['message'];
|
|---|
| 82 | $sender_sql = "SELECT `Sender` FROM `Messages` WHERE `Recipient` = '$memberID' AND `ID` = '$messageID'";
|
|---|
| 83 | $sender_arr = db_arr( $sender_sql );
|
|---|
| 84 |
|
|---|
| 85 | if ($sender_arr) {
|
|---|
| 86 |
|
|---|
| 87 | $senderID = (int)$sender_arr['Sender'];
|
|---|
| 88 |
|
|---|
| 89 | $message_sql= "SELECT m.`Text`, m.`Subject`, DATE_FORMAT( m.`Date`, '$short_date_format' ) AS `Date`, p.Status FROM `Messages` AS m LEFT JOIN Profiles AS p ON m.Sender = p.ID WHERE m.`ID` = '$messageID' AND `Recipient` = '$memberID'";
|
|---|
| 90 |
|
|---|
| 91 | $message_arr= db_arr($message_sql);
|
|---|
| 92 |
|
|---|
| 93 | $ret = '';
|
|---|
| 94 | $ret .= '<div class="profile_ditails_block">';
|
|---|
| 95 | $ret .= ProfileDetails( $senderID );
|
|---|
| 96 | $ret .= '<div class="clear_both"></div>';
|
|---|
| 97 | $ret .= '</div>';
|
|---|
| 98 | $ret .= '<div class="m_block">';
|
|---|
| 99 | $ret .= '<div class="m_subject_date">';
|
|---|
| 100 | $ret .= '<div class="name">';
|
|---|
| 101 | $ret .= _t('_Date').':';
|
|---|
| 102 | $ret .= '</div>';
|
|---|
| 103 |
|
|---|
| 104 | $ret .= '<div class="value">';
|
|---|
| 105 | $ret .= $message_arr['Date'];
|
|---|
| 106 | $ret .= '</div>';
|
|---|
| 107 |
|
|---|
| 108 | $ret .= '<div class="name">';
|
|---|
| 109 | $ret .= _t('_Subject').':';
|
|---|
| 110 | $ret .= '</div>';
|
|---|
| 111 |
|
|---|
| 112 | $ret .= '<div class="value">';
|
|---|
| 113 | $ret .= process_smiles( process_line_output($message_arr['Subject']) );
|
|---|
| 114 | $ret .= '</div>';
|
|---|
| 115 |
|
|---|
| 116 | $ret .= '</div>';
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 | $ret .= '<div class="m_text">';
|
|---|
| 120 | $ret .= process_html_output($message_arr['Text'], 150);
|
|---|
| 121 | $ret .= '</div>';
|
|---|
| 122 | $ret .= '<div class="clear_both"></div>';
|
|---|
| 123 |
|
|---|
| 124 | $ret .= '</div>';
|
|---|
| 125 |
|
|---|
| 126 | if( $message_arr['Status'] == 'Active' )
|
|---|
| 127 | {
|
|---|
| 128 | $ret .= '<div class="reply">';
|
|---|
| 129 | $ret .= '<a href="' . $site['url'] . 'compose.php?ID=' . $senderID . '&messageID=' . $messageID . '&subject='.process_smiles( process_line_output($message_arr['Subject']) ).'">'. _t('_Reply') .'</a>';
|
|---|
| 130 | $ret .= '</div>';
|
|---|
| 131 | $ret .= '<div class="reply">';
|
|---|
| 132 | $ret .= "<a onClick=\"javascript:window.open( 'list_pop.php?action=spam&ID=" . $senderID . "', '', 'width=500,height=200,menubar=no,status=no,resizeable=no,scrollbars=no,toolbar=no,location=no' );\" href=\"javascript:void(0)\">". _t('_Spam report') ."</a>";
|
|---|
| 133 | $ret .= '</div>';
|
|---|
| 134 | $ret .= '<div class="reply">';
|
|---|
| 135 | $ret .= '<a href="messages_inbox.php?action=delete&message=' . $messageID . '">'. _t('_Delete') .'</a>';
|
|---|
| 136 | $ret .= '</div>';
|
|---|
| 137 | $ret .= '<div class="clear_both"></div>';
|
|---|
| 138 | }
|
|---|
| 139 | else
|
|---|
| 140 | {
|
|---|
| 141 | $ret .= '';
|
|---|
| 142 | }
|
|---|
| 143 | //$ret .= '</div>';
|
|---|
| 144 | //####################################################
|
|---|
| 145 | $ret .= '<div style="position:relative; height:20px;"></div>';
|
|---|
| 146 | $ret .= PageCorespondence( $memberID, $senderID );
|
|---|
| 147 | $ret .= '<div class="clear_both"></div>';
|
|---|
| 148 |
|
|---|
| 149 | } else {
|
|---|
| 150 | $ret = MsgBox(_t('_Access denied'));
|
|---|
| 151 | }
|
|---|
| 152 |
|
|---|
| 153 | return $ret;
|
|---|
| 154 |
|
|---|
| 155 | }
|
|---|
| 156 |
|
|---|
| 157 | function PageCorespondence( $memberID, $senderID )
|
|---|
| 158 | {
|
|---|
| 159 | global $site;
|
|---|
| 160 | global $date_format;
|
|---|
| 161 |
|
|---|
| 162 | $preview_leight = 25;
|
|---|
| 163 |
|
|---|
| 164 | $sender_nickname = getProfileInfo( $senderID ); //db_arr("SELECT `NickName` FROM `Profiles` WHERE `ID` = '$senderID'");
|
|---|
| 165 |
|
|---|
| 166 | $member_to_sender_query = "SELECT `Profiles`.`ID` AS pID, `Profiles`.`NickName`, `Profiles`.`Status`, `Messages`.`ID` AS mID, `New`, DATE_FORMAT( `Date`, '$date_format') as 'Date', `Subject`, LEFT( `Text`, {$preview_leight} ) AS Preview FROM `Messages` LEFT JOIN `Profiles` ON `Messages`.`Recipient` = `Profiles`.`ID` WHERE `Sender` = '" . (int)$memberID . "' AND `Recipient` = '" . (int)$senderID . "' ORDER BY `Date` DESC";
|
|---|
| 167 | $member_to_sender_res = db_res($member_to_sender_query);
|
|---|
| 168 |
|
|---|
| 169 | $member_to_sender_num = mysql_num_rows($member_to_sender_res);
|
|---|
| 170 |
|
|---|
| 171 | $sender_to_member_query = "SELECT `Messages`.`ID` AS mID, `New`, DATE_FORMAT( `Date`, '$date_format') as 'Date', `Subject`, LEFT( `Text`, {$preview_leight} ) AS Preview FROM `Messages` LEFT JOIN `Profiles` ON Messages.Sender = Profiles.ID WHERE `Sender` = '" . (int)$senderID . "' AND `Recipient` = '" . (int)$memberID . "' ORDER BY `Date` DESC";
|
|---|
| 172 | $sender_to_member_res = db_res($sender_to_member_query);
|
|---|
| 173 |
|
|---|
| 174 | $sender_to_member_num = mysql_num_rows($sender_to_member_res);
|
|---|
| 175 |
|
|---|
| 176 | $ret = '';
|
|---|
| 177 | $ret .= '<div class="member_to_sender">';
|
|---|
| 178 | if($member_to_sender_num > 0 )
|
|---|
| 179 | {
|
|---|
| 180 |
|
|---|
| 181 | $ret .= '<table cellpadding="0" cellspacing="0" border="0" width="100%">';
|
|---|
| 182 | $ret .= '<tr>';
|
|---|
| 183 | $ret .= '<td colspan="3" class="cor_title">';
|
|---|
| 184 | $ret .= _t('_messages_to', $sender_nickname['NickName']);
|
|---|
| 185 | $ret .= '</td>';
|
|---|
| 186 | $ret .= '</tr>';
|
|---|
| 187 | $ret .= '<tr>';
|
|---|
| 188 | $ret .= '<td width="17">';
|
|---|
| 189 | $ret .= '<img src="' . getTemplateIcon('convert.gif') . '" alt="" />';
|
|---|
| 190 | $ret .= '</td>';
|
|---|
| 191 | $ret .= '<td width="70">';
|
|---|
| 192 | $ret .= _t('_Date');
|
|---|
| 193 | $ret .= '</td>';
|
|---|
| 194 | $ret .= '<td>';
|
|---|
| 195 | $ret .= _t('_Subject');
|
|---|
| 196 | $ret .= '</td>';
|
|---|
| 197 | $ret .= '</tr>';
|
|---|
| 198 |
|
|---|
| 199 | $j_out = '0';
|
|---|
| 200 | while($member_to_sender_arr = mysql_fetch_assoc($member_to_sender_res))
|
|---|
| 201 | {
|
|---|
| 202 | if(strlen( $member_to_sender_arr['Subject'] ) == 0 )
|
|---|
| 203 | {
|
|---|
| 204 |
|
|---|
| 205 | $cor_subject_out = $member_to_sender_arr['Preview'];
|
|---|
| 206 | if ( strlen( $member_to_sender_arr['Preview'] ) >= $preview_length )
|
|---|
| 207 | {
|
|---|
| 208 | $cor_subject_out .= "...";
|
|---|
| 209 | }
|
|---|
| 210 | }
|
|---|
| 211 | else
|
|---|
| 212 | {
|
|---|
| 213 | $cor_subject_out = $member_to_sender_arr['Subject'];
|
|---|
| 214 | if ( strlen( $member_to_sender_arr['Subject'] ) >= $preview_length )
|
|---|
| 215 | {
|
|---|
| 216 | $cor_subject_out .= "...";
|
|---|
| 217 | }
|
|---|
| 218 | }
|
|---|
| 219 |
|
|---|
| 220 | if( '1' == $member_to_sender_arr['New'] )
|
|---|
| 221 | {
|
|---|
| 222 | $new_out = 'not_readed.gif';
|
|---|
| 223 | $style_add = 'style="font-weight:bold;"';
|
|---|
| 224 | }
|
|---|
| 225 | else
|
|---|
| 226 | {
|
|---|
| 227 | $new_out = 'readed.gif';
|
|---|
| 228 | $style_add = '';
|
|---|
| 229 | }
|
|---|
| 230 |
|
|---|
| 231 | if( ($j_out%2) != '0')
|
|---|
| 232 | {
|
|---|
| 233 | $bgcolor = '#FFFFFF';
|
|---|
| 234 | }
|
|---|
| 235 | else
|
|---|
| 236 | {
|
|---|
| 237 | $bgcolor = '#EAF6C6';
|
|---|
| 238 | }
|
|---|
| 239 |
|
|---|
| 240 |
|
|---|
| 241 | $ret .= '<tr class="tr_hover" bgcolor="' . $bgcolor . '">';
|
|---|
| 242 | $ret .= '<td height="20">';
|
|---|
| 243 | $ret .= '<img src="' . getTemplateIcon($new_out) . '" alt="" />';
|
|---|
| 244 | $ret .= '</td>';
|
|---|
| 245 | $ret .= '<td ' . $style_add . '>';
|
|---|
| 246 | $ret .= $member_to_sender_arr['Date'];
|
|---|
| 247 | $ret .= '</td>';
|
|---|
| 248 | $ret .= '<td ' . $style_add . ' align="left">';
|
|---|
| 249 | $ret .= '<a href="' . $site['url'] . 'messages_outbox.php?message=' . $member_to_sender_arr['mID']. '">';
|
|---|
| 250 | $ret .= process_line_output(html2txt($cor_subject_out));
|
|---|
| 251 | $ret .= '</a>';
|
|---|
| 252 | $ret .= '</td>';
|
|---|
| 253 | $ret .= '</tr>';
|
|---|
| 254 | $j_out++;
|
|---|
| 255 | }
|
|---|
| 256 | $ret .= '</table>';
|
|---|
| 257 |
|
|---|
| 258 | }
|
|---|
| 259 | else
|
|---|
| 260 | {
|
|---|
| 261 | $ret .= '<div class="no_result"><div>';
|
|---|
| 262 | $ret .= _t('_no_messages_to', $sender_nickname['NickName'] );
|
|---|
| 263 | $ret .= '</div></div>';
|
|---|
| 264 | }
|
|---|
| 265 | $ret .= '</div>';
|
|---|
| 266 |
|
|---|
| 267 | //#################################################################################
|
|---|
| 268 |
|
|---|
| 269 | $ret .= '<div class="sender_to_member">';
|
|---|
| 270 | if( $sender_to_member_num )
|
|---|
| 271 | {
|
|---|
| 272 | $ret .= '<table cellpadding="0" cellspacing="0" border="0" width="100%">';
|
|---|
| 273 | $ret .= '<tr>';
|
|---|
| 274 | $ret .= '<td colspan="3" class="cor_title">';
|
|---|
| 275 | $ret .= _t('_messages_from', $sender_nickname['NickName']);
|
|---|
| 276 | $ret .= '</td>';
|
|---|
| 277 | $ret .= '</tr>';
|
|---|
| 278 | $ret .= '<tr>';
|
|---|
| 279 | $ret .= '<td width="17">';
|
|---|
| 280 | $ret .= '<img src="' . getTemplateIcon('convert.gif') . '" alt="" />';
|
|---|
| 281 | $ret .= '</td>';
|
|---|
| 282 | $ret .= '<td width="70">';
|
|---|
| 283 | $ret .= _t('_Date');
|
|---|
| 284 | $ret .= '</td>';
|
|---|
| 285 | $ret .= '<td>';
|
|---|
| 286 | $ret .= _t('_Subject');
|
|---|
| 287 | $ret .= '</td>';
|
|---|
| 288 | $ret .= '</tr>';
|
|---|
| 289 |
|
|---|
| 290 | $j_in = '0';
|
|---|
| 291 | while ($sender_to_member_arr = mysql_fetch_assoc($sender_to_member_res))
|
|---|
| 292 | {
|
|---|
| 293 | if(strlen( $sender_to_member_arr['Subject'] ) == 0 )
|
|---|
| 294 | {
|
|---|
| 295 | $cor_subject_in = $sender_to_member_arr['Preview'];
|
|---|
| 296 | if ( strlen( $sender_to_member_arr['Preview'] ) >= $preview_length )
|
|---|
| 297 | {
|
|---|
| 298 | $cor_subject_in .= "...";
|
|---|
| 299 | }
|
|---|
| 300 | }
|
|---|
| 301 | else
|
|---|
| 302 | {
|
|---|
| 303 | $cor_subject_in = $sender_to_member_arr['Subject'];
|
|---|
| 304 | if ( strlen( $sender_to_member_arr['Subject'] ) >= $preview_length )
|
|---|
| 305 | {
|
|---|
| 306 | $cor_subject_in .= "...";
|
|---|
| 307 | }
|
|---|
| 308 | }
|
|---|
| 309 |
|
|---|
| 310 | if( $_GET['message'] == $sender_to_member_arr['mID'] )
|
|---|
| 311 | {
|
|---|
| 312 | $new_in = 'current_mes.png';
|
|---|
| 313 | $style_add_in = '';
|
|---|
| 314 | }
|
|---|
| 315 | else
|
|---|
| 316 | {
|
|---|
| 317 | if( '1' == $sender_to_member_arr['New'] )
|
|---|
| 318 | {
|
|---|
| 319 | $new_in = 'not_readed.gif';
|
|---|
| 320 | $style_add_in = 'style="font-weight:bold;"';
|
|---|
| 321 | }
|
|---|
| 322 | else
|
|---|
| 323 | {
|
|---|
| 324 | $new_in = 'readed.gif';
|
|---|
| 325 | $style_add_in = '';
|
|---|
| 326 | }
|
|---|
| 327 | }
|
|---|
| 328 |
|
|---|
| 329 | if( ($j_in%2) != '0')
|
|---|
| 330 | {
|
|---|
| 331 | $bgcolor = '#FFFFFF';
|
|---|
| 332 | }
|
|---|
| 333 | else
|
|---|
| 334 | {
|
|---|
| 335 | $bgcolor = '#EAF6C6';
|
|---|
| 336 | }
|
|---|
| 337 |
|
|---|
| 338 | $ret .= '<tr class="tr_hover" bgcolor="' . $bgcolor . '">';
|
|---|
| 339 | $ret .= '<td height="20">';
|
|---|
| 340 | $ret .= '<img src="' . getTemplateIcon($new_in) . '" alt="" />';
|
|---|
| 341 | $ret .= '</td>';
|
|---|
| 342 | $ret .= '<td ' . $style_add_in . '>';
|
|---|
| 343 | $ret .= $sender_to_member_arr['Date'];
|
|---|
| 344 | $ret .= '</td>';
|
|---|
| 345 | $ret .= '<td ' . $style_add_in . ' align="left">';
|
|---|
| 346 | $ret .= '<a href="' . $site['url'] . 'messages_inbox.php?message=' . $sender_to_member_arr['mID'] . '">';
|
|---|
| 347 | $ret .= process_line_output(html2txt($cor_subject_in));
|
|---|
| 348 | $ret .= '</a>';
|
|---|
| 349 | $ret .= '</td>';
|
|---|
| 350 | $j_in++;
|
|---|
| 351 | }
|
|---|
| 352 |
|
|---|
| 353 | $ret .= '</table>';
|
|---|
| 354 | }
|
|---|
| 355 | else
|
|---|
| 356 | {
|
|---|
| 357 | $ret .= '<div class="no_result"></div>';
|
|---|
| 358 | $ret .= _t('_no_messages_from', $sender_nickname['NickName'] );
|
|---|
| 359 | $ret .= '</div></div>';
|
|---|
| 360 | }
|
|---|
| 361 | $ret .= '</div>';
|
|---|
| 362 |
|
|---|
| 363 |
|
|---|
| 364 | return $ret;
|
|---|
| 365 | }
|
|---|
| 366 |
|
|---|
| 367 | ?> |
|---|