From 7d4f2556a940a492dc996a8c20bdbb0d9f3795a7 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Thu, 3 Mar 2016 16:42:23 -0500 Subject: [PATCH] Roughed in Event add/edit/delete and forms for recurrences. --- classes/data/dataCategories.php | 242 +++++- classes/data/dataEventCategories.php | 177 ++++- classes/data/dataEvents.php | 136 +++- classes/data/dataLocations.php | 3 - classes/data/dataRecurrences.php | 16 +- classes/data/dataTimes.php | 3 - models/admin/events/add.php | 148 ---- models/admin/events/categories.php | 153 ---- models/admin/events/index.php | 106 +-- models/admin/events/list.php | 376 +++++++++ models/admin/events/more.php | 125 --- models/admin/member/events.php | 189 +++-- models/admin/settings/eventCategories.php | 201 +++++ setup/adminMenus.php | 32 +- setup/adminTabs.php | 22 +- .../create_database_V0.0.2.sql | 2 +- setup/validActions.php | 10 +- views/admin/events/add.html | 88 --- views/admin/events/categories.html | 25 - views/admin/events/edit.html | 720 ++++++++++++++++++ views/admin/events/header.html | 8 +- views/admin/events/index.html | 121 ++- views/admin/events/list.html | 159 ++++ views/admin/settings/eventCategories.html | 194 +++++ 24 files changed, 2489 insertions(+), 767 deletions(-) delete mode 100644 models/admin/events/add.php delete mode 100644 models/admin/events/categories.php create mode 100644 models/admin/events/list.php delete mode 100644 models/admin/events/more.php create mode 100644 models/admin/settings/eventCategories.php delete mode 100644 views/admin/events/add.html delete mode 100644 views/admin/events/categories.html create mode 100644 views/admin/events/edit.html create mode 100644 views/admin/events/list.html create mode 100644 views/admin/settings/eventCategories.html diff --git a/classes/data/dataCategories.php b/classes/data/dataCategories.php index c39ce72..e7997f2 100644 --- a/classes/data/dataCategories.php +++ b/classes/data/dataCategories.php @@ -12,9 +12,6 @@ * @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 * @@ -176,7 +173,240 @@ class GlmDataEventsCategories extends GlmDataAbstract { 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; + } + +} diff --git a/classes/data/dataEventCategories.php b/classes/data/dataEventCategories.php index bd2bc02..7d31bd2 100644 --- a/classes/data/dataEventCategories.php +++ b/classes/data/dataEventCategories.php @@ -12,9 +12,6 @@ * @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 * @@ -176,6 +173,180 @@ class GlmDataEventsEventCategories extends GlmDataAbstract 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; + + } + + } ?> diff --git a/classes/data/dataEvents.php b/classes/data/dataEvents.php index b234626..c58c8d1 100644 --- a/classes/data/dataEvents.php +++ b/classes/data/dataEvents.php @@ -12,9 +12,6 @@ * @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 * @@ -153,7 +150,7 @@ class GlmDataEvents extends GlmDataAbstract 'created' => array ( 'field' => 'created', 'type' => 'datetime', - 'use' => 'lgie' + 'use' => 'lgieu' ), // Date/Time Updated @@ -232,13 +229,23 @@ class GlmDataEvents extends GlmDataAbstract '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 ( @@ -304,9 +311,128 @@ class GlmDataEvents extends GlmDataAbstract */ 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; + + } + } ?> diff --git a/classes/data/dataLocations.php b/classes/data/dataLocations.php index 7ae85a8..566910f 100644 --- a/classes/data/dataLocations.php +++ b/classes/data/dataLocations.php @@ -12,9 +12,6 @@ * @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 * diff --git a/classes/data/dataRecurrences.php b/classes/data/dataRecurrences.php index 1a902b1..8fa8ff7 100644 --- a/classes/data/dataRecurrences.php +++ b/classes/data/dataRecurrences.php @@ -12,9 +12,6 @@ * @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 * @@ -137,9 +134,20 @@ class GlmDataEventsRecurrences extends GlmDataAbstract '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', @@ -151,6 +159,7 @@ class GlmDataEventsRecurrences extends GlmDataAbstract 'from_date' => array ( 'field' => 'from_date', 'type' => 'date', + 'required' => true, 'use' => 'a' ), @@ -158,6 +167,7 @@ class GlmDataEventsRecurrences extends GlmDataAbstract 'to_date' => array ( 'field' => 'to_date', 'type' => 'date', + 'required' => true, 'use' => 'a' ), diff --git a/classes/data/dataTimes.php b/classes/data/dataTimes.php index ee1b284..7298781 100644 --- a/classes/data/dataTimes.php +++ b/classes/data/dataTimes.php @@ -12,9 +12,6 @@ * @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 * diff --git a/models/admin/events/add.php b/models/admin/events/add.php deleted file mode 100644 index eccb64d..0000000 --- a/models/admin/events/add.php +++ /dev/null @@ -1,148 +0,0 @@ - - * @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!
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 "
EventsArray:"; - echo "
";print_r($eventsArray,true);echo "
"; - foreach($eventsArray as $key=>$value) { - echo(""); - - } - echo "
$key$value

"; - - $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 - ); - } -} - - diff --git a/models/admin/events/categories.php b/models/admin/events/categories.php deleted file mode 100644 index 5348e2c..0000000 --- a/models/admin/events/categories.php +++ /dev/null @@ -1,153 +0,0 @@ - - * @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!
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 '
', print_r($names, true), '
'; - // 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 - ); - } -} diff --git a/models/admin/events/index.php b/models/admin/events/index.php index 5205998..4132e64 100644 --- a/models/admin/events/index.php +++ b/models/admin/events/index.php @@ -1,7 +1,7 @@ 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 '
', print_r($names, true), '
'; - // 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( diff --git a/models/admin/events/list.php b/models/admin/events/list.php new file mode 100644 index 0000000..874cab9 --- /dev/null +++ b/models/admin/events/list.php @@ -0,0 +1,376 @@ + + * @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); + } + + } + + + +} diff --git a/models/admin/events/more.php b/models/admin/events/more.php deleted file mode 100644 index 07de2ea..0000000 --- a/models/admin/events/more.php +++ /dev/null @@ -1,125 +0,0 @@ - - * @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!
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 - ); - - } - - -} diff --git a/models/admin/member/events.php b/models/admin/member/events.php index f140a14..a5cfd8e 100644 --- a/models/admin/member/events.php +++ b/models/admin/member/events.php @@ -1,7 +1,7 @@ 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 "
Request:"; - foreach($_REQUEST as $key=>$value) { - echo(""); - } - echo "
$key$value
"; - $eventsArray = array_filter($_REQUEST, function($k) { - return preg_match('/^events_/',$k); - }, ARRAY_FILTER_USE_KEY); - echo "
EventsArray:"; - echo "
";print_r($eventsArray,true);echo "
"; - foreach($eventsArray as $key=>$value) { - echo(""); - } - echo "
$key$value

"; - 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 ); - + } diff --git a/models/admin/settings/eventCategories.php b/models/admin/settings/eventCategories.php new file mode 100644 index 0000000..28d76fb --- /dev/null +++ b/models/admin/settings/eventCategories.php @@ -0,0 +1,201 @@ + + * @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 + ); + + } + + +} diff --git a/setup/adminMenus.php b/setup/adminMenus.php index 4749178..b905976 100644 --- a/setup/adminMenus.php +++ b/setup/adminMenus.php @@ -80,28 +80,30 @@ add_menu_page( 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');} ); diff --git a/setup/adminTabs.php b/setup/adminTabs.php index 8dafef1..c4721e5 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -33,19 +33,6 @@ * */ -//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( @@ -61,13 +48,13 @@ add_filter('glm-member-db-add-tab-for-member', } ); -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' ), ); @@ -76,6 +63,7 @@ add_filter('glm-member-db-add-tab-for-events', } ); + add_filter('glm-member-db-add-tab-for-events', function($addOnTabs) { $newTabs = array( diff --git a/setup/databaseScripts/create_database_V0.0.2.sql b/setup/databaseScripts/create_database_V0.0.2.sql index 0f82524..221caf6 100644 --- a/setup/databaseScripts/create_database_V0.0.2.sql +++ b/setup/databaseScripts/create_database_V0.0.2.sql @@ -118,7 +118,7 @@ CREATE TABLE {prefix}events ( 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 diff --git a/setup/validActions.php b/setup/validActions.php index defa730..1b91b89 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -32,17 +32,15 @@ $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 diff --git a/views/admin/events/add.html b/views/admin/events/add.html deleted file mode 100644 index 15a0478..0000000 --- a/views/admin/events/add.html +++ /dev/null @@ -1,88 +0,0 @@ -{include file='admin/events/header.html'} - Event Details -
-
-

Event Name

- - -

All Day

- -

Active?

- - -

Start Date

- -

End Date

- -

Start Time

- -

End Time

- -

Recurring

- - -
- Location Details -
- -

Hide Event Address

- -

Place

- -

Address

- -

City

- -

State

- -

ZIP Code

- - - -
- Cost and tickets -
- -

Cost

- -

Free Event

- -

Website

- - -
- Event Contact Information -
- -

Contact Name

- -

Contact Phone

- -

Contact Email

- - -
- Event Admin Information -
- -

Contact Name Submitting Event

- -

Organization Name Submitting Event

- -

Contact Phone

- -

Contact Email

- -

Notes

- - - -
- - - - - - diff --git a/views/admin/events/categories.html b/views/admin/events/categories.html deleted file mode 100644 index 4fb15a7..0000000 --- a/views/admin/events/categories.html +++ /dev/null @@ -1,25 +0,0 @@ -{include file='admin/events/header.html'} -
-
-
-
- - - - - - - - - {foreach from=$categoryNames key=k item=category} - - - - {/foreach} - - -
Add New Category:
-
-
-
-
\ No newline at end of file diff --git a/views/admin/events/edit.html b/views/admin/events/edit.html new file mode 100644 index 0000000..1765c6d --- /dev/null +++ b/views/admin/events/edit.html @@ -0,0 +1,720 @@ +{include file='admin/events/header.html'} + +{if apply_filters('glm_members_permit_admin_members_packaging_edit_package', true)} + + Return to Events List + + {if $option == 'edit'} + Delete this Event + +

Edit Event

+ {else} +

Add new Event

+ {/if} + + +
+ + + + {if $haveEvent} + + + {else} + + {/if} + + + + + + + + + + + {if $haveEvent} + + + + + + + + + + + + + + + + + {/if} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Event Name: + + {if $event.fieldFail.name}

{$event.fieldFail.name}

{/if}
+
Name for URLs:{$event.fieldData.name_slug}
Created:{$event.fieldData.created.datetime}
Last Updated:{$event.fieldData.updated.datetime}
Last Approved:{$event.fieldData.approved.datetime}
Status: + + {if $event.fieldFail.status}

{$event.fieldFail.status}

{/if} +
Hide Member Address: + +
Featured Event: + +
Include in Slideshow: + +
Major Event: + +
Categories + + + +
Add a new Category
+
+ + + + + + + + + +
Category Name: + +
+
Parent Category: + +
OR
+ +
+

* Required

+ Cancel + +
+ + + +    Select a category to add to box below.
+
+ + {if isset($event.fieldData.categories) && $event.fieldData.categories} + {foreach from=$event.fieldData.categories item=c} +
+ {if $c.parent_name != ''}{$c.parent_name}: {/if}{$c.name} + X + +
+ {/foreach} + {/if} +
+
Intro Text: + + {if $event.fieldFail.intro}

{$event.fieldFail.intro}

{/if} +
Description: + {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}

{$event.fieldFail.descr}

{/if} +
Image: + + {if $event.fieldData.image} + + + + + {/if} + +
+
+ +
+
+ Delete Image
+ {$event.fieldData.image}
+
New image:
+
+ {if $event.fieldFail.image}

{$event.fieldFail.image}

{/if} +
Web Address (URL): + + {if $event.fieldFail.url}

{$event.fieldFail.url}

{/if}
+
Description of Cost: + + {if $event.fieldFail.cost}

{$event.fieldFail.cost}

{/if}
+
Notes: + + {if $event.fieldFail.notes}

{$event.fieldFail.notes}

{/if} +
+ + + + + + + + +
A parameterLocations data goes here along with a big map
+ + + + + + + + + + {if $recurrences} + {foreach from=$recurrences item=v} + + {/foreach} + {else} + + {/if} + +
Schedules + Add an Event Schedule + +
(no schedule listed)
+ + + + + + + + +
A parameterA bunch of calendars for all the dates covered by this event.
+ + + +
+ +{else} + + + +
Name:{$event.fieldData.name}
+ +{/if} + + + +
+
+

Cancel

+

+
+
+

WARNING:

+

+ Clicking the "Delete this Event" button above will + delete all of the data and images associated with this event. + +

+

+ + 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. + +

+
+
+ + + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
All Day Event: + +

First ocurrance of event

Start Date & Time: + + {if $newRecurrence.fieldFail.start_time}

{$newRecurrence.fieldFail.start_time}

{/if} +
End Date & Time: + + {if $newRecurrence.fieldFail.end_time}

{$newRecurrence.fieldFail.end_time}

{/if} +
Event Date: + + {if $newRecurrence.fieldFail.start_time}

{$newRecurrence.fieldFail.start_time}

{/if} +

Date range over which recurring event can take place

From Date: + + {if $newRecurrence.fieldFail.from_date}

{$newRecurrence.fieldFail.from_date}

{/if} +
To Date: + + {if $newRecurrence.fieldFail.to_date}

{$newRecurrence.fieldFail.to_date}

{/if} +

When the event recurrs

Months + + + + +
+ {foreach from=$newRecurrence.fieldData.month_of_year.bitmap item=v} + {if $v.value == 6} {/if} + {$v.name}
+ {/foreach} +
+
Select specific days of the month: + +
Week of the Month + {foreach from=$newRecurrence.fieldData.week_of_month.bitmap item=v} + {$v.name}   + {/foreach} +
Day of the Week + + + + +
+ {foreach from=$newRecurrence.fieldData.day_of_week.bitmap item=v} + {if $v.value == 4} {/if} + {$v.name}
+ {/foreach} +
+
Day of the Month + + + {foreach from=$newRecurrence.fieldData.day_of_month.bitmap item=v} + {if in_array($v.value, array(7, 14, 21, 28))} + + {/if} + + {/foreach} + + +
+ {$v.name} + + Last day of the month +
+
+ +
+

+ Cancel Adding Schedule + +

+
+ + + + + + + +{include file='admin/footer.html'} diff --git a/views/admin/events/header.html b/views/admin/events/header.html index 2ff3cdc..9bf19a2 100644 --- a/views/admin/events/header.html +++ b/views/admin/events/header.html @@ -1,8 +1,8 @@ - +
+

All Events

diff --git a/views/admin/events/index.html b/views/admin/events/index.html index 28a6313..400d5d3 100644 --- a/views/admin/events/index.html +++ b/views/admin/events/index.html @@ -1,27 +1,106 @@ {include file='admin/events/header.html'} -
-
- - - - + +{if apply_filters('glm_members_permit_admin_events_index_add_event', true)} + Add A New Event +{/if} +

Events Dashboard

+ +
+ + + + +{if apply_filters('glm_members_permit_admin_events_index_event_config_warning', true)} + {if !$haveCategories} + + + + + {/if} +{/if} + +{if $numbEvents == 0} + + + + + +{/if} +
+ + Events Search: +
You do not have any Events Categories setup.Click here to add Event Categories.
 
You do not have any events listed.Click here to create your first event.
+ + + +
Number of Events Listed: {$numbEvents}
+ +{if $pending} +

 
Pending Events

+ + - - - - - - - + + - {foreach from=$title key=k item=name} + + + {assign var="i" value="0"} + {foreach $pending as $p} + {if $i++ is odd by 1} - + {else} + + {/if} + + - - {/foreach} - - - - + {/foreach} + +
Event TitleCategoryTimesDaysStart DateEnd Date Event NameLast Updated
+ {$p.name} + + {$p.updated.datetime} +
+{/if} + +{if $events} + +{/if} + +{include file='admin/footer.html'} + diff --git a/views/admin/events/list.html b/views/admin/events/list.html new file mode 100644 index 0000000..4960743 --- /dev/null +++ b/views/admin/events/list.html @@ -0,0 +1,159 @@ +{include file='admin/events/header.html'} + + +{if apply_filters('glm_members_permit_admin_events_index_add_event', true)} +

+ Add A New Event + {if $eventDeleted}Event Deleted{/if} + {if $eventDeleteError}Event Delete Error{/if} +

List of Events

+ +{/if} + +
+ + + + + + + + + + + +
Events Found:{$numbEvents}Categories: + + Show Archived:Pending Only:Text Search:
+
+ + + + + + + + + + + + + +{if $events} + {assign var="i" value="0"} + {foreach $events as $e} + {if $i++ is odd by 1} + + {else} + + {/if} + + + + + + + + {/foreach} +{else} + +{/if} + +
IDEvent NameStatusCreatedUpdatedApproved
+ {$e.id} + + {$e.name} + + {$e.status.name} + + {$e.created.datetime} + + {$e.updated.datetime} + + {$e.approved.datetime} +
(no events listed)
+ + + + +{include file='admin/footer.html'} diff --git a/views/admin/settings/eventCategories.html b/views/admin/settings/eventCategories.html new file mode 100644 index 0000000..5c1a8ad --- /dev/null +++ b/views/admin/settings/eventCategories.html @@ -0,0 +1,194 @@ +{include file='admin/settings/header.html'} + + +
Add a Category
+
+
+ + + + + + + + + + + + + + + + +
Category Name: + +
Parent Category: + +
Description: + +
+

* Required

+ Cancel + +
+
+ + +
+
+

Are you sure you want to delete this category?

+

Yes, delete this category

+

Cancel

+
+
+ + +
+
+ + + + + + + + + + + + + + + + +
Category Name: + +
Parent Category: + +
Description: + +
+

* Required

+ Cancel + +
+
+ +

Categories

+ + + + + + + + + + + +{if $haveCategories} + {assign var="i" value="0"} + {foreach $categories as $t} + {if $i++ is odd by 1} + + {else} + + {/if} + + + + + + {/foreach} +{else} + +{/if} + +
IDCategoryDescription 
{$t.id} + + {$t.name} + + + {$t.descr} + +
Delete
+
(no categories listed)
+ + + +{include file='admin/footer.html'} -- 2.17.1