Пример #1
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));
     }
 }
Пример #2
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;
     }
 }