8 require_once( CH_DIRECTORY_PATH_CLASSES .
'ChWsbPageView.php');
9 require_once( CH_DIRECTORY_PATH_CLASSES .
'ChWsbAlerts.php' );
10 require_once( CH_DIRECTORY_PATH_CLASSES .
'ChWsbEmailTemplates.php' );
44 parent::__construct(
'communicator_page');
48 if ( $this -> aCommunicatorSettings[
'per_page'] < 1 )
49 $this -> aCommunicatorSettings[
'per_page'] = 10 ;
51 if ($this -> aCommunicatorSettings[
'per_page'] > 100 )
52 $this -> aCommunicatorSettings[
'per_page'] = 100;
82 $aSortCriterias = array
85 'date' =>
"`{$sTableName}`.`When` ASC",
88 'author' =>
'`Profiles`.`NickName` ASC',
91 'date_desc' =>
"`{$sTableName}`.`When` DESC",
94 'author_desc' =>
'`Profiles`.`NickName` DESC',
98 $sSortParameter = ( array_key_exists($this -> aCommunicatorSettings[
'sorting'], $aSortCriterias) )
99 ? $aSortCriterias[$this -> aCommunicatorSettings[
'sorting']]
100 : $aSortCriterias[
'date_desc'];
103 switch( $this -> aCommunicatorSettings[
'person_switcher'] ) {
105 $sFieldName =
'`ID`';
108 $sFieldName =
'`Profile`';
111 $sFieldName =
'`ID`';
115 $this -> iTotalRequestsCount =
db_value
122 `{$sTableName}`.{$sFieldName} = {$this -> aCommunicatorSettings['member_id']}
126 if ( $this -> iTotalRequestsCount ) {
128 $sRequestFrom =
$GLOBALS[
'MySQL'] -> escape($aRequestTypes[
'from']);
129 $sRequestTo =
$GLOBALS[
'MySQL'] -> escape($aRequestTypes[
'to']);
132 if( $this -> aCommunicatorSettings[
'page'] < 1 )
133 $this -> aCommunicatorSettings[
'page'] = 1;
135 $sLimitFrom = ( $this -> aCommunicatorSettings[
'page'] - 1 ) * $this -> aCommunicatorSettings[
'per_page'];
136 $sSqlLimit =
"LIMIT {$sLimitFrom}, {$this -> aCommunicatorSettings['per_page']}";
139 $sExtFieldName = ( $sAdditionalField ) ?
", `{$sTableName}`.`{$sAdditionalField}`" :
null ;
144 IF(`{$sTableName}`.`ID` = {$this -> aCommunicatorSettings['member_id']},
145 `{$sTableName}`.`Profile`, `{$sTableName}`.`ID`) AS `iMemberID`,
147 IF(`{$sTableName}`.`ID` = {$this -> aCommunicatorSettings['member_id']}, $sRequestFrom, $sRequestTo)
157 `Profiles`.`ID` = IF(`{$sTableName}`.`ID` = {$this -> aCommunicatorSettings['member_id']},
158 `{$sTableName}`.`Profile`, `{$sTableName}`.`ID`)
160 `{$sTableName}`.{$sFieldName} = {$this -> aCommunicatorSettings['member_id']}
167 $rResult =
db_res($sQuery);
168 while(
true == ($aRow = $rResult->fetch()) ) {
169 $sExtType = ( !
empty($aRequestTypes[
'specific_key'])
and $sAdditionalField )
170 ?
' ' .
_t( $aRequestTypes[
'specific_key'], $aRow[$sAdditionalField] )
175 'member_id' => $aRow[
'iMemberID'],
176 'date' => $aRow[
'sDate'],
177 'type' => $aRow[
'sType'] . $sExtType,
197 $aCallback = array($this, $sCallback);
202 call_user_func_array($aCallback, $aExtendedParameters );
220 $iFromOwner = (int) $iFromOwner;
221 $iExtraDelete = (int) $iExtraDelete;
224 if ( !$iFromOwner ) {
226 $iProfile = $this -> aCommunicatorSettings[
'member_id'];
228 $iID = $this -> aCommunicatorSettings[
'member_id'];
232 if ( $iExtraDelete ) {
241 `Profile` = {$this -> aCommunicatorSettings['member_id']}
245 `ID` = {$this -> aCommunicatorSettings['member_id']}
247 `Profile` = {$iMemberID}
253 $sQuery =
"DELETE FROM `{$sTableName}` WHERE `ID` = {$iID} AND `Profile` = {$iProfile}";
260 case 'sys_friend_list':
264 case 'sys_fave_list':
268 case 'sys_block_list':
296 `ID` = {$this -> aCommunicatorSettings['member_id']}
298 `Profile` = {$iMemberID}
309 `ID` = {$this -> aCommunicatorSettings['member_id']},
310 `Profile` = {$iMemberID}
330 $iAccepted = (int)
db_value(
"SELECT `Check` FROM `{$sTableName}` WHERE `ID`={$iMemberID} AND `Profile`={$this -> aCommunicatorSettings['member_id']} LIMIT 1");
334 db_res(
"UPDATE `{$sTableName}` SET `Check`=1 WHERE `ID`={$iMemberID} AND `Profile`={$this -> aCommunicatorSettings['member_id']}");
343 $aTemplate = $oEmailTemplate->getTemplate(
't_FriendRequestAccepted',
$iMemberID);
346 sendMail($aRecipient[
'Email'], $aTemplate[
'Subject'], $aTemplate[
'Body'],
'', array(
348 'SenderLink' =>
getProfileLink($this -> aCommunicatorSettings[
'member_id']),
349 'Sender' =>
getNickName($this -> aCommunicatorSettings[
'member_id']),
356 return 'oCommunicatorPage' . str_replace(
' ',
'', ucwords(str_replace(
'_',
' ', $this->aCommunicatorSettings[
'communicator_mode'])));