[Fusionforge-commits] FusionForge branch Branch_5_3 updated. 3937655fd99d1e7c86e54b11fbb0b701711aff38

Franck Villaume nerville at fusionforge.org
Sun Mar 30 19:29:36 CEST 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, Branch_5_3 has been updated
       via  3937655fd99d1e7c86e54b11fbb0b701711aff38 (commit)
       via  2853a750d4a99610e5d1e3f9aa2ca0846901f8f9 (commit)
       via  ac28f5e2b8ca7bf65b0f071014c6769715778b11 (commit)
      from  5839a6ec85848ad698370b34eb6c7afbe2f44ec9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 3937655fd99d1e7c86e54b11fbb0b701711aff38
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Sun Mar 30 19:29:13 2014 +0200

    tracker vote: fix permission

diff --git a/src/common/include/RBAC.php b/src/common/include/RBAC.php
index 2a08fd5..1307190 100644
--- a/src/common/include/RBAC.php
+++ b/src/common/include/RBAC.php
@@ -69,11 +69,11 @@ abstract class BaseRole extends Error {
 			'pm_admin' => array(0, 1),
 			'forum_admin' => array(0, 1),
 
-			'tracker' => array(0, 1, 9, 11, 13, 15, 23, 25, 27, 29),
+			'tracker' => array(0, 1, 9, 11, 13, 15, 25, 27, 29, 31),
 			'pm' => array(0, 1, 3, 5, 7),
 			'forum' => array(0, 1, 2, 3, 4),
 
-			'new_tracker' => array(0, 1, 9, 11, 13, 15, 23, 25, 27, 29),
+			'new_tracker' => array(0, 1, 9, 11, 13, 15, 25, 27, 29, 31),
 			'new_pm' => array(0, 1, 3, 5, 7),
 			'new_forum' => array(0, 1, 2, 3, 4),
 
diff --git a/src/common/include/rbac_texts.php b/src/common/include/rbac_texts.php
index e03d74e..901ed9f 100644
--- a/src/common/include/rbac_texts.php
+++ b/src/common/include/rbac_texts.php
@@ -81,14 +81,22 @@ function setup_rbac_strings () {
 								  'tracker13' => _('Manager'),
 								  'tracker14' => _('Tech & manager (no read access)'),
 								  'tracker15' => _('Tech & manager'),
-								  'tracker22' => _('No access + Vote'),
-								  'tracker23' => _('Read only + Vote'),
-								  'tracker24' => _('Technician (no read access) + Vote'),
-								  'tracker25' => _('Technician + Vote'),
-								  'tracker26' => _('Manager (no read access) + Vote'),
-								  'tracker27' => _('Manager + Vote'),
-								  'tracker28' => _('Tech & manager (no read access) + Vote'),
-								  'tracker29' => _('Tech & manager + Vote'),
+								  'tracker16' => _('No access + Vote'),
+								  'tracker17' => _('Read only + Vote'),
+								  'tracker18' => _('Technician (no read access, no submitting) + Vote'),
+								  'tracker19' => _('Technician (no submitting) + Vote'),
+								  'tracker20' => _('Manager (no read access, no submitting) + Vote'),
+								  'tracker21' => _('Manager (no submitting) + Vote'),
+								  'tracker22' => _('Tech & manager (no read access, no submitting) + Vote'),
+								  'tracker23' => _('Tech & manager (no submitting) + Vote'),
+								  'tracker24' => _('Submit only + Vote'),
+								  'tracker25' => _('Read & submit + Vote'),
+								  'tracker26' => _('Technician (no read access) + Vote'),
+								  'tracker27' => _('Technician + Vote'),
+								  'tracker28' => _('Manager (no read access) + Vote'),
+								  'tracker29' => _('Manager + Vote'),
+								  'tracker30' => _('Tech & manager (no read access) + Vote'),
+								  'tracker31' => _('Tech & manager + Vote'),
 								  'pm0' => _('No Access'),
 								  'pm1' => _('Read only'),
 								  'pm2' => _('Technician (no read access)'),
@@ -119,14 +127,22 @@ function setup_rbac_strings () {
 								  'new_tracker13' => _('Manager'),
 								  'new_tracker14' => _('Tech & manager (no read access)'),
 								  'new_tracker15' => _('Tech & manager'),
-								  'new_tracker22' => _('No access + Vote'),
-								  'new_tracker23' => _('Read only + Vote'),
-								  'new_tracker24' => _('Technician (no read access) + Vote'),
-								  'new_tracker25' => _('Technician + Vote'),
-								  'new_tracker26' => _('Manager (no read access) + Vote'),
-								  'new_tracker27' => _('Manager + Vote'),
-								  'new_tracker28' => _('Tech & manager (no read access) + Vote'),
-								  'new_tracker29' => _('Tech & manager + Vote'),
+								  'new_tracker16' => _('No access + Vote'),
+								  'new_tracker17' => _('Read only + Vote'),
+								  'new_tracker18' => _('Technician (no read access, no submitting) + Vote'),
+								  'new_tracker19' => _('Technician (no submitting) + Vote'),
+								  'new_tracker20' => _('Manager (no read access, no submitting) + Vote'),
+								  'new_tracker21' => _('Manager (no submitting) + Vote'),
+								  'new_tracker22' => _('Tech & manager (no read access, no submitting) + Vote'),
+								  'new_tracker23' => _('Tech & manager (no submitting) + Vote'),
+								  'new_tracker24' => _('Submit only + Vote'),
+								  'new_tracker25' => _('Read & submit + Vote'),
+								  'new_tracker26' => _('Technician (no read access) + Vote'),
+								  'new_tracker27' => _('Technician + Vote'),
+								  'new_tracker28' => _('Manager (no read access) + Vote'),
+								  'new_tracker29' => _('Manager + Vote'),
+								  'new_tracker30' => _('Tech & manager (no read access) + Vote'),
+								  'new_tracker31' => _('Tech & manager + Vote'),
 								  'new_pm0' => _('No Access'),
 								  'new_pm1' => _('Read only'),
 								  'new_pm2' => _('Technician (no read access)'),

commit 2853a750d4a99610e5d1e3f9aa2ca0846901f8f9
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Sun Mar 30 18:49:17 2014 +0200

    indent

diff --git a/src/common/valid/Rule.class.php b/src/common/valid/Rule.class.php
index 5172fca..a4d72e8 100644
--- a/src/common/valid/Rule.class.php
+++ b/src/common/valid/Rule.class.php
@@ -24,30 +24,30 @@
  * @package Codendi
  */
 class Rule {
-    /**
-     * @access private
-     */
-    var $error;
+	/**
+	* @access private
+	*/
+	var $error;
 
-    /**
-     * Check if $val is a valid not.
-     *
-     * @param  String  $val Value to check.
-     * @return Boolean
-     */
-    function isValid($val) {
-        trigger_error(get_class($this).'::isValid() => Not yet implemented', E_USER_ERROR);
-    }
+	/**
+	* Check if $val is a valid not.
+	*
+	* @param  String  $val Value to check.
+	* @return Boolean
+	*/
+	function isValid($val) {
+		trigger_error(get_class($this).'::isValid() => Not yet implemented', E_USER_ERROR);
+	}
 
-    /**
-     * Default error message if rule is not apply on value.
-     *
-     * @param  string  $key Value to check.
-     * @return boolean
-     */
-    function getErrorMessage($key) {
-        return $this->error;
-    }
+	/**
+	* Default error message if rule is not apply on value.
+	*
+	* @param  string  $key Value to check.
+	* @return boolean
+	*/
+	function getErrorMessage($key) {
+		return $this->error;
+	}
 }
 
 /**
@@ -56,84 +56,78 @@ class Rule {
  * Note: this date format is more restrictive than php check date because in
  * this case, 2007-01-01 format (with zero in month or day) is not allowed.
  */
-class Rule_Date
-extends Rule {
-    function isValid($val) {
-        if(preg_match('/^(\d{1,4})-(\d{1,2})-(\d{1,2}?)$/', $val, $m)) {
-            return checkdate($m[2], $m[3], $m[1]);
-        } else {
-            return false;
-        }
-    }
+class Rule_Date extends Rule {
+	function isValid($val) {
+		if(preg_match('/^(\d{1,4})-(\d{1,2})-(\d{1,2}?)$/', $val, $m)) {
+			return checkdate($m[2], $m[3], $m[1]);
+		} else {
+			return false;
+		}
+	}
 }
 
 /**
  * Abstract class that define left-hand operand for a comparison.
  */
-class Rule_Comparator
-extends Rule {
-    /**
-     * @access private
-     */
-    var $ref;
-    function Rule_Comparator($ref) {
-        $this->ref = $ref;
-    }
+class Rule_Comparator extends Rule {
+	/**
+	 * @access private
+	 */
+	var $ref;
+	function Rule_Comparator($ref) {
+		$this->ref = $ref;
+	}
 }
 
 /**
  * Check that given value is strictly greater than the one defined in
  * constructor.
  */
-class Rule_GreaterThan
-extends Rule_Comparator {
-    function isValid($val) {
-        if(is_numeric($val) && $val > $this->ref) {
-            return true;
-        }
-        return false;
-    }
+class Rule_GreaterThan extends Rule_Comparator {
+	function isValid($val) {
+		if(is_numeric($val) && $val > $this->ref) {
+			return true;
+		}
+		return false;
+	}
 }
 
 /**
  * Check that given value is strictly less than the one defined in constructor.
  */
-class Rule_LessThan
-extends Rule_Comparator {
-    function isValid($val) {
-        if(is_numeric($val) && $val < $this->ref) {
-            return true;
-        }
-        return false;
-    }
+class Rule_LessThan extends Rule_Comparator {
+	function isValid($val) {
+		if(is_numeric($val) && $val < $this->ref) {
+			return true;
+		}
+		return false;
+	}
 }
 
 /**
  * Check that given value is greater or equal to the one defined in
  * constructor.
  */
-class Rule_GreaterOrEqual
-extends Rule_Comparator {
-    function isValid($val) {
-        if(is_numeric($val) && $val >= $this->ref) {
-            return true;
-        }
-        return false;
-    }
+class Rule_GreaterOrEqual extends Rule_Comparator {
+	function isValid($val) {
+		if(is_numeric($val) && $val >= $this->ref) {
+			return true;
+		}
+		return false;
+	}
 }
 
 /**
  * Check that given value is strictly less or equal to the one defined in
  * constructor.
  */
-class Rule_lessOrEqual
-extends Rule_Comparator {
-    function isValid($val) {
-        if(is_numeric($val) && $val <= $this->ref) {
-            return true;
-        }
-        return false;
-    }
+class Rule_lessOrEqual extends Rule_Comparator {
+	function isValid($val) {
+		if(is_numeric($val) && $val <= $this->ref) {
+			return true;
+		}
+		return false;
+	}
 }
 
 /**
@@ -141,74 +135,65 @@ extends Rule_Comparator {
  *
  * There is no type check.
  */
-class Rule_WhiteList
-extends Rule_Comparator {
-    function isValid($val) {
-        if(is_array($this->ref)
-           && count($this->ref) > 0
-           && in_array($val, $this->ref)) {
-            return true;
-        }
-        return false;
-    }
+class Rule_WhiteList extends Rule_Comparator {
+	function isValid($val) {
+		if(is_array($this->ref) && count($this->ref) > 0 && in_array($val, $this->ref)) {
+			return true;
+		}
+		return false;
+	}
 }
 
 /**
  * Check that given value is a valid signed 32 bits decimal integer.
  */
-class Rule_Int
-extends Rule {
-    /**
-     * Check the format according to PHP definition of a decimal integer.
-     * @see http://php.net/int
-     * @access private
-     */
-    function checkFormat($val) {
-        if(preg_match('/^([+-]?[1-9][0-9]*|[+-]?0)$/', $val)) {
-            return true;
-        } else {
-            return false;
-        }
-    }
+class Rule_Int extends Rule {
+	/**
+	 * Check the format according to PHP definition of a decimal integer.
+	 * @see http://php.net/int
+	 * @access private
+	 */
+	function checkFormat($val) {
+		if(preg_match('/^([+-]?[1-9][0-9]*|[+-]?0)$/', $val)) {
+			return true;
+		}
+		return false;
+	}
 
-    function isValid($val) {
-        // Need to check with the regexp because of octal form '0123' that is
-        // equal to '123' with string '==' comparison.
-        if($this->checkFormat($val)) {
-            // Check (-2^31;2^31-1) range
-            if(strval(intval($val)) == $val) {
-                return true;
-            } else {
-                return false;
-            }
-        } else {
-            return false;
-        }
-    }
+	function isValid($val) {
+		// Need to check with the regexp because of octal form '0123' that is
+		// equal to '123' with string '==' comparison.
+		if($this->checkFormat($val)) {
+			// Check (-2^31;2^31-1) range
+			if(strval(intval($val)) == $val) {
+				return true;
+			} else {
+				return false;
+			}
+		}
+		return false;
+	}
 }
 
 /**
  * Check that given value is a string.
  */
-class Rule_String
-extends Rule {
-    function isValid($val) {
-        return is_string($val);
-    }
+class Rule_String extends Rule {
+	function isValid($val) {
+		return is_string($val);
+	}
 }
 
 /**
  * Check if given string contains neither a carrige return nor a null char.
  */
-class Rule_NoCr
-extends Rule {
-    function isValid($val) {
-        if(is_string($val) && strpos($val, 0x0A) === false && strpos($val, 0x0D) === false
-           && strpos($val, 0x00) === false) {
-            return true;
-        }
-        return false;
-    }
+class Rule_NoCr extends Rule {
+	function isValid($val) {
+		if(is_string($val) && strpos($val, 0x0A) === false && strpos($val, 0x0D) === false && strpos($val, 0x00) === false) {
+			return true;
+		}
+		return false;
+	}
 }
 
 /**
@@ -220,49 +205,47 @@ extends Rule {
  *
  * The faulty email address is available with $this->getErrorMessage();
  */
-class Rule_Email
-extends Rule {
-    var $separator;
+class Rule_Email extends Rule {
+	var $separator;
 
-    function Rule_Email($separator = null) {
-        $this->separator = $separator;
-    }
+	function Rule_Email($separator = null) {
+		$this->separator = $separator;
+	}
 
-    function isValid($val) {
-        if($this->separator !== null) {
-            // If separator is defined, split the string and check each email.
-            $emails = split($this->separator, $val);
-            $valid = true;
-            while((list($key,$email) = each($emails)) && $valid) {
-                $valid = $valid & $this->validEmail(trim(rtrim($email)));
-            }
-        } else {
-            // $val must contains only one email address
-            $valid = $this->validEmail($val);
-        }
-        return $valid;
-    }
+	function isValid($val) {
+		if($this->separator !== null) {
+			// If separator is defined, split the string and check each email.
+			$emails = split($this->separator, $val);
+			$valid = true;
+			while((list($key,$email) = each($emails)) && $valid) {
+				$valid = $valid & $this->validEmail(trim(rtrim($email)));
+			}
+		} else {
+		// $val must contains only one email address
+			$valid = $this->validEmail($val);
+		}
+		return $valid;
+	}
 
-    /**
-     * Check email validity
-     *
-     * Important note: this is very important to keep the 'D' regexp modifier
-     * as this is the only way not to be bothered by injections of \n into the
-     * email address.
-     *
-     * Spaces are allowed at the beginning and the end of the address.
-     */
-    function validEmail($email) {
-        $valid_chars='-!#$%&\'*+0-9=?A-Z^_`a-z{|}~\.';
-        if (array_key_exists('sys_disable_subdomains', $GLOBALS)
-            && $GLOBALS['sys_disable_subdomains']) {
-            $valid_domain='['.$valid_chars.']+';
-        } else {
-            $valid_domain='['.$valid_chars.']+\.['.$valid_chars.']+';
-        }
-        $regexp = '/^['.$valid_chars.']+'.'@'.$valid_domain.'$/D';
-        return preg_match($regexp, $email);
-    }
+	/**
+	 * Check email validity
+	 *
+	 * Important note: this is very important to keep the 'D' regexp modifier
+	 * as this is the only way not to be bothered by injections of \n into the
+	 * email address.
+	 *
+	 * Spaces are allowed at the beginning and the end of the address.
+	 */
+	function validEmail($email) {
+		$valid_chars='-!#$%&\'*+0-9=?A-Z^_`a-z{|}~\.';
+		if (array_key_exists('sys_disable_subdomains', $GLOBALS) && $GLOBALS['sys_disable_subdomains']) {
+			$valid_domain='['.$valid_chars.']+';
+		} else {
+			$valid_domain='['.$valid_chars.']+\.['.$valid_chars.']+';
+		}
+		$regexp = '/^['.$valid_chars.']+'.'@'.$valid_domain.'$/D';
+		return preg_match($regexp, $email);
+	}
 }
 
 /**
@@ -270,38 +253,37 @@ extends Rule {
  *
  * This rule doesn't check that user actually exists.
  */
-class Rule_UserNameFormat
-extends Rule {
+class Rule_UserNameFormat extends Rule {
 
-    function containsIllegalChars($val) {
-        return (strspn($val,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_") != strlen($val));
-    }
+	function containsIllegalChars($val) {
+		return (strspn($val,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_") != strlen($val));
+	}
 
-    function isNotLegalName($val) {
-        return preg_match('/^((root)|(bin)|(daemon)|(adm)|(lp)|(sync)|(shutdown)|(halt)|(mail)|(news)'
-                          .'|(uucp)|(operator)|(games)|(mysql)|(httpd)|(nobody)|(dummy)'
-                          .'|(www)|(cvs)|(shell)|(ftp)|(irc)|(debian)|(ns)|(download))$/i', $val);
-    }
+	function isNotLegalName($val) {
+		return preg_match('/^((root)|(bin)|(daemon)|(adm)|(lp)|(sync)|(shutdown)|(halt)|(mail)|(news)'
+				.'|(uucp)|(operator)|(games)|(mysql)|(httpd)|(nobody)|(dummy)'
+				.'|(www)|(cvs)|(shell)|(ftp)|(irc)|(debian)|(ns)|(download))$/i', $val);
+	}
 
-    function isCvsAccount($val) {
-        return preg_match('/^anoncvs_/i', $val);
-    }
+	function isCvsAccount($val) {
+		return preg_match('/^anoncvs_/i', $val);
+	}
 
-    function lessThanMin($val) {
-        return (strlen($val) < 3);
-    }
+	function lessThanMin($val) {
+		return (strlen($val) < 3);
+	}
 
-    function greaterThanMax($val) {
-        return (strlen($val) > 30);
-    }
+	function greaterThanMax($val) {
+		return (strlen($val) > 30);
+	}
 
-    function isValid($val) {
-        return !$this->isNotLegalName($val)
-            && !$this->isCvsAccount($val)
-            && !$this->lessThanMin($val)
-            && !$this->greaterThanMax($val)
-            && !$this->containsIllegalChars($val);
-    }
+	function isValid($val) {
+		return !$this->isNotLegalName($val)
+			&& !$this->isCvsAccount($val)
+			&& !$this->lessThanMin($val)
+			&& !$this->greaterThanMax($val)
+			&& !$this->containsIllegalChars($val);
+	}
 }
 
 /**
@@ -315,23 +297,22 @@ extends Rule {
  * variable but may be customized with setMaxSize.
  */
 //require_once("www/file/file_utils.php"); // Needed for 2 GB workaround
-class Rule_File
-extends Rule {
-    var $maxSize;
-    var $i18nPageName;
+class Rule_File extends Rule {
+	var $maxSize;
+	var $i18nPageName;
 
-    function Rule_File() {
-        $this->maxSize = $GLOBALS['sys_max_size_upload'];
-        $this->i18nPageName = 'rule_valid';
-    }
+	function Rule_File() {
+		$this->maxSize = $GLOBALS['sys_max_size_upload'];
+		$this->i18nPageName = 'rule_valid';
+	}
 
-    function setMaxSize($max) {
-        $this->maxSize = $max;
-    }
+	function setMaxSize($max) {
+		$this->maxSize = $max;
+	}
 
-    function geti18nError($key, $params="") {
-        return $GLOBALS['Language']->getText($this->i18nPageName, $key, $params);
-    }
+	function geti18nError($key, $params="") {
+		return $GLOBALS['Language']->getText($this->i18nPageName, $key, $params);
+	}
 
 	/**
 	 * Check file upload validity
@@ -339,42 +320,42 @@ extends Rule {
 	 * @param string $file
 	 * @return boolean Is file upload valid or not.
 	 */
-    function isValid($file) {
-        $ok = false;
-        if(is_array($file)) {
-            switch($file['error']) {
-            case UPLOAD_ERR_OK:
-                // all is OK
-                $ok = true;
-                break;
-            case UPLOAD_ERR_INI_SIZE:
-            case UPLOAD_ERR_FORM_SIZE:
-                $this->error = $this->geti18nError('error_upload_size', $file['error']);
-                break;
-            case UPLOAD_ERR_PARTIAL:
-                $this->error = $this->geti18nError('error_upload_partial', $file['error']);
-                break;
-            case UPLOAD_ERR_NO_FILE:
-                $this->error = $this->geti18nError('error_upload_nofile', $file['error']);
-                break;
-                //case UPLOAD_ERR_NO_TMP_DIR: PHP 5.0.3
-                //case UPLOAD_ERR_CANT_WRITE: PHP 5.1.0
-                //case UPLOAD_ERR_EXTENSION: PHP 5.2.0
-            default:
-                $this->error = $this->geti18nError('error_upload_unknown', $file['error']);
-            }
-            if($ok && $file['name'] == '') {
-                $ok = false;
-                $this->error = $this->geti18nError('error_upload');
-            }
-            if($ok) {
-                // Re-check filesize (do not trust uploaded MAX_FILE_SIZE)
-                if(file_utils_get_size($file['tmp_name']) > $this->maxSize) {
-                   $ok = false;
-                   $this->error = $this->geti18nError('error_upload_size', 1);
-                }
-            }
-        }
-        return $ok;
-    }
+	function isValid($file) {
+		$ok = false;
+		if(is_array($file)) {
+			switch($file['error']) {
+				case UPLOAD_ERR_OK:
+					// all is OK
+					$ok = true;
+					break;
+				case UPLOAD_ERR_INI_SIZE:
+				case UPLOAD_ERR_FORM_SIZE:
+					$this->error = $this->geti18nError('error_upload_size', $file['error']);
+					break;
+				case UPLOAD_ERR_PARTIAL:
+					$this->error = $this->geti18nError('error_upload_partial', $file['error']);
+					break;
+				case UPLOAD_ERR_NO_FILE:
+					$this->error = $this->geti18nError('error_upload_nofile', $file['error']);
+					break;
+				//case UPLOAD_ERR_NO_TMP_DIR: PHP 5.0.3
+				//case UPLOAD_ERR_CANT_WRITE: PHP 5.1.0
+				//case UPLOAD_ERR_EXTENSION: PHP 5.2.0
+				default:
+					$this->error = $this->geti18nError('error_upload_unknown', $file['error']);
+			}
+			if($ok && $file['name'] == '') {
+				$ok = false;
+				$this->error = $this->geti18nError('error_upload');
+			}
+			if($ok) {
+				// Re-check filesize (do not trust uploaded MAX_FILE_SIZE)
+				if(file_utils_get_size($file['tmp_name']) > $this->maxSize) {
+					$ok = false;
+					$this->error = $this->geti18nError('error_upload_size', 1);
+				}
+			}
+		}
+		return $ok;
+	}
 }
diff --git a/src/common/valid/ValidFactory.class.php b/src/common/valid/ValidFactory.class.php
index 0466037..0d6fd5c 100644
--- a/src/common/valid/ValidFactory.class.php
+++ b/src/common/valid/ValidFactory.class.php
@@ -26,79 +26,72 @@ require_once 'common/valid/Valid.class.php';
  * Check that value is a decimal integer greater or equal to zero.
  * @package Codendi
  */
-class Valid_UInt
-extends Valid {
-    function validate($value) {
-        $this->addRule(new Rule_Int());
-        $this->addRule(new Rule_GreaterOrEqual(0));
-        return parent::validate($value);
-    }
-
+class Valid_UInt extends Valid {
+	function validate($value) {
+		$this->addRule(new Rule_Int());
+		$this->addRule(new Rule_GreaterOrEqual(0));
+		return parent::validate($value);
+	}
 }
 
 /**
  * Check that group_id variable is valid
  */
-class Valid_GroupId
-extends Valid {
-    function Valid_GroupId() {
-        parent::Valid('group_id');
-        //$this->setErrorMessage(_("Error: No group_id was chosen."));
-    }
-
-    function validate($value) {
-        $this->addRule(new Rule_Int());
-        $this->addRule(new Rule_GreaterThan(0));
-        return parent::validate($value);
-    }
+class Valid_GroupId extends Valid {
+	function Valid_GroupId() {
+		parent::Valid('group_id');
+		//$this->setErrorMessage(_("Error: No group_id was chosen."));
+	}
+
+	function validate($value) {
+		$this->addRule(new Rule_Int());
+		$this->addRule(new Rule_GreaterThan(0));
+		return parent::validate($value);
+	}
 }
 
 /**
  * Check that 'pv' parameter is set to an acceptable value.
  */
-class Valid_Pv
-extends Valid {
-    function Valid_Pv() {
-        parent::Valid('pv');
-    }
-
-    function validate($value) {
-        $this->addRule(new Rule_WhiteList(array(0,1,2)));
-        return parent::validate($value);
-    }
+class Valid_Pv extends Valid {
+	function Valid_Pv() {
+		parent::Valid('pv');
+	}
+
+	function validate($value) {
+		$this->addRule(new Rule_WhiteList(array(0,1,2)));
+		return parent::validate($value);
+	}
 }
 
 /**
  * Check that value is a string (should always be true).
  */
-class Valid_Text
-extends Valid {
-    function validate($value) {
-        $this->addRule(new Rule_String());
-        return parent::validate($value);
-    }
+class Valid_Text extends Valid {
+	function validate($value) {
+		$this->addRule(new Rule_String());
+		return parent::validate($value);
+	}
 }
 
 /**
  * Check that value is a string with neither carrige return nor null char.
  */
-class Valid_String
-extends Valid_Text {
-    function validate($value) {
-        $this->addRule(new Rule_NoCr());
-        return parent::validate($value);
-    }
+class Valid_String extends Valid_Text {
+	function validate($value) {
+		$this->addRule(new Rule_NoCr());
+		return parent::validate($value);
+	}
 }
 
 /**
  * Wrapper for 'WhiteList' rule
  */
-class Valid_WhiteList
-extends Valid {
-    function Valid_WhiteList($key, $whitelist) {
-        parent::Valid($key);
-        $this->addRule(new Rule_WhiteList($whitelist));
-    }
+class Valid_WhiteList extends Valid {
+	function Valid_WhiteList($key, $whitelist) {
+		parent::Valid($key);
+		$this->addRule(new Rule_WhiteList($whitelist));
+	}
 }
 
 /**
@@ -106,94 +99,89 @@ extends Valid {
  *
  * This rule doesn't check that user actually exists.
  */
-class Valid_UserNameFormat
-extends Valid_String {
-    function validate($value) {
-        $this->addRule(new Rule_UserNameFormat());
-        return parent::validate($value);
-    }
+class Valid_UserNameFormat extends Valid_String {
+	function validate($value) {
+		$this->addRule(new Rule_UserNameFormat());
+		return parent::validate($value);
+	}
 }
 
 
 /**
  * Check that submitted value is a simple string and a valid Codendi email.
  */
-class Valid_Email
-extends Valid_String {
-    var $separator;
-
-    function Valid_Email($key=null, $separator=null) {
-        if(is_string($separator)) {
-            $this->separator = $separator;
-        } else {
-            $this->separator = null;
-        }
-        parent::Valid($key);
-    }
-
-    function validate($value) {
-        $this->addRule(new Rule_Email($this->separator));
-        return parent::validate($value);
-    }
+class Valid_Email extends Valid_String {
+	var $separator;
+
+	function Valid_Email($key=null, $separator=null) {
+		if(is_string($separator)) {
+			$this->separator = $separator;
+		} else {
+			$this->separator = null;
+		}
+		parent::Valid($key);
+	}
+
+	function validate($value) {
+		$this->addRule(new Rule_Email($this->separator));
+		return parent::validate($value);
+	}
 }
 
 /**
  * Check uploaded file validity.
  */
-class Valid_File
-extends Valid {
+class Valid_File extends Valid {
 
-    /**
-     * Is uploaded file empty or not.
-     *
-     * @param	array $file	One entry of $_FILES
+	/**
+	 * Is uploaded file empty or not.
+	 *
+	 * @param	array	$file	One entry of $_FILES
 	 * @return	bool
 	 */
-    function isEmptyValue($file) {
-        if(!is_array($file)) {
-            return false;
-        } elseif(parent::isEmptyValue($file['name'])) {
-            return false;
-        } else {
-            return true;
-        }
-    }
+	function isEmptyValue($file) {
+		if(!is_array($file)) {
+			return false;
+		} elseif(parent::isEmptyValue($file['name'])) {
+			return false;
+		}
+		return true;
+	}
 
 	/**
 	 * Check rules on given file.
 	 *
-	 * @param	array	$files $_FILES superarray.
+	 * @param	array	$files	$_FILES superarray.
 	 * @param	string	$index
 	 * @return bool
 	 */
-    function validate($files, $index='') {
-        if(is_array($files) && isset($files[$index])) {
-            $this->addRule(new Rule_File());
-            return parent::validate($files[$index]);
-        } elseif($this->isRequired) {
-            return false;
-        } else {
-            return true;
-        }
-    }
+	function validate($files, $index='') {
+		if(is_array($files) && isset($files[$index])) {
+			$this->addRule(new Rule_File());
+			return parent::validate($files[$index]);
+		} elseif($this->isRequired) {
+			return false;
+		}
+		return true;
+	}
 }
 
 
 class ValidFactory {
-    /**
-     * If $validator is an instance of a Validator, do nothing and returns it
-     * If $validator is a string and a validator exists (Valid_String for 'string', Valid_UInt for 'uint', ...) then creates an instance and returns it
-     * Else returns null
-     */
-    /* public static */ function getInstance($validator, $key = null) {
-        if (is_a($validator, 'Valid')) {
-            return $validator;
-        } else if(is_string($validator) && class_exists('Valid_'.$validator)) {
-            $validator_classname = 'Valid_'.$validator;
-            $v = new $validator_classname($key);
-            return $v;
-        } else {
-            return null;
-        }
-    }
+	/**
+	 * If $validator is an instance of a Validator, do nothing and returns it
+	 * If $validator is a string and a validator exists (Valid_String for 'string', Valid_UInt for 'uint', ...) then creates an instance and returns it
+	 * Else returns null
+	 */
+	/* public static */
+	function getInstance($validator, $key = null) {
+		if (is_a($validator, 'Valid')) {
+			return $validator;
+		} else if(is_string($validator) && class_exists('Valid_'.$validator)) {
+			$validator_classname = 'Valid_'.$validator;
+			$v = new $validator_classname($key);
+			return $v;
+		}
+		return null;
+	}
 }

commit ac28f5e2b8ca7bf65b0f071014c6769715778b11
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Sun Mar 30 18:39:38 2014 +0200

    indent

diff --git a/src/common/valid/Valid.class.php b/src/common/valid/Valid.class.php
index 97c1016..d6072df 100644
--- a/src/common/valid/Valid.class.php
+++ b/src/common/valid/Valid.class.php
@@ -3,6 +3,7 @@
  * Copyright (c) STMicroelectronics, 2007. All Rights Reserved.
  *
  * Originally written by Manuel VACELET, 2007.
+ * Copyright 2014, Franck Villaume - TrivialDev
  *
  * This file is a part of Fusionforge.
  *
@@ -26,62 +27,62 @@ require_once 'common/valid/Rule.class.php';
  * @package Codendi
  */
 class Valid {
-    /**
-     * @access private
-     */
-    var $errors;
-
-    /**
-     * @access private
-     */
-    var $key;
-
-    /**
-     * @access private
-     */
-    var $rules;
-
-    /**
-     * @access private
-     */
-    var $isRequired;
-
-    /**
-     * @access private
-     */
-    var $useFeedback;
-
-    /**
-     * @access private
-     */
-    var $globalErrorMessage;
-
-    /**
-     * @access private
-     */
-    var $isValid;
-
-    /**
-     * Constructor
-     */
-    function Valid($key = null) {
-        $this->key = $key;
-        $this->errors = array();
-        $this->rules = array();
-        $this->isRequired = false;
-        $this->useFeedback = true;
-        $this->globalErrorMessage = null;
-        $this->isValid;
-    }
-
-    /**
-     * Return the variable name on which rules must applies.
-     *
-     * @access private
-     */
-    function getKey() {
-        return $this->key;
-    }
+	/**
+	 * @access private
+	 */
+	var $errors;
+
+	/**
+	 * @access private
+	 */
+	var $key;
+
+	/**
+	 * @access private
+	 */
+	var $rules;
+
+	/**
+	 * @access private
+	 */
+	var $isRequired;
+
+	/**
+	 * @access private
+	 */
+	var $useFeedback;
+
+	/**
+	 * @access private
+	 */
+	var $globalErrorMessage;
+
+	/**
+	 * @access private
+	 */
+	var $isValid;
+
+	/**
+	 * Constructor
+	 */
+	function Valid($key = null) {
+		$this->key = $key;
+		$this->errors = array();
+		$this->rules = array();
+		$this->isRequired = false;
+		$this->useFeedback = true;
+		$this->globalErrorMessage = null;
+		$this->isValid;
+	}
+
+	/**
+	 * Return the variable name on which rules must applies.
+	 *
+	 * @access private
+	 */
+	function getKey() {
+		return $this->key;
+	}
 
 	/**
 	 * Add a new rule in this validation.
@@ -91,55 +92,55 @@ class Valid {
 	 * @param Rule   $rule    Reference on rule.
 	 * @param string|bool $message Error message.
 	 */
-    function addRule(&$rule, $message=false) {
-        $this->rules[] =& $rule;
-        $this->errors[] = $message;
-    }
-
-    /**
-     * The value is required.
-     *
-     * All rules must succeed (as usual). Empty / null values are forbidden
-     * (raise an error). And all failure generate an error (instead of a
-     * warning).
-     */
-    function required() {
-        $this->isRequired = true;
-    }
-
-    /**
-     * Turn feedback off.
-     */
-    function disableFeedback() {
-        $this->useFeedback = false;
-    }
-
-    /**
-     * Set a global error message that will replace all other messages.
-     *
-     * Note: If no error, no message raised. The message is raised with either
-     * 'warning' or 'error' level according to required();
-     * @param String Error message
-     */
-    function setErrorMessage($msg) {
-        $this->globalErrorMessage = $msg;
-    }
-
-    /**
-     * Return true if given value is empty
-     *
-     * @access private
-     * @param mixed	$value	Value to test
-     * @return boolean
-     */
-    function isValueEmpty($value) {
-        return ($value === '' || $value === false || $value === null);
-    }
-
-	/**
-	* Append feedback in the global Response object.
-	* @access private
-	*/
+	function addRule(&$rule, $message=false) {
+		$this->rules[] =& $rule;
+		$this->errors[] = $message;
+	}
+
+	/**
+	 * The value is required.
+	 *
+	 * All rules must succeed (as usual). Empty / null values are forbidden
+	 * (raise an error). And all failure generate an error (instead of a
+	 * warning).
+	 */
+	function required() {
+		$this->isRequired = true;
+	}
+
+	/**
+	 * Turn feedback off.
+	 */
+	function disableFeedback() {
+		$this->useFeedback = false;
+	}
+
+	/**
+	 * Set a global error message that will replace all other messages.
+	 *
+	 * Note: If no error, no message raised. The message is raised with either
+	 * 'warning' or 'error' level according to required();
+	 * @param	String	Error message
+	 */
+	function setErrorMessage($msg) {
+		$this->globalErrorMessage = $msg;
+	}
+
+	/**
+	 * Return true if given value is empty
+	 *
+	 * @access	private
+	 * @param	mixed	$value	Value to test
+	 * @return	boolean
+	 */
+	function isValueEmpty($value) {
+		return ($value === '' || $value === false || $value === null);
+	}
+
+	/**
+	 * Append feedback in the global Response object.
+	 * @access private
+	 */
 	function addFeedback($level, $error) {
 		global $feedback, $error_msg, $warning_msg;
 		switch ($level) {
@@ -158,85 +159,83 @@ class Valid {
 		}
 	}
 
-    /**
-     * Generate error message according to settings.
-     *
-     * Takes in account user requirement 'required' and
-     * 'disableFeedback'. Empty error messages are discarded.
-     * @access private
-     */
-    function populateFeedback() {
-        if($this->useFeedback) {
-            $level = 'warning';
-            if($this->isRequired) {
-                $level = 'error';
-            }
-            if($this->globalErrorMessage !== null &&
-               !$this->isValid) {
-                $this->addFeedback($level, $this->globalErrorMessage);
-            } else {
-                foreach($this->errors as $error) {
-                    if($error != '') {
-                        $this->addFeedback($level, $error);
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * Prepare error message on Rule:isValid result.
-     *
-     * If the test succeeded, the error message is cleared (either custom or
-     * built-in messages).
-     * @access private
-     * @param int	$i			Index of the Rule that was applied.
-     * @param bool	$result		Result of the test.
-     */
-    function errorMessage($i, $result) {
-        if($result === true) {
-            $this->errors[$i] = '';
-        } else {
-            if($this->errors[$i] === false) {
-                $this->errors[$i] = $this->rules[$i]->getErrorMessage($this->key);
-            }
-        }
-    }
-
-    /**
-     * Apply each rule on the given value and prepare feedback.
-     *
-     * @access private
-     * @param mixed $value	Value to test.
-     */
-    function checkEachRules($value) {
-        $isValid = true;
-        $rCtr = count($this->rules);
-        for($i = 0; $i < $rCtr; $i++) {
-            $valid = $this->rules[$i]->isValid($value);
-            $this->errorMessage($i, $valid);
-            $isValid = $isValid && $valid;
-        }
-        if($isValid && $this->isRequired && $this->isValueEmpty($value)) {
-            $this->isValid = false;
-        } else {
-            $this->isValid = $isValid;
-        }
-        $this->populateFeedback();
-    }
-
-    /**
-     * Run validation on given value.
-     *
-     * @param mixed $value	Value to test.
-	 * @return bool
-	 */
-    function validate($value) {
-        if($this->isRequired
-           || (!$this->isRequired && !$this->isValueEmpty($value))) {
-            $this->checkEachRules($value);
-            return $this->isValid;
-        }
-        return true;
-    }
+	/**
+	 * Generate error message according to settings.
+	 *
+	 * Takes in account user requirement 'required' and
+	 * 'disableFeedback'. Empty error messages are discarded.
+	 * @access private
+	 */
+	function populateFeedback() {
+		if($this->useFeedback) {
+			$level = 'warning';
+			if($this->isRequired) {
+				$level = 'error';
+			}
+			if($this->globalErrorMessage !== null && !$this->isValid) {
+				$this->addFeedback($level, $this->globalErrorMessage);
+			} else {
+				foreach($this->errors as $error) {
+					if($error != '') {
+						$this->addFeedback($level, $error);
+					}
+				}
+			}
+		}
+	}
+
+	/**
+	 * Prepare error message on Rule:isValid result.
+	 *
+	 * If the test succeeded, the error message is cleared (either custom or
+	 * built-in messages).
+	 * @access private
+	 * @param int	$i	Index of the Rule that was applied.
+	 * @param bool	$result	Result of the test.
+	 */
+	function errorMessage($i, $result) {
+		if($result === true) {
+			$this->errors[$i] = '';
+		} else {
+			if($this->errors[$i] === false) {
+				$this->errors[$i] = $this->rules[$i]->getErrorMessage($this->key);
+			}
+		}
+	}
+
+	/**
+	 * Apply each rule on the given value and prepare feedback.
+	 *
+	 * @access	private
+	 * @param	mixed	$value	Value to test.
+	 */
+	function checkEachRules($value) {
+		$isValid = true;
+		$rCtr = count($this->rules);
+		for($i = 0; $i < $rCtr; $i++) {
+			$valid = $this->rules[$i]->isValid($value);
+			$this->errorMessage($i, $valid);
+			$isValid = $isValid && $valid;
+		}
+		if($isValid && $this->isRequired && $this->isValueEmpty($value)) {
+			$this->isValid = false;
+		} else {
+			$this->isValid = $isValid;
+		}
+		$this->populateFeedback();
+	}
+
+	/**
+	 * Run validation on given value.
+	 *
+	 * @param	mixed	$value	Value to test.
+	 * @return	bool
+	 */
+	function validate($value) {
+		if($this->isRequired || (!$this->isRequired && !$this->isValueEmpty($value))) {
+			$this->checkEachRules($value);
+			return $this->isValid;
+		}
+		return true;
+	}
 }

-----------------------------------------------------------------------

Summary of changes:
 src/common/include/RBAC.php             |    4 +-
 src/common/include/rbac_texts.php       |   48 ++--
 src/common/valid/Rule.class.php         |  465 +++++++++++++++----------------
 src/common/valid/Valid.class.php        |  371 ++++++++++++------------
 src/common/valid/ValidFactory.class.php |  214 +++++++-------
 5 files changed, 543 insertions(+), 559 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list