* @release SVN: $Id: dataEvents.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
*/
-// Member Info Data required
-require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php');
-
/**
* GlmDataEvent class
*
{
return $r;
}
-
-}
-?>
+
+ /**
+ * Add a category using supplied parameters
+ *
+ * @param string $name Category Name
+ * @param mixed $parent Existing Parent ID or name of parent to add
+ *
+ * @return integer ID of new category or false if failed
+ *
+ * @access public
+ */
+
+ public function addCategory($name, $parent) {
+
+ $categoryID = false;
+ $parentID = false;
+
+ // Filter new category name
+ $name = filter_var($name);
+ if ($name == false || trim($name) == '') {
+ return false;
+ }
+
+ // Determine parent supplied as an ID
+
+ $parentInt = $parent - 0;
+ if (is_int($parent) && $parentInt > 0) {
+
+ // If it's not positive, then fail
+ if ($parent <= 0) {
+ return false;
+ }
+
+ // Check that parent exists
+ $sql = "
+ SELECT COUNT(id) AS count
+ FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."categories
+ WHERE id = $parent
+ ;";
+ $test = $this->wpdb->get_row($sql, ARRAY_A);
+
+ // Should be only one entry if the parent category exists
+ if ($test['count'] != 1) {
+ return false;
+ }
+
+ $parentID = $parent;
+
+ // Else check to see if parent was supplied as a name
+ } elseif ($parent != '') {
+
+ $parent = filter_var($parent);
+
+ // If the name didn't pass the filer then fail
+ if ($parent == false) {
+ return false;
+ }
+
+ // Check if the name already exists
+ $sql = "
+ SELECT id
+ FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."categories
+ WHERE name = '$parent'
+ ;";
+ $parentCategory = $this->wpdb->get_row($sql, ARRAY_A);
+
+ // If we found the parent ID
+ if ($parentCategory['id']) {
+
+ // Set that as the parent ID for the new category
+ $parentID = $parentCategory['id'];
+
+ // Otherwise, try to add the parent category
+ } else {
+
+ // Add the parent as a new category
+ $sql = "
+ INSERT INTO ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."categories
+ ( name, parent )
+ VALUES
+ ( '".addslashes($parent)."', 0 )
+ ;";
+ $this->wpdb->query($sql);
+ $parentID = $this->wpdb->insert_id;
+
+ // Check if it didn't store properly
+ if (!$parentID) {
+ return false;
+ }
+
+ }
+
+ // Otherwise the categroy being added has no parent
+ } else {
+ $parentID = 0;
+ }
+
+ // Check if the new category name/parent already exists
+ $sql = "
+ SELECT id
+ FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."categories
+ WHERE name = '$name'
+ AND parent = $parentID
+ ;";
+ $existing = $this->wpdb->get_row($sql, ARRAY_A);
+
+ if ($existing['id']) {
+
+ $categoryID = $existing['id'];
+
+ } else {
+
+ // Try to add the new category
+ $sql = "
+ INSERT INTO ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."categories
+ ( name, parent )
+ VALUES
+ ( '".addslashes($name)."', $parentID )
+ ;";
+ $this->wpdb->query($sql);
+ $categoryID = $this->wpdb->insert_id;
+
+ }
+
+ if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
+ glmMembersAdmin::addNotice("Category added: name = $name, parent = $parent, ID = $categoryID", 'DataBlock', "addCategory()");
+ }
+
+ return $categoryID;
+
+ }
+
+ /**
+ * Get categories list sorted by parent/child then alpha
+ *
+ * @return array Array of categories
+ * @param boolean $forEdit If true include list of options for each parent field
+ *
+ * @access public
+ */
+
+ public function getListSortedParentChild($forEdit = true) {
+
+ $categories = $this->getList();
+ $categoriesSorted = $this->sortParentChild($categories);
+
+ if (!$forEdit) {
+ while (list($k, $v) = each($categoriesSorted)) {
+ $categoriesSorted[$k]['parent_id'] = $v['parent']['value'];
+ $categoriesSorted[$k]['parent'] = $v['parent']['name'];
+ }
+ }
+
+ return $categoriesSorted;
+
+ }
+
+ /*
+ * Check other requirements
+ *
+ * When deleteing categories, check for references in sub-categories and set them to no parent.
+ *
+ */
+ function checkOther($r, $a)
+ {
+ // Required
+ parent::checkOther($r, $a);
+
+ // If there's a valid category ID
+ if (isset($r['id']) && $r['id'] > 0) {
+
+ // Set any parent references with this ID to 0
+ $sql = "
+ UPDATE ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."categories
+ SET parent = 0
+ WHERE parent = ".$r['id']."
+ ;";
+ $this->wpdb->query($sql);
+
+ }
+
+ return $r;
+ }
+
+ /*
+ * Sort a database result array (from DataAbstract.php) by parent, child relationships
+ *
+ * @param array $array Array to be sorted
+ * @param string $name Name of array element that represents the text to sort on
+ * @param string $parent Name of the array element that represents the parent ID to sort on
+ *
+ * @return array Sorted array
+ */
+ public static function sortParentChild($array, $name = 'name', $parent = 'parent')
+ {
+
+ if (!is_array($array) || count($array) == 0) {
+ return false;
+ }
+
+ // Do a sort by custom function with it included in the call
+ // This lets me directly use $name and $parent in the sort function
+ uasort($array, function ($a, $b) use ($name, $parent) {
+
+ // If there's a parent, append the name of this entry to the parent
+ // The '~~~' simply keeps appended strings from any chance of a match with something else
+ if ($a[$parent]['value']) {
+ $aVal = $a[$parent]['name'].'~~~'.$a['name'];
+ } else {
+ // Otheriwse just use the name.
+ $aVal = $a['name'];
+ }
+
+ // Same for b value
+ if ($b[$parent]['value']) {
+ $bVal = $b[$parent]['name'].'~~~'.$b['name'];
+ } else {
+ $bVal = $b['name'];
+ }
+
+ if ($aVal > $bVal) {
+ return 1;
+ }
+
+ if ($aVal < $bVal) {
+ return -1;
+ }
+
+ return 0;
+
+ });
+
+ return $array;
+ }
+
+}
* @release SVN: $Id: dataEvents.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
*/
-// Member Info Data required
-require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php');
-
/**
* GlmDataEvent class
*
return $r;
}
+ /*
+ * Get list of categories with parent information
+ *
+ * @param integer $eventID Optional event ID to match
+ * Used to find all categories for a particular event ID
+ *
+ * @param integer $category Optional category ID to match
+ * Used to find all event records for a particular category
+ *
+ * NOTE: Both parameters above can't be used at the same time
+ *
+ * @return array List of selected categories
+ *
+ * @access public
+ */
+
+ public function getListWithParents($eventID = false, $category = false)
+ {
+
+ $where = '';
+
+ if ($category) {
+ $where = "WHERE T.category = $category";
+ } elseif ($ventID) {
+ $where = "WHERE T.event = $eventID";
+ }
+
+ $sql = "
+ SELECT T.category, T.event,
+ (
+ SELECT name
+ FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."categories
+ WHERE id = T.category
+ ) AS category_name,
+ (
+ SELECT parent
+ FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."categories
+ WHERE id = T.category
+ ) AS category_parent,
+ COALESCE (
+ (
+ SELECT name
+ FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."categories
+ WHERE id = category_parent
+ ),
+ ''
+ ) AS parent_name
+ FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."event_categories T
+ $where
+ ;";
+ $list = $this->wpdb->get_results($sql, ARRAY_A);
+
+ if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
+ glmMembersAdmin::addNotice($sql, 'DataBlock', "DataAbstract - getListWithParents() query");
+ glmMembersAdmin::addNotice($list, 'DataBlock', 'getListWithParents() data');
+ }
+
+ return $list;
+
+ }
+
+ /**
+ * Use supplied category ID list to set selected categories for this
+ * event record. Any others that were set will be cleared.
+ *
+ * @param integer $eventID Event Record ID
+ * @param array $selectedCategories Array of selected category IDs (key is also category ID)
+ *
+ * @return array List of selected categories
+ *
+ * @access public
+ */
+
+ public function setEventCategories($eventID, $selectedCategories)
+ {
+
+ // Check supplied data
+ if (!is_int($eventID) || $eventID <=0 || !is_array($selectedCategories) || count($selectedCategories) == 0 ) {
+ return false;
+ }
+
+ // Get current list
+ $current = $this->getList("T.event = $eventID");
+
+ // If we have any currently selected categories
+ if (is_array($current) && count($current) > 0) {
+
+ // For each category in the list
+ foreach ($current as $key => $val) {
+
+ $current[$key]['selected'] = false;
+
+ // Delete existing ones from the supplied selection list and mark selected ones in the current list
+ if (isset($selectedCategories[$val['id']])) {
+
+ unset($selectedCategories[$val['id']]);
+
+ $current[$key]['selected'] = true;
+
+ }
+
+ }
+
+ }
+
+ // For each remaining selected category, add the category
+ foreach ($selectedCategories as $s) {
+
+ // Add the category
+ $sql = "
+ INSERT INTO ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."event_categories
+ ( category, event )
+ VALUES
+ ( $s, $eventID )
+ ;";
+ $this->wpdb->query($sql);
+
+
+ }
+
+ // For any existing categories listed that aren't marked as selected, remove them
+ if (is_array($current) && count($current) > 0) {
+ foreach ($current as $key => $val) {
+
+ if (!$val['selected']) {
+
+ // Delete the entry
+ // Add the category
+ $sql = "
+ DELETE FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."event_categories
+ WHERE event = $eventID
+ AND id = ".$val['id']."
+ ;";
+ $this->wpdb->query($sql);
+
+ }
+ }
+ }
+
+ // Get new list and return it
+ $current = $this->getList($eventID);
+
+ if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
+ glmMembersAdmin::addNotice($current, 'DataBlock', 'Currently Selected Event Categories');
+ }
+
+ return $current;
+ }
+
+ /**
+ * Clear all categories for a specific event record
+ *
+ * @param integer $eventID Event Record ID
+ *
+ * @return null
+ *
+ * @access public
+ */
+
+ public function clearEventCategories($eventID)
+ {
+
+ $sql = "
+ DELETE FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."event_caetgories
+ WHERE event = $eventID
+ ;";
+ $this->wpdb->query($sql);
+
+ // Returns false to indicate there are no categories selected
+ return false;
+
+ }
+
+
}
?>
* @release SVN: $Id: dataEvents.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
*/
-// Member Info Data required
-require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php');
-
/**
* GlmDataEvents class
*
'created' => array (
'field' => 'created',
'type' => 'datetime',
- 'use' => 'lgie'
+ 'use' => 'lgieu'
),
// Date/Time Updated
'use' => 'a'
),
+ // Name Slug for URLs
+ 'name_slug' => array (
+ 'field' => 'name_slug',
+ 'type' => 'text',
+ 'required' => true,
+ 'use' => 'lge'
+ ),
+
+/* Not currently in use
// Header
'header' => array (
'field' => 'header',
'type' => 'text',
- 'required' => true,
+ 'required' => false,
'use' => 'a'
),
+*/
// Intro Text
'intro' => array (
*/
public function entryPostProcessing($r, $a)
{
+
+ // Get Member Category data for this entry
+ $sql = "
+ SELECT EC.event AS event_id, C.id, C.name, C.descr,
+ COALESCE (
+ (
+ SELECT name
+ FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX. "categories
+ WHERE id = C.parent
+ ), ''
+ ) AS parent_name
+ FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX. "categories AS C,
+ ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX. "event_categories AS EC
+ WHERE C.id = EC.category
+ AND EC.event = ".$r['id']."
+ ;";
+ $r['categories'] = $this->wpdb->get_results($sql, ARRAY_A);
+
return $r;
}
+ /*
+ * Update event slug - should be called after an event record is added or updated
+ *
+ * @param integer id ID of event that needs the slug updated
+ *
+ * @access public
+ */
+ public function updateSlug($id = false)
+ {
+
+ if ($id == false) {
+ return false;
+ }
+
+ $e = $this->getEntry($id);
+
+ $slug = sanitize_title($e['name']);
+
+ // Update the city selected for this memberInfo record
+ $sql = "
+ UPDATE ".$this->table."
+ SET name_slug = '$slug'
+ WHERE id = $id
+ ;";
+ $this->wpdb->query($sql);
+
+ return $slug;
+
+ }
+
+ /*
+ * Update timestamps for created, updated, approved
+ *
+ * @param string $field Field to update
+ * @param integer $id ID of event
+ *
+ * @return void
+ */
+ public function updateTimestamp($field = false, $id = false)
+ {
+
+ if (!in_array($field, array('created', 'updated', 'approved')) || !$id) {
+ return false;
+ }
+
+ $sql = "
+ UPDATE ".$this->table."
+ SET $field = now()
+ WHERE id = $id
+ ;";
+ $this->wpdb->query($sql);
+
+
+ }
+
+ /*
+ * Delete an event and all data associated with it.
+ *
+ * @param integer $id ID of event
+ *
+ * @return void
+ */
+ public function deleteEvent($id = false)
+ {
+
+ // Load recurrences data class to deal with event times
+ require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataRecurrences.php');
+ $Recurrences = new GlmDataEventsRecurrences($this->wpdb, $this->config);
+
+ // Check ID
+ $if = ($if - 0);
+ if ($id <= 0) {
+ return false;
+ }
+
+ // Try to get the event data
+ $event = $this->getEntry($id);
+ if (!event) {
+ return false;
+ }
+
+ // Get list of all recurrences
+ $recur = $Recurrences->getList("T.event = $id");
+ if ($recur) {
+
+ // For each recurrance for this event
+ foreach($recur as $k=>$v) {
+
+ // Delete all times and custom events
+ $this->deleteTimeEntriesForRecurrance($v['id'], true);
+
+ }
+ }
+
+ // Delete the event
+ $event = $this->deleteEntry($id, true);
+
+ return $event;
+
+ }
+
}
?>
* @release SVN: $Id: dataEvents.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
*/
-// Member Info Data required
-require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php');
-
/**
* GlmDataEvent class
*
* @release SVN: $Id: dataEvents.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
*/
-// Member Info Data required
-require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php';
-
/**
* GlmDataEvent class
*
'start_time' => array (
'field' => 'start_time',
'type' => 'datetime',
+ 'required' => true,
'use' => 'a'
),
+ // Start Date (for all-day events)
+ 'start_date' => array (
+ 'field' => 'start_time',
+ 'as' => 'start_date',
+ 'type' => 'date',
+ 'default' => time(),
+ 'required' => true,
+ 'use' => 'ne'
+ ),
+
// End Date & Time
'end_time' => array (
'field' => 'end_time',
'from_date' => array (
'field' => 'from_date',
'type' => 'date',
+ 'required' => true,
'use' => 'a'
),
'to_date' => array (
'field' => 'to_date',
'type' => 'date',
+ 'required' => true,
'use' => 'a'
),
* @release SVN: $Id: dataEvents.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
*/
-// Member Info Data required
-require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php');
-
/**
* GlmDataEvent class
*
+++ /dev/null
-<?php
-/**
- * Gaslight Media Members Database
- * Admin Member User Profile
- *
- * PHP version 5.5
- *
- * @category glmWordPressPlugin
- * @package glmMembersDatabase
- * @author Chuck Scott <cscott@gaslightmedia.com>
- * @license http://www.gaslightmedia.com Gaslightmedia
- * @release index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
- * @link http://dev.gaslightmedia.com/
- */
-
-// Load Contacts data abstract
-require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataEvents.php');
-
-class GlmMembersAdmin_events_add extends GlmDataEvents
-{
-
- /**
- * WordPress Database Object
- *
- * @var $wpdb
- * @access public
- */
- public $wpdb;
- /**
- * Plugin Configuration Data
- *
- * @var $config
- * @access public
- */
- public $config;
- /**
- * Contact Info
- *
- * @var $contactInfo
- * @access public
- */
- public $contactInfo = false;
- /**
- * Member ID
- *
- * @var $memberID
- * @access public
- */
- public $memberID = false;
- /**
- * Contact ID
- *
- * @var $contactID
- * @access public
- */
- public $contactID = false;
-
-
- /*
- * Constructor
- *
- * This contructor performs the work for this model. This model returns
- * an array containing the following.
- *
- * 'status'
- *
- * True if successfull and false if there was a fatal failure.
- *
- * '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.
- *
- * @wpdb object WordPress database object
- *
- * @return array Array containing status, suggested view, and any data
- */
- public function __construct ($wpdb, $config)
- {
-
- // Save WordPress Database object
- $this->wpdb = $wpdb;
-
- // Save plugin configuration object
- $this->config = $config;
-
- /*
- * Run constructor for the Contacts data class
- *
- * Note, the third parameter is a flag that indicates to the Contacts
- * data class that it should flag a group of fields as 'view_only'.
- */
-// parent::__construct(false, false, true);
-
-
- }
-
- public function modelAction($actionData = false)
- {
-
- $displayData = 'Welcome to more information!<br>This is the Events Add-On "events" model with action "more" talking to you from inside WordPress.';
- $eventsArray = array_filter($_REQUEST, function($k) {
- return preg_match('/^events_/',$k);
- }, ARRAY_FILTER_USE_KEY);
- echo "<hr />EventsArray:<table>";
- echo "<pre>";print_r($eventsArray,true);echo "</pre>";
- foreach($eventsArray as $key=>$value) {
- echo("<tr><td>$key</td><td>$value</td></tr>");
-
- }
- echo "</table><hr />";
-
- $option = $_REQUEST['option'];
- if($option == 'submit'){
- if (isset($_REQUEST['events_name']) && $_REQUEST['events_name'] != '') {
- $title = trim(filter_var($_REQUEST['events_name'],FILTER_SANITIZE_STRING));
-
- // sql query
- $sql = "
- INSERT INTO ". GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events
- (name)
- VALUES (" . "'$title '". ")
- ;";
- $this->wpdb->query($sql);
- }
- }
- // Compile template data
- $templateData = array(
- 'displayData' => $displayData
- );
-
- // Return status, any suggested view, and any data to controller
- return array(
- 'status' => true,
- 'modelRedirect' => false,
- 'view' => 'admin/events/add.html',
- 'data' => $templateData
- );
- }
-}
-
-
+++ /dev/null
-<?php
-/**
- * Gaslight Media Members Database
- * Admin Member User Profile
- *
- * PHP version 5.5
- *
- * @category glmWordPressPlugin
- * @package glmMembersDatabase
- * @author Chuck Scott <cscott@gaslightmedia.com>
- * @license http://www.gaslightmedia.com Gaslightmedia
- * @release index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
- * @link http://dev.gaslightmedia.com/
- */
-
-// Load Contacts data abstract
-require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataCategories.php');
-
-class GlmMembersAdmin_events_categories extends GlmDataEventsCategories
-{
-
- /**
- * WordPress Database Object
- *
- * @var $wpdb
- * @access public
- */
- public $wpdb;
- /**
- * Plugin Configuration Data
- *
- * @var $config
- * @access public
- */
- public $config;
- /**
- * Contact Info
- *
- * @var $contactInfo
- * @access public
- */
- public $contactInfo = false;
- /**
- * Member ID
- *
- * @var $memberID
- * @access public
- */
- public $memberID = false;
- /**
- * Contact ID
- *
- * @var $contactID
- * @access public
- */
- public $contactID = false;
-
-
- /*
- * Constructor
- *
- * This contructor performs the work for this model. This model returns
- * an array containing the following.
- *
- * 'status'
- *
- * True if successfull and false if there was a fatal failure.
- *
- * '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.
- *
- * @wpdb object WordPress database object
- *
- * @return array Array containing status, suggested view, and any data
- */
- public function __construct ($wpdb, $config)
- {
-
- // Save WordPress Database object
- $this->wpdb = $wpdb;
-
- // Save plugin configuration object
- $this->config = $config;
-
- /*
- * Run constructor for the Contacts data class
- *
- * Note, the third parameter is a flag that indicates to the Contacts
- * data class that it should flag a group of fields as 'view_only'.
- */
-// parent::__construct(false, false, true);
-
-
- }
-
- public function modelAction($actionData = false)
- {
-
- $displayData = 'Welcome to more information!<br>This is the Events Add-On "events" model with action "more" talking to you from inside WordPress.';
- $Categories = new GlmDataEventsCategories($this->wpdb, $this->config);
- $categoriesStats = $Categories->getStats();
- $haveCategories = ($categoriesStats > 0);
-
- if($_REQUEST['Action'] == 'Add Topic'){
- if(isset($_REQUEST['topic'])){
- $title = trim(filter_var($_REQUEST['topic'],FILTER_SANITIZE_STRING));
-
- // sql query
- $sql = "
- INSERT INTO ". GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "categories
- (name)
- VALUES ("."'$title'".")
- ;";
- $this->wpdb->query($sql);
- }
- }
-
-
-
- // retrieve category names
- $entries = $Categories->getList();
- foreach($entries as $keys=>$value){
- $index[] = $keys;
- }
-
- foreach($index as $id){
- $entries[] = $Categories->getEntry($id);
- $names[] = $entries[$id]['name'];
- }
-
-// echo '<pre>', print_r($names, true), '</pre>';
- // Compile template data
- $templateData = array(
- 'displayData' => $displayData,
- 'categoryNames' => $names
- );
- // Return status, any suggested view, and any data to controller
- return array(
- 'status' => true,
- 'modelRedirect' => false,
- 'view' => 'admin/events/categories.html',
- 'data' => $templateData
- );
- }
-}
<?php
/**
* Gaslight Media Members Database
- * Admin Member User Profile
+ * Admin Events Dashboard
*
* PHP version 5.5
*
*/
public $config;
/**
- * Contact Info
+ * Event ID
*
- * @var $contactInfo
+ * @var $eventID
* @access public
*/
- public $contactInfo = false;
- /**
- * Member ID
- *
- * @var $memberID
- * @access public
- */
- public $memberID = false;
- /**
- * Contact ID
- *
- * @var $contactID
- * @access public
- */
- public $contactID = false;
-
+ public $eventID = false;
/*
* Constructor
$this->config = $config;
/*
- * Run constructor for the Contacts data class
+ * Run constructor for the Events data class
*
* Note, the third parameter is a flag that indicates to the Contacts
* data class that it should flag a group of fields as 'view_only'.
*/
-// parent::__construct(false, false, true);
-
+ parent::__construct(false, false, true);
}
public function modelAction($actionData = false)
{
- $displayData = 'Hello, World! This is the Events Add-On "events" model talking to you from inside WordPress.';
-
-// // Return status, any suggested view, and any data to controller
-// return array(
-// 'status' => true,
-// 'modelRedirect' => false,
-// 'view' => 'admin/events/index.html',
-// 'data' => $templateData
-// );
-//
-
-
-//
-// // Check for required Event Categories
- require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataEventCategories.php');
- $eventCategories = new GlmDataEventsEventCategories($this->wpdb, $this->config);
- $eventCategoriesStats = $eventCategories->getStats();
- $eventHaveCategories = ($eventCategoriesStats > 0);
-
- require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataLocations.php');
- $Locations = new GlmDataEventsLocations($this->wpdb, $this->config);
- $locationsStats = $Locations->getStats();
- $haveLocations = ($locationsStats > 0);
-
- require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataRecurrences.php');
- $Recurrences = new GlmDataEventsRecurrences($this->wpdb, $this->config);
- $recurrencesStats = $Recurrences->getStats();
- $haveRecurrences = ($recurrencesStats > 0);
-
- require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataTimes.php');
- $Times = new GlmDataEventsTimes($this->wpdb, $this->config);
- $timesStats = $Times->getStats();
- $haveTimes = ($timesStats > 0);
-
-
-
- $eventEntries = new GlmDataEvents($this->wpdb, $this->config);
-
- $entries = $eventEntries->getList();
- foreach($entries as $keys=>$value){
- $index[] = $keys;
+ $numbEvents = 0;
+ $numbPending = 0;
+ $haveCategories = false;
+
+ // Check for required Event Categories
+ require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataCategories.php');
+ $EventCategories = new GlmDataEventsCategories($this->wpdb, $this->config);
+ $eventCategoriesStats = $EventCategories->getStats();
+ if ($eventCategoriesStats && $eventCategoriesStats > 0) {
+ $haveCategories = true;
+ }
+
+ // Get list of events
+ $events = $this->getList();
+ if ($events) {
+ $numbEvents = count($events);
}
-
- foreach($index as $id){
- $entries[] = $eventEntries->getEntry($id);
- $names[] = $entries[$id]['name'];
+
+ // Get list of Pending Events
+ $pending = $this->getList('T.status = '.$this->config['status_numb']['Pending']);
+ if ($pending) {
+ $numbPending = count($pending);
}
-// echo '<pre>', print_r($names, true), '</pre>';
- // Compile template data
+
+
+ // Compile template data
$templateData = array(
- 'displayData' => $displayData,
- 'title' => $names
+ 'events' => $events,
+ 'numbEvents' => $numbEvents,
+ 'pending' => $pending,
+ 'numbPending' => $numbPending,
+ 'haveCategories' => $haveCategories
);
// Return status, any suggested view, and any data to controller
return array(
--- /dev/null
+<?php
+/**
+ * Gaslight Media Members Database
+ * Admin Events List
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link http://dev.gaslightmedia.com/
+ */
+
+// Load Contacts data class
+require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataEvents.php');
+
+// Load event categories data class
+require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataCategories.php');
+require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataEventCategories.php');
+
+class GlmMembersAdmin_events_list extends GlmDataEvents
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+ /**
+ * Event ID
+ *
+ * @var $eventID
+ * @access public
+ */
+ public $eventID = false;
+
+ /*
+ * Constructor
+ *
+ * This contructor performs the work for this model. This model returns
+ * an array containing the following.
+ *
+ * 'status'
+ *
+ * True if successfull and false if there was a fatal failure.
+ *
+ * '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.
+ *
+ * @wpdb object WordPress database object
+ *
+ * @return array Array containing status, suggested view, and any data
+ */
+ public function __construct ($wpdb, $config)
+ {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ /*
+ * Run constructor for the Contacts data class
+ *
+ * Note, the third parameter is a flag that indicates to the Contacts
+ * data class that it should flag a group of fields as 'view_only'.
+ */
+ parent::__construct(false, false, true);
+
+ }
+
+ public function modelAction($actionData = false)
+ {
+
+ $numbEvents = 0;
+ $option = 'list';
+ $events = false;
+ $event = false;
+ $haveEvent = false;
+ $this->eventID = false;
+ $eventUpdated = false;
+ $eventUpdateError = false;
+ $eventAdded = false;
+ $eventAddError = false;
+ $view = 'list';
+ $filterArchived = false;
+ $filterPending = false;
+ $eventDeleted = false;
+ $eventDeleteError = false;
+ $recurrences = false;
+
+ // Get a list of categories
+ $Categories = new GlmDataEventsCategories($this->wpdb, $this->config);
+ $categories = $Categories->getListSortedParentChild(false);
+
+ // Load recurrences data class to deal with event times
+ require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataRecurrences.php');
+ $Recurrences = new GlmDataEventsRecurrences($this->wpdb, $this->config);
+ $newRecurrence = $Recurrences->newEntry();
+
+ // Get any provided option
+ if (isset($_REQUEST['option'])) {
+ $option = $_REQUEST['option'];
+ }
+
+ // Get event ID if supplied
+ if (isset($_REQUEST['event'])) {
+
+ // Make sure it's numeric
+ $this->eventID = ($_REQUEST['event'] - 0);
+
+ if ($this->eventID <= 0) {
+ $this->eventID = false;
+ } else {
+
+ // Get recurrences for this event
+ $recurrences = $Recurrences->getList("T.event = ".$this->eventID);
+
+ }
+ }
+
+
+
+ // Do selected option
+ switch ($option) {
+
+ case 'add':
+
+ $event = $this->newEntry();
+
+ $view = 'edit';
+
+ break;
+
+ case 'insert':
+
+ $this->updateCategories();
+ $categories = $Categories->getListSortedParentChild(false);
+
+ $event = $this->insertEntry();
+
+ if ($event['status']) {
+ $this->eventID = $event['fieldData']['id'];
+ $haveEvent = true;
+ $eventAdded = true;
+
+ // Update created timestamp and name slug for URLs
+ $this->updateTimestamp('created', $this->eventID);
+ $this->updateSlug($this->eventID);
+
+ // Get this again so we have the created date
+ $event = $this->editEntry($this->eventID);
+
+ $option = 'edit';
+ $eventAdded = true;
+
+ } else {
+ $option = 'add';
+ $eventAddError = true;
+ }
+
+ $view = 'edit';
+
+ break;
+
+ case 'edit':
+
+ $event = $this->editEntry($this->eventID);
+
+ if ($event['status']) {
+ $haveEvent = true;
+ }
+
+ $view = 'edit';
+
+ // Get any recurrence entries
+
+
+ break;
+
+ case 'update':
+
+ $this->updateCategories();
+ $categories = $Categories->getListSortedParentChild(false);
+
+ // Try to update this event
+ $event = $this->updateEntry($this->eventID);
+
+ // Check if that was successful
+ if ($event['status']) {
+ $eventUpdated = true;
+
+ // Update updated timestamp and name slug for URLs
+ $this->updateTimestamp('updated', $this->eventID);
+ $this->updateSlug($this->eventID);
+
+ $event = $this->editEntry($this->eventID);
+ } else {
+ $eventUpdateError = true;
+ }
+
+ $haveEvent = true;
+ $view = 'edit';
+
+ break;
+
+ case 'delete':
+
+ $event = $this->deleteEvent($this->eventID);
+
+ if ($event) {
+ $eventDeleted = true;
+ } else {
+ $eventDeleteError = true;
+ }
+
+ case 'list':
+ default:
+
+ // Add "selected" element default false;
+ reset($categories);
+ while (list($k, $v) = each($categories)) {
+ $categories[$k]['selected'] = false;
+ }
+
+ // Determine number of events in list
+ $events = $this->getList();
+ if ($events) {
+ $numbEvents = count($events);
+ }
+
+ break;
+
+ }
+
+ $templateData = array(
+ 'option' => $option,
+ 'events' => $events,
+ 'event' => $event,
+ 'haveEvent' => $haveEvent,
+ 'eventID' => $this->eventID,
+ 'eventUpdated' => $eventUpdated,
+ 'eventUpdateError' => $eventUpdateError,
+ 'eventAdded' => $eventAdded,
+ 'eventAddError' => $eventAddError,
+ 'numbEvents' => $numbEvents,
+ 'categories' => $categories,
+ 'filterArchived' => $filterArchived,
+ 'filterPending' => $filterPending,
+ 'eventDeleted' => $eventDeleted,
+ 'eventDeleteError' => $eventDeleteError,
+ 'recurrences' => $recurrences,
+ 'newRecurrence' => $newRecurrence
+ );
+
+ // Return status, any suggested view, and any data to controller
+ return array(
+ 'status' => true,
+ 'modelRedirect' => false,
+ 'view' => "admin/events/$view.html",
+ 'data' => $templateData
+ );
+
+ }
+
+ /*
+ * Update categories for the current submission
+ *
+ * @return void
+ */
+ public function updateCategories()
+ {
+
+ // Instatiate the dataCategories class
+ $Categories = new GlmDataEventsCategories($this->wpdb, $this->config);
+
+ // Instatiate Event/Categories data class
+ $EventCategories = new GlmDataEventsEventCategories($this->wpdb, $this->config);
+
+ // Get any selected categories
+ $selectedCategories = array();
+ $newCategory = false;
+ if (isset($_REQUEST['category']) && is_array($_REQUEST['category']) && count($_REQUEST['category']) > 0) {
+
+ /*
+ * For each selected category
+ *
+ * Note that categories are submitted with either a positive key, which indicates
+ * that it represents an existing category, or a negative key, which indicates
+ * that the user is trying to add it to the list of categories.
+ *
+ */
+ foreach ($_REQUEST['category'] as $key) {
+
+ // Make sure key is an integer
+ $key = intval($key -0);
+
+ // If negative, this is a new category that needs to be added to the category table
+ if ($key < 0) {
+
+ $newCategory = true;
+
+ // Check if a parent is specified
+ $parent = 0;
+ if ($_REQUEST['newCatParent'][$key] != '') {
+ $parent = $_REQUEST['newCatParent'][$key] -0;
+ } elseif ($_REQUEST['newCatParentName'][$key]) {
+ $parent = $_REQUEST['newCatParentName'][$key];
+ }
+
+ // Clean up the category name
+ $category = filter_var($_REQUEST['newCategory'][$key]);
+
+ // Add it to the category table and get the new category ID
+ $categoryID = $Categories->addCategory($category, $parent);
+
+ // If we got a new category ID, add it to the array of currently selected eventCategory records
+ if ($categoryID) {
+ $selectedCategories[$categoryID] = $categoryID;
+ }
+
+ // Otherwise if it's positive, the category is an existing one
+ } else if ($key > 0) {
+
+ $selectedCategories[$key] = $key;
+
+ }
+
+ // If there's selected categories
+ if (count($selectedCategories) > 0) {
+
+ // Update the selected categories for this event record, returns new list
+ $EventCategories->setEventCategories($this->eventID, $selectedCategories);
+
+ }
+
+ // If there's been a new category
+ if ($newCategory) {
+
+ // Get the full category list again
+ $this->categories = $Categories->getListSortedParentChild();
+
+ }
+
+ } // For each category being submitted
+
+ // Otherwise if this is a submission and there's no categories submitted, so make sure there's none stored
+ } elseif (isset($_REQUEST['option']) && $_REQUEST['option'] == 'submit') {
+ $EventCategories->clearEventCategories($this->eventID);
+ }
+
+ }
+
+
+
+}
+++ /dev/null
-<?php
-/**
- * Gaslight Media Members Database
- * Admin Member User Profile
- *
- * PHP version 5.5
- *
- * @category glmWordPressPlugin
- * @package glmMembersDatabase
- * @author Chuck Scott <cscott@gaslightmedia.com>
- * @license http://www.gaslightmedia.com Gaslightmedia
- * @release index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
- * @link http://dev.gaslightmedia.com/
- */
-
-// Load Contacts data abstract
-//require_once(GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH.'/data/dataContacts.php');
-
-class GlmMembersAdmin_events_more // extends GlmDataContacts
-{
-
- /**
- * WordPress Database Object
- *
- * @var $wpdb
- * @access public
- */
- public $wpdb;
- /**
- * Plugin Configuration Data
- *
- * @var $config
- * @access public
- */
- public $config;
- /**
- * Contact Info
- *
- * @var $contactInfo
- * @access public
- */
- public $contactInfo = false;
- /**
- * Member ID
- *
- * @var $memberID
- * @access public
- */
- public $memberID = false;
- /**
- * Contact ID
- *
- * @var $contactID
- * @access public
- */
- public $contactID = false;
-
-
- /*
- * Constructor
- *
- * This contructor performs the work for this model. This model returns
- * an array containing the following.
- *
- * 'status'
- *
- * True if successfull and false if there was a fatal failure.
- *
- * '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.
- *
- * @wpdb object WordPress database object
- *
- * @return array Array containing status, suggested view, and any data
- */
- public function __construct ($wpdb, $config)
- {
-
- // Save WordPress Database object
- $this->wpdb = $wpdb;
-
- // Save plugin configuration object
- $this->config = $config;
-
- /*
- * Run constructor for the Contacts data class
- *
- * Note, the third parameter is a flag that indicates to the Contacts
- * data class that it should flag a group of fields as 'view_only'.
- */
-// parent::__construct(false, false, true);
-
-
- }
-
- public function modelAction($actionData = false)
- {
-
- $displayData = 'Welcome to more information!<br>This is the Events Add-On "events" model with action "more" talking to you from inside WordPress.';
-
- // Compile template data
- $templateData = array(
- 'displayData' => $displayData
- );
-
- // Return status, any suggested view, and any data to controller
- return array(
- 'status' => true,
- 'modelRedirect' => false,
- 'view' => 'admin/events/more.html',
- 'data' => $templateData
- );
-
- }
-
-
-}
<?php
/**
* Gaslight Media Members Database
- * Admin Member User Profile
+ * Admin Events List
*
* PHP version 5.5
*
// Load Contacts data abstract
require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataEvents.php');
-class GlmMembersAdmin_member_events extends GlmDataEvents
+class GlmMembersAdmin_events_list extends GlmDataEvents
{
+
/**
* WordPress Database Object
*
*/
public $config;
/**
- * Contact Info
- *
- * @var $contactInfo
- * @access public
- */
- public $contactInfo = false;
- /**
- * Member ID
+ * Event ID
*
- * @var $memberID
+ * @var $eventID
* @access public
*/
- public $memberID = false;
- /**
- * Contact ID
- *
- * @var $contactID
- * @access public
- */
- public $contactID = false;
-
+ public $eventID = false;
/*
* Constructor
* Note, the third parameter is a flag that indicates to the Contacts
* data class that it should flag a group of fields as 'view_only'.
*/
-// parent::__construct(false, false, true);
-
+ parent::__construct(false, false, true);
}
public function modelAction($actionData = false)
{
- $displayData = 'This is the Events "Members" "Events" model talking to you from inside WordPress.';
+ $numbEvents = 0;
+ $option = 'list';
+ $events = false;
+ $event = false;
+ $haveEvent = false;
+ $eventID = false;
+ $eventUpdated = false;
+ $eventUpdateError = false;
+ $view = 'list';
- // Get the Member ID
- $memberID = 0;
- if (isset($_REQUEST['member']) && ($_REQUEST['member']-0) > 0) {
- $memberID = $_REQUEST['member'] - 0;
- }
- if ($memberID == 0) {
- // There should have been a member ID - So failure
- return array(
- 'status' => false,
- 'menuItemRedirect' => 'error',
- 'modelRedirect' => 'index',
- 'view' => 'admin/error/index.html',
- 'data' => false
- );
+ // Get a list of categories
+ require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataCategories.php');
+ $Categories = new GlmDataEventsCategories($this->wpdb, $this->config);
+ $categories = $Categories->getListSortedParentChild(false);
+ // Get any provided option
+ if (isset($_REQUEST['option'])) {
+ $option = $_REQUEST['option'];
}
-
- $option = $_REQUEST['option'];
- echo $memberID;
- echo "<hr />Request:<table>";
- foreach($_REQUEST as $key=>$value) {
- echo("<tr><td>$key</td><td>$value</td></tr>");
- }
- echo "</table>";
- $eventsArray = array_filter($_REQUEST, function($k) {
- return preg_match('/^events_/',$k);
- }, ARRAY_FILTER_USE_KEY);
- echo "<hr />EventsArray:<table>";
- echo "<pre>";print_r($eventsArray,true);echo "</pre>";
- foreach($eventsArray as $key=>$value) {
- echo("<tr><td>$key</td><td>$value</td></tr>");
- }
- echo "</table><hr />";
- if($option == 'submit'){
- if (isset($_REQUEST['title'])) {
- $title = trim(filter_var($_REQUEST['title'],FILTER_SANITIZE_STRING));
+
+ // Get event ID if supplied
+ if (isset($_REQUEST['event'])) {
+
+ // Make sure it's numeric
+ $eventID = ($_REQUEST['event'] - 0);
+
+ if ($eventID <= 0) {
+ $eventID = false;
+ }
}
-// $sql = "
-// INSERT INTO ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events
-// (id,name)
-// VALUES ('3', '" . $title . "')
-// ;";
-
- $this->wpdb->query($sql);
+
+ // Do selected option
+ switch ($option) {
+
+ case 'add':
+
+ $event = $this->newEntry();
+
+ $view = 'edit';
+
+ break;
+
+ case 'insert':
+
+ $event = $this->insertEntry();
+ if ($event['status']) {
+ $eventID = $event['id'];
+ $haveEvent = true;
+ $eventUpdated = true;
+ } else {
+ $option = 'add';
+ }
+
+ $view = 'edit';
+
+ break;
+
+ case 'edit':
+
+ $event = $this->editEntry($eventID);
+
+ if ($event['status']) {
+ $haveEvent = true;
+ }
+ $view = 'edit';
+
+ break;
+
+ case 'update':
+
+ // Try to update this event
+ $event = $this->updateEntry($eventID);
+
+ // Check if that was successful
+ if ($event['status']) {
+ $eventUpdated = true;
+ $event = $this->editEntry($eventID);
+ } else {
+ $eventUpdateError = true;
+ }
+
+ $haveEvent = true;
+ $view = 'edit';
+
+ break;
+
+ case 'list':
+ default:
+
+ // Add "selected" element default false;
+ reset($categories);
+ while (list($k, $v) = each($categories)) {
+ $categories[$k]['selected'] = false;
+ }
+
+ // Determine number of events in list
+ $events = $this->getList();
+ if ($events) {
+ $numbEvents = count($events);
+ }
+
+ break;
+
}
+
$templateData = array(
- 'displayData' => $displayData,
- 'haveMember' => $haveMember,
- 'memberID' => $memberID,
- 'option' => $option
+ 'option' => $option,
+ 'events' => $events,
+ 'event' => $event,
+ 'haveEvent' => $haveEvent,
+ 'eventID' => $eventID,
+ 'eventUpdated' => $eventUpdated,
+ 'eventUpdateError' => $eventUpdateError,
+ 'numbEvents' => $numbEvents,
+ 'categories' => $categories
);
+
// Return status, any suggested view, and any data to controller
return array(
'status' => true,
'modelRedirect' => false,
- 'view' => 'admin/member/events.html',
+ 'view' => "admin/events/$view.html",
'data' => $templateData
);
-
+
}
--- /dev/null
+<?php
+/**
+ * Gaslight Media Members Database
+ * Admin Event Categories List
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.1
+ */
+
+// Load Event Categories data abstract
+require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataCategories.php');
+
+/*
+ * This class performs the work for the default action of the "Members" menu
+ * option, which is to display the members dashboard.
+ *
+ */
+class GlmMembersAdmin_settings_eventCategories extends GlmDataEventsCategories
+{
+
+ /**
+ * 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 controller 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)
+ {
+
+ $success = true;
+ $haveCategories = false;
+ $categories = false;
+ $error = false;
+
+ // Check if a category ID is supplied
+ $id = 0;
+ if (isset($_REQUEST['id'])) {
+ $id = $_REQUEST['id']-0;
+ }
+
+ // If there's an action option
+ if (isset($_REQUEST['option'])) {
+
+ switch($_REQUEST['option']) {
+
+ case 'addNew':
+ $this->insertEntry();
+ break;
+
+ case 'update':
+ if ($id > 0) {
+ $this->updateEntry($id);
+ }
+ break;
+
+ case 'delete':
+ if ($id > 0) {
+ $this->deleteEntry($id, true);
+
+ // Also delete from member info
+ $this->wpdb->delete(
+ GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'event_categories',
+ array(
+ 'category' => $id
+ )
+ );
+ }
+ break;
+
+ }
+
+ }
+
+ // Get a current list of categories
+ $categories = $this->getList();
+
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
+ glmMembersAdmin::addNotice($categories, 'DataBlock', 'Category Data');
+ }
+
+ // If we have list entries - even if it's an empty list
+ $success = true;
+ $haveCategories = false;
+ if ($categories !== false) {
+
+ $success = true;
+
+ // If we have any entries
+ if (count($categories) > 0) {
+ $haveCategories = true;
+ }
+ }
+
+ // If we had a fatal error, redirect to the error page
+ if ($error) {
+ return array(
+ 'status' => $success,
+ 'menuItemRedirect' => 'error',
+ 'modelRedirect' => 'index',
+ 'view' => 'admin/error/index.html',
+ 'data' => false
+ );
+ }
+
+ // Sort results by higherarchy (Parent/Child and Alpha)
+ $categories = $this->sortParentChild($categories);
+
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
+ glmMembersAdmin::addNotice($categories, 'DataBlock', 'Categories Data');
+ }
+
+ // Compile template data
+ $templateData = array(
+ 'haveCategories' => $haveCategories,
+ 'categories' => $categories
+ );
+
+ // Return status, suggested view, and data to controller
+ return array(
+ 'status' => $success,
+ 'menuItemRedirect' => false,
+ 'modelRedirect' => false,
+ 'view' => 'admin/settings/eventCategories.html',
+ 'data' => $templateData
+ );
+
+ }
+
+
+}
false, // Icon URL
'92' // Menu Position
);
- add_submenu_page(
+
+add_submenu_page(
'glm-members-admin-menu-events', // Parent slug
- 'Add Event', // Page title
- 'Add Event', // Menu Title
+ 'Add Event', // Page title
+ 'Add Event', // Menu Title
'glm_members_members', // Capability required
- 'glm-members-admin-menu-events-add', // Menu slug
+ 'glm-members-admin-menu-events-add', // Menu slug
function() {$this->controller('add');}
);
- add_submenu_page(
- 'glm-members-admin-menu-events', // Parent slug
- 'Event Categories', // Page title
- 'Event Categories', // Menu Title
+
+add_submenu_page(
+ 'glm-members-admin-menu-members', // Parent slug
+ 'Events', // Page title
+ 'Events', // Menu Title
'glm_members_members', // Capability required
- 'glm-members-admin-menu-events-categories', // Menu slug
- function() {$this->controller('categories');}
+ 'glm-members-admin-menu-events-index', // Menu slug
+ function() {$this->controller('events');}
);
add_submenu_page(
'glm-members-admin-menu-members', // Parent slug
- 'Events', // Page title
- 'Events', // Menu Title
- 'glm_members_members', // Capability required
- 'glm-members-admin-menu-members-events', // Menu slug
- function() {$this->controller('events');}
+ 'Events List', // Page title
+ ' List', // Menu Title
+ 'glm_members_members', // Capability required
+ 'glm-members-admin-menu-events-list', // Menu slug
+ function() {$this->controller('events', 'list');}
);
*
*/
-//add_filter('glm-member-db-add-tab-for-members',
-// function($addOnTabs) {
-// $newTabs = array(
-// array(
-// 'text' => 'Events',
-// 'menu' => 'members',
-// 'action' => 'events'
-// ),
-// );
-// $addOnTabs = array_merge($addOnTabs, $newTabs);
-// return $addOnTabs;
-// }
-//);
add_filter('glm-member-db-add-tab-for-member',
function($addOnTabs) {
$newTabs = array(
}
);
-add_filter('glm-member-db-add-tab-for-events',
+add_filter('glm-member-db-add-tab-for-settings',
function($addOnTabs) {
$newTabs = array(
array(
- 'text' => 'Add Event',
- 'menu' => 'events',
- 'action' => 'add'
+ 'text' => 'Event Categories',
+ 'menu' => 'settings',
+ 'action' => 'eventCategories'
),
);
}
);
+
add_filter('glm-member-db-add-tab-for-events',
function($addOnTabs) {
$newTabs = array(
major BOOLEAN NULL, -- Option to mark as a major event
name TINYTEXT NULL, -- Name of this event
name_slug TINYTEXT NULL, -- Slug for this event
- header TINYTEXT NULL, -- Header text for front-end display
+ header TINYTEXT NULL, -- Header text for front-end display - NOT CURRENTLY USED
intro TINYTEXT NULL, -- Intro text for front-end display
descr TEXT NULL, -- Full description text
image TINYTEXT NULL, -- Image file name
$glmMembersEventsAddOnValidActions = array(
'adminActions' => array(
- 'members' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
- 'event'=> GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
'member' => array(
'events' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
- 'add' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
- 'categories' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
),
'events' => array(
'index' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
- 'add' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
- 'categories' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG
+ 'list' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
+ ),
+ 'settings' => array(
+ 'eventCategories' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG
),
'management' => array(
'events' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG
+++ /dev/null
-{include file='admin/events/header.html'}
- <a id="dateTimeLink" href="#"> Event Details </a>
- <div id="dateTime">
- <form action="{$thisURL}?page={$thisPage}&glm_action=add" method="post" enctype="multipart/form-data">
- <p> Event Name </p>
- <input name="events_name" type="text" id="eventName">
- <select name="events_category" id="category">
- <option> Category</option></select>
- <p> All Day</p>
- <input name="events_allDay" type="checkbox">
- <p> Active?</p>
- <input name="events_active" type="checkbox">
- <select name="events_partner" id="partner">
- <option> Partner </option></select>
- <p> Start Date</p>
- <input name="events_startDate" id="startDate" type="text">
- <p> End Date</p>
- <input name="events_endDate" id="endDate" type="text">
- <p> Start Time </p>
- <input name="events_startTime" id="startTime" type="text">
- <p> End Time</p>
- <input name="events_endtime" id="endTime" type="text">
- <p> Recurring </p>
- <input name="events_recurring" type="checkbox">
-
- </div>
- <a id="location" href="#"> Location Details </a>
- <div id="locationDetails">
-
- <p> Hide Event Address </p>
- <input name="events_hide" type="checkbox">
- <p> Place </p>
- <input type="text" name="events_place" id="place">
- <p> Address </p>
- <input type="text" name="events_address" id="address">
- <p> City </p>
- <input type="text" name="events_city" id="city">
- <p> State</p>
- <input type="text" name="events_state" id="state">
- <p> ZIP Code </p>
- <input type="text" name="events_zip" id="zip">
-
-
- </div>
- <a id="cost" href="#"> Cost and tickets </a>
- <div id="costDetails">
-
- <p> Cost</p>
- <input name="events_cost" id="costInput" type="text">
- <p> Free Event </p>
- <input id="freeEvent" name="events_freeEvent" type="checkbox">
- <p> Website </p>
- <input name="events_website" id="website" type="text">
-
- </div>
- <a id="admin" href="#"> Event Contact Information </a>
- <div id="adminDetails">
-
- <p> Contact Name</p>
- <input name="events_adminName" id="contactName" type="text">
- <p> Contact Phone</p>
- <input name="events_adminPhone" id="contactPhone" type="text">
- <p> Contact Email</p>
- <input name="events_adminEmail" id="contactEmail" type="text">
-
- </div>
- <a id="eventAdmin" href="#"> Event Admin Information </a>
- <div id="eventAdminDetails">
-
- <p> Contact Name Submitting Event</p>
- <input id="contactName" type="text">
- <p> Organization Name Submitting Event</p>
- <input name="events_contactName" id="contactName" type="text">
- <p> Contact Phone</p>
- <input name="events_contactName" id="contactPhone" type="text">
- <p> Contact Email</p>
- <input name="events_contactEmail" id="contactEmail" type="text">
- <p> Notes </p>
- <textarea name="events_notes" id="notes"> </textarea>
-
-
- </div>
- <input type="submit" class="button glm-button submit" value="submit">
- <input type="hidden" name="option" value="submit">
- </form>
- </body>
-
-
+++ /dev/null
-{include file='admin/events/header.html'}
-<div class="wrap">
- <div id="glm-admin-content-container">
- <div class="topic-row">
- <form action="" method="post">
- <table>
- <tbody>
- <tr>
- <td>Add New Category:</td>
- <td><input name="topic" value=""></td>
- <td><input name="Action" value="Add Topic" type="hidden"><input value="Create Category" type="submit"></td>
- </tr>
-
- {foreach from=$categoryNames key=k item=category}
- <tr>
- <td><input class="catField" type="text" value="{$category}"></td>
- </tr>
- {/foreach}
-
- </tbody>
- </table>
- </form>
- </div>
- </div>
-</div>
\ No newline at end of file
--- /dev/null
+{include file='admin/events/header.html'}
+
+{if apply_filters('glm_members_permit_admin_members_packaging_edit_package', true)}
+
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=list" class="button button-primary glm-button glm-right">Return to Events List</a>
+
+ {if $option == 'edit'}
+ <a id="deleteEventButton" class="button button-primary glm-button glm-right">Delete this Event</a>
+
+ <h2>Edit Event</h2>
+ {else}
+ <h2>Add new Event</h2>
+ {/if}
+
+
+ <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="glm_action" value="list">
+ <input type="hidden" name="ref_type" value="0">
+ <input type="hidden" name="ref_dest" value="0">
+ {if $haveEvent}
+ <input type="hidden" name="option" value="update">
+ <input type="hidden" name="event" value="{$event.fieldData.id}">
+ {else}
+ <input type="hidden" name="option" value="insert">
+ {/if}
+
+ <h2 class="nav-tab-wrapper" style="margin-bottom: 1em;">
+ <a id="glm-event-descr" data-show-table="glm-table-descr" class="glm-event-tab nav-tab nav-tab-active">Status & Description</a>
+ <a id="glm-event-location" data-show-table="glm-table-location" class="glm-event-tab nav-tab">Location</a>
+ <a id="glm-event-recurrence" data-show-table="glm-table-recurrence" class="glm-event-tab nav-tab">Event Schedule</a>
+ <a id="glm-event-calendar" data-show-table="glm-table-calendar" class="glm-event-tab nav-tab">Calendar</a>
+ {if $eventUpdated}<span class="glm-notice glm-flash-updated glm-right">Event Updated</span>{/if}
+ {if $eventUpdateError}<span class="glm-error glm-flash-updated glm-right">Event Update Error</span>{/if}
+ {if $eventAdded}<span class="glm-notice glm-flash-updated glm-right">Event Added</span>{/if}
+ {if $eventAddError}<span class="glm-error glm-flash-updated glm-right">Event Add Error</span>{/if}
+ </h2>
+
+ <!-- Status and Description -->
+
+ <table id="glm-table-descr" class="glm-admin-table glm-event-table">
+ <tr>
+ <th {if $event.fieldRequired.name}class="glm-required"{/if}>Event Name:</th>
+ <td {if $event.fieldFail.name}class="glm-form-bad-input" data-tabid="glm-event-descr"{/if}>
+ <input type="text" name="name" value="{$event.fieldData.name}" class="glm-form-text-input-medium" placeholder="Name of this event.">
+ {if $event.fieldFail.name}<p>{$event.fieldFail.name}</p>{/if}<br>
+ </td>
+ </tr>
+ {if $haveEvent}
+ <tr>
+ <th>Name for URLs:</th>
+ <td>{$event.fieldData.name_slug}</td>
+ </tr>
+ <tr>
+ <th>Created:</th>
+ <td>{$event.fieldData.created.datetime}</td>
+ </tr>
+ <tr>
+ <th>Last Updated:</th>
+ <td>{$event.fieldData.updated.datetime}</td>
+ </tr>
+ <tr>
+ <th>Last Approved:</th>
+ <td>{$event.fieldData.approved.datetime}</td>
+ </tr>
+ {/if}
+ <tr>
+ <th>Status:</th>
+ <td>
+ <select name="status">
+ {foreach from=$event.fieldData.status.list item=v}
+ <option value="{$v.value}"{if $v.default} selected{/if}>{$v.name}</option>
+ {/foreach}
+ </select>
+ {if $event.fieldFail.status}<p>{$event.fieldFail.status}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th>Hide Member Address:</th>
+ <td>
+ <input type="checkbox" name="hide_address" {if $event.fieldData.hide_address.value} checked{/if}>
+ </td>
+ </tr>
+ <tr>
+ <th>Featured Event:</th>
+ <td>
+ <input type="checkbox" name="featured" {if $event.fieldData.featured.value} checked{/if}>
+ </td>
+ </tr>
+ <tr>
+ <th>Include in Slideshow:</th>
+ <td>
+ <input type="checkbox" name="slideshow" {if $event.fieldData.slideshow.value} checked{/if}>
+ </td>
+ </tr>
+ <tr>
+ <th>Major Event:</th>
+ <td>
+ <input type="checkbox" name="major" {if $event.fieldData.major.value} checked{/if}>
+ </td>
+ </tr>
+ <tr>
+ <th>Categories</th>
+ <td class="glm-item-container">
+
+ <!-- Add new category dialog -->
+
+ <div id="newCategoryButton" class="button button-secondary glm-right">Add a new Category</div>
+ <div id="newCategoryDialog" class="glm-dialog-box" title="Enter a New Category">
+ <table class="glm-admin-table">
+ <tr>
+ <th class="glm-required">Category Name:</th>
+ <td id="newCatNameTD">
+ <input id="newCatName" type="text" name="newCatName" class="glm-form-text-input">
+ <div id="newCatNameRequired"></div>
+ </td>
+ </tr>
+ <tr>
+ <th>Parent Category:</th>
+ <td>
+ <select id="newCatParent" name="newCatParent">
+ {if $categories}
+ <option value=""></option>
+ {foreach $categories as $t}
+ {if !$t.parent} <!-- don't show child categories -->
+ <option value="{$t.id}" data-parent="{$t.name}">{$t.name}</option>
+ {/if}
+ {/foreach}
+ {/if}
+ </select>
+ <br>OR<br>
+ <input id="newCatParentName" type="text" name="newCatParentName" placeholder="Enter a new parent name.">
+ </td>
+ </tr>
+ </table>
+ <p><span class="glm-required">*</span> Required</p>
+ <a id="newCategoryCancel" class="button button-primary glm-right">Cancel</a>
+ <input id="newCategorySubmit" type="submit" value="Add new Category">
+ </div>
+
+ <!-- Category Selection -->
+
+ <select name="categorySelect" id="categorySelect">
+ {if $categories}
+ <option id="categoryNone" value=""></option>
+ {foreach from=$categories item=v}
+ <option value="{$v.id}" data-parent="{$v.parent}">
+ {if $v.parent_id} {/if}{$v.name}
+ </option>
+ {/foreach}
+ {else}
+ <option id="" value="">(No Categories Listed - Select "Add a new Category" to the right. )</option>
+ {/if}
+ </select> Select a category to add to box below.<br>
+ <div id="activeCategories" class="glm-dynSelect-box">
+
+ {if isset($event.fieldData.categories) && $event.fieldData.categories}
+ {foreach from=$event.fieldData.categories item=c}
+ <div data-id="{$c.id}" class="glm-dynSelect-item glm-events-category">
+ {if $c.parent_name != ''}{$c.parent_name}: {/if}{$c.name}
+ <span data-id="{$c.id}" class="glm-dynSelect-delete catDelete">X</span>
+ <input type="hidden" name="category[{$c.id}]" value="{$c.id}">
+ </div>
+ {/foreach}
+ {/if}
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <th {if $event.fieldRequired.intro}class="glm-required"{/if}>Intro Text:</th>
+ <td {if $event.fieldFail.intro}class="glm-form-bad-input" data-tabid="glm-event-descr"{/if}>
+ <textarea name="intro" class="glm-form-textarea">{$event.fieldData.intro}</textarea>
+ {if $event.fieldFail.intro}<p>{$event.fieldFail.intro}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $event.fieldRequired.descr}class="glm-required"{/if}>Description:</th>
+ <td {if $event.fieldFail.descr}class="glm-form-bad-input" data-tabid="glm-event-descr"{/if}>
+ {php}
+ wp_editor('{$event.fieldData.descr|escape:quotes}', 'glm_descr', array(
+ // 'media_buttons' => true,
+ // 'quicktags' => false,
+ // 'wpautop' => false, NOTE: Dont's use. Problem when numerous spaces before text.
+ 'textarea_name' => 'descr',
+ 'editor_height' => 200, // Height in px, overrides editor_rows
+ // 'textarea_rows' => 8
+ ));
+ {/php}
+ {if $event.fieldFail.descr}<p>{$event.fieldFail.descr}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $event.fieldRequired.image}class="glm-required"{/if}>Image:</th>
+ <td {if $event.fieldFail.image}class="glm-form-bad-input"{/if}>
+ <table class="glm-admin-image-edit-table">
+ {if $event.fieldData.image}
+ <tr>
+ <td>
+ <div class="glm-galleryImage" data-id="image">
+ <img src="{$glmPluginMediaUrl}/images/small/{$event.fieldData.image}">
+ </div>
+ </td>
+ <td>
+ <input type="checkbox" name="image_delete"> Delete Image<br>
+ {$event.fieldData.image}<br>
+ </td>
+ </tr>
+ {/if}
+ <tr><td colspan="2"><b>New image:</b> <input type="file" name="image_new"></td></tr>
+ </table>
+ <div id="glm-galleryImageLarger_image" class="glm-imageDialog"><img src="{$glmPluginMediaUrl}/images/large/{$event.fieldData.image}"></div>
+ {if $event.fieldFail.image}<p>{$event.fieldFail.image}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $event.fieldRequired.url}class="glm-required"{/if}>Web Address (URL):</th>
+ <td {if $event.fieldFail.url}class="glm-form-bad-input" data-tabid="glm-event-descr"{/if}>
+ <input type="text" name="url" value="{$event.fieldData.url}" class="glm-form-text-input-medium" placeholder="ex: http://www.gaslightmedia.com">
+ {if $event.fieldFail.url}<p>{$event.fieldFail.url}</p>{/if}<br>
+ </td>
+ </tr>
+ <tr>
+ <th {if $event.fieldRequired.cost}class="glm-required"{/if}>Description of Cost:</th>
+ <td {if $event.fieldFail.cost}class="glm-form-bad-input" data-tabid="glm-event-descr"{/if}>
+ <input type="text" name="cost" value="{$event.fieldData.cost}" class="glm-form-text-input-medium">
+ {if $event.fieldFail.cost}<p>{$event.fieldFail.cost}</p>{/if}<br>
+ </td>
+ </tr>
+ <tr>
+ <th {if $event.fieldRequired.notes}class="glm-required"{/if}>Notes:</th>
+ <td {if $event.fieldFail.notes}class="glm-form-bad-input" data-tabid="glm-event-descr"{/if}>
+ <textarea name="notes" class="glm-form-textarea">{$event.fieldData.notes}</textarea>
+ {if $event.fieldFail.notes}<p>{$event.fieldFail.notes}</p>{/if}
+ </td>
+ </tr>
+
+ </table>
+
+ <!-- Location -->
+
+ <table id="glm-table-location" class="glm-admin-table glm-hidden glm-event-table">
+ <tr>
+ <th>A parameter</th>
+ <td>Locations data goes here along with a big map</td>
+ </tr>
+ </table>
+
+ <!-- Recurrences - Event Schedule -->
+
+ <table id="glm-table-recurrence" class="glm-admin-table glm-hidden glm-event-table">
+ <tr>
+ <tr>
+ <th>Schedules</th>
+ <td>
+ <a id="addRecurrenceButton" class="button button-primary glm-button glm-right">Add an Event Schedule</a>
+
+ </td>
+ </tr>
+ {if $recurrences}
+ {foreach from=$recurrences item=v}
+
+ {/foreach}
+ {else}
+ <tr><td>(no schedule listed)</td></tr>
+ {/if}
+ </tr>
+ </table>
+
+ <!-- Calendar -->
+
+ <table id="glm-table-calendar" class="glm-admin-table glm-hidden glm-event-table">
+ <tr>
+ <th>A parameter</th>
+ <td>A bunch of calendars for all the dates covered by this event.</td>
+ </tr>
+ </table>
+
+ <input id="updateEvent" type="submit" value="{if $haveEvent}Update Event{else}Add New Event{/if}">
+
+ </form>
+
+{else} <!-- Can just display -->
+
+ <table class="glm-admin-table">
+ <tr><th>Name:</th><td>{$event.fieldData.name}</td></tr>
+ </table>
+
+{/if}
+
+ <!-- Delete Event Dialog Box -->
+
+ <div id="deleteEventDialog" class="glm-dialog-box" title="Delete Event">
+ <center>
+ <p><a id="deleteEventCancel" class="button button-primary">Cancel</a></p>
+ <p><input id="deleteEventSubmit" type="submit" value="Delete this event"></p>
+ </center>
+ <div class="glm-item-container">
+ <p><center><span class="glm-error">WARNING:</span></center></p>
+ <p>
+ <span class="glm-warning">Clicking the "Delete this Event" button above will
+ delete all of the data and images associated with this event.
+ </span>
+ </p>
+ <p>
+ <span class="glm-error">
+ Once deleted, this information will no longer be available and cannot be retrieved!
+ If you are unsure that you want to completely remove this data, consider changing the status
+ of this event to "Archived" instead.
+ </span>
+ </p>
+ </div>
+ </div>
+
+ <!-- Add/Edit Recurrence Dialog Box -->
+
+ <div id="addRecurrenceDialog" class="glm-dialog-box" title="Add a Schedule">
+ <center>
+ </center>
+ <div class="glm-item-container">
+
+ <table class="glm-admin-table">
+ <tr>
+ <th>All Day Event:</th>
+ <td>
+ <input id="allDayEvent" type="checkbox" name="all_day" {if $event.fieldData.all_day.value} checked{/if}>
+ </td>
+ </tr>
+ <tr><th></th><th><p>First ocurrance of event</p></th></tr>
+ <tr class="not-all-day">
+ <th {if $newRecurrence.fieldRequired.start_time}class="glm-required"{/if}>Start Date & Time:</th>
+ <td {if $newRecurrence.fieldFail.start_time}class="glm-form-bad-input"{/if}>
+ <input type="text" name="start_time" value="{$newRecurrence.fieldData.start_time.datetime}" class="glm-form-text-input-small glm-datetime-input" placeholder="Click to Select Date/Time">
+ {if $newRecurrence.fieldFail.start_time}<p>{$newRecurrence.fieldFail.start_time}</p>{/if}
+ </td>
+ </tr>
+ <tr class="not-all-day">
+ <th {if $newRecurrence.fieldRequired.end_time}class="glm-required"{/if}>End Date & Time:</th>
+ <td {if $newRecurrence.fieldFail.end_time}class="glm-form-bad-input"{/if}>
+ <input type="text" name="end_time" value="{$newRecurrence.fieldData.end_time.datetime}" class="glm-form-text-input-small glm-datetime-input" placeholder="Click to Select Date/Time">
+ {if $newRecurrence.fieldFail.end_time}<p>{$newRecurrence.fieldFail.end_time}</p>{/if}
+ </td>
+ </tr>
+
+ <tr class="all-day glm-hidden">
+ <th {if $newRecurrence.fieldRequired.start_time}class="glm-required"{/if}>Event Date:</th>
+ <td {if $newRecurrence.fieldFail.start_time}class="glm-form-bad-input"{/if}>
+ <input type="text" name="start_time" value="{$newRecurrence.fieldData.start_date.date}" class="glm-form-text-input-small glm-date-input" placeholder="Click to Select Date/Time">
+ {if $newRecurrence.fieldFail.start_time}<p>{$newRecurrence.fieldFail.start_time}</p>{/if}
+ </td>
+ </tr>
+
+ <tr><th></th><th><p>Date range over which recurring event can take place</p></th></tr>
+ <tr>
+ <th {if $newRecurrence.fieldRequired.from_date}class="glm-required"{/if}>From Date:</th>
+ <td {if $newRecurrence.fieldFail.from_date}class="glm-form-bad-input"{/if}>
+ <input type="text" name="from_date" value="{$newRecurrence.fieldData.from_date.date}" class="glm-form-text-input-small glm-date-input" placeholder="Click to Select Date/Time">
+ {if $newRecurrence.fieldFail.from_date}<p>{$newRecurrence.fieldFail.from_date}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $newRecurrence.fieldRequired.to_date}class="glm-required"{/if}>To Date:</th>
+ <td {if $newRecurrence.fieldFail.to_date}class="glm-form-bad-input"{/if}>
+ <input type="text" name="to_date" value="{$newRecurrence.fieldData.to_date.date}" class="glm-form-text-input-small glm-date-input" placeholder="Click to Select Date/Time">
+ {if $newRecurrence.fieldFail.to_date}<p>{$newRecurrence.fieldFail.to_date}</p>{/if}
+ </td>
+ </tr>
+ <tr><th></th><th><p>When the event recurrs</p></th></tr>
+ <tr>
+ <th>Months</th>
+ <td>
+ <table width="100%">
+ <tr>
+ <td>
+ {foreach from=$newRecurrence.fieldData.month_of_year.bitmap item=v}
+ {if $v.value == 6} </td><td> {/if}
+ <input type="checkbox" name="month_of_year[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name} <br>
+ {/foreach}
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <th>Select specific days of the month:</th>
+ <td>
+ <input id="specificDaysOfMonth" type="checkbox" name="by_days_of_month" {if $event.fieldData.all_day.value} checked{/if}>
+ </td>
+ </tr>
+ <tr class="not-by-day-of-month">
+ <th>Week of the Month</th>
+ <td>
+ {foreach from=$newRecurrence.fieldData.week_of_month.bitmap item=v}
+ <input type="checkbox" name="week_of_month[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name}
+ {/foreach}
+ </td>
+ </tr>
+ <tr class="not-by-day-of-month">
+ <th>Day of the Week</th>
+ <td>
+ <table width="100%">
+ <tr>
+ <td>
+ {foreach from=$newRecurrence.fieldData.day_of_week.bitmap item=v}
+ {if $v.value == 4} </td><td> {/if}
+ <input type="checkbox" name="date_of_week[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name} <br>
+ {/foreach}
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr class="by-day-of-month glm-hidden">
+ <th>Day of the Month</th>
+ <td>
+ <table width="100%" class="glm-calendar">
+ <tr>
+ {foreach from=$newRecurrence.fieldData.day_of_month.bitmap item=v}
+ {if in_array($v.value, array(7, 14, 21, 28))}
+ </tr><tr>
+ {/if}
+ <td>
+ <input type="checkbox" name="date_of_week[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name}
+ </td>
+ {/foreach}
+ <td colspan="4" style="text-align: center;">
+ <input type="checkbox" name="last_day_of_month" value="{$v.value}"{if $v.default} checked{/if}> Last day of the month
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+
+ </div>
+ <p>
+ <a id="addRecurrenceCancel" class="button button-primary glm-right">Cancel Adding Schedule</a>
+ <input id="addRecurrenceSubmit" type="submit" value="Add this schedule">
+ </p>
+ </div>
+
+
+
+
+ <script type="text/javascript">
+ jQuery(document).ready(function($) {
+
+ /*
+ * Edit area tabs
+ */
+ $('.glm-event-tab').click( function() {
+
+ // Clear tabl highlights and hide all tables
+ $('.glm-event-tab').removeClass('nav-tab-active');
+ $('.glm-event-table').addClass('glm-hidden');
+
+ // Highlight selected tab
+ $(this).addClass('nav-tab-active');
+
+ // Show selected table
+ var table = $(this).attr('data-show-table');
+ $('#' + table).removeClass('glm-hidden');
+
+
+ if (table == 'glm-table-recurrence') {
+ initRecurrence();
+ }
+
+ });
+
+ /*
+ * Date/Time Pickers
+ */
+ function initRecurrence() {
+
+ $('.glm-datetime-input').datetimepicker({
+ format: 'm/d/Y H:i',
+ lang: 'en',
+ step: 15,
+ closeOnWithoutClick: true
+ });
+
+ $('.glm-date-input').datepicker();
+
+ }
+
+ // All-Day selection
+ $('#allDayEvent').click( function() {
+ if ($("#allDayEvent")[0].checked) {
+ $(".not-all-day").addClass('glm-hidden');
+ $(".all-day").removeClass('glm-hidden');
+ } else {
+ $(".not-all-day").removeClass('glm-hidden');
+ $(".all-day").addClass('glm-hidden');
+ }
+ });
+
+ // By day of month selection
+ $('#specificDaysOfMonth').click( function() {
+ if ($("#specificDaysOfMonth")[0].checked) {
+ $(".not-by-day-of-month").addClass('glm-hidden');
+ $(".by-day-of-month").removeClass('glm-hidden');
+ } else {
+ $(".not-by-day-of-month").removeClass('glm-hidden');
+ $(".by-day-of-month").addClass('glm-hidden');
+ }
+ });
+
+ // Add Event Button Action
+ $('#addEventButton').click( function() {
+ window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=list&option=add";
+ });
+
+ // Flash certain elements for a short time after display
+ $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
+
+ {if $haveEvent}
+ // Delete Event dialog
+ $("#deleteEventDialog").dialog({
+ autoOpen: false,
+ minWidth: 400,
+ dialogClass: "glm-dialog-no-close"
+ });
+ $('#deleteEventButton').click( function() {
+ $('#deleteEventDialog').dialog('open');
+ });
+ $('#deleteEventCancel').click( function() {
+ $("#deleteEventDialog").dialog("close");
+ });
+ $('#deleteEventSubmit').click( function() {
+ window.location.replace("{$thisUrl}?page={$thisPage}&glm_action=list&option=delete&event={$event.fieldData.id}");
+ });
+ {/if}
+
+ /*
+ * Recurrences
+ */
+ // Add Recurrence dialog
+ $("#addRecurrenceDialog").dialog({
+ autoOpen: false,
+ minWidth: 800,
+ dialogClass: "glm-dialog-no-close"
+ });
+ $('#addRecurrenceButton').click( function() {
+ $('#addRecurrenceDialog').dialog('open');
+ });
+ $('#addRecurrenceCancel').click( function() {
+ $("#addRecurrenceDialog").dialog("close");
+ });
+ $('#addRecurrenceSubmit').click( function() {
+ // window.location.replace("{$thisUrl}?page={$thisPage}&glm_action=list&option=delete&event={$event.fieldData.id}");
+ });
+
+
+ /*
+ * Category Selection
+ */
+
+ // Action to select a category
+ $('#categorySelect').change( function() {
+
+ // Get the ID, name, and parent of the category
+ var catValue = $('#categorySelect').val();
+ var catName = $('#categorySelect').find(':selected').text();
+ var catParent = $('#categorySelect').find(':selected').attr('data-parent');
+
+ // Check if the category has already been added
+ var found = false;
+ $(".glm-events-category").each( function() {
+ var id = $(this).attr('data-id');
+ if (id == catValue) {
+ found = true;
+ }
+ });
+
+ // Check if there's a parent
+ parentName = '';
+ if (catParent != '') {
+ parentName = catParent + ': ';
+ }
+
+ // If not found, Add the category
+ if (!found) {
+ $('#activeCategories').append('<div data-id="' + catValue
+ + '" class="glm-dynSelect-item glm-events-category">'
+ + parentName + catName.trim() + ' <span class="glm-dynSelect-delete catDelete">X</span>'
+ + '<input type="hidden" name="category[' + catValue + ']" value="' + catValue + '"></div>');
+ }
+
+ // Reset picklist
+ $('#categorySelect').val('');
+
+ });
+
+ // Action to de-select a category
+ $('.catDelete').live('click', function() {
+ $(this).parent().remove();
+ });
+
+ /*
+ * New Category Dialog
+ */
+
+ var newCat = 0; // Used for new category numbering (new cats are negative numbers)
+
+ // Setup dialog box for adding a new category
+ $("#newCategoryDialog").dialog({
+ autoOpen: false,
+ minWidth: 400,
+ dialogClass: "glm-dialog-no-close"
+ });
+
+ // Ad a new category button action - pop-up dialog
+ $('#newCategoryButton').click( function() {
+ $("#newCategoryDialog").dialog("open");
+ });
+
+ // Submit new category
+ $('#newCategorySubmit').click( function() {
+
+ // Assign new cat number
+ newCat--;
+
+ // Get new category information
+ var newCatName = $('#newCatName').val();
+ var newCatParent = $('#newCatParent').val();
+ var catParent = $('#newCatParent').find(':selected').attr('data-parent');
+ var newCatParentName = $('#newCatParentName').val();
+
+ // If there's no name, tell the user we need one.
+ if (newCatName == '') {
+ $('#newCatNameTD').addClass('glm-form-bad-input');
+ $('#newCatNameRequired').text('A catogory name is required!');
+ return false;
+ }
+
+ // Check if there's a parent, get the name - new parent name overrides selected parent
+ parentName = '';
+ if (newCatParentName && newCatParentName != '') {
+ parentName = newCatParentName + ': ';
+ } else if (catParent && catParent != '') {
+ parentName = catParent + ': ';
+ }
+
+ // Add the new category to the active categories list
+ $('#activeCategories').append('<div data-id="' + newCat
+ + '" class="glm-dynSelect-item glm-events-category">'
+ + parentName + newCatName.trim() + ' <span data-id="' + newCat + '" class="glm-dynSelect-delete catDelete">X</span>'
+ + '<input type="hidden" name="category[' + newCat + ']" value="' + newCat + '">'
+ + '<input type="hidden" name="newCategory[' + newCat + ']" value="' + newCatName + '">'
+ + '<input type="hidden" name="newCatParent[' + newCat + ']" value="' + newCatParent + '">'
+ + '<input type="hidden" name="newCatParentName[' + newCat + ']" value="' + newCatParentName + '">'
+ + '</div>');
+
+ // Clear the dialog input fields
+ $('#newCatName').val('');
+ $('#newCatParent').val('');
+ $('#newCatParentName').val('');
+
+ $("#newCategoryDialog").dialog("close");
+
+ });
+ $('#newCategoryCancel').click( function() {
+ $("#newCategoryDialog").dialog("close");
+ });
+
+ // Setup dialog box for adding a new category
+ $("#newCategoryDialog").dialog({
+ autoOpen: false,
+ minWidth: 400,
+ dialogClass: "glm-dialog-no-close"
+ });
+
+ /*
+ * Check for bad input or input changes
+ */
+
+ // Check for any field errors and if found change related tab to error color.
+
+ $('.glm-form-bad-input').each( function(index) {
+
+ tab = $(this).attr('data-tabid');
+
+ if (!$('#' + tab).hasClass('glm-bad-input-area')) {
+ $('#' + tab).addClass('glm-bad-input-area');
+ }
+ });
+
+ // Check for most input changes
+ $('input, textarea, select').on( 'change', function() {
+ glmPageUpdateRequired();
+ });
+
+ /*
+ * Checks for leaving the page
+ */
+ var glmSubmitRequired = false;
+
+ // Flag submit button when updates are required.
+ function glmPageUpdateRequired() {
+ $('#updateEvent').addClass('glm-bad-input-area');
+ glmSubmitRequired = true;
+ }
+ // When submit button is clicked, disable the beforeunload message
+ $('#updateEvent').on('click', function() {
+ glmSubmitRequired = false;
+ return true;
+ });
+
+ // If submit is required and we're laving the page, alert the user
+ $(window).bind('beforeunload', function() {
+ if (glmSubmitRequired) {
+ return true;
+ }
+ });
+
+
+ });
+ </script>
+
+
+{include file='admin/footer.html'}
-
+<div class="wrap">
+ <h2>All Events</h2>
<h2 class="nav-tab-wrapper">
- <a href="{$thisURL}?page={$thisPage}&glm_action=index" class="nav-tab{if $thisAction==index} nav-tab-active{/if}">All Events</a>
- <a href="{$thisURL}?page={$thisPage}&glm_action=add" class="nav-tab{if $thisAction==add} nav-tab-active{/if}">Add Event</a>
- <a href="{$thisURL}?page={$thisPage}&glm_action=categories" class="nav-tab{if $thisAction==categories} nav-tab-active{/if}">Event Categories</a>
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=index" class="nav-tab{if $thisAction==index} nav-tab-active{/if}">Dashboard</a>
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=list" class="nav-tab{if $thisAction==list} nav-tab-active{/if}">Event List</a>
</h2>
<div id="glm-admin-content-container">
{include file='admin/events/header.html'}
-<div class="wrap">
- <div id="glm-admin-content-container">
- <input class="button button-primary glm-button glm-right" type="button" value="Pending Events">
- <input class="button button-primary glm-button glm-right" type="button" value="Archived Events">
-
- <table class="wp-list-table striped glm-admin-table">
+
+{if apply_filters('glm_members_permit_admin_events_index_add_event', true)}
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=list&option=add" class="button button-primary glm-button glm-right">Add A New Event</a>
+{/if}
+ <h2 class="glm-left">Events Dashboard</h2>
+
+ <table class="glm-admin-table">
+ <tr>
+ <td colspan="2" align="">
+ <input id="glmEventsList" type="text" id="autoTest" style="margin-left: 2em;">
+ <span class="glm-left">Events Search:</span>
+ </td>
+ </tr>
+
+{if apply_filters('glm_members_permit_admin_events_index_event_config_warning', true)}
+ {if !$haveCategories}
+ <tr>
+ <th><span class="glm-error">You do not have any Events Categories setup.</span></th>
+ <td><a href="{$thisUrl}?page=glm-members-admin-menu-settings&glm_action=eventCategories">Click here to add Event Categories.</a></td>
+ </tr>
+ {/if}
+{/if}
+
+{if $numbEvents == 0}
+ <tr><td colspan="2"> </td></tr>
+ <tr>
+ <th> <span class="glm-error">You do not have any events listed.</span></th>
+ <td><a href="{$thisUrl}?page=glm-members-admin-menu-events&glm_action=eventEdit&option=add">Click here to create your first event.</a></td>
+ </tr>
+{/if}
+ </table>
+
+ <table class="glm-admin-table">
+ <tr><th>Number of Events Listed: </th><td>{$numbEvents}</td></tr>
+ </table>
+
+{if $pending}
+ <h3 class="glm-error"> <br>Pending Events</h3>
+
+ <table class="wp-list-table widefat fixed posts glm-admin-table"">
<thead>
<tr>
- <th>Event Title</th>
- <th>Category</th>
- <th>Times</th>
- <th>Days</th>
- <th>Start Date</th>
- <th>End Date</th>
- <th> </th>
+ <th>Event Name</th>
+ <th>Last Updated</th>
</tr>
- {foreach from=$title key=k item=name}
+ </thead>
+ <tbody>
+ {assign var="i" value="0"}
+ {foreach $pending as $p}
+ {if $i++ is odd by 1}
<tr>
- <td><input class="catField" type="text" value="{$name}"></td>
+ {else}
+ <tr class="alternate">
+ {/if}
+ <td>
+ <a href="{$thisUrl}?page=glm-members-admin-menu-events-index&glm_action=list&option=edit&event={$p.id}">{$p.name}</a>
+ </td>
+ <td>
+ {$p.updated.datetime}
+ </td>
</tr>
-
- {/foreach}
- </thead>
-
- </div>
-</div>
+ {/foreach}
+ </tbody>
+ </table>
+{/if}
+
+{if $events}
+ <script type="text/javascript">
+ jQuery(document).ready(function($) {
+
+ /*
+ * Do autocomplete search for event
+ * label: What will be searched
+ * value: What will be displayed when selected
+ * id: Member id added so we can go to the event while showing what was selected
+ * Also note that autocomplete does not properly render HTML codes, so we
+ * "unescape" them for HTML in Smarty.
+ */
+ var availableTags = [
+ {foreach $events as $e}
+ { label: "{$e.name|unescape:'html'}", value: "{$e.name|unescape:'html'}", id: '{$e.id}' },
+ {/foreach}
+ ];
+ $( "#glmEventsList" ).autocomplete({
+ source: availableTags,
+ html: true,
+ select: function( event, ui ) {
+ var eventID = ui.item.id;
+ window.location.replace("{$adminUrl}?page=glm-members-admin-menu-events-list&glm_action=list&option=edit&&event=" + eventID );
+ },
+ response: function(event, ui) {
+ if (!ui.content.length) {
+ var noResult = { value:"",label:"No results found" };
+ ui.content.push(noResult);
+ }
+ }
+ });
+
+ });
+
+ </script>
+{/if}
+
+{include file='admin/footer.html'}
+
--- /dev/null
+{include file='admin/events/header.html'}
+
+
+{if apply_filters('glm_members_permit_admin_events_index_add_event', true)}
+ <h2 style="margin-bottom: 1em;">
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=list&option=add" class="button button-primary glm-button glm-right">Add A New Event</a>
+ {if $eventDeleted}<span class="glm-notice glm-flash-updated glm-right">Event Deleted</span>{/if}
+ {if $eventDeleteError}<span class="glm-error glm-flash-updated glm-right">Event Delete Error</span>{/if}
+ <h2>List of Events</h2>
+ </h2>
+{/if}
+
+ <form action="{$thisUrl}?page={$thisPage}" method="post" id="searchForm" class="glm-right">
+ <input type="hidden" name="glm_action" value="list">
+ <table>
+ <tr>
+ <th>Events Found:</th><td><span style="margin-right: 2em;">{$numbEvents}</span></td>
+ <th>Categories:</th>
+ <td style="min-width: 25em; padding-right: 1em;">
+ <select id="filterCategories" name="filterCategories[]" multiple="multiple">
+ {foreach from=$categories item=v}
+ <option value="{$v.id}" data-parent="{$v.parent}"{if $v.selected} selected{/if}>
+ {if $v.parent_id} {/if}{$v.name}
+ </option>
+ {/foreach}
+ </select>
+ </td>
+ <td><input type="submit" value="Submit" style="margin-right: 2em;"></td>
+ <th>Show Archived:</th><td><input type="checkbox" id="filterArchived" class="listFilter"{if $filterArchived} checked{/if} style="margin-right: 1em;"></td>
+ <th>Pending Only:</th><td><input type="checkbox" id="filterPending" class="listFilter"{if $filterPending} checked{/if} style="margin-right: 1em;"></td>
+ <th>Text Search:</th><td><input id="glmEventsSearch" type="text" id="autoTest"></td>
+ </tr>
+ </table>
+ </form>
+
+ <table class="wp-list-table striped glm-admin-table">
+ <thead>
+ <tr>
+ <th>ID</th>
+ <th>Event Name</th>
+ <th>Status</th>
+ <th>Created</th>
+ <th>Updated</th>
+ <th>Approved</th>
+ </tr>
+ </thead>
+ <tbody>
+{if $events}
+ {assign var="i" value="0"}
+ {foreach $events as $e}
+ {if $i++ is odd by 1}
+ <tr>
+ {else}
+ <tr class="alternate">
+ {/if}
+ <td>
+ {$e.id}
+ </td>
+ <td class="glm-nowrap">
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=list&option=edit&event={$e.id}">{$e.name}</a>
+ </td>
+ <td class="glm-nowrap">
+ {$e.status.name}
+ </td>
+ <td>
+ {$e.created.datetime}
+ </td>
+ <td>
+ {$e.updated.datetime}
+ </td>
+ <td>
+ {$e.approved.datetime}
+ </td>
+ </tr>
+ {/foreach}
+{else}
+ <tr class="alternate"><td colspan="2">(no events listed)</td></tr>
+{/if}
+ </tbody>
+ </table>
+
+ <script type="text/javascript">
+ jQuery(document).ready(function($) {
+
+ // Add Event Button Action
+ $('#addEventButton').click( function() {
+ window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=list&option=add";
+ });
+
+ // Date Input
+ $('.glm-date-input').datepicker();
+
+ // Flash certain elements for a short time after display
+ $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
+
+ // Filter triggers
+ $(".listFilter" ).change( function() {
+
+ var filter = '';
+
+ // Check for archived filter
+ if ($("#filterArchived").attr('checked')) {
+ filter += '&filterArchived=true';
+ }
+
+ // Check for pending data filter
+ if ($("#filterPending").attr('checked')) {
+ filter += '&filterPending=true';
+ }
+
+ window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=list" + filter;
+
+ return false;
+ });
+
+ /*
+ * Do autocomplete search for member
+ * label: What will be searched
+ * value: What will be displayed when selected
+ * id: Member id added so we can go to the member while showing what was selected
+ * Also note that autocomplete does not properly render HTML codes, so we
+ * "unescape" them for HTML in Smarty.
+ */
+
+ var availableTags = [
+ {foreach $events as $e}
+ { label: "{$e.name|unescape:'html'}", value: "{$e.name|unescape:'html'}", id: '{$e.id}' },
+ {/foreach}
+ ];
+ $( "#glmEventsSearch" ).autocomplete({
+ source: availableTags,
+ html: true,
+ select: function( event, ui ) {
+ var eventID = ui.item.id;
+ window.location.replace("{$adminUrl}?page=glm-members-admin-menu-events&glm_action=list&event=" + eventID );
+ },
+ response: function(event, ui) {
+ if (!ui.content.length) {
+ var noResult = { value:"",label:"No results found" };
+ ui.content.push(noResult);
+ }
+ }
+ });
+
+ // Expand multi-select on hover
+ $('#filterCategories').multiselect({
+ columns: 1,
+ placeholder: 'Click to select categories',
+ search: 1,
+ selectAll: true,
+ maxWidth: 200
+ });
+
+
+ });
+ </script>
+
+
+{include file='admin/footer.html'}
--- /dev/null
+{include file='admin/settings/header.html'}
+
+ <!-- Add Categories Button and Dialog Box -->
+ <div id="newCategoryButton" class="button button-primary glm-right">Add a Category</div>
+ <div id="newCategoryDialog" class="glm-dialog-box" title="Enter a New Category">
+ <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="glm_action" value="eventCategories">
+ <input type="hidden" name="option" value="addNew">
+
+ <table class="glm-admin-table">
+ <tr>
+ <th class="glm-required">Category Name:</th>
+ <td>
+ <input type="text" name="name" class="glm-form-text-input">
+ </td>
+ </tr>
+ <tr>
+ <th>Parent Category:</th>
+ <td>
+ <select name="parent">
+ <option value="0">(none)</option>
+ {if $haveCategories}
+ {foreach $categories as $t}
+ {if !$t.parent.value} <!-- don't show child categories -->
+ <option value="{$t.id}">{$t.name}</option>
+ {/if}
+ {/foreach}
+ {/if}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <th>Description:</th>
+ <td>
+ <textarea name="descr" class="glm-form-textarea"></textarea>
+ </td>
+ </tr>
+ </table>
+ <p><span class="glm-required">*</span> Required</p>
+ <a id="newCategoryCancel" class="button button-primary glm-right">Cancel</a>
+ <input type="submit" value="Add new Category" class="button button-primary">
+ </form>
+ </div>
+
+ <!-- Delete Category Button and Dialog Box -->
+ <div id="deleteCategoryDialog" class="glm-dialog-box" title="Delete Category">
+ <center>
+ <p>Are you sure you want to delete this category?</p>
+ <p><div id="deleteCategoryConfirm" class="button button-primary">Yes, delete this category</div></p>
+ <p><div id="deleteCategoryCancel" class="button button-primary">Cancel</div></p>
+ </center>
+ </div>
+
+ <!-- Edit Category Dialog Box -->
+ <div id="editCategoryDialog" class="glm-dialog-box" title="Edit this Category">
+ <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="glm_action" value="eventCategories">
+ <input type="hidden" name="option" value="update">
+ <input id="editCategoryID" type="hidden" name="id" value="">
+ <table class="glm-admin-table">
+ <tr>
+ <th class="glm-required">Category Name:</th>
+ <td>
+ <input id="editCategoryName" type="text" name="name" class="glm-form-text-input">
+ </td>
+ </tr>
+ <tr>
+ <th>Parent Category:</th>
+ <td>
+ <select id="editCategoryParent" name="parent">
+ <option value="0">(none)</option>
+ {if $haveCategories}
+ {foreach $categories as $t}
+ {if !$t.parent.value} <!-- don't show child categories -->
+ <option value="{$t.id}">{$t.name}</option>
+ {/if}
+ {/foreach}
+ {/if}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <th>Description:</th>
+ <td>
+ <textarea id="editCategoryDescr" name="descr" class="glm-form-textarea"></textarea>
+ </td>
+ </tr>
+ </table>
+ <p><span class="glm-required">*</span> Required</p>
+ <a id="editCategoryCancel" class="button button-primary glm-right">Cancel</a>
+ <input type="submit" value="Update this Category">
+ </form>
+ </div>
+
+ <h2>Categories</h2>
+
+ <table class="wp-list-table widefat fixed posts glm-admin-table"">
+ <thead>
+ <tr>
+ <th>ID</th>
+ <th>Category</th>
+ <th>Description</th>
+ <th> </th>
+ </tr>
+ </thead>
+ <tbody>
+{if $haveCategories}
+ {assign var="i" value="0"}
+ {foreach $categories as $t}
+ {if $i++ is odd by 1}
+ <tr>
+ {else}
+ <tr class="alternate">
+ {/if}
+ <td>{$t.id}</td>
+ <td>
+ <div{if $t.parent.value} class="glm-indent"{/if}>
+ <a class="editCategory" data-categoryID="{$t.id}" data-categoryParent="{$t.parent.value}">{$t.name}</a>
+ </div>
+ </td>
+ <td id="editCategoryDescr_{$t.id}">
+ {$t.descr}
+ </td>
+ <td>
+ <div class="deleteCategoryButton button button-secondary glm-button-small glm-right" data-categoryID="{$t.id}">Delete</div>
+ </td>
+ </tr>
+ {/foreach}
+{else}
+ <tr class="alternate"><td colspan="2">(no categories listed)</td></tr>
+{/if}
+ </tbody>
+ </table>
+
+ <script type="text/javascript">
+ jQuery(document).ready(function($) {
+
+ $("#newCategoryDialog").dialog({
+ autoOpen: false,
+ minWidth: 400,
+ width: 'auto',
+ dialogClass: "glm-dialog-no-close"
+ });
+ $("#editCategoryDialog").dialog({
+ autoOpen: false,
+ minWidth: 400,
+ width: 'auto',
+ dialogClass: "glm-dialog-no-close"
+ });
+ $("#deleteCategoryDialog").dialog({
+ autoOpen: false,
+ minWidth: 400,
+ width: 'auto',
+ dialogClass: "glm-dialog-no-close"
+ });
+
+ $('#newCategoryButton').click( function() {
+ $("#newCategoryDialog").dialog("open");
+ });
+ $('.editCategory').click( function() {
+ var catID = $(this).attr('data-categoryID');
+ var catName = $(this).text();
+ var catParent = $(this).attr('data-categoryParent');
+ var catDescr = $('#editCategoryDescr_' + catID).html();
+ $('#editCategoryID').val(catID);
+ $('#editCategoryName').val(catName.trim());
+ $('#editCategoryParent').val(catParent);
+ $('#editCategoryDescr').val(catDescr.trim());
+ $("#editCategoryDialog").dialog("open");
+ });
+ $('#editCategoryCancel').click( function() {
+ $("#editCategoryDialog").dialog("close");
+ });
+ $('#newCategoryCancel').click( function() {
+ $("#newCategoryDialog").dialog("close");
+ });
+
+ var id = false;
+ $('.deleteCategoryButton').click( function() {
+ id = $(this).attr('data-categoryID');
+ $("#deleteCategoryDialog").dialog("open");
+ });
+ $('#deleteCategoryConfirm').click( function() {
+ $("#deleteCategoryDialog").dialog("close");
+ window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=eventCategories&option=delete&id=" + id;
+ });
+ $('#deleteCategoryCancel').click( function() {
+ $("#deleteCategoryDialog").dialog("close");
+ });
+
+ });
+ </script>
+
+{include file='admin/footer.html'}