public function validate($data)
 {
     global $PAGE;
     // Don't force the plugin to be fully set up when installing.
     if ($PAGE->pagelayout === 'maintenance' && strlen($data) === 0) {
         return true;
     }
     return parent::validate($data);
 }
예제 #2
0
 /**
  * Validate data.
  *
  * @param string $data
  * @return mixed True on success, else error message
  */
 public function validate($data)
 {
     $result = parent::validate($data);
     if ($result !== true) {
         return $result;
     }
     if ((int) $data < 1) {
         return get_string('awaittimeerror', 'realtimequiz');
     }
     return true;
 }
 /**
  * Validate data.
  *
  * This ensures that key ID is specified if URL is provided
  *
  * @param string $data
  * @return mixed True on success, else error message.
  */
 public function validate($data)
 {
     $result = parent::validate($data);
     if ($result !== true) {
         return $result;
     }
     $url = get_config('filter_cloudfront_signurl', 'distributionurl');
     if ($url != '' && empty($data)) {
         return get_string('errornokeyid', 'filter_cloudfront_signurl');
     }
     return true;
 }
 /**
  * Validate data before storage
  * @param string data
  * @return mixed true if ok string if error found
  */
 public function validate($data)
 {
     $validated = parent::validate($data);
     // Pass parent validation first.
     if ($validated == true) {
         $matches = preg_match($this->regex, $data);
         if ($matches === false) {
             $validated = 'preg_match() error.';
         } else {
             if ($matches == 0) {
                 $validated = '\'' . $data . '\'' . $this->error;
             }
         }
     }
     return $validated;
 }
 /**
  * Validate data before storage
  * @param string data
  * @return mixed true if ok string if error found
  */
 public function validate($data)
 {
     $validated = parent::validate($data);
     // Pass parent validation first.
     if ($validated == true) {
         if ($data < $this->lower) {
             $validated = get_string('asconfigintlower', 'theme_essential', array('value' => $data, 'lower' => $this->lower));
         } else {
             if ($data > $this->upper) {
                 $validated = get_string('asconfigintupper', 'theme_essential', array('value' => $data, 'upper' => $this->upper));
             } else {
                 $validated = true;
             }
         }
     }
     return $validated;
 }
예제 #6
0
파일: adminlib.php 프로젝트: dg711/moodle
 /**
  * Validate data.
  *
  * This ensures that unix socket setting is correct and ClamAV is running.
  *
  * @param string $data
  * @return mixed True on success, else error message.
  */
 public function validate($data)
 {
     $result = parent::validate($data);
     if ($result !== true) {
         return $result;
     }
     $runningmethod = get_config('antivirus_clamav', 'runningmethod');
     if ($runningmethod === 'unixsocket') {
         $socket = stream_socket_client('unix://' . $data, $errno, $errstr, ANTIVIRUS_CLAMAV_SOCKET_TIMEOUT);
         if (!$socket) {
             return get_string('errorcantopensocket', 'antivirus_clamav', "{$errstr} ({$errno})");
         } else {
             // Send PING query to ClamAV socket to check its running state.
             fwrite($socket, "nPING\n");
             $response = stream_get_line($socket, 4);
             fclose($socket);
             if ($response !== 'PONG') {
                 return get_string('errorclamavnoresponse', 'antivirus_clamav');
             }
         }
     }
     return true;
 }
예제 #7
0
 /**
  * Validate data before storage
  *
  * @param string $data data
  * @return mixed true if ok string if error found
  */
 public function validate($data)
 {
     $parentvalidation = parent::validate($data);
     if ($parentvalidation === true) {
         if ($this->maxlength > 0) {
             // Max length check.
             $length = core_text::strlen($data);
             if ($length > $this->maxlength) {
                 return get_string('maximumchars', 'moodle', $this->maxlength);
             }
             return true;
         } else {
             return true;
             // No max length check needed.
         }
     } else {
         return $parentvalidation;
     }
 }
예제 #8
0
 /**
  * Validate data.
  *
  * This ensures that license key is specified for any hosting mode.
  *
  * @param string $data
  * @return mixed True on success, else error message.
  */
 public function validate($data)
 {
     $result = parent::validate($data);
     if ($result !== true) {
         return $result;
     }
     if (empty($data)) {
         return get_string('errornolicensekey', 'filter_jwplayer');
     }
     return true;
 }
예제 #9
0
 /**
  * Validate data.
  *
  * This ensures that account token is specified if cloud-hosted player is
  * selected.
  *
  * @param string $data
  * @return mixed True on success, else error message.
  */
 public function validate($data)
 {
     $result = parent::validate($data);
     if ($result !== true) {
         return $result;
     }
     $hostingmethod = get_config('filter_jwplayer', 'hostingmethod');
     if ($hostingmethod === 'cloud' && empty($data)) {
         return get_string('errornoaccounttoken', 'filter_jwplayer');
     }
     return true;
 }