L#3
authorLaury GvR <laury@gaslightmedia.com>
Wed, 8 Feb 2017 18:56:01 +0000 (13:56 -0500)
committerLaury GvR <laury@gaslightmedia.com>
Wed, 8 Feb 2017 18:56:01 +0000 (13:56 -0500)
models/admin/management/registrations.php
views/admin/management/registrations.html

index bd56d6c..dd3a7e0 100644 (file)
@@ -44,21 +44,21 @@ class GlmMembersAdmin_management_registrations extends GlmDataRegistrationsManag
      * @var mixed
      * @access public
      */
-    public $dbh;
+    public $config;
     /**
      * settings used for the schema and tablenames
      *
      * @var mixed
      * @access public
      */
-    public $settings = array();
-    /**
-     * registrations
-     *
-     * @var bool
-     * @access public
-     */
-    public $registrations = array();
+//    public $settings = array();
+//    /**
+//     * registrations
+//     *
+//     * @var bool
+//     * @access public
+//     */
+//    public $registrations = array();
 
     /**
      * Constructor
@@ -107,16 +107,9 @@ class GlmMembersAdmin_management_registrations extends GlmDataRegistrationsManag
      * @return void
      */
     public function modelAction($actionData = false)
-    {
-
-        $option                 = false;
-        $option2                = false;
-        $settings_updated       = false;
-        $settings_update_error  = false;
-        $reg_settings           = false;
-        $id                     = 1;
-        
-
+    {       
+        // General settings are always stored in a record with ID=1.
+        $id = 1;
         // Determine if current user can edit configurations
         if (!current_user_can('glm_members_management')) {
             return array(
@@ -131,23 +124,26 @@ class GlmMembersAdmin_management_registrations extends GlmDataRegistrationsManag
         }
 
         // Check for submission option
-        $option2 = '';
-        if (isset($_REQUEST['option2'])) {
-            $option2 = $_REQUEST['option2'];
+        // Check for submission option
+
+        // Check for submission option
+        $option = '';
+        if (isset($_REQUEST['option']) && $_REQUEST['option'] == 'submit') {
+            $option = $_REQUEST['option'];
         }
 
-        switch($option2) {
+        switch( $option ) {
 
             // Update the settings and redisplay the form
             case 'submit':
 
-                // Update the event management settings
-                $reg_settings = $this->updateEntry( $id );
-                if ($reg_settings['status']) {
-                    $settings_updated = true;
-                } else {
-                    $settings_update_error = true;
-                }
+                // Update the general settings
+                $reg_settings = $this->updateEntry( 1 );
+
+                echo "<pre>" . print_r($reg_settings, true) . "</pre>";
+                
+                // Display admin message that the data has been updated
+                glmMembersAdmin::addNotice('General Settings for the '.GLM_MEMBERS_REGISTRATIONS_PLUGIN_NAME.' plugin have been updated.', 'AdminNotice');
 
                 break;
 
@@ -155,41 +151,38 @@ class GlmMembersAdmin_management_registrations extends GlmDataRegistrationsManag
             default:
 
                 // Try to get the first (should be only) entry for general settings.
-                $reg_settings = $this->editEntry( $id );
-                //echo '<pre>$reg_settings: ' . print_r( $reg_settings, true ) . '</pre>';
+                $reg_settings = $this->editEntry( 1 );
 
+                echo "<pre>" . print_r($reg_settings, true) . "</pre>";
+                
+                // Check that we actually have the terms
                 if ($reg_settings === false) {
 
                     if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
-                        glmMembersAdmin::addNotice("<b>&nbsp;&nbsp;/models/admin/management/events.php: Unable to load events management settings.", 'Alert');
+                        glmMembersAdmin::addNotice("<b>/modesl/admin/settings/terms.php:</b> Unable to load Terms Settings.", 'Alert');
                     }
 
+                    return array(
+                        'status' => false,
+                        'menuItemRedirect' => 'error',
+                        'modelRedirect' => 'index',
+                        'view' => 'admin/error/index.html',
+                        'data' => array(
+                            'reason' => 'Unable to create terms settings entry in database.'
+                        )
+                    );
                 }
 
                 break;
 
         }
-
-
-
-        
-        // Try to get the first (should be only) entry for general settings.
-        $regSettings = $this->editEntry( $id );
-
-        if ( $regSettings === false ) {
-
-            if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG ) {
-                glmMembersAdmin::addNotice("<b>&nbsp;&nbsp;/modesl/admin/settings/index.php: Unable to load General Settings.", 'Alert');
-            }
-        }
-        
         
         // Compile template data
         $template_data = array(
             'regSettings'           => $reg_settings,
             'option'                => $option,
-            'settingsUpdated'       => $settings_updated,
-            'settingsUpdateError'   => $settings_update_error,
+//            'settingsUpdated'       => $settings_updated,
+//            'settingsUpdateError'   => $settings_update_error,
         );
         
         //echo "<pre>" . print_r($regSettings, true) . "</pre>";
@@ -201,55 +194,6 @@ class GlmMembersAdmin_management_registrations extends GlmDataRegistrationsManag
             'view'                  => 'admin/management/registrations.html',
             'data'                  => $template_data
         );
-
-
-    }
-
-    /**
-     * connectPostgresDb
-     *
-     * Make a connection to the given database for the site. (postgres)
-     * Sets the $this->dbh with the postgers database connection
-     *
-     * @param mixed $db_host
-     * @param mixed $db_name
-     * @param mixed $db_user
-     * @param mixed $db_password
-     * @access public
-     * @return void
-     */
-    public function connectPostgresDb($db_host, $db_name, $db_user, $db_password)
-    {
-        $conn_str      = "pgsql:";
-        if ( $db_host ) {
-            $conn_part[] = "host={$db_host}";
-        }
-        if ( $db_name ) {
-            $conn_part[] = "dbname={$db_name}";
-        }
-        if ( $db_user ) {
-            $conn_part[] = "user={$db_user}";
-        }
-        if ( $db_password ) {
-            $conn_part[] = "password={$db_password}";
-        }
-        if ( !empty($conn_part) ) {
-             $conn_str .= implode( " ", $conn_part );
-        }
-        $driver_options = array(
-            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_BOTH,
-        );
-        try {
-            $this->dbh = new PDO($conn_str, null, null, $driver_options);
-            $this->dbh->setAttribute(
-                PDO::ATTR_ERRMODE,
-                PDO::ERRMODE_EXCEPTION
-            );
-        } catch(PDOException $e) {
-            echo '<pre>$e: ' . print_r($e, true) . '</pre>';
-            wp_die();
-        }
     }
 }
-
-?>
+?>
\ No newline at end of file
index ddcc5ea..cb40abd 100644 (file)
@@ -2,7 +2,7 @@
 <h2 class="nav-tab-wrapper" style="margin-bottom: 1em;">
         
     <a id="glm-settings" data-show-table="glm-table-registrations" href="{$thisUrl}?page=glm-members-admin-menu-management&glm_action=registrations" 
-       class="glm-settings-tab nav-tab{if $option=='registrations'} nav-tab-active{/if}">
+       class="glm-settings-tab nav-tab{if $option=='registrations' || $option==''} nav-tab-active{/if}">
         General
     </a>
     
 <table id="glm-table-settings" class="glm-admin-table glm-settings-table">
     <tr>
         <td colspan="2">
-            {if $settingsUpdated}<h2 class="glm-notice glm-flash-updated glm-right">Settings Updated</h2>{/if}
-            {if $settingsUpdateError}<span class="glm-error glm-flash-updated glm-right">Settings Update Error</span>{/if}
+<!--            {if $settingsUpdated}<h2 class="glm-notice glm-flash-updated glm-right">Settings Updated</h2>{/if}
+            {if $settingsUpdateError}<span class="glm-error glm-flash-updated glm-right">Settings Update Error</span>{/if}-->
             <h3>Registrations General Settings</h3>
         </td>
     </tr>
     <tr>
         <td>
-                             
             <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
                 <input type="hidden" name="glm_action" value="registrations">
-                <input type="hidden" name="option" value="registrations">
-                <input type="hidden" name="option2" value="submit">
+                <input type="hidden" name="option" value="submit">
 
                 <table>
                     <tr>