'NewHeaderForm', // must be unique 'ActionValue' => 'ProgChairEdit', 'Field1Label' => 'New Prog Chair', 'Input1Name' => 'ProgramChair', 'Field2Label' => 'Edit Prog Chair', 'Select1Name' => 'ExistingProgChair', 'DocPath' => $ProgChairPath, 'FormFields' => $ProgChairFormFields, 'dbKey' => 'ProgramChair', ]; EmitAdminFormType2($args); TraceProgram(__FILE__, __FUNCTION__, __LINE__, "", TR_EXIT); } // X Action=ProgChairEdit // X ProgramChair= // # ChairNotes= // function ShowProgChairForm() { global $ProgChairPath, $ProgChairFormFields; global $ckEditor_FQFN, $allowedTypes, $UploadPath; global $CleanRequestData, $CleanFiles; TraceProgram(__FILE__, __FUNCTION__, __LINE__, "", TR_ENTRY); $actDelete = 'DeleteProgChairItem'; $FormData = array(); $Action = $CleanRequestData['Action'] ?? ''; $ProgramChair = ''; // Form Submission could be new or edit existing $formSubmission = false; TraceProgram(__FILE__, __FUNCTION__, __LINE__, print_r($CleanRequestData, true)); if (isset($CleanRequestData['ProgramChair']) && $CleanRequestData['ProgramChair'] != "") { TraceProgram(__FILE__, __FUNCTION__, __LINE__, $CleanRequestData['ProgramChair']); $ProgramChair = $ProgramFolder = $CleanRequestData['ProgramChair']; } else { $ProgramFolder = $CleanRequestData['ExistingProgChair'] ?? ''; } $ProgChairPath = $ProgChairPath . '/' . MakeValidFolderName($ProgramFolder); TraceProgram(__FILE__, __FUNCTION__, __LINE__, "ProgChairPath: '$ProgChairPath'"); if (!is_dir($ProgChairPath)) { if (mkdir($ProgChairPath, 0777, true)) { TraceProgram(__FILE__, __FUNCTION__, __LINE__, "mkdir '$ProgChairPath'"); } else { TraceProgram(__FILE__, __FUNCTION__, __LINE__, "Failed to mkdir '$ProgChairPath'"); } } if ($Action == $actDelete) { $item = $CleanRequestData['Item'] ?? ''; $success = ReadTableData($ProgChairPath, $ProgChairformFields, $evData); TraceProgram(__FILE__, __FUNCTION__, __LINE__, $success); TraceProgram(__FILE__, __FUNCTION__, __LINE__, print_r($evData, true)); $fqfn = $evData[$item]; $targetFile = $ProgChairPath . '/' . $fqfn; TraceProgram(__FILE__, __FUNCTION__, __LINE__, "unlink '$targetFile'"); unlink($targetFile); echo "ok"; TraceProgram(__FILE__, __FUNCTION__, __LINE__, "", TR_EXIT); exit(); } if (($Action == 'ProgChairEdit') && ($ProgramChair != '')) { // Form Submission could be new ProgChair or edit existing // check FILES and then form fields foreach ($CleanFiles as $fileKey => $fileInfo) { TraceProgram(__FILE__, __FUNCTION__, __LINE__, "Check ". print_r($fileKey, true)); TraceProgram(__FILE__, __FUNCTION__, __LINE__, "Check ". print_r($fileInfo, true)); if (in_array($fileInfo['type'], array_keys($allowedTypes))) { $basename = basename($fileInfo['name']); $filename = $fileKey . $allowedTypes[$fileInfo['type']]; if ($ProgChairFormFields[$fileKey]['FieldType'] == 'pix') { $targetFile = $ProgChairPath . '/' . $filename; $un = $ProgChairPath . '/' . $fileKey . ".*"; TraceProgram(__FILE__, __FUNCTION__, __LINE__, "unlink $un"); deleteFilesWithWildcard($ProgChairPath, $fileKey . ".*"); TraceProgram(__FILE__, __FUNCTION__, __LINE__, "target $targetFile"); if (!is_uploaded_file($fileInfo['tmp_name']) || !@copy($fileInfo['tmp_name'], $targetFile)) { $err = error_get_last(); TraceProgram(__FILE__, __FUNCTION__, __LINE__, $err); } else { $FormData[$fileKey] = $filename; $formSubmission = true; } @unlink($fileInfo['tmp_name']); } else { TraceProgram(__FILE__, __FUNCTION__, __LINE__, "$basename not legitimate for a pix upload"); } } else { TraceProgram(__FILE__, __FUNCTION__, __LINE__, "Nothing to upload"); } } // Form items foreach ($CleanRequestData as $key => $value) { TraceProgram(__FILE__, __FUNCTION__, __LINE__, "check $key"); if (isset($ProgChairFormFields[$key])) { TraceProgram(__FILE__, __FUNCTION__, __LINE__, "$key => $value"); $FormData[$key] = $value; $formSubmission = true; } } } if ($formSubmission) { SaveTableData($ProgChairPath, $ProgChairFormFields, $FormData); MoveFiles($UploadPath, $ProgChairPath); } // Read the event file if it exists $success = ReadTableData($ProgChairPath, $ProgChairFormFields, $FormData); TraceProgram(__FILE__, __FUNCTION__, __LINE__, $success); EmitHTMLStart("ProgChair Editor"); EmitBodyStart(); EmitPageHeader("ProgChair Editor"); ?>