if ($size = filesize($full_path)) { $rsc_handle = fopen($full_path, 'r'); $edited_File->content = fread($rsc_handle, $size); fclose($rsc_handle); } else { // Empty file $edited_File->content = ''; } break; case 'edit_properties': // TODO: We don't need the Filelist, move UP! // Edit File properties (Meta Data) // Check that this action request is not a CSRF hacked request: $Session->assert_received_crumb('file'); // Check permission! $current_User->check_perm('files', 'edit_allowed', true, $selected_Filelist->get_FileRoot()); $edited_File =& $selected_Filelist->get_by_idx(0); $edited_File->load_meta(); break; case 'update_properties': // TODO: We don't need the Filelist, move UP! // Update File properties (Meta Data); on success this ends the file_properties mode: // Check that this action request is not a CSRF hacked request: $Session->assert_received_crumb('file'); // Check permission! $current_User->check_perm('files', 'edit_allowed', true, $selected_Filelist->get_FileRoot()); $edited_File =& $selected_Filelist->get_by_idx(0); // Load meta data: $edited_File->load_meta(); $edited_File->set('title', param('title', 'string', '')); $edited_File->set('alt', param('alt', 'string', ''));
$edited_Link =& new Link(); $edited_Link->set('itm_ID', $edited_Item->ID); $edited_Link->set('file_ID', $l_File->ID); $edited_Link->dbinsert(); $DB->commit(); $Messages->add(sprintf(T_('«%s» has been posted.'), $l_File->dget('name')), 'success'); } // Note: we redirect without restoring filter. This should allow to see the new files. // &filter=restore header_redirect('admin.php?ctrl=items&blog=' . $blog); // Will save $Messages // Note: we have EXITED here. In case we remove the redir, we need this: // Reset stuff so it doesn't interfere with upcomming display unset($edited_Item); unset($edited_Link); $selected_Filelist =& new Filelist($fm_Filelist->get_FileRoot(), false); break; case 'edit_file': // TODO: We don't need the Filelist, move UP! // Edit Text File // Check permission! $current_User->check_perm('files', 'edit', true); $edit_File =& $selected_Filelist->get_by_idx(0); // Check that the file is editable: if (!$edit_File->is_editable($current_User->check_perm('files', 'all'))) { $Messages->add(sprintf(T_('You are not allowed to edit «%s».'), $edit_File->dget('name')), 'error'); // Leave special display mode: $action = 'list'; break; } $full_path = $edit_File->get_full_path();