Updating api plugin
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 1 May 2017 20:02:01 +0000 (16:02 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 1 May 2017 20:02:01 +0000 (16:02 -0400)
Updates to be used for Harbor Country Golf Club.

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

index 957f29c..27d4f5b 100644 (file)
@@ -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;
index 6270226..08f7a1d 100644 (file)
@@ -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,
index 8df33a8..6ba2c4b 100644 (file)
@@ -1,13 +1,13 @@
 <?php
 /**
- * detail.php
+ * bibcoCalendar.php
  *
  * This is the Member Api Plugin model for the front detail shortcode.
  * Handles the view of the detail pages.
  */
 
 /**
- * GLmMembersFront_api_detail
+ * GlmMembersFront_apis_bibcoCalendar
  *
  * @uses      GlmDataApis
  * @package   GlmMemberApis
@@ -32,13 +32,6 @@ class GlmMembersFront_apis_bibcoCalendar
         $this->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 '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
-        //echo '<pre>$actionData: ' . print_r( $actionData, true ) . '</pre>';
         $view        = 'bibcoCalendar';
         $settings    = array();
         $content     = '';
diff --git a/models/front/apis/bibcoSearch.php b/models/front/apis/bibcoSearch.php
new file mode 100644 (file)
index 0000000..c87c57b
--- /dev/null
@@ -0,0 +1,84 @@
+<?php
+/**
+ * bibcoSearch.php
+ *
+ * This is the Member Api Plugin model for the front detail shortcode.
+ * Handles the view of the detail pages.
+ */
+
+/**
+ * GlmMembersFront_apis_bibcoSearch
+ *
+ * @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_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 (file)
index 0000000..c2b6fbf
--- /dev/null
@@ -0,0 +1,104 @@
+<?php
+/**
+ * golfclubDirectory.php
+ *
+ * This is the Member Api Plugin model for the front detail shortcode.
+ * Handles the view of the detail pages.
+ */
+
+/**
+ * GlmMembersFront_apis_golfclubDirectory
+ *
+ * @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_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
+        );
+    }
+}
index 2760897..40999d6 100644 (file)
@@ -1,13 +1,13 @@
 <?php
 /**
- * detail.php
+ * schedule.php
  *
  * This is the Member Api Plugin model for the front detail shortcode.
  * Handles the view of the detail pages.
  */
 
 /**
- * GLmMembersFront_api_detail
+ * GlmMembersFront_apis_schedule
  *
  * @uses      GlmDataApis
  * @package   GlmMemberApis
@@ -49,8 +49,6 @@ class GlmMembersFront_apis_schedule
      */
     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     = '';
index 957829d..1fb7d24 100644 (file)
@@ -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 = '
         <td width="50%">
             Pulls in the Schedule for Bibco
         </td>
+    </tr>
+     <tr>
+        <th>[glm-members-api-golf-directory]</th>
+        <td>&nbsp;</td>
+        <td width="50%">
+            Pulls in the Directory for Harbor Point Golf Club
+        </td>
     </tr>
     ';
 
index 79b7f0d..8926334 100644 (file)
@@ -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,
         ),
     )
 );
index ec63c31..4dc748e 100644 (file)
                 </form>
             </td>
         </tr>
+        <tr>
+            <td>
+                <h3>Harbor Point Golf Club 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="option4" value="submit">
+                    <table class="glm-admin-table">
+                        <tr>
+                            <th> URL for Directory [include ending slash] </th>
+                            <td>
+                                <input
+                                    class="glm-form-text-input-medium"
+                                    name="{$golfclubOptionName}[directoryUrl]"
+                                    id="directoryUrl"
+                                    type="text"
+                                    value="{$directoryUrl}">
+                            </td>
+                        </tr>
+                    </table>
+                    <input type="submit" value="Update Settings" class="button-primary">
+                </form>
+            </td>
+        </tr>
     </table>
 
 <script>
diff --git a/views/front/apis/golfclubDirectory.html b/views/front/apis/golfclubDirectory.html
new file mode 100644 (file)
index 0000000..d9f1e44
--- /dev/null
@@ -0,0 +1 @@
+{$content}