source: trunk/communicator.php

Last change on this file was 2, checked in by george, 14 years ago
  • Přidáno: Trunk revize 13719.
File size: 6.8 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/BxTemplCommunicator.php');
24
25 // ** init some needed variables ;
26
27 $sOutputHtml = null;
28
29 // contain all receivied members ID separeted by comma ;
30 $sMembersList = isset( $_GET['rows'] ) ? $_GET['rows'] : null;
31
32 // array : contain all received member id ;
33 $aMembersList = array();
34
35 // try to segregate received members list;
36 if ( $sMembersList )
37 {
38 $aMembersList = explode(',', $sMembersList);
39 }
40
41 $iProfileId = getLoggedId();
42
43 // contain some needed settings for the Communicator's object ;
44 $aCommunicatorSettings = array
45 (
46 // logged member's ID;
47 'member_id' => $iProfileId,
48
49 // page mode ;
50 'communicator_mode' => ( isset($_GET['communicator_mode']) ) ? $_GET['communicator_mode'] : null,
51
52 // switch the person mode - from me or to me ;
53 'person_switcher' => ( isset($_GET['person_switcher']) ) ? $_GET['person_switcher'] : 'to',
54
55 // type of message's sort ;
56 'sorting' => (isset($_GET['sorting'])) ? $_GET['sorting'] : 'date_desc',
57
58 // contain number of current page ;
59 'page' => (isset($_GET['page'])) ? (int) $_GET['page']: 1,
60
61 // contain per page number for current page ;
62 'per_page' => (isset($_GET['per_page'])) ? (int) $_GET['per_page']: 10,
63
64 // contain number of current alert's page ;
65 'alert_page' => (isset($_GET['alert_page'])) ? (int) $_GET['alert_page']: 1,
66 );
67
68
69 // create BxTemplCommunicator object ;
70 $oCommunicator = new BxTemplCommunicator( 'communicator_page', $aCommunicatorSettings );
71
72 // ajax request processing ;
73 if ( isset($_GET['ajax_mode']) and isset($_GET['action']) )
74 {
75 // contain all the available callback functions ;
76 $aCallbackFunctions = array( 'getProcessingRows' );
77
78 switch($_GET['action'])
79 {
80 // just return the processed requests;
81 case 'get_page' :
82 $sOutputHtml = $oCommunicator -> getProcessingRows();
83 break;
84
85 // function will set 'accept' mode for received members list ;
86 case 'accept_friends_request' :
87 $oCommunicator -> execFunction( '_acceptFriendInvite', 'sys_friend_list', $aMembersList );
88 break;
89
90 // function will set 'reject' mode for received members list ;
91 case 'reject_friends_request' :
92 if ( $aCommunicatorSettings['person_switcher'] == 'from' )
93 {
94 $oCommunicator -> execFunction( '_deleteRequest', 'sys_friend_list', $aMembersList, array(1) );
95 }
96 else
97 {
98 $oCommunicator -> execFunction('_deleteRequest', 'sys_friend_list', $aMembersList);
99 }
100 break;
101
102 // function will delete friends list ;
103 case 'delete_friends_request' :
104 $oCommunicator -> execFunction( '_deleteRequest', 'sys_friend_list', $aMembersList, array(1, 1) );
105 break;
106
107 // function will delete the received members from 'sys_fave_list' ;
108 case 'delete_hotlisted' :
109 $oCommunicator -> execFunction('_deleteRequest', 'sys_fave_list', $aMembersList, array(1));
110 break;
111
112 // function will add the received members to 'sys_fave_list' ;
113 case 'add_hotlist' :
114 $oCommunicator -> execFunction( '_addRequest', 'sys_fave_list', $aMembersList );
115 break;
116
117 // function will delete the received members from 'sys_greetings' ;
118 case 'delete_greetings' :
119 if ( $aCommunicatorSettings['person_switcher'] == 'from' )
120 {
121 $oCommunicator -> execFunction( '_deleteRequest', 'sys_greetings', $aMembersList, array(1) );
122 }
123 else
124 {
125 $oCommunicator -> execFunction('_deleteRequest', 'sys_greetings', $aMembersList);
126 }
127 break;
128
129 // function will unblock the received members from 'sys_block_list' ;
130 case 'unblock_blocked' :
131 $oCommunicator -> execFunction('_deleteRequest', 'sys_block_list', $aMembersList, array(1));
132 break;
133
134 // function will block the received members to 'sys_block_list' ;
135 case 'block_unblocked' :
136 $oCommunicator -> execFunction( '_addRequest', 'sys_block_list', $aMembersList );
137 break;
138 }
139
140 // try to define the callback function name ;
141 if ( isset($_GET['callback_function']) and in_array($_GET['callback_function'], $aCallbackFunctions) )
142 {
143 if ( method_exists($oCommunicator, $_GET['callback_function']) )
144 $sOutputHtml = $oCommunicator -> $_GET['callback_function']();
145 }
146
147 echo $sOutputHtml ;
148 exit;
149 }
150
151 // ** prepare to output page in normal mode ;
152
153 $_page['name_index'] = 7;
154 $_page['header'] = _t( "_Activity" );
155 $_page['header_text'] = _t( "_Activity" );
156
157 $_page['css_name'] = array('communicator_page.css', 'alert.css');
158 $_page['js_name'] = 'communicator_page.js';
159
160 $_ni = $_page['name_index'];
161
162 if ( $aCommunicatorSettings['member_id'] )
163 $sOutputHtml = $oCommunicator -> getCode();
164 else
165 login_form( _t( "_LOGIN_OBSOLETE" ), 0, false );
166
167 $_page_cont[$_ni]['page_main_code'] = $sOutputHtml;
168
169 PageCode();
170
171?>
Note: See TracBrowser for help on using the repository browser.