8 require_once( CH_DIRECTORY_PATH_CLASSES .
'ChWsbCommunicator.php');
34 $this -> aUsedTemplates = array (
35 'communicator_page' =>
'communicator_page.html',
36 'communicator_page_fr' =>
'communicator_page_fr.html',
37 'communicator_settings' =>
'communicator_settings.html',
38 'communicator_settings_page' =>
'communicator_page_top_settings.html',
44 return array(
'communicator_page.css');
49 return array(
'communicator_page.js');
60 if(!$this -> aCommunicatorSettings[
'communicator_mode'])
61 $this -> aCommunicatorSettings[
'communicator_mode'] =
'friends_list';
64 $aTopToggleItems = array (
65 'friends_list' =>
_t(
'_sys_cnts_txt_frients'),
66 'hotlist_requests' =>
_t(
'_sys_cnts_txt_favorites'),
67 'blocks_requests' =>
_t(
'_sys_cnts_txt_blocked')
70 $sRequest = CH_WSB_URL_ROOT .
'communicator.php?';
71 foreach( $aTopToggleItems AS $sKey => $sValue ) {
72 $aTopToggleEllements[$sValue] = array (
73 'href' => $sRequest .
'&communicator_mode=' . $sKey . ($sKey !=
'friends_list' ?
'&person_switcher=from' :
''),
75 'active' => ($this -> aCommunicatorSettings[
'communicator_mode'] == $sKey ),
83 return array(
$sOutputHtml, $aTopToggleEllements, array(),
true);
94 $this -> aCommunicatorSettings[
'communicator_mode'] =
'friends_requests';
95 $this -> aCommunicatorSettings[
'person_switcher'] =
'to';
100 $this -> aCommunicatorSettings[
'communicator_mode'] =
'';
120 $bShowSettings =
false;
123 $sEmptyMessage =
'_Empty';
124 $sRowsTemplName = $this -> aUsedTemplates[
'communicator_page'];
128 $sMemberNickName =
getNickName($this -> aCommunicatorSettings[
'member_id']);
131 $aLanguageKeys = array (
132 'author' =>
_t(
'_Author' ),
133 'type' =>
_t(
'_Type' ),
134 'date' =>
_t(
'_Date' ),
135 'click_sort' =>
_t(
'_Click to sort' ),
136 'from_me' =>
_t(
'_From' ) .
' ' . $sMemberNickName,
137 'to_me' =>
_t(
'_To' ) .
' ' . $sMemberNickName,
138 'accept' =>
_t(
'_sys_cnts_btn_fr_accept' ),
139 'reject' =>
_t(
'_sys_cnts_btn_fr_reject' ),
140 'delete' =>
_t(
'_Delete' ),
141 'back_invite' =>
_t(
'_Back Invite' ),
142 'fave' =>
_t(
'_sys_cnts_btn_fave' ),
143 'visitor' =>
_t(
'_Visitor' ),
144 'unblock' =>
_t(
'_Unblock' ),
145 'block' =>
_t(
'_Block' ),
146 'select' =>
_t(
'_Select' ),
147 'all' =>
_t(
'_All' ),
148 'none' =>
_t(
'_None' ),
149 'read' =>
_t(
'_Read' ),
150 'unread' =>
_t(
'_Unread' ),
154 switch($this -> aCommunicatorSettings[
'communicator_mode']) {
155 case 'friends_requests' :
156 $sEmptyMessage =
'_sys_cnts_msg_fr_empty';
157 $sRowsTemplName = $this -> aUsedTemplates[
'communicator_page_fr'];
160 'from' =>
_t(
'_MEMBERS_INVITE_YOU_FRIENDLIST' ),
161 'to' =>
_t(
'_MEMBERS_YOU_INVITED_FRIENDLIST' )
163 $aRows = $this ->
getRequests(
'sys_friend_list', $aTypes,
' AND `sys_friend_list`.`Check` = 0 ');
166 case 'hotlist_requests' :
169 'from' =>
_t(
'_MEMBERS_YOU_HOTLISTED' ),
170 'to' =>
_t(
'_MEMBERS_YOU_HOTLISTED_BY' )
172 $aRows = $this ->
getRequests(
'sys_fave_list', $aTypes);
175 case 'greeting_requests' :
178 'from' =>
_t(
'_MEMBERS_YOU_KISSED' ),
179 'to' =>
_t(
'_MEMBERS_YOU_KISSED_BY' ),
180 'specific_key' =>
'_N times',
182 $aRows = $this ->
getRequests(
'sys_greetings', $aTypes,
null,
'Number' );
185 case 'blocks_requests' :
188 'from' =>
_t(
'_MEMBERS_YOU_BLOCKLISTED' ),
189 'to' =>
_t(
'_MEMBERS_YOU_BLOCKLISTED_BY' ),
191 $aRows = $this ->
getRequests(
'sys_block_list', $aTypes );
194 case 'friends_list' :
197 'from' =>
_t(
'_Friend list' ),
198 'to' =>
_t(
'_Friend list' ),
200 $aRows = $this ->
getRequests(
'sys_friend_list', $aTypes,
201 ' AND `sys_friend_list`.`Check` = 1 OR ( `sys_friend_list`.`ID` = ' . $this -> aCommunicatorSettings[
'member_id']
202 .
' AND `sys_friend_list`.`Check` = 1 )' );
208 'from' =>
_t(
'_MEMBERS_INVITE_YOU_FRIENDLIST' ),
209 'to' =>
_t(
'_MEMBERS_YOU_INVITED_FRIENDLIST' )
211 $aRows = $this ->
getRequests(
'sys_friend_list', $aTypes,
' AND `sys_friend_list`.`Check` = 0 ' );
214 if(
empty($aRows) && !$bShowEmpty)
220 $aNeededParameters = array(
'communicator_mode',
'person_switcher',
'sorting' );
223 $sRequest = CH_WSB_URL_ROOT .
'communicator.php?action=get_page' ;
226 foreach( $aNeededParameters AS $sKey ) {
227 $sRequest .= ( array_key_exists($sKey, $this -> aCommunicatorSettings)
and $this -> aCommunicatorSettings[$sKey] )
228 ?
'&' . $sKey .
'=' . $this -> aCommunicatorSettings[$sKey]
232 $sCuttedUrl = $sRequest;
233 $sRequest .=
'&page={page}&per_page={per_page}';
238 'page_url' => $sRequest,
239 'count' => $this -> iTotalRequestsCount,
240 'per_page' => $this -> aCommunicatorSettings[
'per_page'],
241 'sorting' => $this -> aCommunicatorSettings[
'sorting'],
242 'page' => $this -> aCommunicatorSettings[
'page'],
244 'on_change_page' =>
"if ( typeof " . $sJsObject .
" != 'undefined' ) " . $sJsObject .
".getPaginatePage('{$sRequest}')",
245 'on_change_per_page' =>
"if ( typeof " . $sJsObject .
" != 'undefined' ) " . $sJsObject .
".getPage(this.value, '{$sCuttedUrl}')",
249 $sPagination = $oPaginate -> getPaginate();
254 foreach($aRows AS $iKey => $aItems ) {
256 if ( $aItems[
'member_id'] ) {
270 $sMemberAge = (
$aProfileInfo[
'DateOfBirth'] !=
"0000-00-00" )
276 $sMemberFlag =
$site[
'flags'] . strtolower($sMemberCountry) . $this -> sMembersFlagExtension;
279 if ( $sMemberCountry )
280 $sMemberCountryFlag =
'<img src="' . $sMemberFlag .
'" alt="' . $sMemberCountry .
'" />';
287 $sMemberIcon = $aLanguageKeys[
'visitor'];
290 $sMemberLocation =
null;
291 $sMemberSexImg =
null;
293 $sMemberCountryFlag =
null;
294 $sMemberCountry =
null;
297 $aProcessedRows[] = array (
298 'js_object' => $sJsObject,
300 'row_value' => $aItems[
'member_id'],
301 'member_icon' => $sMemberIcon,
302 'member_nick_name' => $sMemberNickName,
305 'member_location' => $sMemberLocation ?
'<a href="' . $sMemberLocation .
'">' . $sMemberNickName .
'</a>' :
'',
308 'member_sex_img' => $sMemberSexImg ?
' <img src="' . $sMemberSexImg .
'" alt="' .
$aProfileInfo[
'Sex'] .
'" />' :
'',
310 'member_age' => $sMemberAge,
311 'member_flag' => $sMemberCountryFlag,
312 'member_country' => $sMemberCountry,
314 'member_mutual_friends' =>
_t(
'_sys_cnts_txt_mutual_friends', ($iMemberMutualFriends > 0 ? $iMemberMutualFriends :
_t(
'_sys_cnts_txt_mf_no'))),
316 'type' => $aItems[
'type'],
317 'message_date' => $aItems[
'date'],
324 switch ( $this -> aCommunicatorSettings[
'sorting'] ) {
326 $aSortToglleElements[
'date_sort_toggle'] =
'toggle_up';
329 $aSortToglleElements[
'date_sort_toggle'] =
'toggle_down';
332 $aSortToglleElements[
'author_sort_toggle'] =
'toggle_up';
335 $aSortToglleElements[
'author_sort_toggle'] =
'toggle_down';
340 switch( $this -> aCommunicatorSettings[
'communicator_mode'] ) {
341 case 'friends_requests':
343 switch ($this -> aCommunicatorSettings[
'person_switcher']) {
346 'form_attrs' => array (
352 'remove_form' =>
true,
354 'submit_name' =>
'do_submit',
360 'type' =>
'input_set',
364 'value' => $aLanguageKeys[
'accept'],
365 'attrs' => array(
'onclick' =>
"if ( typeof " . $sJsObject .
" != 'undefined' ) " . $sJsObject .
".sendAction(this, 'communicator_container', 'accept_friends_request', 'getProcessingRows')"),
369 'value' => $aLanguageKeys[
'reject'],
370 'attrs' => array(
'onclick' =>
"if ( typeof " . $sJsObject .
" != 'undefined' ) " . $sJsObject .
".sendAction(this, 'communicator_container', 'reject_friends_request', 'getProcessingRows')"),
382 'form_attrs' => array (
388 'remove_form' =>
true,
390 'submit_name' =>
'do_submit',
396 'type' =>
'input_set',
400 'value' => $aLanguageKeys[
'back_invite'],
401 'attrs' => array(
'onclick' =>
"if ( typeof " . $sJsObject .
" != 'undefined' ) " . $sJsObject .
".sendAction(this, 'communicator_container', 'delete_friends_request', 'getProcessingRows')"),
413 case 'hotlist_requests' :
415 switch ($this -> aCommunicatorSettings[
'person_switcher']) {
418 'form_attrs' => array (
424 'remove_form' =>
true,
426 'submit_name' =>
'do_submit',
432 'type' =>
'input_set',
436 'value' => $aLanguageKeys[
'fave'],
437 'attrs' => array(
'onclick' =>
"if ( typeof " . $sJsObject .
" != 'undefined' ) " . $sJsObject .
".sendAction(this, 'communicator_container', 'add_hotlist', 'getProcessingRows')"),
449 'form_attrs' => array (
455 'remove_form' =>
true,
457 'submit_name' =>
'do_submit',
463 'type' =>
'input_set',
467 'value' => $aLanguageKeys[
'delete'],
468 'attrs' => array(
'onclick' =>
"if ( typeof " . $sJsObject .
" != 'undefined' ) " . $sJsObject .
".sendAction(this, 'communicator_container', 'delete_hotlisted', 'getProcessingRows')"),
480 case 'greeting_requests' :
482 'form_attrs' => array (
488 'remove_form' =>
true,
490 'submit_name' =>
'do_submit',
496 'type' =>
'input_set',
500 'value' => $aLanguageKeys[
'delete'],
501 'attrs' => array(
'onclick' =>
"if ( typeof " . $sJsObject .
" != 'undefined' ) " . $sJsObject .
".sendAction(this, 'communicator_container', 'delete_greetings', 'getProcessingRows')"),
511 case 'blocks_requests' :
513 switch ($this -> aCommunicatorSettings[
'person_switcher']) {
516 'form_attrs' => array (
522 'remove_form' =>
true,
524 'submit_name' =>
'do_submit',
530 'type' =>
'input_set',
534 'value' => $aLanguageKeys[
'block'],
535 'attrs' => array(
'onclick' =>
"if ( typeof " . $sJsObject .
" != 'undefined' ) " . $sJsObject .
".sendAction(this, 'communicator_container', 'block_unblocked', 'getProcessingRows')"),
547 'form_attrs' => array (
553 'remove_form' =>
true,
555 'submit_name' =>
'do_submit',
561 'type' =>
'input_set',
565 'value' => $aLanguageKeys[
'unblock'],
566 'attrs' => array(
'onclick' =>
"if ( typeof " . $sJsObject .
" != 'undefined' ) " . $sJsObject .
".sendAction(this, 'communicator_container', 'unblock_blocked', 'getProcessingRows')"),
578 case 'friends_list' :
580 'form_attrs' => array (
586 'remove_form' =>
true,
588 'submit_name' =>
'do_submit',
594 'type' =>
'input_set',
598 'value' => $aLanguageKeys[
'delete'],
599 'attrs' => array(
'onclick' =>
"if ( typeof " . $sJsObject .
" != 'undefined' ) " . $sJsObject .
".sendAction(this, 'communicator_container', 'reject_friends_request', 'getProcessingRows')"),
611 $sSortLink =
getClearedParam(
'sorting', $sCuttedUrl) .
'&page=' . $this -> aCommunicatorSettings[
'page']
612 .
'&per_page=' . $this -> aCommunicatorSettings[
'per_page'] ;
615 $aTemplateKeys = array (
616 'js_object' => $sJsObject,
617 'from_me' => $aLanguageKeys[
'from_me'],
618 'to_me' => $aLanguageKeys[
'to_me'],
619 'selected_from' => ($this -> aCommunicatorSettings[
'person_switcher'] ==
'from') ?
'checked="checked"' :
null,
620 'selected_to' => ($this -> aCommunicatorSettings[
'person_switcher'] ==
'to') ?
'checked="checked"' :
null,
622 'page_sort_url' => $sSortLink,
623 'sort_date' => ( $this -> aCommunicatorSettings[
'sorting'] ==
'date' ) ?
'date_desc' :
'date',
624 'sort_author' => ( $this -> aCommunicatorSettings[
'sorting'] ==
'author' ) ?
'author_desc' :
'author',
626 'date_sort_toggle_ellement' => $aSortToglleElements[
'date_sort_toggle'],
627 'author_sort_toggle_ellement' => $aSortToglleElements[
'author_sort_toggle'],
629 'author' => $aLanguageKeys[
'author'],
630 'type' => $aLanguageKeys[
'type'],
631 'date' => $aLanguageKeys[
'date'],
632 'click_sort' => $aLanguageKeys[
'click_sort'],
635 'ch_repeat:rows' => $aProcessedRows,
638 'actions_list' => $sActionsList,
640 'current_page' =>
'communicator.php',
641 'select' => $aLanguageKeys[
'select'],
642 'all_messages' => $aLanguageKeys[
'all'],
643 'none_messages' => $aLanguageKeys[
'none'],
644 'read_messages' => $aLanguageKeys[
'read'],
645 'unread_messages' => $aLanguageKeys[
'unread'],
647 'page_pagination' => $sPagination,
653 'content' =>
MsgBox(
_t($sEmptyMessage))
659 if ($bShowSettings) {
660 $aTemplateKeys = array (
661 'js_object' => $sJsObject,
662 'from_me' => $aLanguageKeys[
'from_me'],
663 'to_me' => $aLanguageKeys[
'to_me'],
664 'selected_from' => ($this -> aCommunicatorSettings[
'person_switcher'] ==
'from') ?
'checked="checked"' :
null,
665 'selected_to' => ($this -> aCommunicatorSettings[
'person_switcher'] ==
'to') ?
'checked="checked"' :
null,
668 $sSettings =
$oSysTemplate -> parseHtmlByName( $this -> aUsedTemplates[
'communicator_settings'], $aTemplateKeys );
672 $aTemplateKeys = array (
673 'js_object' => $sJsObject,
674 'current_page' =>
'communicator.php',
675 'communicator_mode' => $this -> aCommunicatorSettings[
'communicator_mode'],
676 'communicator_person_mode' => $this -> aCommunicatorSettings[
'person_switcher'],
677 'error_message' =>
ch_js_string(
_t(
'_Please, select at least one message' )),
680 'settings' => $sSettings,
685 return $oSysTemplate -> parseHtmlByName( $this -> aUsedTemplates[
'communicator_settings_page'], $aTemplateKeys );