/** * @param $file * @return false|array, the array of paths where the given file has been put, * or false in case of errors. */ public function upload($file) { if (is_array($file) && false === ArrayTool::getMissingKeys($file, ['name', 'type', 'size', 'tmp_name', 'error'])) { $oFile = PhpFile::create(); $oFile->name = $file['name']; $oFile->type = $file['type']; $oFile->size = $file['size']; $oFile->tmp_name = $file['tmp_name']; $oFile->error = $file['error']; return $this->uploadFile($oFile); } else { $this->addError("invalid file input"); } return false; }
$server->error($processor->getErrorMsg()); } } else { $table = $formId; // should also handle when you need to update multiple tables $arr = $_POST; // maybe add an obfuscating layer here (if you are paranoid...) $mc = MeredithSupervisor::inst()->getMainController($formId); $defaultValues = $mc->getFormDataProcessor()->getDefaultValues(); $arr = array_replace($defaultValues, $arr); $idf = $mc->getFormDataProcessor()->getIdentfyingFields(); $nac = $mc->getFormDataProcessor()->getNonAutoIncrementedFields(); $nac2Values = array_intersect_key($arr, array_flip($nac)); try { $mode = 'insert'; if (false === ($missing = ArrayTool::getMissingKeys($arr, $idf))) { $mode = 'update'; // update if (true === MeredithSupervisor::inst()->isGranted($formId, 'update')) { $idf2Values = array_intersect_key($arr, array_flip($idf)); $where = []; foreach ($idf2Values as $k => $v) { $where[] = [$k, '=', $v]; } if (true === QuickPdo::update($table, $nac2Values, $where)) { $msg = $mc->getFormDataProcessor()->getSuccessMessage($formId, 'update'); if (false === $msg) { $msg = MeredithSupervisor::inst()->translate("The record has been successfully updated"); } $server->success(['msg' => $msg]); } else {