-
Notifications
You must be signed in to change notification settings - Fork 1
/
jomres2jomres_changelog_item_process_review_deleted.php
77 lines (64 loc) · 2.61 KB
/
jomres2jomres_changelog_item_process_review_deleted.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/**
* Jomres CMS Agnostic Plugin
* @author Woollyinwales IT <sales@jomres.net>
* @version Jomres 9
* @package Jomres
* @copyright 2005-2020 Vince Wooll
* Jomres (tm) PHP files are released under both MIT and GPL2 licenses. This means that you can choose the license that best suits your project.
**/
// ################################################################
defined( '_JOMRES_INITCHECK' ) or die( 'Direct Access to this file is not allowed.' );
// ################################################################
/**
*
* @package Jomres\CMF
*
* Handles webhook events on the parent server
*
*
*/
class jomres2jomres_changelog_item_process_review_deleted
{
function __construct($componetArgs)
{
$item = unserialize(base64_decode($componetArgs->item));
if ( isset($item->data->property_uid) ) {
$item_type = "reviews";
$cross_references = channelmanagement_framework_utilities :: get_cross_references_for_property_uid ( 'jomres2jomres' , $componetArgs->property_uid , $item_type );
jr_import('jomres_call_api');
$jomres_call_api = new jomres_call_api('system');
$local_id = 0;
foreach ($cross_references as $rev) {
if ($rev["remote_id"] == $item->data->review_uid) {
$local_id = $rev['local_id'];
}
}
if ($local_id > 0 ) {
$send_response = $jomres_call_api->send_request(
"DELETE",
"cmf/property/review/".$componetArgs->property_uid."/".$local_id ,
[],
array("X-JOMRES-channel-name: " . "jomres2jomres", "X-JOMRES-proxy-id: " . channelmanagement_framework_utilities :: get_manager_id_for_property_uid ( $componetArgs->property_uid ) )
);
if (isset($send_response->data->response) && $send_response->data->response == true ) {
//channelmanagement_framework_utilities::set_cross_references_for_property_uid('jomres2jomres', $componetArgs->property_uid, $item_type, $local_id, 0 );
logging::log_message("Deleted review ", 'JOMRES2JOMRES', 'DEBUG', '');
logging::log_message("Component args ", 'JOMRES2JOMRES', 'DEBUG', serialize($componetArgs));
logging::log_message("Response ", 'JOMRES2JOMRES', 'DEBUG', serialize($send_response));
$this->success = true;
} else {
logging::log_message("Failed to delete review ", 'JOMRES2JOMRES', 'ERROR', '');
logging::log_message("Component args ", 'JOMRES2JOMRES', 'ERROR', serialize($componetArgs));
logging::log_message("Response ", 'JOMRES2JOMRES', 'ERROR', serialize($send_response));
$this->success = false;
}
}
} else {
logging::log_message("Property id not set", 'JOMRES2JOMRES', 'INFO' , '' );
}
if (!isset($this->success)) {
$this->success = false;
}
}
}