51 $this -> aUsedTemplates = array (
52 'messages_init_box' =>
'mail_init_box.html',
53 'messages_box' =>
'mail_box.html',
54 'messages_types_list' =>
'mail_box_messages_types.html',
55 'messages_top_section' =>
'mail_box_top_section.html',
56 'contacts_section' =>
'mail_box_contacts_list.html',
57 'archives_section' =>
'mail_box_archives_list.html',
58 'archives_init_section' =>
'mail_box_init_archives_list.html',
59 'archives_pagina_section' =>
'mail_box_archives_pagination.html',
60 'archives_pagina_items' =>
'mail_box_archives_pagination_items.html',
61 'view_message_box' =>
'mail_box_view_message.html',
62 'message_replay' =>
'mail_box_replay_message.html',
63 'message_compose' =>
'mail_box_compose_message.html',
69 return array(
'mail.css');
74 return array(
'mail_box.js');
88 'plugins/jquery/|jquery.ui.autocomplete.min.js',
89 'plugins/jquery/|jquery.ui.menu.min.js',
96 if(!
isAdmin($this -> aMailBoxSettings[
'member_id']) &&
isBlocked($this -> aMailBoxSettings[
'recipient_id'], $this -> aMailBoxSettings[
'member_id']) ) {
97 return MsgBox(
_t(
'_FAILED_TO_SEND_MESSAGE_BLOCK') );
101 $aMemberInfo = ($this -> aMailBoxSettings[
'recipient_id']) ?
getProfileInfo($this -> aMailBoxSettings[
'recipient_id']) :
null;
107 return array($sErrMsg);
109 $aLanguageKeys = array (
110 'cancel' =>
_t(
'_Cancel' ),
111 'send' =>
_t(
'_Send' ),
113 'send_copy_my' =>
_t(
'_Send copy to my personal email' ),
115 'error_message' =>
_t(
'_please_fill_next_fields_first' ),
116 'subject' =>
_t(
'_Subject' ),
117 'message_to' =>
_t(
'_SEND_MSG_TO' ),
127 'form_attrs' => array (
133 'remove_form' =>
true,
135 'submit_name' =>
'do_submit',
141 'type' =>
'input_set',
145 'value' => $aLanguageKeys[
'send'],
146 'attrs' => array(
'onclick' =>
'if(typeof oMailBoxComposeMessage != \'undefined\') oMailBoxComposeMessage.sendMessage()'),
150 'value' => $aLanguageKeys[
'cancel'],
151 'attrs' => array(
'onclick' =>
'if(typeof oMailBoxComposeMessage != \'undefined\') oMailBoxComposeMessage.cancelCompose()'),
160 $aTemplateKeys = array
162 'plugins_dir' => CH_WSB_URL_PLUGINS,
163 'error_message' => $aLanguageKeys[
'error_message'],
164 'current_page' =>
'mail.php',
167 'member_thumbnail' => $sMemberIcon,
168 'member_location' => $sMemberLocation,
170 'recipient_name' => $sRecipientName,
171 'subject' => $aLanguageKeys[
'subject'],
173 'send_copy_my' => $aLanguageKeys[
'send_copy_my'],
174 'send_copy_to' => $aLanguageKeys[
'send_copy'],
175 'notify' => $aLanguageKeys[
'notify'],
176 'message_to' => $aLanguageKeys[
'message_to'],
178 'compose_actions_buttons' => $sMessageBoxActions,
182 -> parseHtmlByName( $this -> aUsedTemplates[
'message_compose'], $aTemplateKeys );
185 $aToggleItems = array
187 'inbox' =>
_t(
'_Inbox' ),
188 'outbox' =>
_t(
'_Outbox' ),
189 'trash' =>
_t(
'_Trash' ),
190 'compose' =>
_t(
'_Compose' ),
193 $sRequest =
'mail.php?';
194 foreach( $aToggleItems AS $sKey => $sValue ) {
195 $aTopToggleEllements[$sValue] = array
197 'href' => $sRequest .
'mode=' . $sKey,
199 'active' => ($this -> aMailBoxSettings[
'mailbox_mode'] == $sKey ),
207 $oEditor->setCustomConf (
"remove_script_host: false,\nrelative_urls: false,\n");
208 $sEditor = $oEditor->attachEditor (
'#compose_message',
CH_EDITOR_FULL);
211 return array($sEditor .
$sOutputHtml, $aTopToggleEllements);
233 `Sender`, `Recipient`
237 `ID` = {$this -> aMailBoxSettings['messageID']}
240 `Sender` = {$this -> aMailBoxSettings['member_id']}
242 `Recipient` = {$this -> aMailBoxSettings['member_id']}
246 $rResult =
db_res($sQuery);
247 while(
true == ($aRow = $rResult->fetch())) {
248 $iMessageOwner = ( $aRow[
'Sender'] == $this -> aMailBoxSettings[
'member_id'] )
252 $iSenderID = $aRow[
'Sender'];
258 if ( !$this -> aMailBoxSettings[
'contacts_mode']) {
259 if ($iSenderID != $this -> aMailBoxSettings[
'member_id'])
260 $this -> aMailBoxSettings[
'contacts_mode'] =
'From';
262 $this -> aMailBoxSettings[
'contacts_mode'] =
'To';
267 $aTopToggleEllements = array();
268 $aBottomToggleEllements = array();
271 $sRequest =
'mail.php?mode=view_message';
272 foreach( $this -> aRegisteredArchivesTypes AS $sKey => $sValue ) {
273 $aTopToggleEllements[
_t(
'_' . $sKey) .
' ' . $sSenderNickName ] = array
275 'href' => $sRequest .
'&contacts_mode=' . $sKey .
'&messageID=' . $this -> aMailBoxSettings[
'messageID'],
277 'active' => ($this -> aMailBoxSettings[
'contacts_mode'] == $sKey ),
281 $aLanguageKeys = array
283 'delete_messages' =>
_t(
'_Delete'),
284 'select_all' =>
_t(
'_Select all'),
285 'spam_messages' =>
_t(
'_Spam report' ),
292 $sTopControls =
$oSysTemplate->parseHtmlByName(
'mail_box_init_archives_list_top_controls.html', array(
293 'select_all' => $aLanguageKeys[
'select_all'],
294 'delete_messages' => $aLanguageKeys[
'delete_messages'],
295 'spam_messages' => $aLanguageKeys[
'spam_messages'],
298 $aTemplateKeys = array (
299 'top_controls' => $sTopControls,
300 'select_messages' =>
_t(
'_Please, select at least one message'),
301 'are_you_sure' =>
_t(
'_Are_you_sure'),
303 'current_page' =>
'mail.php',
308 return array(
$sOutputHtml, $aTopToggleEllements, array(),
true);
325 $sActionsList =
null;
328 $aToggleItems = array
330 'inbox' =>
_t(
'_Inbox' ),
331 'outbox' =>
_t(
'_Outbox' ),
332 'trash' =>
_t(
'_Trash' ),
333 'compose' =>
_t(
'_Compose' ),
336 $sRequest =
'mail.php' .
'?';
337 foreach( $aToggleItems AS $sKey => $sValue ) {
338 $aTopToggleEllements[$sValue] = array
340 'href' => $sRequest .
'&mode=' . $sKey,
347 $aLanguageKeys = array
349 'back_inbox' =>
_t(
'_sys_mailbox_back_inbox'),
350 'back_outbox' =>
_t(
'_sys_mailbox_back_outbox'),
351 'back_trash' =>
_t(
'_sys_mailbox_back_trash'),
352 'spam_message' =>
_t(
'_Report' ),
353 'delete_message' =>
_t(
'_Delete' ),
354 'reply_message' =>
_t(
'_Reply' ),
355 'restore_message' =>
_t(
'_Restore' ),
356 'are_you_sure' =>
_t(
'_Are_you_sure' ),
357 'more' =>
_t(
'_More actions' ),
358 'mark_read' =>
_t(
'_Mark as old' ),
359 'mark_unread' =>
_t(
'_Mark as New' ),
370 `ID` = {$this -> aMailBoxSettings['messageID']}
373 `Sender` = {$this -> aMailBoxSettings['member_id']}
375 `Recipient` = {$this -> aMailBoxSettings['member_id']}
379 $rResult =
db_res($sQuery);
380 while(
true == ($aRow = $rResult->fetch()) ) {
387 if($aRow[
'Trash'] ==
'recipient') {
388 $sBackCaption = $aLanguageKeys[
'back_trash'];
389 $sBackUrl =
'mail.php' .
'?mode=trash';
390 }
else if ( $aRow[
'Sender'] == $this -> aMailBoxSettings[
'member_id'] ) {
391 $sBackCaption = $aLanguageKeys[
'back_outbox'];
392 $sBackUrl =
'mail.php' .
'?mode=outbox';
394 $sBackCaption = $aLanguageKeys[
'back_inbox'];
395 $sBackUrl =
'mail.php' .
'?mode=inbox';
410 $sMemberFlag = ($sMemberCountry)
411 ?
$site[
'flags'] . strtolower($sMemberCountry) . $this -> sMembersFlagExtension
414 if ( $sMemberCountry )
415 $sMemberCountryFlag =
'<img src="' . $sMemberFlag .
'" alt="' . $sMemberCountry .
'" />';
422 $sMemberCountry = $sCity . $sMemberCountry;
425 if ( $aRow[
'Sender'] != $this -> aMailBoxSettings[
'member_id'] ) {
426 $sActionsList =
$oFunctions->getProfileViewActions($aRow[
'Sender']);
430 if ( $aRow[
'Sender'] == $this -> aMailBoxSettings[
'member_id'] ) {
431 if ( strstr($aRow[
'Trash'],
'sender') ) {
432 $this -> aMailBoxSettings[
'mailbox_mode'] =
'trash';
434 $this -> aMailBoxSettings[
'mailbox_mode'] =
'outbox';
436 $sRelocateParameter =
'outbox';
437 }
else if ( $aRow[
'Sender'] != $this -> aMailBoxSettings[
'member_id'] ) {
438 if ( strstr($aRow[
'Trash'],
'recipient') ) {
439 $this -> aMailBoxSettings[
'mailbox_mode'] =
'trash';
441 $this -> aMailBoxSettings[
'mailbox_mode'] =
'inbox';
443 $sRelocateParameter =
'inbox';
447 switch($this -> aMailBoxSettings[
'mailbox_mode']) {
451 'form_attrs' => array (
457 'remove_form' =>
true,
459 'submit_name' =>
'do_submit',
465 'type' =>
'input_set',
470 'value' => $aLanguageKeys[
'delete_message'],
471 'attrs' => array(
'onclick' =>
'if ( typeof oMailBoxViewMessage != \'undefined\') oMailBoxViewMessage.deleteMessages(' . $aRow[
'ID'] .
')',
'class' =>
'ch-btn-small'),
475 'value' => $aLanguageKeys[
'spam_message'],
476 'attrs' => array(
'onclick' =>
'if ( typeof oMailBoxViewMessage != \'undefined\') oMailBoxViewMessage.spamMessages(\'\', ' . $aRow[
'Sender'] .
')',
'class' =>
'ch-btn-small'),
480 'value' => $aLanguageKeys[
'mark_read'],
481 'attrs' => array(
'onclick' =>
'if ( typeof oMailBoxViewMessage != \'undefined\') oMailBoxViewMessage.markMessages(\'read\', ' . $aRow[
'ID'] .
')',
'class' =>
'ch-btn-small'),
485 'value' => $aLanguageKeys[
'mark_unread'],
486 'attrs' => array(
'onclick' =>
'if ( typeof oMailBoxViewMessage != \'undefined\') oMailBoxViewMessage.markMessages(\'unread\', ' . $aRow[
'ID'] .
')',
'class' =>
'ch-btn-small'),
492 if($aRow[
'Sender'] != $this -> aMailBoxSettings[
'member_id']){
493 $aForm[
'inputs'][
'actions'][0] = array(
495 'value' => $aLanguageKeys[
'reply_message'],
496 'attrs' => array(
'onclick' =>
'oMailBoxViewMessage.replyMessage(' . $this -> aMailBoxSettings[
'messageID'] .
', ' . $aRow[
'Sender'] .
');',
'class' =>
'ch-btn-small'),
507 'form_attrs' => array (
513 'remove_form' =>
true,
515 'submit_name' =>
'do_submit',
521 'type' =>
'input_set',
525 'value' => $aLanguageKeys[
'delete_message'],
526 'attrs' => array(
'onclick' =>
'if (typeof oMailBoxViewMessage != \'undefined\') oMailBoxViewMessage.deleteMessages(' . $aRow[
'ID'] .
')',
'class' =>
'ch-btn-small'),
539 'form_attrs' => array (
545 'remove_form' =>
true,
547 'submit_name' =>
'do_submit',
553 'type' =>
'input_set',
558 'value' => $aLanguageKeys[
'restore_message'],
559 'attrs' => array(
'onclick' =>
'if (typeof oMailBoxViewMessage != \'undefined\') oMailBoxViewMessage.restoreMessages(' . $aRow[
'ID'] .
');',
'class' =>
'ch-btn-small'),
565 if($aRow[
'Sender'] != $this -> aMailBoxSettings[
'member_id']){
566 $aForm[
'inputs'][
'actions'][0] = array(
568 'value' => $aLanguageKeys[
'reply_message'],
569 'attrs' => array(
'onclick' =>
'oMailBoxViewMessage.replyMessage(' . $this -> aMailBoxSettings[
'messageID'] .
', ' . $aRow[
'Sender'] .
');',
'class' =>
'ch-btn-small'),
579 $sTopcontrols =
$oSysTemplate->parseHtmlByName(
'mail_box_view_message_top_controls.html', array(
580 'inbox_mode' => $sBackUrl,
581 'back_to_inbox' => $sBackCaption,
585 $aTemplateKeys = array (
586 'top_controls' => $sTopcontrols,
588 'member_thumbnail' => $sMemberIcon,
589 'member_nick_name' => $sMemberNickName,
590 'member_location' => $sMemberLocation,
592 'member_sex_img' => $sMemberSexImage,
595 'member_age' => $sMemberAge,
596 'member_flag' => $sMemberCountryFlag,
597 'city_country' => $sMemberCountry,
599 'date_create' => $aRow[
'Date'],
601 'message_subject' => $aRow[
'Subject'],
602 'member_actions_list' => $sActionsList,
604 'message_text' => $aRow[
'Text'],
606 'are_you_sure' => $aLanguageKeys[
'are_you_sure'],
607 'current_page' =>
'mail.php',
608 'spam_message' => $aLanguageKeys[
'spam_message'],
609 'delete_message' => $aLanguageKeys[
'delete_message'],
611 'message_id' => $aRow[
'ID'],
612 'message_actions' => $sMessageBoxActions,
613 'page_mode' => $sRelocateParameter,
621 if ( !$rResult->rowCount() )
624 return array(
$sOutputHtml, $aTopToggleEllements, array(),
true);
638 if(
empty($aMessages))
639 return $bShowEmpty ?
MsgBox(
_t(
'_Empty')) :
'';
642 'ch_repeat:messages' => array()
645 foreach($aMessages
as $aMessage) {
646 $aTmplVars[
'ch_repeat:messages'][] = array(
647 'message_page' =>
'mail.php',
648 'message_link' => $aMessage[
'ID'],
650 'member_nickname' =>
getNickName($aMessage[
'Sender']),
652 'message_subject' => $aMessage[
'Subject']
656 return $oSysTemplate->parseHtmlByName(
'mail_box_short.html', $aTmplVars);
676 $aTemplateKeys = array
678 'current_page' =>
'mail.php',
679 'mail_rows' => ( $sMessageRows ) ? $sMessageRows :
MsgBox(
_t(
'_Empty' )),
680 'select_messages' =>
_t(
'_Please, select at least one message'),
681 'are_you_sure' =>
_t(
'_Are_you_sure'),
688 $aToggleItems = array
690 'inbox' =>
_t(
'_Inbox' ),
691 'outbox' =>
_t(
'_Outbox' ),
692 'trash' =>
_t(
'_Trash' ),
693 'compose' =>
_t(
'_Compose' ),
696 $sRequest =
'mail.php' .
'?';
697 foreach( $aToggleItems AS $sKey => $sValue ) {
698 $aTopToggleEllements[$sValue] = array
700 'href' => $sRequest .
'mode=' . $sKey,
702 'active' => ($this -> aMailBoxSettings[
'mailbox_mode'] == $sKey ),
706 return array(
$sOutputHtml, $aTopToggleEllements, array(),
true);
721 $sFunctionNam =
null;
725 $aRegisteredContacts_keys = array_keys($this -> aRegisteredContactTypes);
726 $sDefaultItem = $aRegisteredContacts_keys[0];
728 if ( !$this -> aMailBoxSettings[
'contacts_mode'] )
729 $this -> aMailBoxSettings[
'contacts_mode'] = $sDefaultItem;
733 $aTopToggleEllements = array();
734 $aBottomToggleEllements = array();
737 if( $this -> aMailBoxSettings[
'contacts_page'] < 1 )
738 $this -> aMailBoxSettings[
'contacts_page'] = 1;
740 $sLimitFrom = ( $this -> aMailBoxSettings[
'contacts_page'] - 1 ) * $this -> iContactsPerPage;
741 $sSqlLimit =
"LIMIT {$sLimitFrom}, {$this -> iContactsPerPage}";
743 if($this -> aMailBoxSettings[
'contacts_mode'] && array_key_exists($this -> aMailBoxSettings[
'contacts_mode'], $this -> aRegisteredContactTypes))
744 $sFunctionName = $this -> aRegisteredContactTypes[$this -> aMailBoxSettings[
'contacts_mode']];
747 if (!$sFunctionName )
748 $sFunctionName = $this -> aRegisteredContactTypes[$sDefaultItem];
751 if (method_exists($this, $sFunctionName)) {
760 $sMemberSexImg =
null;
772 $sMemberFlag =
$site[
'flags'] . strtolower(
$aProfileInfo[
'Country']) . $this -> sMembersFlagExtension;
775 $sMemberCountryFlag = ($sMemberFlag)
776 ?
'<img src="' . $sMemberFlag .
'" alt="' .
$aProfileInfo[
'Country'] .
'" />'
779 $aMemberKeys[] = array
781 'member_icon' => $sMemberIcon,
782 'member_location' => $sMemberLocation,
785 'member_sex_img' => $sMemberSexImg,
787 'member_age' => $sMemberAge,
788 'member_flag' => $sMemberCountryFlag,
791 'compose_img' => $sComposeImg,
794 'current_page' =>
'mail.php',
800 $aTemplateKeys = array
802 'ch_repeat:members' => $aMemberKeys,
806 -> parseHtmlByName( $this -> aUsedTemplates[
'contacts_section'], $aTemplateKeys );
812 $sRequest =
'mail.php?';
813 $sSelectedItem = ( $this -> aMailBoxSettings[
'contacts_mode'] )
814 ? $this -> aMailBoxSettings[
'contacts_mode']
818 $sRecipientParam = ($this -> aMailBoxSettings[
'recipient_id'])
819 ?
'&recipient_id=' . $this -> aMailBoxSettings[
'recipient_id']
822 foreach( $this -> aRegisteredContactTypes AS $sKey => $sValue ) {
823 $aTopToggleEllements[
_t(
'_' . $sKey) ] = array
825 'href' => $sRequest .
'&mode=' . $this -> aMailBoxSettings[
'mailbox_mode'] .
'&contacts_mode=' . $sKey . $sRecipientParam,
827 'active' => ($sSelectedItem == $sKey ),
832 $iAllContactPages = ceil( $this -> iTotalContactsCount / $this -> iContactsPerPage );
833 $aNeededParameters = array
835 'contacts_mode',
'recipient_id'
839 $sRequest =
'mail.php?';
840 foreach( $aNeededParameters AS $sKey ) {
841 if ( $this -> aMailBoxSettings[$sKey] )
842 $sRequest .= $sKey .
'=' . $this -> aMailBoxSettings[$sKey] .
'&';
846 if ( $this -> aMailBoxSettings[
'contacts_page'] < $iAllContactPages ) {
847 $aBottomToggleEllements[
_t(
'_Next') ] = array
849 'href' => $sRequest .
'mode=' . $this -> aMailBoxSettings[
'mailbox_mode'] .
'&contacts_page=' . ($this -> aMailBoxSettings[
'contacts_page'] + 1),
851 'class' =>
'moreMembers',
856 if ( $this -> aMailBoxSettings[
'contacts_page'] > 1 ) {
857 $aBottomToggleEllements[
_t(
'_Back') ] = array
859 'href' => $sRequest .
'mode=' . $this -> aMailBoxSettings[
'mailbox_mode'] .
'&contacts_page=' . ($this -> aMailBoxSettings[
'contacts_page'] - 1),
861 'class' =>
'backMembers',
868 return array(
$sOutputHtml, $aTopToggleEllements, $aBottomToggleEllements,
false);
891 function _genPaginationItem( $sItemType, $oObject )
901 $sLinkValue =
_t(
'_Next');
902 $iNeededPage = $oObject -> aMailBoxSettings[
'contacts_page'] + 1;
904 $aTemplateKeys = array
907 'item_img_alt' => $sLinkValue,
908 'item_img_css_class' =>
'bot_icon_right',
909 'item_link_action' =>
"oMailBoxArchive.getPaginatePage('{$iNeededPage}');return false",
910 'item_link_css_class' =>
'moreMembers',
911 'item_link_href' =>
'mail.php',
912 'item_link_value' => $sLinkValue,
916 $sLinkValue =
_t(
'_Back');
917 $iNeededPage = $oObject -> aMailBoxSettings[
'contacts_page'] - 1;
919 $aTemplateKeys = array
922 'item_img_alt' => $sLinkValue,
923 'item_img_css_class' =>
'bot_icon_left',
924 'item_link_action' =>
"oMailBoxArchive.getPaginatePage('{$iNeededPage}');return false",
925 'item_link_css_class' =>
'backMembers',
926 'item_link_href' =>
'mail.php',
927 'item_link_value' => $sLinkValue,
932 if ( is_array($aTemplateKeys) ) {
934 -> parseHtmlByName( $oObject -> aUsedTemplates[
'archives_pagina_items'], $aTemplateKeys );
942 $sFunctionName =
null;
944 $sPaginationHtml =
null;
947 $aRegisteredContacts_keys = array_keys($this -> aRegisteredArchivesTypes);
948 $sDefaultItem = $aRegisteredContacts_keys[0];
950 if ( !$this -> aMailBoxSettings[
'contacts_mode'] )
951 $this -> aMailBoxSettings[
'contacts_mode'] = $sDefaultItem;
954 $aMessagesList = array();
957 if( $this -> aMailBoxSettings[
'contacts_page'] < 1 )
958 $this -> aMailBoxSettings[
'contacts_page'] = 1;
960 $sLimitFrom = ( $this -> aMailBoxSettings[
'contacts_page'] - 1 ) * $this -> iContactsPerPage;
961 $sSqlLimit =
"LIMIT {$sLimitFrom}, {$this -> iContactsPerPage}";
963 if($this->aMailBoxSettings[
'contacts_mode'] && array_key_exists($this -> aMailBoxSettings[
'contacts_mode'], $this -> aRegisteredArchivesTypes))
964 $sFunctionName = $this -> aRegisteredArchivesTypes[$this -> aMailBoxSettings[
'contacts_mode']];
967 if (!$sFunctionName )
968 $sFunctionName = $this -> aRegisteredArchivesTypes[$sDefaultItem];
971 if ( method_exists($this, $sFunctionName) ) {
973 $aMessagesList = $this -> $sFunctionName( $sSqlLimit );
974 if ( is_array($aMessagesList)
and !
empty($aMessagesList) ) {
975 foreach($aMessagesList AS $iKey => $aItems ) {
977 $sMessageSubject = (mb_strlen($aItems[
'Subject']) > $this -> iArchivesSubjectLength)
978 ? mb_substr($aItems[
'Subject'], 0, $this -> iArchivesSubjectLength) .
'...'
979 : $aItems[
'Subject'];
981 $sMessageLink = ( $aItems[
'ID'] == $this -> aMailBoxSettings[
'messageID'] )
983 :
'<a href="mail.php?mode=view_message&messageID=' . $aItems[
'ID'].
'">' .
$sMessageSubject .
'</a>';
985 $aMessageKeys[] = array
987 'member_icon' => $sMemberIcon,
989 'current_page' =>
'mail.php',
990 'message_id' => $aItems[
'ID'],
991 'message_owner' => $aItems[
'Sender'],
992 'message_subject' => $sMessageLink,
994 'message_date' => $aItems[
'When'],
1000 $aTemplateKeys = array
1002 'contacts_mode' => $this -> aMailBoxSettings[
'contacts_mode'],
1003 'message_id' => $this -> aMailBoxSettings[
'messageID'],
1004 'ch_repeat:messages' => $aMessageKeys,
1012 $sPaginationHtml =
'';
1013 $iAllContactPages = ceil( $this -> iTotalContactsCount / $this -> iContactsPerPage );
1014 if($iAllContactPages > 1) {
1015 $aNeededParameters = array (
1016 'contacts_mode',
'messageID',
1020 $sRequest =
'mail.php?';
1021 foreach($aNeededParameters AS $sKey)
1022 $sRequest .= $sKey .
'=' . $this -> aMailBoxSettings[$sKey] .
'&';
1025 $aTemplateKeys = array (
1026 'prev_link' => ( $this -> aMailBoxSettings[
'contacts_page'] > 1 ) ? _genPaginationItem(
'prev', $this) :
null,
1027 'next_link' => ( $this -> aMailBoxSettings[
'contacts_page'] < $iAllContactPages ) ? _genPaginationItem(
'next', $this) :
null,
1030 $sPaginationHtml .=
$oSysTemplate -> parseHtmlByName( $this -> aUsedTemplates[
'archives_pagina_section'], $aTemplateKeys );
1054 $sMessageBoxActions =
null;
1055 $sMessagesTypesList =
null;
1056 $sPerPageBlock =
null;
1058 $aSortToglleElements = array
1060 'date_sort_toggle',
'subject_sort_toggle',
1061 'type_sort_toggle',
'author_sort_toggle',
1064 $aMessageRows = array();
1067 $aLanguageKeys = array
1069 'author' =>
_t(
'_Author' ),
1070 'type' =>
_t(
'_Type' ),
1071 'subject' =>
_t(
'_Subject' ),
1072 'date' =>
_t(
'_Date' ),
1073 'new' =>
_t(
'_new' ),
1074 'contact' =>
_t(
'_Contact' ),
1075 'select' =>
_t(
'_Select' ),
1076 'all' =>
_t(
'_All' ),
1077 'none' =>
_t(
'_None' ),
1078 'read' =>
_t(
'_Read' ),
1079 'unread' =>
_t(
'_Unread' ),
1080 'delete' =>
_t(
'_Delete' ),
1081 'spam' =>
_t(
'_Report' ),
1082 'more' =>
_t(
'_More actions' ),
1083 'mark_read' =>
_t(
'_Mark as old' ),
1084 'mark_unread'=>
_t(
'_Mark as New' ),
1085 'restore' =>
_t(
'_Restore' ),
1086 'click_sort' =>
_t(
'_Click to sort' ),
1087 'recipient' =>
_t(
'_Recipient' ),
1094 if ( is_array($this -> aRegisteredMessageTypes)
and !
empty($this -> aRegisteredMessageTypes) ) {
1095 foreach( $this -> aRegisteredMessageTypes AS $iKey => $sRegisteredType ) {
1097 if ( !
empty($this -> aReceivedMessagesTypes)
and in_array($sRegisteredType, $this -> aReceivedMessagesTypes) ) {
1098 $sChecked =
' checked="checked" ';
1101 $aTemplateKeys = array
1103 'letters_type' => $sRegisteredType,
1104 'letters_type_caption' =>
_t(
'_' . $sRegisteredType ),
1105 'checked' => $sChecked,
1109 -> parseHtmlByName( $this -> aUsedTemplates[
'messages_types_list'], $aTemplateKeys );
1111 unset($aTemplateKeys);
1115 if ( is_array($aMessages)
and !
empty($aMessages) ) {
1118 foreach( $aMessages
as $iKey => $aItems ) {
1120 $sTypeIcon =
getTemplateIcon( $this -> sMessageIconPrefix . $aItems[
'Type'] . $this -> sMessageIconExtension );
1121 $sTypeLang =
_t(
'_' . $aItems[
'Type'] );
1124 $sSubject = ( mb_strlen($aItems[
'Subject']) > $this -> iMessageSubjectLength )
1125 ? mb_substr($aItems[
'Subject'], 0, $this -> iMessageSubjectLength) .
'...'
1126 : $aItems[
'Subject'];
1129 $sDescription = strip_tags($aItems[
'Text']);
1130 ( mb_strlen($sDescription) > $this -> iMessageDescrLength )
1131 ? $sDescription = mb_substr($sDescription, 0, $this -> iMessageDescrLength) .
'...'
1138 $sFiledCss = !(
$iIndex % 2 ) ?
'filled' :
'not_filled';
1140 $aProfileInfo = $this -> aMailBoxSettings[
'mailbox_mode'] !=
'outbox'
1144 $sMemberIcon = $this -> aMailBoxSettings[
'mailbox_mode'] !=
'outbox'
1148 $sMemberLocation = $this -> aMailBoxSettings[
'mailbox_mode'] !=
'outbox'
1153 $sMemberAge = (
$aProfileInfo[
'DateOfBirth'] !=
"0000-00-00" )
1158 $sMemberFlag =
$site[
'flags'] . strtolower($sMemberCountry) . $this -> sMembersFlagExtension;
1161 if ( $sMemberCountry )
1162 $sMemberCountryFlag =
'<img src="' . $sMemberFlag .
'" alt="' . $sMemberCountry .
'" />';
1165 $sMessageStatus = ($aItems[
'New']) ?
'unread' :
'read';
1167 $aMessageRows[] = array
1169 'message_id' => $aItems[
'ID'],
1170 'message_status' => $sMessageStatus,
1171 'message_owner' => $aItems[
'Sender'],
1172 'message_link' => $aItems[
'ID'],
1173 'message_page' =>
'mail.php',
1175 'member_icon' => $sMemberIcon,
1176 'member_location' => $sMemberLocation,
1177 'member_nickname' => $sMemberNickName,
1178 'member_sex_img' => $sMemberSexImg,
1180 'member_age' => $sMemberAge,
1181 'member_flag' => $sMemberCountryFlag,
1182 'member_country' => $sMemberCountry,
1184 'message_type' => $sTypeLang,
1185 'message_type_icon' => $sTypeIcon,
1187 'message_subject' => $sSubject,
1188 'ch_if:show_new' => array(
1189 'condition' => $aItems[
'New'],
1190 'content' => array()
1192 'message_descr' => $sDescription,
1194 'message_new_img' => $sNewMessageImg,
1195 'message_new' => $aLanguageKeys[
'new'],
1196 'message_contact_url' => CH_WSB_URL_ROOT .
"mail.php?mode=compose&recipient_id=" .
$aProfileInfo[
'ID'],
1197 'message_contact' => $aLanguageKeys[
'contact'],
1199 'message_date' => $aItems[
'Date'],
1201 'filled_class' => $sFiledCss,
1208 switch ( $this -> aMailBoxSettings[
'sort_mode'] ) {
1210 $aSortToglleElements[
'date_sort_toggle'] =
'toggle_up';
1213 $aSortToglleElements[
'date_sort_toggle'] =
'toggle_down';
1216 $aSortToglleElements[
'subject_sort_toggle'] =
'toggle_up';
1218 case 'subject_desc' :
1219 $aSortToglleElements[
'subject_sort_toggle'] =
'toggle_down';
1222 $aSortToglleElements[
'type_sort_toggle'] =
'toggle_up';
1225 $aSortToglleElements[
'type_sort_toggle'] =
'toggle_down';
1228 $aSortToglleElements[
'author_sort_toggle'] =
'toggle_up';
1230 case 'author_desc' :
1231 $aSortToglleElements[
'author_sort_toggle'] =
'toggle_down';
1236 $sRequest = CH_WSB_URL_ROOT .
'mail.php?';
1239 $aGetParams = array(
'mode',
'sorting',
'messages_types');
1240 if ( is_array($aGetParams)
and !
empty($aGetParams) )
1241 foreach($aGetParams AS $sValue )
1242 if ( isset(
$_GET[$sValue]) ) {
1243 $sRequest .=
'&' . $sValue .
'=' .
$_GET[$sValue];
1246 $sCuttedUrl = $sRequest;
1247 $sRequest = $sRequest .
'&page={page}&per_page={per_page}';
1252 'page_url' => $sRequest,
1253 'count' => $this -> iTotalMessageCount,
1254 'per_page' => $this -> aMailBoxSettings[
'per_page'],
1255 'sorting' => $this -> aMailBoxSettings[
'sort_mode'],
1256 'page' => $this -> aMailBoxSettings[
'page'],
1258 'on_change_page' =>
"oMailBoxMessages.getPaginatePage('{$sRequest}')",
1259 'on_change_per_page' =>
"oMailBoxMessages.getPage(this.value, '{$sCuttedUrl}')",
1262 $sPagination = $oPaginate -> getPaginate();
1265 if ( !
empty($aMessageRows) ) {
1266 $aTemplateKeys = array
1268 'per_page' => $this -> aMailBoxSettings[
'per_page'],
1269 'page_number' => $this -> aMailBoxSettings[
'page'],
1270 'page_mode' => $this -> aMailBoxSettings[
'mailbox_mode'],
1271 'messages_types' => $this -> aMailBoxSettings[
'messages_types'],
1273 'messages_types_list' => $sMessagesTypesList,
1274 'per_page_block' => $oPaginate -> getPages(),
1276 'author' => $this -> aMailBoxSettings[
'mailbox_mode'] !=
'outbox'
1277 ? $aLanguageKeys[
'author']
1278 : $aLanguageKeys[
'recipient'],
1280 'type' => $aLanguageKeys[
'type'],
1281 'subject' => $aLanguageKeys[
'subject'],
1282 'date' => $aLanguageKeys[
'date'],
1283 'click_sort' => $aLanguageKeys[
'click_sort'],
1284 'ch_repeat:messages' => $aMessageRows,
1286 'sort_date' => ( $this -> aMailBoxSettings[
'sort_mode'] ==
'date' ) ?
'date_desc' :
'date',
1287 'sort_subject' => ( $this -> aMailBoxSettings[
'sort_mode'] ==
'subject' ) ?
'subject_desc' :
'subject',
1288 'sort_type' => ( $this -> aMailBoxSettings[
'sort_mode'] ==
'type' ) ?
'type_desc' :
'type',
1289 'sort_author' => ( $this -> aMailBoxSettings[
'sort_mode'] ==
'author' ) ?
'author_desc' :
'author',
1291 'date_sort_toggle_ellement' => $aSortToglleElements[
'date_sort_toggle'],
1292 'subject_sort_toggle_ellement' => $aSortToglleElements[
'subject_sort_toggle'],
1293 'type_sort_toggle_ellement' => $aSortToglleElements[
'type_sort_toggle'],
1294 'author_sort_toggle_ellement' => $aSortToglleElements[
'author_sort_toggle'],
1296 'current_page' =>
'mail.php',
1297 'select' => $aLanguageKeys[
'select'],
1298 'all_messages' => $aLanguageKeys[
'all'],
1299 'none_messages' => $aLanguageKeys[
'none'],
1300 'read_messages' => $aLanguageKeys[
'read'],
1301 'unread_messages' => $aLanguageKeys[
'unread'],
1303 'pagination_block' => $sPagination,
1307 switch($this -> aMailBoxSettings[
'mailbox_mode']) {
1310 'form_attrs' => array (
1316 'remove_form' =>
true,
1318 'submit_name' =>
'do_submit',
1324 'type' =>
'input_set',
1325 'colspan' =>
'true',
1328 'value' => $aLanguageKeys[
'delete'],
1329 'attrs' => array(
'onclick' =>
'if ( typeof oMailBoxMessages != \'undefined\' ) oMailBoxMessages.deleteMessages(\'messages_container\', \'genMessagesRows\')',
'class' =>
'ch-btn-small'),
1333 'value' => $aLanguageKeys[
'spam'],
1334 'attrs' => array(
'onclick' =>
'if (typeof oMailBoxMessages != \'undefined\') oMailBoxMessages.spamMessages(\'messages_container\')',
'class' =>
'ch-btn-small'),
1338 'value' => $aLanguageKeys[
'mark_read'],
1339 'attrs' => array(
'onclick' =>
'if ( typeof oMailBoxMessages != \'undefined\' ) oMailBoxMessages.markMessages(\'read\', \'genMessagesRows\')',
'class' =>
'ch-btn-small'),
1343 'value' => $aLanguageKeys[
'mark_unread'],
1344 'attrs' => array(
'onclick' =>
'if ( typeof oMailBoxMessages != \'undefined\' ) oMailBoxMessages.markMessages(\'unread\', \'genMessagesRows\')',
'class' =>
'ch-btn-small'),
1356 'form_attrs' => array (
1362 'remove_form' =>
true,
1364 'submit_name' =>
'do_submit',
1370 'type' =>
'input_set',
1371 'colspan' =>
'true',
1374 'value' => $aLanguageKeys[
'delete'],
1375 'attrs' => array(
'onclick' =>
'if ( typeof oMailBoxMessages != \'undefined\' ) oMailBoxMessages.deleteMessages(\'messages_container\', \'genMessagesRows\')',
'class' =>
'ch-btn-small'),
1387 'form_attrs' => array (
1393 'remove_form' =>
true,
1395 'submit_name' =>
'do_submit',
1401 'type' =>
'input_set',
1402 'colspan' =>
'true',
1405 'value' => $aLanguageKeys[
'restore'],
1406 'attrs' => array(
'onclick' =>
'if ( typeof oMailBoxMessages != \'undefined\' ) oMailBoxMessages.restoreMessages(\'messages_container\', \'genMessagesRows\')',
'class' =>
'ch-btn-small'),
1410 'value' => $aLanguageKeys[
'delete'],
1411 'attrs' => array(
'onclick' =>
'if ( typeof oMailBoxMessages != \'undefined\' ) oMailBoxMessages.hideDeletedMessages(\'messages_container\', \'genMessagesRows\')',
'class' =>
'ch-btn-small'),
1422 $aTemplateKeys[
'messages_actions_block'] = $sMessageBoxActions;
1425 $sMessagesSection =
$oSysTemplate -> parseHtmlByName( $this -> aUsedTemplates[
'messages_box'], $aTemplateKeys );
1426 $sPerPageBlock = $oPaginate -> getPages();
1428 $sMessagesSection =
MsgBox(
_t(
'_Empty') );
1431 $sTopControls =
$oSysTemplate -> parseHtmlByName(
'mail_box_messages_list_top_controls.html', array(
1432 'messages_types_list' => $sMessagesTypesList,
1433 'per_page_block' => $sPerPageBlock,
1436 $aTemplateKeys = array (
1437 'per_page' => $this -> aMailBoxSettings[
'per_page'],
1438 'page_number' => $this -> aMailBoxSettings[
'page'],
1439 'page_mode' => $this -> aMailBoxSettings[
'mailbox_mode'],
1440 'messages_types' => $this -> aMailBoxSettings[
'messages_types'],
1441 'messages_sort' => $this -> aMailBoxSettings[
'sort_mode'],
1442 'top_controls' => $sTopControls,
1443 'messages_section' => $sMessagesSection
1464 $iRecipientID = (int) $iRecipientID;
1477 $aLanguageKeys = array
1479 'information' => (
$iMessageID ) ?
_t(
'_Reply' ) :
_t(
'_COMPOSE_H1' ),
1482 'send_copy' =>
_t(
'_Send copy to personal email', $aRecipientInfo[
'NickName'] ),
1483 'send_copy_my' =>
_t(
'_Send copy to my personal email' ),
1484 'notify' =>
_t(
'_Notify by e-mail', $aRecipientInfo[
'NickName'] ),
1485 'error_message' =>
ch_js_string(
_t(
'_please_fill_next_fields_first') ),
1495 $sCurrentDate = date(
'd.m.Y G:i');
1506 `ID` = {$iMessageID}
1509 `Sender` = {$this -> aMailBoxSettings['member_id']}
1511 `Recipient` = {$this -> aMailBoxSettings['member_id']}
1518 'form_attrs' => array (
1524 'remove_form' =>
true,
1526 'submit_name' =>
'do_submit',
1532 'type' =>
'input_set',
1533 'colspan' =>
'true',
1536 'value' => $aLanguageKeys[
'send'],
1537 'attrs' => array(
'onclick' =>
'if(typeof oMailBoxReplayMessage != \'undefined\') oMailBoxReplayMessage.sendMessage(' . $iRecipientID .
')'),
1541 'value' => $aLanguageKeys[
'cancel'],
1542 'attrs' => array(
'onclick' =>
'if(typeof oMailBoxReplayMessage != \'undefined\') oMailBoxReplayMessage.cancelReplay()'),
1551 $aTemplateKeys = array
1553 'error_message' => $aLanguageKeys[
'error_message'],
1554 'current_page' =>
'mail.php',
1556 'information' => $aLanguageKeys[
'information'],
1558 'member_thumbnail' => $sMemberIcon,
1559 'member_nick_name' => $sMemberNickName,
1560 'member_location' => $sMemberLocation,
1562 'date_create' => $sCurrentDate,
1566 'send_copy_my' => $aLanguageKeys[
'send_copy_my'],
1567 'send_copy_to' => $aLanguageKeys[
'send_copy'],
1568 'notify' => $aLanguageKeys[
'notify'],
1570 'action_buttons' => $sMessageBoxActions,
1574 -> parseHtmlByName( $this -> aUsedTemplates[
'message_replay'], $aTemplateKeys );
1581 $oEditor->setCustomConf (
"remove_script_host: false,\nrelative_urls: false,\n");
1582 $sEditor = $oEditor->attachEditor (
'#compose_message',
CH_EDITOR_FULL, $this->bAjaxMode);
1594 if (preg_match(
'/^(Re)(\[(\d+)\])?\:\s?(.*)$/i', $sSubject, $aMatches)) {
1596 $iRe =
empty($aMatches[3]) ? 1 : (int)$aMatches[3];
1598 $sSubject = $aMatches[1] .
'[' . ($iRe + 1) .
']: ' . $aMatches[4];
1600 $sSubject =
'Re: ' . $sSubject;
1623 $iLimit = (int) $iLimit;
1628 $sWhere .=
"`{$sField}` LIKE '%{$sQuery}%' OR ";
1631 $sQuery =
"SELECT `ID`, `NickName` FROM `Profiles` WHERE $sWhere LIMIT {$iLimit}";
1632 $rResult =
db_res($sQuery);
1634 while(
true == ($aRow = $rResult->fetch()) )
1635 $aOutput[] = array(
'id' => $aRow[
'ID'],
'value' =>
getNickName($aRow[
'ID']));
1637 return json_encode($aOutput);
1654 $iOldCount = (int) $iOldCount;
1657 $aNotifyMessages = array();
1664 `ID`, `Sender`, `Type`
1669 `Recipient` = {$iMemberId}
1671 NOT FIND_IN_SET('Recipient', `Trash`)
1679 $rResult =
db_res($sQuery);
1680 $aMessages = array();
1681 while(
true == ($aRow = $rResult->fetch()) ) {
1682 $aMessages[] = array($aRow[
'ID'], $aRow[
'Sender'], $aRow[
'Type']);
1685 $iNewMessages = count($aMessages);
1688 if ( $iNewMessages > $iOldCount) {
1690 for( $i = $iOldCount; $i < $iNewMessages; $i++) {
1692 'sender_thumb' =>
$oFunctions -> getMemberIcon($aMessages[$i][1],
'left'),
1693 'sender_nickname' =>
getNickName($aMessages[$i][1]),
1694 'message_id' => $aMessages[$i][0],
1696 'sent_key' =>
_t(
'_Sent you a' ),
1697 'letter_key' =>
_t(
'_' . $aMessages[$i][2] ),
1701 $aNotifyMessages[] = array(
1703 -> parseHtmlByName(
'member_menu_notify_window.html', array(
'message' =>
$sMessage))
1710 'count' => $iNewMessages,
1711 'messages' => $aNotifyMessages,
1730 $sExtraMenuPosition = ( isset($_COOKIE[
'menu_position']) )
1731 ? $_COOKIE[
'menu_position']
1732 :
getParam(
'ext_nav_menu_top_position' );
1734 $aNewMessages = array();
1735 $aLanguageKeys = array (
1736 'sent' =>
_t(
'_Sent'),
1737 'compose' =>
_t(
'_Compose new letter'),
1738 'trash' =>
_t(
'_Trash'),
1739 'inbox' =>
_t(
'_Inbox'),
1760 `ID`, `Sender`, `Subject`
1764 `Recipient`={$iMemberId}
1768 NOT FIND_IN_SET('Recipient', `Trash`)
1774 $rResult =
db_res($sQuery);
1775 while(
true == ($aRow = $rResult->fetch()) ) {
1779 $sSubject = ( mb_strlen($aRow[
'Subject']) > 40 )
1780 ? mb_substr($aRow[
'Subject'], 0, 40) .
'...'
1783 $aNewMessages[] = array(
1786 'msg_caption' => $sSubject,
1787 'thumbnail' => $sThumb,
1788 'message_id' => $aRow[
'ID'],
1789 'site_url' =>
$GLOBALS[
'site'][
'url'],
1794 $aExtraSection = array(
1795 'go_inbox' => $aLanguageKeys[
'inbox'],
1796 'inbox_count' => $iInboxCount,
1798 'go_outbox' => $aLanguageKeys[
'sent'],
1799 'outbox_count' => $iSentCount,
1801 'go_trash' => $aLanguageKeys[
'trash'],
1802 'trash_count' => $iTrashCount,
1804 'go_compose' => $aLanguageKeys[
'compose'],
1808 $aTemplateKeys = array (
1810 'ch_if:menu_position_bottom' => array (
1811 'condition' => ( $sExtraMenuPosition ==
'bottom' ),
1812 'content' => $aExtraSection,
1815 'ch_if:menu_position_top' => array (
1816 'condition' => ( $sExtraMenuPosition ==
'top' || $sExtraMenuPosition ==
'static' ),
1817 'content' => $aExtraSection,
1820 'ch_repeat:new_message' => $aNewMessages,
1824 -> parseHtmlByName(
'mail_box_member_menu_messages.html', $aTemplateKeys );
1826 return $sOutputCode;