From: Laury GvR Date: Wed, 8 Feb 2017 18:56:01 +0000 (-0500) Subject: L#3 X-Git-Tag: v1.0.0^2~511 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=a4b59e32f45327a1b5d72da798a17a67e444de19;p=WP-Plugins%2Fglm-member-db-registrations.git L#3 --- diff --git a/models/admin/management/registrations.php b/models/admin/management/registrations.php index bd56d6c..dd3a7e0 100644 --- a/models/admin/management/registrations.php +++ b/models/admin/management/registrations.php @@ -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 "
" . print_r($reg_settings, true) . "
"; + + // 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 '
$reg_settings: ' . print_r( $reg_settings, true ) . '
'; + $reg_settings = $this->editEntry( 1 ); + echo "
" . print_r($reg_settings, true) . "
"; + + // Check that we actually have the terms if ($reg_settings === false) { if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { - glmMembersAdmin::addNotice("  /models/admin/management/events.php: Unable to load events management settings.", 'Alert'); + glmMembersAdmin::addNotice("/modesl/admin/settings/terms.php: 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("  /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 "
" . print_r($regSettings, true) . "
"; @@ -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 '
$e: ' . print_r($e, true) . '
'; - wp_die(); - } } } - -?> +?> \ No newline at end of file diff --git a/views/admin/management/registrations.html b/views/admin/management/registrations.html index ddcc5ea..cb40abd 100644 --- a/views/admin/management/registrations.html +++ b/views/admin/management/registrations.html @@ -2,7 +2,7 @@