From: Steve Sutton Date: Mon, 1 May 2017 20:02:01 +0000 (-0400) Subject: Updating api plugin X-Git-Tag: v1.0.1^2~2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=70535206959625bfe4bff75eea90f16d5f738111;p=WP-Plugins%2Fglm-member-db-apis.git Updating api plugin Updates to be used for Harbor Country Golf Club. --- diff --git a/defines.php b/defines.php index 957f29c..27d4f5b 100644 --- a/defines.php +++ b/defines.php @@ -14,6 +14,7 @@ define('GLM_MEMBERS_APIS_PLUGIN_SLUG', 'glm-member-db-apis'); // Defines for different API's define( 'GLM_MEMBERS_APIS_STARLINE_OPTION_NAME', 'glm_member_db_apis_starline_url' ); define( 'GLM_MEMBERS_APIS_BIBCO_OPTION_NAME', 'glm_member_db_apis_bibco_url' ); +define( 'GLM_MEMBERS_APIS_GOLFCLUB_OPTION_NAME', 'glm_member_db_apis_golfclub_url' ); // Database table prefixes - change if using add-on tables global $wpdb; diff --git a/models/admin/management/apis.php b/models/admin/management/apis.php index 6270226..08f7a1d 100644 --- a/models/admin/management/apis.php +++ b/models/admin/management/apis.php @@ -98,6 +98,9 @@ class GlmMembersAdmin_management_apis $option3 = false; $calendarUrl = false; $bibcoOptionName = GLM_MEMBERS_APIS_BIBCO_OPTION_NAME; + $option4 = false; + $directoryUrl = false; + $golfclubOptionName = GLM_MEMBERS_APIS_GOLFCLUB_OPTION_NAME; if (isset($_REQUEST['option'])) { $option = $_REQUEST['option']; @@ -131,7 +134,12 @@ class GlmMembersAdmin_management_apis if ( isset( $_REQUEST['option3'] ) ) { $option3 = $_REQUEST['option3']; } + $option4 = ''; + if ( isset( $_REQUEST['option4'] ) ) { + $option4 = $_REQUEST['option4']; + } + // Option for saving the Starline settings. switch($option2) { // Update the settings and redisplay the form case 'submit': @@ -151,6 +159,8 @@ class GlmMembersAdmin_management_apis break; } + + // Option for saving the Bibco settings. switch($option3) { // Update the settings and redisplay the form case 'submit': @@ -168,6 +178,26 @@ class GlmMembersAdmin_management_apis break; } + + // Option for saving the golfclub settings. + switch($option4) { + // Update the settings and redisplay the form + case 'submit': + $settings_updated = true; + update_option( $golfclubOptionName, serialize( $_REQUEST[$golfclubOptionName] ) ); + $golfclubOptions = unserialize( get_option( $golfclubOptionName ) ); + $directoryUrl = ( isset( $golfclubOptions['directoryUrl'] ) ) ? $golfclubOptions['directoryUrl'] : ''; + + break; + + // Default is to get the current settings and display the form + default: + $golfclubOptions = unserialize( get_option( $golfclubOptionName ) ); + $directoryUrl = ( isset( $golfclubOptions['directoryUrl'] ) ) ? $golfclubOptions['directoryUrl'] : ''; + + break; + } + break; } @@ -179,6 +209,8 @@ class GlmMembersAdmin_management_apis 'starlineOptionName' => $starlineOptionName, 'calendarUrl' => $calendarUrl, 'bibcoOptionName' => $bibcoOptionName, + 'golfclubOptionName' => $golfclubOptionName, + 'directoryUrl' => $directoryUrl, 'settingsUpdated' => $settings_updated, 'settingsUpdateError' => $settings_update_error, 'apisSettings' => $api_settings, diff --git a/models/front/apis/bibcoCalendar.php b/models/front/apis/bibcoCalendar.php index 8df33a8..6ba2c4b 100644 --- a/models/front/apis/bibcoCalendar.php +++ b/models/front/apis/bibcoCalendar.php @@ -1,13 +1,13 @@ wpdb = $wpdb; $this->config = $config; - //parent::__construct(false, false); - - if ( $this->config['settings']['use_venue_locations'] ) { - $this->getMemberList(); - } - - } /** * modelAction * @@ -49,8 +42,6 @@ class GlmMembersFront_apis_bibcoCalendar */ public function modelAction($actionData = false) { - //echo '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; - //echo '
$actionData: ' . print_r( $actionData, true ) . '
'; $view = 'bibcoCalendar'; $settings = array(); $content = ''; diff --git a/models/front/apis/bibcoSearch.php b/models/front/apis/bibcoSearch.php new file mode 100644 index 0000000..c87c57b --- /dev/null +++ b/models/front/apis/bibcoSearch.php @@ -0,0 +1,84 @@ + + * @license PHP Version 3.0 {@link http://www.php.net/license/3_0.txt} + */ +class GlmMembersFront_apis_bibcoSearch +{ + /** + * __construct + * + * @param mixed $wpdb The main Word Press DB Object + * @param mixed $config The main Config + * + * @access public + * @return void + */ + public function __construct($wpdb, $config) + { + $this->wpdb = $wpdb; + $this->config = $config; + + //parent::__construct(false, false); + + if ( $this->config['settings']['use_venue_locations'] ) { + $this->getMemberList(); + } + + } + /** + * modelAction + * + * @param bool $actionData Action Data passed to the modelAction + * + * @access public + * @return void + */ + public function modelAction($actionData = false) + { + $view = 'bibcoSearch'; + $settings = array(); + $content = ''; + $mainSchedId = false; + + // Get the options for bibco + $bibcoOptions = unserialize( get_option( GLM_MEMBERS_APIS_BIBCO_OPTION_NAME ) ); + $calendarUrl = ( isset( $bibcoOptions['calendarUrl'] ) ) ? $bibcoOptions['calendarUrl'] : ''; + + // Setup the url. + $url = $calendarUrl . 'scheduleSearch.php'; + $curl = curl_init( $url ); + curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true ); + curl_setopt( $curl, CURLOPT_USERPWD, 'dev55:Glm15Keep!' ); + curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, false ); + $content = curl_exec( $curl ); + curl_close( $curl ); + + $templateData = array( + 'content' => $content, + ); + + error_reporting(E_ALL ^ E_NOTICE); + return array( + 'status' => $status, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'front/apis/' . $view . '.html', + 'data' => $templateData, + 'settings' => $settings + ); + } +} diff --git a/models/front/apis/golfclubDirectory.php b/models/front/apis/golfclubDirectory.php new file mode 100644 index 0000000..c2b6fbf --- /dev/null +++ b/models/front/apis/golfclubDirectory.php @@ -0,0 +1,104 @@ + + * @license PHP Version 3.0 {@link http://www.php.net/license/3_0.txt} + */ +class GlmMembersFront_apis_golfclubDirectory +{ + /** + * __construct + * + * @param mixed $wpdb The main Word Press DB Object + * @param mixed $config The main Config + * + * @access public + * @return void + */ + public function __construct($wpdb, $config) + { + $this->wpdb = $wpdb; + $this->config = $config; + + } + /** + * modelAction + * + * @param bool $actionData Action Data passed to the modelAction + * + * @access public + * @return void + */ + public function modelAction($actionData = false) + { + global $wp; + $view = 'golfclubDirectory'; + $settings = array(); + $content = ''; + $mainSchedId = false; + + // Get the options for golfclub + $golfclubOptions = unserialize( get_option( GLM_MEMBERS_APIS_GOLFCLUB_OPTION_NAME ) ); + $directoryUrl = ( isset( $golfclubOptions['directoryUrl'] ) ) ? $golfclubOptions['directoryUrl'] : ''; + + // Setup the url. + $url = $directoryUrl . 'Directory.php'; + $urlParams = array(); + if ( isset( $_REQUEST['fname'] ) ) { + $urlParams[] = 'fname=' . $_REQUEST['fname']; + } + if ( isset( $_REQUEST['lname'] ) ) { + $urlParams[] = 'lname=' . $_REQUEST['lname']; + } + if ( isset( $_REQUEST['cottage'] ) ) { + $urlParams[] = 'cottage=' . $_REQUEST['cottage']; + } + if ( isset( $_REQUEST['alpha'] ) ) { + $urlParams[] = 'alpha=' . $_REQUEST['alpha']; + } + if ( !empty( $urlParams ) ) { + $url .= '?' . implode( '&', $urlParams ); + } + $curl = curl_init( $url ); + curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true ); + curl_setopt( $curl, CURLOPT_USERPWD, 'dev55:Glm15Keep!' ); + curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, false ); + $content = curl_exec( $curl ); + curl_close( $curl ); + + + // Go through the content and replace the url links for the Directory page. + $parsedUrl = parse_url( $_SERVER['REQUEST_URI'] ); + $currentPage = home_url() . $parsedUrl['path']; + $currentEnd = $parsedUrl['path']; + // Drop everything after ? in $currentPage + + $content = preg_replace( '%' . $directoryUrl .'Directory.php%', $currentPage, $content ); + + $templateData = array( + 'content' => $content, + ); + + error_reporting(E_ALL ^ E_NOTICE); + return array( + 'status' => $status, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'front/apis/' . $view . '.html', + 'data' => $templateData, + 'settings' => $settings + ); + } +} diff --git a/models/front/apis/schedule.php b/models/front/apis/schedule.php index 2760897..40999d6 100644 --- a/models/front/apis/schedule.php +++ b/models/front/apis/schedule.php @@ -1,13 +1,13 @@ $_REQUEST: ' . print_r( $_REQUEST, true ) . ''; - //echo '
$actionData: ' . print_r( $actionData, true ) . '
'; $view = 'schedule'; $settings = array(); $content = ''; diff --git a/setup/shortcodes.php b/setup/shortcodes.php index 957829d..1fb7d24 100644 --- a/setup/shortcodes.php +++ b/setup/shortcodes.php @@ -106,6 +106,15 @@ $glmMembersApisShortcodes = array( //'template' => false, ) ), + 'glm-members-api-golf-directory' => array( + 'plugin' => GLM_MEMBERS_APIS_PLUGIN_SLUG, + 'menu' => 'apis', + 'action' => 'golfclubDirectory', + 'table' => false, + 'attributes' => array( + //'template' => false, + ) + ), ); $glmMembersApisShortcodesDescription = ' @@ -123,6 +132,13 @@ $glmMembersApisShortcodesDescription = ' Pulls in the Schedule for Bibco + + + [glm-members-api-golf-directory] +   + + Pulls in the Directory for Harbor Point Golf Club + '; diff --git a/setup/validActions.php b/setup/validActions.php index 79b7f0d..8926334 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -71,8 +71,9 @@ $glmMembersApisAddOnValidActions = array( ), 'frontActions' => array( 'apis' => array( - 'schedule' => GLM_MEMBERS_APIS_PLUGIN_SLUG, - 'bibcoCalendar' => GLM_MEMBERS_APIS_PLUGIN_SLUG, + 'schedule' => GLM_MEMBERS_APIS_PLUGIN_SLUG, + 'bibcoCalendar' => GLM_MEMBERS_APIS_PLUGIN_SLUG, + 'golfclubDirectory' => GLM_MEMBERS_APIS_PLUGIN_SLUG, ), ) ); diff --git a/views/admin/management/apis.html b/views/admin/management/apis.html index ec63c31..4dc748e 100644 --- a/views/admin/management/apis.html +++ b/views/admin/management/apis.html @@ -70,6 +70,30 @@ + + +

Harbor Point Golf Club API

+
+ + + + + + + + +
URL for Directory [include ending slash] + +
+ +
+ +