X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Faction.php;h=50370c09feca6086b4b1a68a03f26b9ed174b111;hb=fb3029d74e5552641d005079de422e762e7ac73b;hp=c346c751313482206230f1d016a7379bfdc62005;hpb=5d0bd93eb3e958b41113afdce85643a82a1f5bb3;p=quix0rs-gnu-social.git diff --git a/lib/action.php b/lib/action.php index c346c75131..50370c09fe 100644 --- a/lib/action.php +++ b/lib/action.php @@ -46,4 +46,18 @@ class Action { // lawsuit $this->args[$k] = ($strip) ? stripslashes($v) : $v; } } + + function boolean($key, $def=false) { + $arg = strtolower($this->trimmed($key)); + + if (is_null($arg)) { + return $def; + } else if (in_array($arg, array('true', 'yes', '1'))) { + return true; + } else if (in_array($arg, array('false', 'no', '0'))) { + return false; + } else { + return $def; + } + } }