2013-03-07 15:19:55 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
App::uses('AppModel', 'Model');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Regexp Model
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class Regexp extends AppModel {
|
|
|
|
|
2013-03-07 11:51:43 +01:00
|
|
|
public $actsAs = array(
|
|
|
|
'SysLogLogable.SysLogLogable' => array( // TODO Audit, logable
|
|
|
|
'roleModel' => 'Role',
|
|
|
|
'roleKey' => 'role_id',
|
|
|
|
'change' => 'full'
|
|
|
|
),
|
2013-03-07 15:19:55 +01:00
|
|
|
);
|
|
|
|
/**
|
|
|
|
* Use table
|
|
|
|
*
|
|
|
|
* @var mixed False or table name
|
|
|
|
*/
|
|
|
|
public $useTable = 'regexp';
|
|
|
|
|
|
|
|
// this checks whether the regexp would fail and if yes, the entry is blocked from being entered.
|
|
|
|
public function beforeValidate($options = array()) {
|
|
|
|
$test = preg_replace($this->data['Regexp']['regexp'], 'success', $this->data['Regexp']['regexp']);
|
|
|
|
if ($test == null) return false;
|
|
|
|
return true;
|
|
|
|
}
|
2012-11-30 13:52:09 +01:00
|
|
|
}
|