Cheetah
ChSpyResponseContent.php
Go to the documentation of this file.
1 <?php
2 
8  require_once(CH_DIRECTORY_PATH_CLASSES . 'ChWsbAlerts.php');
9 
11  {
12  var $_oModule;
14 
20  {
21  parent::__construct();
22 
23  $this->_oModule = $oModule;
24  $aInternalHandlers = $this->_oModule->_oDb->getInternalHandlers();
25 
26  // procces all recived handlers;
27  if($aInternalHandlers && is_array($aInternalHandlers))
28  foreach($aInternalHandlers as $iKey => $aItems)
29  $this -> aInternalHandlers[$aItems['alert_unit'] . '_' . $aItems['alert_action']] = $aItems;
30  }
31 
37  function response($oAlert)
38  {
39  $sKey = $oAlert->sUnit . '_' . $oAlert->sAction;
40 
41  $iCommentId = 0;
42  switch($oAlert->sAction) {
43  case 'delete':
44  case 'delete_poll':
45  case 'delete_post':
46  $this->_oModule->_oDb->deleteActivityByObject($oAlert->sUnit, $oAlert->iObject);
47  return;
48 
49  case 'commentPost':
50  if(!isset($oAlert->aExtras['comment_id']) || (int)$oAlert->aExtras['comment_id'] == 0)
51  return;
52 
53  $iCommentId = (int)$oAlert->aExtras['comment_id'];
54  break;
55 
56  case 'commentRemoved':
57  if(!isset($oAlert->aExtras['comment_id']) || (int)$oAlert->aExtras['comment_id'] == 0)
58  return;
59 
60  $this->_oModule->_oDb->deleteActivityByObject($oAlert->sUnit, $oAlert->iObject, (int)$oAlert->aExtras['comment_id']);
61  return;
62  }
63 
64  // call defined method;
65  if(!is_array($this -> aInternalHandlers) || !array_key_exists($sKey, $this -> aInternalHandlers))
66  return;
67 
68  if(!ChWsbRequest::serviceExists($this -> aInternalHandlers[$sKey]['module_uri'], $this -> aInternalHandlers[$sKey]['module_method']))
69  return;
70 
71  // define functions parameters;
72  $aParams = array(
73  'action' => $oAlert->sAction,
74  'object_id' => $oAlert->iObject,
75  'sender_id' => $oAlert->iSender,
76  'extra_params' => $oAlert->aExtras,
77  );
78 
79  $aResult = ChWsbService::call($this->aInternalHandlers[$sKey]['module_uri'], $this->aInternalHandlers[$sKey]['module_method'], $aParams);
80  if(empty($aResult))
81  return;
82 
83  // create new event;
84  // define recipent id;
85  $iRecipientId = isset($aResult['recipient_id']) ? $aResult['recipient_id'] : $oAlert -> iObject;
86  if(isset($aResult['spy_type']) && $aResult['spy_type'] == 'content_activity' && $iRecipientId == $oAlert->iSender)
87  $iRecipientId = 0;
88 
89  $iEventId = 0;
90  if($oAlert->iSender || (!$oAlert->iSender && $this->_oModule->_oConfig->bTrackGuestsActivites))
91  $iEventId = $this->_oModule->_oDb->createActivity(
92  $oAlert->sUnit,
93  $oAlert->sAction,
94  $oAlert->iObject,
95  $iCommentId,
96  $oAlert->iSender,
97  $iRecipientId,
98  $aResult
99  );
100 
101  if(!$iEventId)
102  return;
103 
104  // try to define all profile's friends;
105  $aFriends = getMyFriendsEx($oAlert->iSender);
106  if(empty($aFriends) || !is_array($aFriends))
107  return;
108 
109  // attach event to friends;
110  foreach($aFriends as $iFriendId => $aItems)
111  $this->_oModule->_oDb->attachFriendEvent($iEventId, $oAlert->iSender, $iFriendId);
112  }
113  }
ChWsbAlertsResponse
Definition: ChWsbAlerts.php:127
ChSpyResponseContent
Definition: ChSpyResponseContent.php:11
$oModule
if(! @isAdmin()) $oModule
Definition: admin.php:25
getMyFriendsEx
getMyFriendsEx($iID, $sWhereParam='', $sSortParam='', $sqlLimit='')
Definition: profiles.inc.php:384
ChWsbRequest\serviceExists
static serviceExists($mixedModule, $sMethod, $sClass="Module")
Definition: ChWsbRequest.php:70
$aResult
$aResult
Definition: index.php:19
$oAlert
$oAlert
Definition: embed.php:15
ChSpyResponseContent\response
response($oAlert)
Definition: ChSpyResponseContent.php:37
php
ChSpyResponseContent\$_oModule
$_oModule
Definition: ChSpyResponseContent.php:12
ChSpyResponseContent\$aInternalHandlers
$aInternalHandlers
Definition: ChSpyResponseContent.php:13
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
ChWsbService\call
static call($mixed, $sMethod, $aParams=array(), $sClass='Module')
Definition: ChWsbService.php:32
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChSpyResponseContent\__construct
__construct($oModule)
Definition: ChSpyResponseContent.php:19