Example #1
0
 /**
  * Shorthand method for inline validation 
  *
  * @param array $data The data to be validated
  * @param array $validators The GUMP validators
  * @return mixed True(boolean) or the array of error messages
  */
 public static function is_valid(array $data, array $validators)
 {
     $gump = new Gump();
     $gump->validation_rules($validators);
     if ($gump->run($data) === false) {
         return $gump->get_readable_errors(false);
     } else {
         return true;
     }
 }
 /**
  * Shorthand method for running only the data filters
  *
  * @param array $data
  * @param array $filters
  * @return mixed
  */
 public static function filter_input(array $data, array $filters)
 {
     $gump = new Gump();
     return $gump->filter($data, $filters);
 }
Example #3
0
 /**
  * Checks all entries for their correctness. Uses gump
  * Dies displaying a message on error
  * @param  array  $content the content of the csv-file
  */
 private function csvCheckGump($content)
 {
     $errors = array();
     $gump = new \Gump();
     //workaround problem of pipe and commata in regex in gumpRules
     $gump->set_validation_rule_delimiter('||');
     $gump->set_validation_rule_param_delimiter(',,');
     $gump->rules($this->_gumpRules);
     foreach ($content as $row) {
         if (!$gump->run($row)) {
             $errors[] = $gump->get_readable_string_errors(true);
         }
     }
     if (count($errors)) {
         $errormsg = '';
         foreach ($errors as $error) {
             $errormsg .= $error;
         }
         $this->_smarty->assign('backlink', 'index.php?module=' . 'administrator|System|User|UserUpdateWithSchoolyearChange|' . 'CsvImport');
         $this->_interface->dieError(_g('Errors occured while importing the csv-file. ' . 'Please correct them and try again.<br />%1$s', $errormsg));
     }
 }
Example #4
0
 public function ajoutalbum()
 {
     if (isset($_POST['nom']) && Session::get('id') != null) {
         $_POST = Gump::sanitize($_POST);
         $a = new Album($_POST['nom'], Session::get('id'));
         EntityManager::getInstance()->save($a);
     }
     Url::previous();
 }
Example #5
0
 protected function changeValidCheck()
 {
     require_once PATH_INCLUDE . '/gump.php';
     $gump = new Gump();
     $validation = array('id' => array('required|min_len,1|max_len,11|numeric', '', 'ID'), 'name' => array('required|min_len,1|max_len,255', '', 'name'), 'isEnabled' => array('required|boolean', '', 'ist Modul aktiviert'), 'displayInMenu' => array('required|boolean', '', 'wird in Menü angezeigt'), 'executablePath' => array('min_len,1|max_len,255', '', 'Asuführungspfad'));
     $gump->rules($validation);
     if ($gump->run($_POST)) {
         $this->changeBooleansParse();
         return $this->changeCheckForSomethingChanged();
     } else {
         die(json_encode(array('value' => 'error', 'message' => $gump->get_readable_string_errors(false))));
         return false;
     }
 }