From: Steve Sutton Date: Wed, 24 Aug 2016 13:12:14 +0000 (-0400) Subject: First Commit X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=ce30a070bfaf66458ce2a54f0b85227b79d7103d;p=WP-Plugins%2Fhomeaway-proplist.git First Commit This is a basic copy from the petoskey area plugin created for fetching the hubspot blog entry. --- ce30a070bfaf66458ce2a54f0b85227b79d7103d diff --git a/controllers/Admin.php b/controllers/Admin.php new file mode 100644 index 0000000..ce45fc8 --- /dev/null +++ b/controllers/Admin.php @@ -0,0 +1,194 @@ + + * @copyright 2013 Gaslight Media + * @license Gaslight Media + * @version SVN: (0.1) + * @link <> + */ + +/** + * Toolkit_Package_Admin + * + * Description of Admin + * + * @category Toolkit + * @package Package + * @author Steve Sutton + * @copyright 2013 Gaslight Media + * @license Gaslight Media + * @release Release: (0.1) + * @link <> + */ +class GlmHomeAway_Admin_Controller +{ + public $path; + + public function __construct($path) + { + $this->path = $path; + add_action('admin_menu', array($this, 'glm_homeaway_add_admin_menu')); + add_action('admin_init', array($this, 'glm_homeaway_settings_init')); + } + + static public function activate_plugin() + { + GlmHomeAway_Admin_Controller::add_capability(); + } + + static public function deactivate_plugin() + { + GlmHomeAway_Admin_Controller::remove_capability(); + } + + static public function add_capability() + { + $roles = get_editable_roles(); + foreach ($GLOBALS['wp_roles']->role_objects as $key => $role) { + if (isset($roles[$key]) && $role->has_cap(GLM_HOMEAWAY_BUILT_IN_CAPABILITY)) { + $role->add_cap(GLM_HOMEAWAY_NEW_CAPABILITY); + } + } + } + + static public function remove_capability() + { + $roles = get_editable_roles(); + foreach ($GLOBALS['wp_roles']->role_objects as $key => $role) { + if (isset($roles[$key]) && $role->has_cap(GLM_HOMEAWAY_NEW_CAPABILITY)) { + $role->remove_cap(GLM_HOMEAWAY_NEW_CAPABILITY); + } + } + } + + static public function glm_homeaway_uninstall() + { + delete_option(GLM_HOMEAWAY_SETTINGS); + } + + public function glm_homeaway_add_admin_menu() + { + add_options_page( + 'HomeAway', + 'HomeAway', + GLM_HOMEAWAY_NEW_CAPABILITY, + 'glm_homeaway', + array($this, 'glm_homeaway_options_page'), + 'dashicons-admin-network' + ); + } + + public function glm_homeaway_settings_exist() + { + if (false == get_option(GLM_HOMEAWAY_SETTINGS)) { + add_option(GLM_HOMEAWAY_SETTINGS); + } + } + + public function glm_homeawayAddSettingTextField($name, $label, $type) + { + switch ($type) { + case 'text': + $callback = 'glm_homeawayRenderText'; + break; + case 'textarea': + $callback = 'glm_homeawayRenderTextArea'; + break; + default: + return false; + break; + } + add_settings_field( + $name, + __($label, 'wordpress'), + array($this, $callback), + GLM_HOMEAWAY_OPTION_GROUP, + 'glm_homeaway_' . GLM_HOMEAWAY_OPTION_GROUP . '_section', + $name + ); + } + + public function glm_homeaway_settings_init() + { + register_setting(GLM_HOMEAWAY_OPTION_GROUP, GLM_HOMEAWAY_SETTINGS); + add_filter( + 'option_page_capability_' . GLM_HOMEAWAY_OPTION_GROUP, + array($this, 'glm_homeaway_option_page_capability') + ); + add_settings_section( + 'glm_homeaway_' . GLM_HOMEAWAY_OPTION_GROUP . '_section', + __('Edit Setting', 'wordpress'), + array($this, 'glm_homeaway_settings_section_callback'), + GLM_HOMEAWAY_OPTION_GROUP + ); + + $fieldNames = array( + array( + 'name' => 'user_id', + 'label' => 'User Id', + 'type' => 'text' + ), + array( + 'name' => 'password', + 'label' => 'Password', + 'type' => 'text' + ), + array( + 'name' => 'coid', + 'label' => 'COID', + 'type' => 'text' + ), + ); + + foreach ($fieldNames as $field) { + $this->glm_homeawayAddSettingTextField( + $field['name'], + $field['label'], + $field['type'] + ); + } + } + + public function glm_homeawayRenderText($fieldName) + { + static $options; + if (!$options) { + $options = get_option(GLM_HOMEAWAY_SETTINGS); + } + include $this->path . 'views/text.php'; + } + + public function glm_homeawayRenderTextArea($fieldName) + { + static $options; + $options = get_option(GLM_HOMEAWAY_SETTINGS); + include $this->path . 'views/textArea.php'; + } + + public function glm_homeaway_settings_section_callback() + { + echo __('HomeAway Creds', 'wordpress'); + } + + public function glm_homeaway_option_page_capability($capability) + { + return GLM_HOMEAWAY_NEW_CAPABILITY; + } + + public function glm_homeaway_options_page() + { + if (current_user_can(GLM_HOMEAWAY_NEW_CAPABILITY)) { + include $this->path . 'views/optionsPage.php'; + } else { + include $this->path . 'views/deniedAccess.php'; + } + } + +} diff --git a/controllers/Front.php b/controllers/Front.php new file mode 100644 index 0000000..a8f4293 --- /dev/null +++ b/controllers/Front.php @@ -0,0 +1,51 @@ + + * @copyright 2013 Gaslight Media + * @license Gaslight Media + * @version SVN: (0.1) + * @link <> + */ + +/** + * Toolkit_Package_Front + * + * Description of Front + * + * @category Toolkit + * @package Package + * @author Steve Sutton + * @copyright 2013 Gaslight Media + * @license Gaslight Media + * @release Release: (0.1) + * @link <> + */ +class GlmHomeAway_Front_controller +{ + + /** + * Plugin Path + * + * @var type String + */ + public $path; + + /** + * Initializes Front Controller class + * + * @param type $path Plugin path + */ + function __construct($path) + { + $this->path = $path; + } + + +} diff --git a/index.php b/index.php new file mode 100644 index 0000000..7ca8f6a --- /dev/null +++ b/index.php @@ -0,0 +1,42 @@ + + * @copyright 2013 Gaslight Media + * @license Gaslight Media + * @version SVN: (0.1) + * @link <> + */ + +/** + * Toolkit_Package_database + * + * Description of database + * + * @category Toolkit + * @package Package + * @author Steve Sutton + * @copyright 2013 Gaslight Media + * @license Gaslight Media + * @release Release: (0.1) + * @link <> + */ +class glm_homeaway_models_database +{ + public $wpdb; + public $homeaway_table; + + /** + * Class constructor for the database + * + * @param type $wpdb Wordpress db object + */ + public function __construct($wpdb) + { + $this->wpdb = $wpdb; + register_activation_hook( + GLM_HUBSPOT_PLUGIN_PATH_FILE, + array($this, 'install') + ); + add_action('plugins_loaded', array($this, 'glm_update_db_check')); + + $this->homeaway_table = $this->wpdb->prefix . GLM_HUBSPOT_TABLE; + } + + /** + * Install the database tables needed for jobs + */ + public function install() + { + $charset_collate = $this->wpdb->get_charset_collate(); + + $sql = "CREATE TABLE {$this->homeaway_table} ( + id BIGINT(20) NOT NULL AUTO_INCREMENT, + created DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL, + updated DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL, + prop_id TEXT NOT NULL, + prop_name TEXT NOT NULL, + UNIQUE KEY id (id) + ) {$charset_collate}"; + include ABSPATH . 'wp-admin/includes/upgrade.php'; + dbDelta($sql); + + update_option(GLM_HUBSPOT_DB_VERSION_OPTION_NAME, GLM_HUBSPOT_DB_VERSION); + } + + /** + * DB Version update check to update the database tables + */ + public function glm_update_db_check() + { + if (GLM_HUBSPOT_DB_VERSION != get_option(GLM_HUBSPOT_DB_VERSION_OPTION_NAME)) { + $this->install(); + } + } + +} diff --git a/other/fetchProps.php b/other/fetchProps.php new file mode 100644 index 0000000..9c0dff5 --- /dev/null +++ b/other/fetchProps.php @@ -0,0 +1,21 @@ + 'P1429', + 'strPassword' => 'IqM3Dh9E', + 'strCOID' => '1134' +); +$result = $client->__soapCall( + 'getPropertyIndexes', array('parameters' => $params) +); +$indexArray = $result->getPropertyIndexesResult->clsPropIndex; +//echo '
$indexArray: ' . print_r( $indexArray, true ) . '
'; +$propListings = array(); +if (is_array($indexArray) && !empty($indexArray)) { + foreach ($indexArray as $propertyObject) { + $propListings["{$propertyObject->strId}"] = "{$propertyObject->strId} {$propertyObject->strName}"; + } +} +echo '
$propListings: ' . print_r( $propListings, true ) . '
'; diff --git a/views/deniedAccess.php b/views/deniedAccess.php new file mode 100644 index 0000000..597bac8 --- /dev/null +++ b/views/deniedAccess.php @@ -0,0 +1 @@ +

You do not have permission!

diff --git a/views/frontPage.php b/views/frontPage.php new file mode 100644 index 0000000..50d697d --- /dev/null +++ b/views/frontPage.php @@ -0,0 +1,36 @@ +' + + . '' + . '' + . '' + . '' + . '
'. $content . '
' + . ' Read More ' + . ''; + ?> + + diff --git a/views/optionsPage.php b/views/optionsPage.php new file mode 100644 index 0000000..afd28d8 --- /dev/null +++ b/views/optionsPage.php @@ -0,0 +1,14 @@ +
+
+

HomeAway Creds

+
+ +
+ +
+
+
+
diff --git a/views/text.php b/views/text.php new file mode 100644 index 0000000..fbd1552 --- /dev/null +++ b/views/text.php @@ -0,0 +1,2 @@ +"> diff --git a/views/textArea.php b/views/textArea.php new file mode 100644 index 0000000..5107f04 --- /dev/null +++ b/views/textArea.php @@ -0,0 +1 @@ +