From: Steve Sutton Date: Tue, 11 Sep 2018 20:21:30 +0000 (-0400) Subject: Start work on settings X-Git-Tag: v1.0.0^2~19 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=ab29ad37866d8bc3fc19b845a41b54b0e08c0ed7;p=WP-Plugins%2Fglm-member-db-staff.git Start work on settings Setting WIP edit and add staff working. --- diff --git a/classes/data/dataBuildings.php b/classes/data/dataBuildings.php new file mode 100644 index 0000000..3269d5c --- /dev/null +++ b/classes/data/dataBuildings.php @@ -0,0 +1,149 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataBuildings.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ + */ + +/** + * GlmDataBuildings class + * + * PHP version 5 + * + * @category Data + * @package GLM Member DB + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmDataBuildings extends GlmDataAbstract +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Data Table Name + * + * @var $table + * @access public + */ + public $table; + /** + * Field definitions + * + * 'type' is type of field as defined by the application + * text Regular text field + * pointer Pointer to an entry in another table + * 'filters' is the filter name for a particular filter ID in PHP filter + * functions + * See PHP filter_id() + * + * 'use' is when to use the field + * l = List + * g = Get + * n = New + * i = Insert + * e = Edit + * u = Update + * d = Delete + * a = All + * + * @var $ini + * @access public + */ + public $fields = false; + /** + * Constructor + * + * @param object $d database connection + * @param array $config Configuration array + * @param bool $limitedEdit Flag to say indicate limited edit requested + * + * @return void + * @access public + */ + public function __construct($wpdb, $config, $limitedEdit = false) + { + + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } + + /* + * Table Name + */ + $this->table = GLM_MEMBERS_STAFF_PLUGIN_DB_PREFIX . 'buildings'; + + /* + * Table Data Fields + */ + + $this->fields = array ( + + 'id' => array ( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + + // Name + 'name' => array ( + 'field' => 'name', + 'type' => 'text', + 'required' => true, + 'use' => 'a' + ), + + ); + + } + + /** + * Entry Post Processing Call-Back Method + * + * Perform post-processing for all result entries. + * + * In this case we're using it to append an array of category + * data to each member result and also sort by member name. + * + * @param array $r Array of field result data for a single entry + * @param string $a Action being performed (l, i, g, ...) + * + * @return object Class object + * + */ + public function entryPostProcessing($r, $a) + { + return $r; + } + + +} diff --git a/classes/data/dataDepartments.php b/classes/data/dataDepartments.php new file mode 100644 index 0000000..85e65e8 --- /dev/null +++ b/classes/data/dataDepartments.php @@ -0,0 +1,149 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataDepartments.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ + */ + +/** + * GlmDataDepartments class + * + * PHP version 5 + * + * @category Data + * @package GLM Member DB + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmDataDepartments extends GlmDataAbstract +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Data Table Name + * + * @var $table + * @access public + */ + public $table; + /** + * Field definitions + * + * 'type' is type of field as defined by the application + * text Regular text field + * pointer Pointer to an entry in another table + * 'filters' is the filter name for a particular filter ID in PHP filter + * functions + * See PHP filter_id() + * + * 'use' is when to use the field + * l = List + * g = Get + * n = New + * i = Insert + * e = Edit + * u = Update + * d = Delete + * a = All + * + * @var $ini + * @access public + */ + public $fields = false; + /** + * Constructor + * + * @param object $d database connection + * @param array $config Configuration array + * @param bool $limitedEdit Flag to say indicate limited edit requested + * + * @return void + * @access public + */ + public function __construct($wpdb, $config, $limitedEdit = false) + { + + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } + + /* + * Table Name + */ + $this->table = GLM_MEMBERS_STAFF_PLUGIN_DB_PREFIX . 'departments'; + + /* + * Table Data Fields + */ + + $this->fields = array ( + + 'id' => array ( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + + // Name + 'name' => array ( + 'field' => 'name', + 'type' => 'text', + 'required' => true, + 'use' => 'a' + ), + + ); + + } + + /** + * Entry Post Processing Call-Back Method + * + * Perform post-processing for all result entries. + * + * In this case we're using it to append an array of category + * data to each member result and also sort by member name. + * + * @param array $r Array of field result data for a single entry + * @param string $a Action being performed (l, i, g, ...) + * + * @return object Class object + * + */ + public function entryPostProcessing($r, $a) + { + return $r; + } + + +} diff --git a/models/admin/staff/index.php b/models/admin/staff/index.php index a430931..65522d3 100644 --- a/models/admin/staff/index.php +++ b/models/admin/staff/index.php @@ -104,6 +104,8 @@ class GlmMembersAdmin_staff_index extends GlmDataStaff $haveStaff = false; $option = 'list'; $total_staff = false; + $insertError = false; + $insertGood = false; $updateError = false; $updateGood = false; @@ -133,20 +135,23 @@ class GlmMembersAdmin_staff_index extends GlmDataStaff break; case 'insert': - $staff = $this->insertEntry(); - $this->staffID = $staff['fieldData']['id']; + $staffInfo = $this->insertEntry(); + if ( $staffInfo['status'] == true ) { + $this->staffID = $staffInfo['fieldData']['id']; + $insertGood = true; + $staff = $this->editEntry( $this->staffID ); + } else { + $insertError = true; + } $view = 'edit'; break; case 'edit': $staff = $this->editEntry($this->staffID); - // echo '
$staff: ' . print_r( $staff, true ) . '
'; $view = 'edit'; break; case 'update': - // echo '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; - // echo '
$staffId: ' . print_r( $this->staffID, true ) . '
'; $staffInfo = $this->updateEntry($this->staffID); if ( $staffInfo['status'] == true ) { $staff = $this->editEntry( $this->staffID ); @@ -186,6 +191,8 @@ class GlmMembersAdmin_staff_index extends GlmDataStaff 'staff' => $staff, 'total_staff' => $total_staff, 'haveStaff' => $haveStaff, + 'insertError' => $insertError, + 'insertGood' => $insertGood, 'updateError' => $updateError, 'updateGood' => $updateGood, ); @@ -203,5 +210,3 @@ class GlmMembersAdmin_staff_index extends GlmDataStaff } - -?> diff --git a/models/admin/staff/settings.php b/models/admin/staff/settings.php new file mode 100644 index 0000000..a2a910d --- /dev/null +++ b/models/admin/staff/settings.php @@ -0,0 +1,214 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +// Load Members data abstract +require_once GLM_MEMBERS_STAFF_PLUGIN_CLASS_PATH.'/data/dataStaff.php'; +require_once GLM_MEMBERS_STAFF_PLUGIN_CLASS_PATH.'/data/dataBuildings.php'; +require_once GLM_MEMBERS_STAFF_PLUGIN_CLASS_PATH.'/data/dataDepartments.php'; + +/* + * This class performs the work for the default action of the "Members" menu + * option, which is to display the members dashboard. + * + */ +class GlmMembersAdmin_staff_settings //extends GlmDataStaff +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + + /* + * Constructor + * + * This contructor sets up this model. At this time that only includes + * storing away the WordPress data object. + * + * @return object Class object + * + */ + public function __construct ($wpdb, $config) + { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + // Run constructor for members data class + // parent::__construct(false, false); + + } + + /* + * Perform Model Action + * + * This method does the work for this model and returns any resulting data + * + * @return array Status and data array + * + * 'status' + * + * True if successfull and false if there was a fatal failure. + * + * 'menuItemRedirect' + * + * If not false, provides a menu item the controller should + * execute after this one. Normally if this is used, there would also be a + * modelRedirect value supplied as well. + * + * 'modelRedirect' + * + * If not false, provides an action the controller should execute after + * this one. + * + * 'view' + * + * A suggested view name that the contoller should use instead of the + * default view for this model or false to indicate that the default view + * should be used. + * + * 'data' + * + * Data that the model is returning for use in merging with the view to + * produce output. + * + */ + public function modelAction ($actionData = false) + { + $data = array(); + $success = true; + $view = 'index'; + $haveStaff = false; + $option = 'list'; + $total_staff = false; + $insertError = false; + $insertGood = false; + $updateError = false; + $updateGood = false; + + // Get any provided option + if (isset($_REQUEST['option'])) { + $option = $_REQUEST['option']; + } + + // Get event ID if supplied + if (isset($_REQUEST['staff'])) { + + // Make sure it's numeric + $this->staffID = ($_REQUEST['staff'] - 0); + + if ($this->staffID <= 0) { + $this->staffID = false; + } + + } + + // Do selected option + switch ($option) { + + case 'add': + $staff = $this->newEntry(); + $view = 'edit'; + break; + + case 'insert': + $staffInfo = $this->insertEntry(); + if ( $staffInfo['status'] == true ) { + $this->staffID = $staffInfo['fieldData']['id']; + $insertGood = true; + $staff = $this->editEntry( $this->staffID ); + } else { + $insertError = true; + } + $view = 'edit'; + break; + + case 'edit': + $staff = $this->editEntry($this->staffID); + $view = 'edit'; + break; + + case 'update': + $staffInfo = $this->updateEntry($this->staffID); + if ( $staffInfo['status'] == true ) { + $staff = $this->editEntry( $this->staffID ); + $updateGood = true; + } else { + $updateError = true; + } + $view = 'edit'; + break; + + case 'delete': + $staff = $this->deleteEntry($this->staffID); + break; + + case 'list': + default: + // Get staff list + // $staff = $this->getList(); + + // Get stats on the current list + // $total_staff = $this->getStats(); + + if ( $staff ) { + $haveStaff = true; + } + + break; + + } + + + + + // Compile template data + $templateData = array( + 'data' => $data, + 'staff' => $staff, + 'total_staff' => $total_staff, + 'haveStaff' => $haveStaff, + 'insertError' => $insertError, + 'insertGood' => $insertGood, + 'updateError' => $updateError, + 'updateGood' => $updateGood, + ); + + // Return status, suggested view, and data to controller + return array( + 'status' => $success, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/settings/' . $view . '.html', + 'data' => $templateData + ); + + } + + +} diff --git a/setup/validActions.php b/setup/validActions.php index 7a2e6b9..ebf06b7 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -60,7 +60,8 @@ $glmMembersStaffAddOnValidActions = array( 'adminActions' => array( 'staff' => array( - 'index' => GLM_MEMBERS_STAFF_PLUGIN_SLUG, + 'index' => GLM_MEMBERS_STAFF_PLUGIN_SLUG, + 'settings' => GLM_MEMBERS_STAFF_PLUGIN_SLUG, ), ), 'frontActions' => array( diff --git a/views/admin/settings/index.html b/views/admin/settings/index.html new file mode 100644 index 0000000..8a8f29e --- /dev/null +++ b/views/admin/settings/index.html @@ -0,0 +1,5 @@ +{include file="admin/staff/header.html"} + +

settings

+ +{include file="admin/staff/footer.html"} diff --git a/views/admin/staff/edit.html b/views/admin/staff/edit.html index 44dfd0c..696c678 100644 --- a/views/admin/staff/edit.html +++ b/views/admin/staff/edit.html @@ -1,13 +1,15 @@ {include file="admin/staff/header.html"} {if $updateGood}

Updated

{/if} +{if $insertGood}

Added

{/if} {if $updateError}Update Error{/if} +{if $insertError}Insert Error{/if}
- {if $staff.fieldData.id} + {if isset($staff.fieldData.id) && $staff.fieldData.id} @@ -20,7 +22,7 @@ First Name - + {if $staff.fieldFail.fname}

{$staff.fieldFail.fname}

{/if}
@@ -28,7 +30,7 @@ Last Name - + {if $staff.fieldFail.lname}

{$staff.fieldFail.lname}

{/if}
@@ -36,7 +38,7 @@ Extension - + {if $staff.fieldFail.extension}

{$staff.fieldFail.extension}

{/if}
@@ -44,7 +46,7 @@ Building - {foreach $staff.fieldData.building.list as $v}