[geeklog-cvs] geeklog: Fixed problems with strings being converted to numbers ...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Thu Feb 24 15:41:20 EST 2011


changeset 8133:b7e0ce2c72e3
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/b7e0ce2c72e3
user: Tom <websitemaster at cogeco.net>
date: Thu Feb 24 15:40:39 2011 -0500
description:
Fixed problems with strings being converted to numbers in Configuration.
Fixed problem in Configuration where OAuth Facebook and Twitter did not allow empty field.
New Configuration validation string and stringOrEmpty.

diffstat:

 public_html/admin/configuration_validation.php |  15 +++++-
 system/classes/validator.class.php             |  57 ++++++++++++++++++++++++++
 2 files changed, 68 insertions(+), 4 deletions(-)

diffs (108 lines):

diff -r 8e419d08f775 -r b7e0ce2c72e3 public_html/admin/configuration_validation.php
--- a/public_html/admin/configuration_validation.php	Thu Feb 24 14:43:41 2011 +0000
+++ b/public_html/admin/configuration_validation.php	Thu Feb 24 15:40:39 2011 -0500
@@ -34,12 +34,17 @@
 $_CONF_VALIDATE['Core']['site_url'] = array('rule' => 'url');
 $_CONF_VALIDATE['Core']['site_admin_url'] = array('rule' => 'url');
 $_CONF_VALIDATE['Core']['site_name'] = array('rule' => 'notEmpty');
+$_CONF_VALIDATE['Core']['site_slogan'] = array('rule' => 'stringOrEmpty');
+$_CONF_VALIDATE['Core']['microsummary_short'] = array('rule' => 'stringOrEmpty');
+$_CONF_VALIDATE['Core']['site_disabled_msg'] = array('rule' => 'stringOrEmpty');
 $_CONF_VALIDATE['Core']['copyrightyear'] = array(
     'rule' => 'copyrightyear',
     'message' => isset($LANG_VALIDATION['year']) ? $LANG_VALIDATION['year'] : $LANG_VALIDATION['default']
 );
 $_CONF_VALIDATE['Core']['url_rewrite'] = array('rule' => 'boolean');
 $_CONF_VALIDATE['Core']['meta_tags'] = array('rule' => array('inList', array(0, 1, 2), true));
+$_CONF_VALIDATE['Core']['meta_description'] = array('rule' => 'stringOrEmpty');
+$_CONF_VALIDATE['Core']['meta_keywords'] = array('rule' => 'stringOrEmpty');
 $_CONF_VALIDATE['Core']['site_mail'] = array('rule' => 'email');
 
 /* Subgroup Site, Tab Mail */
@@ -262,12 +267,14 @@
 $_CONF_VALIDATE['Core']['user_login_method[3rdparty]'] = array('rule' => 'boolean');
 $_CONF_VALIDATE['Core']['user_login_method[oauth]'] = array('rule' => 'boolean');
 $_CONF_VALIDATE['Core']['facebook_login'] = array('rule' => 'boolean');
-$_CONF_VALIDATE['Core']['facebook_consumer_key'] = array('rule' => 'alphaNumeric');
-$_CONF_VALIDATE['Core']['facebook_consumer_secret'] = array('rule' => 'alphaNumeric');
+$_CONF_VALIDATE['Core']['facebook_consumer_key'] = array('rule' => 'stringOrEmpty');
+$_CONF_VALIDATE['Core']['facebook_consumer_secret'] = array('rule' => 'stringOrEmpty');
 $_CONF_VALIDATE['Core']['linkedin_login'] = array('rule' => 'boolean');
+$_CONF_VALIDATE['Core']['linkedin_consumer_key'] = array('rule' => 'stringOrEmpty');
+$_CONF_VALIDATE['Core']['linkedin_consumer_secret'] = array('rule' => 'stringOrEmpty');
 $_CONF_VALIDATE['Core']['twitter_login'] = array('rule' => 'boolean');
-$_CONF_VALIDATE['Core']['twitter_consumer_key'] = array('rule' => 'alphaNumeric');
-$_CONF_VALIDATE['Core']['twitter_consumer_secret'] = array('rule' => 'alphaNumeric');
+$_CONF_VALIDATE['Core']['twitter_consumer_key'] = array('rule' => 'stringOrEmpty');
+$_CONF_VALIDATE['Core']['twitter_consumer_secret'] = array('rule' => 'stringOrEmpty');
 $_CONF_VALIDATE['Core']['aftersave_user'] = array(
     'rule' => array('inList', array('admin', 'home', 'list', 'item'), true)
 );
diff -r 8e419d08f775 -r b7e0ce2c72e3 system/classes/validator.class.php
--- a/system/classes/validator.class.php	Thu Feb 24 14:43:41 2011 +0000
+++ b/system/classes/validator.class.php	Thu Feb 24 15:40:39 2011 -0500
@@ -659,7 +659,64 @@
 		}
 		return is_finite($check);
 	}
+	
+/**
+ * Checks that a string contains something
+ *
+ * Returns true if string contains any characters. Function added so
+ * old validation would be bypassed.
+ *
+ * $check can be passed as an array:
+ * array('check' => 'valueToCheck');
+ *
+ * @param mixed $check Value to check
+ * @return boolean Success
+ * @access public
+ */
+	function string($check) {
+		$_this =& validator::getInstance();
+		$_this->__reset();
+		$_this->check = $check;
 
+		if (is_array($check)) {
+			$_this->_extract($check);
+		}
+
+		// No check is needed expect if something exists
+		if (empty($_this->check) && $_this->check != '0') {
+			return false;
+		}
+		
+		return true;
+	}
+	
+/**
+ * Checks that a string contains either nothing or something
+ *
+ * Returns true if string contains nothing or any characters. Function added so
+ * old validation would be bypassed.
+ *
+ * $check can be passed as an array:
+ * array('check' => 'valueToCheck');
+ *
+ * @param mixed $check Value to check
+ * @return boolean Success
+ * @access public
+ */
+	function stringOrEmpty($check) {
+		$_this =& validator::getInstance();
+		$_this->__reset();
+		$_this->check = $check;
+
+		if (is_array($check)) {
+			$_this->_extract($check);
+		}
+		
+		// No check is needed since none or any values are fine.
+		
+		return true;
+	}	
+	
 /**
  * Checks that a value is a valid URL according to http://www.w3.org/Addressing/URL/url-spec.txt
  *



More information about the geeklog-cvs mailing list