Skip to content
Browse files

New param type, PARAM_SEQUENCE for 5,6,7,8,9

  • Loading branch information...
1 parent 7b12414 commit 0e4af1664cec8ba1fd7cb9cf9d9393cd88ab1912 moodler committed
Showing with 9 additions and 0 deletions.
  1. +9 −0 lib/moodlelib.php
View
9 lib/moodlelib.php
@@ -200,6 +200,11 @@
*/
define('PARAM_SAFEDIR', 0x4000);
+/**
+ * PARAM_SEQUENCE - expects a sequence of numbers like 8 to 1,5,6,4,6,8,9. Numbers and comma only.
+ */
+define('PARAM_SEQUENCE', 0x8000);
+
/// Page types ///
/**
* PAGE_COURSE_VIEW is a definition of a page type. For more information on the page class see moodle/lib/pagelib.php.
@@ -303,6 +308,7 @@ function optional_param($parname, $default=NULL, $type=PARAM_CLEAN) {
* @uses PARAM_URL
* @uses PARAM_LOCALURL
* @uses PARAM_CLEANHTML
+ * @uses PARAM_SEQUENCE
* @param mixed $param the variable we are cleaning
* @param int $type expected format of param after cleaning.
* @return mixed
@@ -348,6 +354,9 @@ function clean_param($param, $type) {
case PARAM_ALPHAEXT: // Remove everything not a-zA-Z/_-
return eregi_replace('[^a-zA-Z/_-]', '', $param);
+ case PARAM_SEQUENCE: // Remove everything not 0-9,
+ return eregi_replace('[^0-9,]', '', $param);
+
case PARAM_BOOL: // Convert to 1 or 0
$tempstr = strtolower($param);
if ($tempstr == 'on' or $tempstr == 'yes' ) {

0 comments on commit 0e4af16

Please sign in to comment.
Something went wrong with that request. Please try again.