aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/session.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2011-09-13 01:46:00 +0200
committerOleg Pudeyev <oleg@bsdpower.com>2011-11-25 15:04:31 -0500
commitf16d72fcfb9a7621bf64b82cc2c710c6e484d965 (patch)
treefee4024018a61b725035017f7254e248cd229de8 /phpBB/includes/session.php
parent757fcd3e63535f9fda68cf359f849a44059c7b27 (diff)
downloadforums-f16d72fcfb9a7621bf64b82cc2c710c6e484d965.tar
forums-f16d72fcfb9a7621bf64b82cc2c710c6e484d965.tar.gz
forums-f16d72fcfb9a7621bf64b82cc2c710c6e484d965.tar.bz2
forums-f16d72fcfb9a7621bf64b82cc2c710c6e484d965.tar.xz
forums-f16d72fcfb9a7621bf64b82cc2c710c6e484d965.zip
[ticket/10345] Fix documentation on the new function and the switch
Also do not min/max the value, but throw an error on an invalid Plural rule. PHPBB3-10345
Diffstat (limited to 'phpBB/includes/session.php')
-rw-r--r--phpBB/includes/session.php15
1 files changed, 13 insertions, 2 deletions
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index cd1975b9d3..4e5257506c 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -1901,6 +1901,10 @@ class user extends session
/**
* Determine which plural form we should use.
* For some languages this is not as simple as for English.
+ *
+ * @param $number int The number we want to get the plural case for
+ * @param $force_rule mixed False to use the plural rule of the language package
+ * or an integer to force a certain plural rule
*/
function get_plural_form($number, $force_rule = false)
{
@@ -1910,10 +1914,17 @@ class user extends session
return 0;
}
- // Default to english system
+ // Default to English system
$plural_rule = ($force_rule !== false) ? $force_rule : ((isset($this->lang['PLURAL_RULE'])) ? $this->lang['PLURAL_RULE'] : 1);
- $plural_rule = max(0, min($plural_rule, 15));
+ if ($plural_rule > 15 || $plural_rule < 0)
+ {
+ trigger_error('INVALID_PLURAL_RULE');
+ }
+ /**
+ * The following plural rules are based on a list published by the Mozilla Developer Network
+ * https://developer.mozilla.org/en/Localization_and_Plurals
+ */
switch ($plural_rule)
{
case 0: