--- /dev/null
+<?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;
+ }
+
+
+}
--- /dev/null
+<?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;
+ }
+
+
+}
$haveStaff = false;
$option = 'list';
$total_staff = false;
+ $insertError = false;
+ $insertGood = false;
$updateError = false;
$updateGood = false;
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 );
'staff' => $staff,
'total_staff' => $total_staff,
'haveStaff' => $haveStaff,
+ 'insertError' => $insertError,
+ 'insertGood' => $insertGood,
'updateError' => $updateError,
'updateGood' => $updateGood,
);
}
-
-?>
--- /dev/null
+<?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
+ );
+
+ }
+
+
+}
$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(
--- /dev/null
+{include file="admin/staff/header.html"}
+
+<h1>settings</h1>
+
+{include file="admin/staff/footer.html"}
{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}" />
<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>
<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>
<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>
<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}
<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}