Add bibco setting for it's API
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 21 Mar 2017 15:27:55 +0000 (11:27 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 21 Mar 2017 15:28:20 +0000 (11:28 -0400)
Add url for the calendar api for bibco.
Add shortcode and management page for settings.

defines.php
models/admin/management/apis.php
models/front/apis/bibcoCalendar.php [new file with mode: 0644]
setup/shortcodes.php
setup/validActions.php
views/admin/management/apis.html
views/front/apis/bibcoCalendar.html [new file with mode: 0644]

index 2d24c94..957f29c 100644 (file)
@@ -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;
index 52d8918..6270226 100644 (file)
@@ -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 (file)
index 0000000..87572b6
--- /dev/null
@@ -0,0 +1,85 @@
+<?php
+/**
+ * detail.php
+ *
+ * This is the Member Api Plugin model for the front detail shortcode.
+ * Handles the view of the detail pages.
+ */
+
+/**
+ * GLmMembersFront_api_detail
+ *
+ * @uses      GlmDataApis
+ * @package   GlmMemberApis
+ * @version   0.0.1
+ * @copyright Copyright (c) 2010 All rights reserved.
+ * @author    Steve Sutton <steve@gaslightmedia.com>
+ * @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 '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
+        //echo '<pre>$actionData: ' . print_r( $actionData, true ) . '</pre>';
+        $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
+        );
+    }
+}
index a7525f7..957829d 100644 (file)
@@ -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 = '
         <td width="50%">
             Pulls in the Schedule for Starline
         </td>
+    </tr>
+     <tr>
+        <th>[glm-members-api-bibco-calander]</th>
+        <td>&nbsp;</td>
+        <td width="50%">
+            Pulls in the Schedule for Bibco
+        </td>
     </tr>
     ';
 
index be73b51..7e747bf 100644 (file)
@@ -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,
+        ),
     )
 );
 
index cc81a61..ec63c31 100644 (file)
                 </form>
             </td>
         </tr>
+        <tr>
+            <td>
+                <h3>Bibco API</h3>
+                <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
+                    <input type="hidden" name="glm_action" value="apis">
+                    <input type="hidden" name="option" value="settings">
+                    <input type="hidden" name="option3" value="submit">
+                    <table class="glm-admin-table">
+                        <tr>
+                            <th> URL for Calendar Schedule system [include ending slash] </th>
+                            <td>
+                                <input
+                                    class="glm-form-text-input-medium"
+                                    name="{$bibcoOptionName}[calendarUrl]"
+                                    id="calendarUrl"
+                                    type="text"
+                                    value="{$calendarUrl}">
+                            </td>
+                        </tr>
+                    </table>
+                    <input type="submit" value="Update Settings" class="button-primary">
+                </form>
+            </td>
+        </tr>
     </table>
 
 <script>
diff --git a/views/front/apis/bibcoCalendar.html b/views/front/apis/bibcoCalendar.html
new file mode 100644 (file)
index 0000000..d9f1e44
--- /dev/null
@@ -0,0 +1 @@
+{$content}