From: Anthony Talarico Date: Thu, 3 Mar 2016 17:20:11 +0000 (-0500) Subject: category names save and can be edited in stand alone events menu X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=74d46daf7d4637204c3d4c5bff6bf325056acec4;p=WP-Plugins%2Fglm-member-db-events.git category names save and can be edited in stand alone events menu --- diff --git a/css/admin.css b/css/admin.css index 3dcfb8c..b2426c2 100644 --- a/css/admin.css +++ b/css/admin.css @@ -11,6 +11,9 @@ and open the template in the editor. .catField{ display: block; } +.edit{ + display: none; +} #dateTimeLink, #location, #cost, #admin, #eventAdmin{ background: grey; color: lawngreen; diff --git a/js/admin.js b/js/admin.js index 4ae8d41..faaa1b6 100644 --- a/js/admin.js +++ b/js/admin.js @@ -9,7 +9,13 @@ jQuery(document).ready( function () { e.preventDefault(); return false; }); - + jQuery(".catField").click( function (){ + if(jQuery(".edit").css("display") == "none"){ + jQuery(".edit").slideToggle(800) ; + } else { + jQuery(".edit").slideToggle(800) ; + } + }); jQuery("#dateTimeLink").click( function (){ if(jQuery("#dateTime").css("display") == "none"){ jQuery("#dateTime").slideDown(600) ; diff --git a/models/admin/events/categories.php b/models/admin/events/categories.php index 4b5bbdc..9182b7e 100644 --- a/models/admin/events/categories.php +++ b/models/admin/events/categories.php @@ -109,17 +109,51 @@ class GlmMembersAdmin_events_categories extends GlmDataEventsCategories $haveCategories = ($categoriesStats > 0); if($_REQUEST['Action'] == 'Add Topic'){ - if(isset($_REQUEST['topic'])){ + if(isset($_REQUEST['topic']) && $_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); - } + if($_REQUEST['Action'] == 'Add Topic'){ + + // sql insert query + $sql = " + INSERT INTO ". GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "categories + (name) + VALUES ("."'$title'".") + ;"; + $this->wpdb->query($sql); + } + } + } + if($_REQUEST['save'] == 'save'){ + $catField = array_filter($_REQUEST, function($k) { + return preg_match('/^cat/',$k); + }, ARRAY_FILTER_USE_KEY); + + foreach($catField as $cat){ + $title = trim(filter_var($cat,FILTER_SANITIZE_STRING)); + } + + $table = GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX; + // get ID of selected category + $sql = "SELECT id + FROM ". GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "categories + WHERE name = " . "'$title'". " + ;"; + + $id = $this->wpdb->get_results($sql, ARRAY_A); + foreach($id[0] as $key=>$value){ + $id = $value; + } + $editField = array_filter($_REQUEST, function($k) { + return preg_match('/^edit/',$k); + }, ARRAY_FILTER_USE_KEY); + foreach($editField as $edit){ + $editTitle = trim(filter_var($edit,FILTER_SANITIZE_STRING)); + } + $sql2 = "UPDATE " . "$table" . "categories + SET name = " . "'$editTitle'" . " + WHERE id = " . $id . " + ;"; + $this->wpdb->query($sql2); } // retrieve category names diff --git a/views/admin/events/categories.html b/views/admin/events/categories.html index bdd7edc..95cea9b 100644 --- a/views/admin/events/categories.html +++ b/views/admin/events/categories.html @@ -1,4 +1,5 @@ {include file='admin/events/header.html'} +{assign var=val value=1}
@@ -8,19 +9,26 @@ Add New Category: - + - - {foreach from=$categoryNames key=k item=category} - - - - - {/foreach} - - -
+ +
- \ No newline at end of file + +

Click Tag To Edit Name

+{foreach from=$categoryNames key=k item=category} +

+
+ + + + + + +
+
+
+ {assign var=val value=$val+1} + {/foreach} diff --git a/views/admin/search.html b/views/admin/search.html index a9fa5a7..bc38c29 100644 --- a/views/admin/search.html +++ b/views/admin/search.html @@ -1,4 +1,7 @@ +

+
+
From - \ No newline at end of file + +
\ No newline at end of file