summaryrefslogtreecommitdiffstats
path: root/apps/admin/lib/myDenyStringValidator.php
blob: d817ea9650125e032c8abd1fea32e5b1b5e00ad2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

class myDenyStringValidator extends sfValidator
{
	public function initialize($context, $parameters = null)
	{
		// initialize parent
		parent::initialize($context);

		// set defaults
		$this->setParameter('values_error', 'Invalid input');

		$this->getParameterHolder()->add($parameters);

		return true;
	}

	public function execute(&$value, &$error)
	{
		$values = $this->getParameter('values');
		
		if(!is_array($values))
			return true;
		
		foreach($values as $check)
		{
			if($check==$value)
			{
				$error = $this->getParameter('values_error');
				return false;
			}
		}
		
		return true;
	}
}

?>