From 19d0a6c528fad38b36aff528717c28be390b3845 Mon Sep 17 00:00:00 2001 From: Laury GvR Date: Thu, 12 Jan 2017 16:09:55 -0500 Subject: [PATCH] Added featured for list, fixed memOnly function Members only function had to check for $post existence before using it. Added 'featured' tag to list view, not just grid view, of member listing. Added list_show_detail_link check for the 'More' button which was likewise missing in list over grid. --- lib/GlmDataAbstract/DataAbstract.php | 396 +++++++++++++-------------- setup/frontHooks.php | 10 +- views/front/error/badAction.html | 2 +- views/front/members/list.html | 11 +- 4 files changed, 215 insertions(+), 204 deletions(-) diff --git a/lib/GlmDataAbstract/DataAbstract.php b/lib/GlmDataAbstract/DataAbstract.php index 224fc77e..67a04877 100755 --- a/lib/GlmDataAbstract/DataAbstract.php +++ b/lib/GlmDataAbstract/DataAbstract.php @@ -12,20 +12,20 @@ * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ */ -/** - * DataAbstract - * - * Database Abstract for data storage, retrieval, input, and output - * - * @category glmWordPressPlugin - * @package glmMembersDatabase - * @author Chuck Scott - * @copyright 2013 Gaslight Media - * @license Gaslight Media - * @release Release: (0.1) - * @link <> +/** + * DataAbstract + * + * Database Abstract for data storage, retrieval, input, and output + * + * @category glmWordPressPlugin + * @package glmMembersDatabase + * @author Chuck Scott + * @copyright 2013 Gaslight Media + * @license Gaslight Media + * @release Release: (0.1) + * @link <> */ - + abstract class GlmDataAbstract { @@ -110,11 +110,11 @@ abstract class GlmDataAbstract * @access public */ public $inputFieldStatus = false; - /** - * Processing Options - * - * @access public - */ + /** + * Processing Options + * + * @access public + */ public $optionIncludeSelectListData = false; /** * Delete Restrictions - Not fully sorted out yet @@ -657,11 +657,11 @@ abstract class GlmDataAbstract $blankText = $f['p_blank_text']; } if (isset($f['p_blank']) && $f['p_blank']) { - $pick_list[0] = array( - 'value' => '', - 'name' => $blankText, - 'default' => (!$p_value) - ); + $pick_list[0] = array( + 'value' => '', + 'name' => $blankText, + 'default' => (!$p_value) + ); } if (count($p_list) > 0) { @@ -850,11 +850,11 @@ abstract class GlmDataAbstract } else { - // Only worry about no options if the field is required. - if (isset($f['required']) && $f['required']) { - // There were no results from the - $this->inputFieldStatus = false; - $this->inputErrorReason = 'No options were available for this pick list.'; + // Only worry about no options if the field is required. + if (isset($f['required']) && $f['required']) { + // There were no results from the + $this->inputFieldStatus = false; + $this->inputErrorReason = 'No options were available for this pick list.'; } } @@ -1081,21 +1081,21 @@ abstract class GlmDataAbstract return $r; } - /* - * Bitmap List Field Processing - */ - private function bitmapField($f) - { - return 'T.'.$f['field']; - } - private function bitmapOptions($f) - { - return false; - } - private function bitmapOutput($f, $d) - { - // Check for a bitmap data - if (!isset($f['bitmap']) || !is_array($f['bitmap'])) { + /* + * Bitmap List Field Processing + */ + private function bitmapField($f) + { + return 'T.'.$f['field']; + } + private function bitmapOptions($f) + { + return false; + } + private function bitmapOutput($f, $d) + { + // Check for a bitmap data + if (!isset($f['bitmap']) || !is_array($f['bitmap'])) { if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { glmMembersAdmin::addNotice( "Field '".$f['name']."' is type bitmap but does not have supplied 'bitmap' data.", @@ -1104,40 +1104,40 @@ abstract class GlmDataAbstract ); } return false; - } - - // Build bitmap array + } + + // Build bitmap array $bitmap = array(); - $bitmapNames = array(); + $bitmapNames = array(); while (list($k, $v) = each($f['bitmap'])) { - $bitmap[$k] = array( - 'name' => $v, + $bitmap[$k] = array( + 'name' => $v, 'nameEsc' => addslashes($v), - 'value' => $k, - 'default' => false - ); + 'value' => $k, + 'default' => false + ); // Check if this option has been selected - $powVal = pow(2, $k); + $powVal = pow(2, $k); if (($powVal & $d) > 0) { $bitmap[$k]['default'] = true; $bitmapNames[$k] = $v; } - } - - $r = array( - 'bitmap' => $bitmap, - 'value' => $d, - 'names' => $bitmapNames - ); - - return $r; - - } - private function bitmapInput($as, $f, $id, $idField, $op) - { + } + + $r = array( + 'bitmap' => $bitmap, + 'value' => $d, + 'names' => $bitmapNames + ); + + return $r; + + } + private function bitmapInput($as, $f, $id, $idField, $op) + { // Check for a bitmap data if (!isset($f['bitmap']) || !is_array($f['bitmap'])) { @@ -1164,51 +1164,51 @@ abstract class GlmDataAbstract } } } - - // Build bitmap array + + // Build bitmap array $bitmap = array(); - $bitmapNames = array(); - while (list($k, $v) = each($f['bitmap'])) { - $bitmap[$k] = array( - 'name' => $v, + $bitmapNames = array(); + while (list($k, $v) = each($f['bitmap'])) { + $bitmap[$k] = array( + 'name' => $v, 'nameEsc' => addslashes($v), - 'value' => $k, - 'default' => false - ); - - // Check if this option has been selected - $powVal = pow(2, $k); - if (($powVal & $in) > 0) { - $bitmap[$k]['default'] = true; - $bitmapNames[] = $v; - } - } - - $r = array( - 'bitmap' => $bitmap, - 'value' => $in, - 'names' => $bitmapNames - ); - - return $r; - } - private function bitmapStore($in, $f) - { - $keytype = 'text'; - - if (isset($f['list_keytype']) && $f['list_keytype'] == 'int') { - $keytype = 'int'; - } - - if ($keytype == 'text') { - $r = "'".addslashes($in['value'])."'"; - } else { - $v = ($in['value'] - 0); - $r = $v; - } - - return $r; - } + 'value' => $k, + 'default' => false + ); + + // Check if this option has been selected + $powVal = pow(2, $k); + if (($powVal & $in) > 0) { + $bitmap[$k]['default'] = true; + $bitmapNames[] = $v; + } + } + + $r = array( + 'bitmap' => $bitmap, + 'value' => $in, + 'names' => $bitmapNames + ); + + return $r; + } + private function bitmapStore($in, $f) + { + $keytype = 'text'; + + if (isset($f['list_keytype']) && $f['list_keytype'] == 'int') { + $keytype = 'int'; + } + + if ($keytype == 'text') { + $r = "'".addslashes($in['value'])."'"; + } else { + $v = ($in['value'] - 0); + $r = $v; + } + + return $r; + } /* * Text Field Processing @@ -1336,62 +1336,62 @@ abstract class GlmDataAbstract return $r; } - /* - * Password Field Processing - */ - private function passwordField($f) - { - return 'T.'.$f['field']; - } - private function passwordOptions($f) - { - return false; - } - private function passwordOutput($f, $d) + /* + * Password Field Processing + */ + private function passwordField($f) + { + return 'T.'.$f['field']; + } + private function passwordOptions($f) + { + return false; + } + private function passwordOutput($f, $d) + { + // No output for a password field + return ''; + } + private function passwordInput($as, $f, $id, $idField, $op) { - // No output for a password field - return ''; - } - private function passwordInput($as, $f, $id, $idField, $op) - { - // If this is setup for a new entry, then just return default value - if ($op == 'n') { - return ''; - } - - $this->inputFieldStatus = true; - - // No options for input filters or options - $filter = FILTER_SANITIZE_STRING; - $filter_options = FILTER_FLAG_NO_ENCODE_QUOTES; - - $in = filter_input(INPUT_POST, $as, $filter, $filter_options); - if (isset($f['required']) && $f['required'] && trim($in) == '') { - $this->inputFieldStatus = false; - $this->inputErrorReason = 'Required input not provided.'; - return $in; - } - - // Check for required field - if (isset($f['required']) && $f['required'] && trim($in) == '') { - $this->inputFieldStatus = false; - $this->inputErrorReason = 'Required input not provided.'; - return $in; - } - + // If this is setup for a new entry, then just return default value + if ($op == 'n') { + return ''; + } + + $this->inputFieldStatus = true; + + // No options for input filters or options + $filter = FILTER_SANITIZE_STRING; + $filter_options = FILTER_FLAG_NO_ENCODE_QUOTES; + + $in = filter_input(INPUT_POST, $as, $filter, $filter_options); + if (isset($f['required']) && $f['required'] && trim($in) == '') { + $this->inputFieldStatus = false; + $this->inputErrorReason = 'Required input not provided.'; + return $in; + } + + // Check for required field + if (isset($f['required']) && $f['required'] && trim($in) == '') { + $this->inputFieldStatus = false; + $this->inputErrorReason = 'Required input not provided.'; + return $in; + } + // Check min/max length - if (isset($f['minLength'])) { - if (trim($in) != '' && $f['minLength'] && strlen($in) < $f['minLength']) { - $this->inputFieldStatus = false; - $this->inputErrorReason = 'Input is shorter than minimum length of '.$f['minLength'].' characters.'; - return $in; + if (isset($f['minLength'])) { + if (trim($in) != '' && $f['minLength'] && strlen($in) < $f['minLength']) { + $this->inputFieldStatus = false; + $this->inputErrorReason = 'Input is shorter than minimum length of '.$f['minLength'].' characters.'; + return $in; } } - if (isset($f['maxLength'])) { - if (trim($in) != '' && $f['maxLength'] && strlen($in) > $f['maxLength']) { - $this->inputFieldStatus = false; - $this->inputErrorReason = 'Input provided is '.strlen($in).' characters. The maximum length is '.$f['maxLength'].' characters.'; - return $in; + if (isset($f['maxLength'])) { + if (trim($in) != '' && $f['maxLength'] && strlen($in) > $f['maxLength']) { + $this->inputFieldStatus = false; + $this->inputErrorReason = 'Input provided is '.strlen($in).' characters. The maximum length is '.$f['maxLength'].' characters.'; + return $in; } } @@ -1402,45 +1402,45 @@ abstract class GlmDataAbstract $sep = ''; switch ($f['pw_type']) { case 'strong': - if (!preg_match("/[0-9]+/", $in)) { + if (!preg_match("/[0-9]+/", $in)) { $pwReason .= "Password must include at least one number!"; $typeOK = false; - $sep = "
"; - } - if (!preg_match("/[a-zA-Z]+/", $in)) { - $pwReason .= $sep."Password must include at least one letter!"; + $sep = "
"; + } + if (!preg_match("/[a-zA-Z]+/", $in)) { + $pwReason .= $sep."Password must include at least one letter!"; $typeOK = false; $sep = "
"; - } - if (!preg_match("/[\#\.\-\_\,\$\%\&\!]+/", $in)) { - $pwReason .= $sep."Password must include at least one of these characters!
   # . - _ , $ % & !"; + } + if (!preg_match("/[\#\.\-\_\,\$\%\&\!]+/", $in)) { + $pwReason .= $sep."Password must include at least one of these characters!
   # . - _ , $ % & !"; $typeOK = false; - } + } break; default: break; } if (!$typeOK) { - $this->inputFieldStatus = false; - $this->inputErrorReason = $pwReason; - return $in; + $this->inputFieldStatus = false; + $this->inputErrorReason = $pwReason; + return $in; } - } - + } + // Don't try to crypt a blank password $c = ''; if ($in != '') { $c = crypt($in); } - - return $c; - } - private function passwordStore($in, $f) - { - $r = "'".addslashes($in)."'"; - return $r; - } + + return $c; + } + private function passwordStore($in, $f) + { + $r = "'".addslashes($in)."'"; + return $r; + } /* * Checkbox Field Processing @@ -1673,24 +1673,24 @@ abstract class GlmDataAbstract 'timestamp' => strtotime($text_date) ); - // Build picklists for date input + // Build picklists for date input $date_list = false; - - if ($this->optionIncludeSelectListData || $forEdit ) { - - $date_list = $this->buildDateFieldLists($min, $max); - - // Get default values for list selection and set in date_list array - $def_month = date('n', $t); - $date_list['month'][$def_month]['default'] = true; - $def_day = date('j', $t); - $date_list['day'][$def_day]['default'] = true; - $def_year = date('Y', $t); + + if ($this->optionIncludeSelectListData || $forEdit ) { + + $date_list = $this->buildDateFieldLists($min, $max); + + // Get default values for list selection and set in date_list array + $def_month = date('n', $t); + $date_list['month'][$def_month]['default'] = true; + $def_day = date('j', $t); + $date_list['day'][$def_day]['default'] = true; + $def_year = date('Y', $t); $date_list['year'][$def_year]['default'] = true; - $out['date_list'] = $date_list; - } - + $out['date_list'] = $date_list; + } + return $out; } private function dateInput($as, $f, $id, $idfield, $op) diff --git a/setup/frontHooks.php b/setup/frontHooks.php index c6a11b5e..db87c01f 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -198,10 +198,12 @@ if (!function_exists('is_in_tree')) { if ( is_page( $pid ) ) { return true; } - $anc = get_post_ancestors( $post->ID ); - foreach ( $anc as $ancestor ) { - if( is_page() && $ancestor == $pid ) { - return true; + if ($post) { + $anc = get_post_ancestors( $post->ID ); + foreach ( $anc as $ancestor ) { + if( is_page() && $ancestor == $pid ) { + return true; + } } } return false; diff --git a/views/front/error/badAction.html b/views/front/error/badAction.html index 50c1f711..3a6f546a 100644 --- a/views/front/error/badAction.html +++ b/views/front/error/badAction.html @@ -25,7 +25,7 @@

Return to Home Page

- +