-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathj06002channelmanagement_rentalsunited_import_all_properties.class.php
75 lines (57 loc) · 3.52 KB
/
j06002channelmanagement_rentalsunited_import_all_properties.class.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
<?php
/**
* Jomres CMS Agnostic Plugin
* @author Woollyinwales IT <sales@jomres.net>
* @version Jomres 9
* @package Jomres
* @copyright 2019 Woollyinwales IT
* 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( '' );
// ################################################################
class j06002channelmanagement_rentalsunited_import_all_properties {
function __construct($componentArgs)
{
// Must be in all minicomponents. Minicomponents with templates that can contain editable text should run $this->template_touch() else just return
$MiniComponents =jomres_getSingleton('mcHandler');
if ($MiniComponents->template_touch)
{
$this->template_touchable=false; return;
}
$ePointFilepath = get_showtime('ePointFilepath');
$current_channel = channelmanagement_framework_utilities :: get_current_channel ( $this , array ( "j06002channelmanagement_" , "_import_all_properties" ) );
$siteConfig = jomres_singleton_abstract::getInstance('jomres_config_site_singleton');
$jrConfig = $siteConfig->get();
$JRUser = jomres_singleton_abstract::getInstance( 'jr_user' );
//First we need to check that Site has set the RU username and password
if ( trim($jrConfig['channel_manager_framework_user_accounts']['rentalsunited']["channel_management_rentals_united_username"]) == '' ) {
throw new Exception( jr_gettext('CHANNELMANAGEMENT_RENTALSUNITED_USERNAME_NOT_SET','CHANNELMANAGEMENT_RENTALSUNITED_USERNAME_NOT_SET',false) );
}
if ( trim($jrConfig['channel_manager_framework_user_accounts']['rentalsunited']["channel_management_rentals_united_password"]) == '' ) {
throw new Exception( jr_gettext('CHANNELMANAGEMENT_RENTALSUNITED_PASSWORD_NOT_SET','CHANNELMANAGEMENT_RENTALSUNITED_PASSWORD_NOT_SET',false) );
}
$local_properties = channelmanagement_framework_properties::get_local_property_ids_for_channel( (int)$JRUser->userid , $current_channel );
$mapped_dictionary_items = channelmanagement_framework_utilities :: get_mapped_dictionary_items ( $current_channel , $mapped_to_jomres_only = true );
jr_import('channelmanagement_rentalsunited_communication');
$this->channelmanagement_rentalsunited_communication = new channelmanagement_rentalsunited_communication();
$this->channelmanagement_rentalsunited_communication->set_username($jrConfig['channel_manager_framework_user_accounts']['rentalsunited']["channel_management_rentals_united_username"]);
$this->channelmanagement_rentalsunited_communication->set_password($jrConfig['channel_manager_framework_user_accounts']['rentalsunited']["channel_management_rentals_united_password"]);
$property_data = $this->channelmanagement_rentalsunited_communication->communicate( array() , 'Pull_ListProp_RQ' );
if ($property_data['Status']["value"] == "Success" ) {
foreach ($property_data["Properties"]["Property"] as $property) {
try {
channelmanagement_rentalsunited_import_property::import_property( $current_channel , $property['ID']["value"] , $mapped_dictionary_items , $JRUser->userid );
} catch (Exception $e) {
logging::log_message(" Failed to import property : ".$e->getMessage(), 'RENTALS_UNITED' , 'ERROR');
}
}
}
jomresRedirect( jomresURL( JOMRES_SITEPAGE_URL . "&task=channelmanagement_framework" ) );
}
// This must be included in every Event/Mini-component
function getRetVals()
{
return null;
}
}