{'Name'} ?? ''); $path = array_key_exists('Path', $_REQUEST['newStorage']) ? $_REQUEST['newStorage']['Path'] : ($storage->{'Path'} ?? ''); # Saving a storage area that failed to load would insert a new one. if (validCardinal($_REQUEST['id']) and !$storage->Id()) { ZM\Warning('Storage area '.validCardinal($_REQUEST['id']).' not found'); $error_message .= 'Storage area not found
'; $changes = array(); } else if (!is_string($name) or (trim($name) === '')) { ZM\Warning('Refusing to save storage area with an empty Name'); $error_message .= 'Storage area Name is required
'; $changes = array(); } else if (!is_string($path) or (trim($path) === '')) { ZM\Warning('Refusing to save storage area with an empty Path'); $error_message .= 'Storage area Path is required
'; $changes = array(); } else { $changes = $storage->changes($_REQUEST['newStorage']); # Storage::changes() filters Name and Path down to letters, numbers and - . ( ) : / space. # If that strips every character, Storage::Name()/Path() ignore the empty value and the # save silently does nothing (or falls back to the default events path for a new area). if ((array_key_exists('Name', $changes) and ($changes['Name'] === '')) or (array_key_exists('Path', $changes) and ($changes['Path'] === ''))) { ZM\Warning('Refusing to save storage area whose Name or Path is empty after filtering'); $error_message .= 'Storage area Name and Path may only contain letters, numbers and - . ( ) : / space
'; $changes = array(); } } } if (count($changes)) { if ($storage->save($changes)) { ZM\AuditAction(($_REQUEST['id'] ? 'update' : 'create'), 'storage', $storage->Id(), 'Changed: '.implode(', ', array_keys($changes))); } else { $error_message .= $storage->get_last_error(); } // end if successful save } if (!$error_message) { // there is no view=storage, so need to redirect somewhere useful $redirect = '?view=options&tab=storage'; $refreshParent = true; } else { // The modal form posts view=storage, which has no view file. Render the // options page instead so that the error is shown. $view = 'options'; $_REQUEST['tab'] = 'storage'; } } else { ZM\Error("Unknown action $action in saving Storage"); } ?>