}
}
}
+ // checking if the save action is performed to save an edited name field
if($_REQUEST['save'] == 'save'){
$catField = array_filter($_REQUEST, function($k) {
- return preg_match('/^cat/',$k);
- }, ARRAY_FILTER_USE_KEY);
-
+ return preg_match('/^cat/',$k);
+ }, ARRAY_FILTER_USE_KEY);
+ if(isset($catField)){
+ echo "asdf";
+ }
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'". "
- ;";
+ $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){
+
+ $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 . "
- ;";
+ // run sql statement only if the edit field isn't blank
+ if($editTitle != ''){
+ // edit category name
+ $sql2 = "UPDATE " . "$table" . "categories
+ SET name = " . "'$editTitle'" . "
+ WHERE id = " . $id . "
+ ;";
$this->wpdb->query($sql2);
+ }
+
}
-
+
// retrieve category names
$entries = $Categories->getList();
foreach($entries as $keys=>$value){
$names[] = $entries[$id]['name'];
}
-// echo '<pre>', print_r($names, true), '</pre>';
+ // Delete a category entry //////////////////////////////
+ if($_REQUEST['delete'] == 'delete'){
+ echo "test";
+
+ }
+
+
+
+
+
+
// Compile template data
$templateData = array(
'displayData' => $displayData,