Beispiel #1
0
 /**
  * Validate field value
  *
  * @throws Exception when empty or not valid email address
  */
 function _validate()
 {
     parent::_validate();
     $value = $this->getParam('value');
     if (!is_null($value) && $value !== '@MAIL@' && !mail_isvalid($value)) {
         throw new Exception(sprintf($this->getLang('e_email'), hsc($this->getParam('display'))));
     }
 }
Beispiel #2
0
 /**
  * Validate field input
  *
  * @throws Exception when empty or wrong time format
  */
 protected function _validate()
 {
     parent::_validate();
     $value = $this->getParam('value');
     if (!is_null($value) && !preg_match('/^\\d{1,2}:\\d{2}(?::\\d{2})?$/', $value)) {
         throw new Exception(sprintf($this->getLang('e_time'), hsc($this->getParam('display'))));
     }
 }
Beispiel #3
0
 /**
  * Validate value of field
  *
  * @throws Exception when user not exists
  */
 protected function _validate()
 {
     parent::_validate();
     /** @var DokuWiki_Auth_Plugin $auth */
     global $auth;
     $value = $this->getParam('value');
     if (!is_null($value) && $auth->getUserData($value) === false) {
         throw new Exception(sprintf($this->getLang('e_user'), hsc($this->getParam('display'))));
     }
 }
Beispiel #4
0
 /**
  * Validate value of field
  *
  * @throws Exception when user not exists
  */
 protected function _validate()
 {
     parent::_validate();
     /** @var DokuWiki_Auth_Plugin $auth */
     global $auth;
     $users = array_filter(preg_split('/\\s*,\\s*/', $this->getParam('value')));
     foreach ($users as $user) {
         if ($auth->getUserData($user) === false) {
             throw new Exception(sprintf($this->getLang('e_users'), hsc($this->getParam('display'))));
         }
     }
 }
Beispiel #5
0
 /**
  * Handle a post to the field
  *
  * Accepts and validates a posted value.
  *
  * @param string $value The passed value or array or null if none given
  * @param array  $fields (reference) form fields (POST handled upto $this field)
  * @param int    $index  index number of field in form
  * @param int    $formid unique identifier of the form which contains this field
  * @return bool Whether the passed value is valid
  */
 public function handle_post($value, &$fields, $index, $formid)
 {
     $value = $this->addLeadingzeros($value);
     return parent::handle_post($value, $fields, $index, $formid);
 }