From f45d40d5713d5396d265c37ebc77a3e350df82ab Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 21 Mar 2017 11:27:55 -0400 Subject: [PATCH] Add bibco setting for it's API Add url for the calendar api for bibco. Add shortcode and management page for settings. --- defines.php | 1 + models/admin/management/apis.php | 26 +++++++++ models/front/apis/bibcoCalendar.php | 85 +++++++++++++++++++++++++++++ setup/shortcodes.php | 16 ++++++ setup/validActions.php | 5 +- views/admin/management/apis.html | 24 ++++++++ views/front/apis/bibcoCalendar.html | 1 + 7 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 models/front/apis/bibcoCalendar.php create mode 100644 views/front/apis/bibcoCalendar.html diff --git a/defines.php b/defines.php index 2d24c94..957f29c 100644 --- a/defines.php +++ b/defines.php @@ -13,6 +13,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' ); // 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 52d8918..6270226 100644 --- a/models/admin/management/apis.php +++ b/models/admin/management/apis.php @@ -95,6 +95,9 @@ class GlmMembersAdmin_management_apis $starlineUrl = false; $starlinePageSlug = false; $starlineOptionName = GLM_MEMBERS_APIS_STARLINE_OPTION_NAME; + $option3 = false; + $calendarUrl = false; + $bibcoOptionName = GLM_MEMBERS_APIS_BIBCO_OPTION_NAME; if (isset($_REQUEST['option'])) { $option = $_REQUEST['option']; @@ -124,6 +127,10 @@ class GlmMembersAdmin_management_apis if ( isset( $_REQUEST['option2'] ) ) { $option2 = $_REQUEST['option2']; } + $option3 = ''; + if ( isset( $_REQUEST['option3'] ) ) { + $option3 = $_REQUEST['option3']; + } switch($option2) { // Update the settings and redisplay the form @@ -144,6 +151,23 @@ class GlmMembersAdmin_management_apis break; } + switch($option3) { + // Update the settings and redisplay the form + case 'submit': + $settings_updated = true; + update_option( $bibcoOptionName, serialize( $_REQUEST[$bibcoOptionName] ) ); + $bibcoOptions = unserialize( get_option( $bibcoOptionName ) ); + $calendarUrl = ( isset( $bibcoOptions['calendarUrl'] ) ) ? $bibcoOptions['calendarUrl'] : ''; + + break; + + // Default is to get the current settings and display the form + default: + $bibcoOptions = unserialize( get_option( $bibcoOptionName ) ); + $calendarUrl = ( isset( $bibcoOptions['calendarUrl'] ) ) ? $bibcoOptions['calendarUrl'] : ''; + + break; + } break; } @@ -153,6 +177,8 @@ class GlmMembersAdmin_management_apis 'starlineUrl' => $starlineUrl, 'starlinePageSlug' => $starlinePageSlug, 'starlineOptionName' => $starlineOptionName, + 'calendarUrl' => $calendarUrl, + 'bibcoOptionName' => $bibcoOptionName, 'settingsUpdated' => $settings_updated, 'settingsUpdateError' => $settings_update_error, 'apisSettings' => $api_settings, diff --git a/models/front/apis/bibcoCalendar.php b/models/front/apis/bibcoCalendar.php new file mode 100644 index 0000000..87572b6 --- /dev/null +++ b/models/front/apis/bibcoCalendar.php @@ -0,0 +1,85 @@ + + * @license PHP Version 3.0 {@link http://www.php.net/license/3_0.txt} + */ +class GlmMembersFront_apis_bibcoCalendar +{ + /** + * __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) + { + //echo '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; + //echo '
$actionData: ' . print_r( $actionData, true ) . '
'; + $view = 'schedule'; + $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 . 'schedule.php'; + $curl = curl_init( $url ); + curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true ); + //curl_setopt( $curl, CURLOPT_USERPWD, 'dev55:Glm15Keep!' ); + $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/setup/shortcodes.php b/setup/shortcodes.php index a7525f7..957829d 100644 --- a/setup/shortcodes.php +++ b/setup/shortcodes.php @@ -97,6 +97,15 @@ $glmMembersApisShortcodes = array( 'off_canvas' => false, ) ), + 'glm-members-api-bibco-calander' => array( + 'plugin' => GLM_MEMBERS_APIS_PLUGIN_SLUG, + 'menu' => 'apis', + 'action' => 'bibcoCalendar', + 'table' => false, + 'attributes' => array( + //'template' => false, + ) + ), ); $glmMembersApisShortcodesDescription = ' @@ -107,6 +116,13 @@ $glmMembersApisShortcodesDescription = ' Pulls in the Schedule for Starline + + + [glm-members-api-bibco-calander] +   + + Pulls in the Schedule for Bibco + '; diff --git a/setup/validActions.php b/setup/validActions.php index be73b51..7e747bf 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -70,8 +70,9 @@ $glmMembersApisAddOnValidActions = array( ), 'frontActions' => array( 'apis' => array( - 'schedule' => GLM_MEMBERS_APIS_PLUGIN_SLUG, - ) + 'schedule' => GLM_MEMBERS_APIS_PLUGIN_SLUG, + 'bibcoCalendar' => GLM_MEMBERS_APIS_PLUGIN_SLUG, + ), ) ); diff --git a/views/admin/management/apis.html b/views/admin/management/apis.html index cc81a61..ec63c31 100644 --- a/views/admin/management/apis.html +++ b/views/admin/management/apis.html @@ -46,6 +46,30 @@ + + +

Bibco API

+
+ + + + + + + + +
URL for Calendar Schedule system [include ending slash] + +
+ +
+ +