2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
$output='<p>'.t('The upload module allows users to upload files to the site. The ability to upload files to a site is important for members of a community who want to share work. It is also useful to administrators who want to keep uploaded files connected to a node or page.').'</p>';
$output.='<p>'.t('Users with the upload files permission can upload attachments. You can choose which post types can take attachments on the content types settings page. Each user role can be customized for the file size of uploads, and the dimension of image files.').'</p>';
$output.=t('<p>You can</p>
<ul>
<li>administer user permissions at <a href="%admin-access">administer >> access control</a>.</li>
<li>administer content at <a href="%admin-content-types">administer >> settings >> content types</a>.</li>
<li>administer upload at <a href="%admin-upload">administer >> settings >> upload</a>.</li>
$output.='<p>'.t('For more information please read the configuration and customization handbook <a href="%upload">Upload page</a>.',array('%upload'=>'http://drupal.org/handbook/modules/upload/')).'</p>';
return$output;
case'admin/modules#description':
returnt('Allows users to upload and attach files to content.');
case'admin/settings/upload':
returnt('<p>Users with the <a href="%permissions">upload files permission</a> can upload attachments. Users with the <a href="%permissions">view uploaded files permission</a> can view uploaded attachments. You can choose which post types can take attachments on the <a href="%types">content types settings</a> page.</p>',array('%permissions'=>url('admin/access'),'%types'=>url('admin/settings/content-types')));
'#description'=>t('Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.'),
'#prefix'=>'<div class="attachments">',
'#suffix'=>'</div>',
'#weight'=>30,
);
// Wrapper for fieldset contents (used by upload JS).
form_set_error('upload',t('The selected file %name can not be attached to this post, because it is only possible to attach files with the following extensions: %files-allowed.',array('%name'=>theme('placeholder',$file->filename),'%files-allowed'=>theme('placeholder',$extensions))));
$valid=FALSE;
}
elseif($error['uploadsize']==$user_roles){
form_set_error('upload',t('The selected file %name can not be attached to this post, because it exceeded the maximum filesize of %maxsize.',array('%name'=>theme('placeholder',$file->filename),'%maxsize'=>theme('placeholder',format_size($uploadsize)))));
$valid=FALSE;
}
elseif($error['usersize']==$user_roles){
form_set_error('upload',t('The selected file %name can not be attached to this post, because the disk quota of %quota has been reached.',array('%name'=>theme('placeholder',$file->filename),'%quota'=>theme('placeholder',format_size($usersize)))));
$valid=FALSE;
}
elseif(strlen($file->filename)>255){
form_set_error('upload',t('The selected file %name can not be attached to this post, because the filename is too long.',array('%name'=>theme('placeholder',$file->filename))));
db_query("UPDATE {file_revisions} SET list = %d, description = '%s' WHERE fid = %d AND vid = %d",$file->list,$file->description,$file->fid,$node->vid);
}
}
}
functionupload_delete($node){
$files=array();
$result=db_query('SELECT * FROM {files} WHERE nid = %d',$node->nid);
while($file=db_fetch_object($result)){
$files[$file->fid]=$file;
}
foreach($filesas$fid=>$file){
// Delete all file revision information associated with the node
db_query('DELETE FROM {file_revisions} WHERE fid = %d',$fid);
file_delete($file->filepath);
}
// Delete all files associated with the node
db_query('DELETE FROM {files} WHERE nid = %d',$node->nid);
}
functionupload_delete_revision($node){
if(is_array($node->files)){
foreach($node->filesas$file){
// Check if the file will be used after this revision is deleted
$count=db_result(db_query('SELECT COUNT(fid) FROM {file_revisions} WHERE fid = %d',$file->fid));
// if the file won't be used, delete it
if($count<2){
db_query('DELETE FROM {files} WHERE fid = %d',$file->fid);
file_delete($file->filepath);
}
}
}
// delete the revision
db_query('DELETE FROM {file_revisions} WHERE vid = %d',$node->vid);
drupal_set_message(t('The image was resized to fit within the maximum allowed resolution of %resolution pixels.',array('%resolution'=>theme('placeholder',variable_get('upload_max_resolution',0)))));
}
}
}
return$file;
}
/**
* Menu-callback for JavaScript-based uploads.
*/
functionupload_js(){
// We only do the upload.module part of the node validation process.
$node=(object)$_POST['edit'];
// Load existing node files.
$node->files=upload_load($node);
// Handle new uploads, and merge tmp files into node-files.