Start work on settings
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 11 Sep 2018 20:21:30 +0000 (16:21 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 11 Sep 2018 20:21:30 +0000 (16:21 -0400)
Setting WIP
edit and add staff working.

classes/data/dataBuildings.php [new file with mode: 0644]
classes/data/dataDepartments.php [new file with mode: 0644]
models/admin/staff/index.php
models/admin/staff/settings.php [new file with mode: 0644]
setup/validActions.php
views/admin/settings/index.html [new file with mode: 0644]
views/admin/staff/edit.html

diff --git a/classes/data/dataBuildings.php b/classes/data/dataBuildings.php
new file mode 100644 (file)
index 0000000..3269d5c
--- /dev/null
@@ -0,0 +1,149 @@
+<?php
+/**
+ * GLM Member-DB WordPress Add-On Plugin
+ * Data Class Building
+ *
+ * PHP version 5.3
+ *
+ * @category Data
+ * @package  GLM Member-DB
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @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 <cscott@gaslightmedia.com>
+ * @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 (file)
index 0000000..85e65e8
--- /dev/null
@@ -0,0 +1,149 @@
+<?php
+/**
+ * GLM Member-DB WordPress Add-On Plugin
+ * Data Class Department
+ *
+ * PHP version 5.3
+ *
+ * @category Data
+ * @package  GLM Member-DB
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @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 <cscott@gaslightmedia.com>
+ * @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;
+    }
+
+
+}
index a430931..65522d3 100644 (file)
@@ -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 '<pre>$staff: ' . print_r( $staff, true ) . '</pre>';
             $view = 'edit';
             break;
 
         case 'update':
-            // echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
-            // echo '<pre>$staffId: ' . print_r( $this->staffID, true ) . '</pre>';
             $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 (file)
index 0000000..a2a910d
--- /dev/null
@@ -0,0 +1,214 @@
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Admin Members Dashboard
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @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
+        );
+
+    }
+
+
+}
index 7a2e6b9..ebf06b7 100644 (file)
@@ -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 (file)
index 0000000..8a8f29e
--- /dev/null
@@ -0,0 +1,5 @@
+{include file="admin/staff/header.html"}
+
+<h1>settings</h1>
+
+{include file="admin/staff/footer.html"}
index 44dfd0c..696c678 100644 (file)
@@ -1,13 +1,15 @@
 {include file="admin/staff/header.html"}
 
 {if $updateGood}<h2 class="glm-notice glm-flash-updated glm-right">Updated</h2>{/if}
+{if $insertGood}<h2 class="glm-notice glm-flash-updated glm-right">Added</h2>{/if}
 {if $updateError}<span class="glm-error glm-flash-updated glm-right">Update Error</span>{/if}
+{if $insertError}<span class="glm-error glm-flash-updated glm-right">Insert Error</span>{/if}
 
 <form action="{$thisUrl}?page={$thisPage}" method="post">
 
     <input type="hidden" name="page" value="{$thisPage}" />
 
-    {if $staff.fieldData.id}
+    {if isset($staff.fieldData.id) && $staff.fieldData.id}
         <input type="hidden" name="option" value="update" />
         <input type="hidden" name="staff" value="{$staff.fieldData.id}" />
         <input type="hidden" name="id" value="{$staff.fieldData.id}" />
@@ -20,7 +22,7 @@
         <tr>
             <th {if $staff.fieldRequired.fname} class="glm-required"}{/if}>First Name</th>
             <td {if $staff.fieldFail.fname}class="glm-form-bad-input" data-tabid="glm-fname"{/if}>
-                <input type="text" name="fname" value="{$staff.fieldData.fname}" class="glm-form-text-input-short">
+                <input type="text" name="fname" value="{$staff.fieldData.fname}" class="glm-form-text-input-short"{if $staff.fieldRequired.fname} required{/if}>
             {if $staff.fieldFail.fname}<p>{$staff.fieldFail.fname}</p>{/if}<br>
             </td>
         </tr>
@@ -28,7 +30,7 @@
         <tr>
             <th {if $staff.fieldRequired.lname} class="glm-required"}{/if}>Last Name</th>
             <td {if $staff.fieldFail.lname}class="glm-form-bad-input" data-tabid="glm-lname"{/if}>
-                <input type="text" name="lname" value="{$staff.fieldData.lname}" class="glm-form-text-input-short">
+                <input type="text" name="lname" value="{$staff.fieldData.lname}" class="glm-form-text-input-short"{if $staff.fieldRequired.lname} required{/if}>
             {if $staff.fieldFail.lname}<p>{$staff.fieldFail.lname}</p>{/if}<br>
             </td>
         </tr>
@@ -36,7 +38,7 @@
         <tr>
             <th {if $staff.fieldRequired.extension} class="glm-required"}{/if}>Extension</th>
             <td {if $staff.fieldFail.extension}class="glm-form-bad-input" data-tabid="glm-Id for bad input"{/if}>
-                <input type="text" name="extension" value="{$staff.fieldData.extension}" class="glm-form-text-input-short">
+                <input type="text" name="extension" value="{$staff.fieldData.extension}" class="glm-form-text-input-short"{if $staff.fieldRequired.extension} required{/if}>
             {if $staff.fieldFail.extension}<p>{$staff.fieldFail.extension}</p>{/if}<br>
             </td>
         </tr>
@@ -44,7 +46,7 @@
         <tr>
             <th {if $staff.fieldRequired.building} class="glm-required"}{/if}>Building</th>
             <td {if $staff.fieldFail.building}class="glm-form-bad-input" data-tabid="glm-building"{/if}>
-                <select name="building">
+                <select name="building"{if $staff.fieldRequired.building} required{/if}>
                     {foreach $staff.fieldData.building.list as $v}
                         <option value="{$v.value}"
                             {if $staff.fieldData.building.value == $v.value} selected{/if}
@@ -60,7 +62,7 @@
         <tr>
             <th {if $staff.fieldRequired.department} class="glm-required"}{/if}>Department</th>
             <td {if $staff.fieldFail.department}class="glm-form-bad-input" data-tabid="glm-deptarment"{/if}>
-                <select name="department">
+                <select name="department"{if $staff.fieldRequired.department} required{/if}>
                     {foreach $staff.fieldData.department.list as $v}
                         <option value="{$v.value}"
                             {if $staff.fieldData.department.value == $v.value} selected{/if}