function _privatemsg_attachments_form in Privatemsg 6.2
2 calls to _privatemsg_attachments_form()
- privatemsg_attachments_form_privatemsg_new_alter in privatemsg_attachments/
privatemsg_attachments.module - Implements hook_form_FORM_ID_alter().
- privatemsg_attachments_upload_js in privatemsg_attachments/
privatemsg_attachments.module - Menu callback for JavaScript-based uploads.
File
- privatemsg_attachments/
privatemsg_attachments.module, line 107 - Allows users to add attachments to messages
Code
function _privatemsg_attachments_form($files = array()) {
global $user;
$form = array(
'#theme' => 'upload_form_new',
'#cache' => TRUE,
);
if (!empty($files)) {
$form['files']['#theme'] = 'upload_form_current';
$form['files']['#tree'] = TRUE;
foreach ($files as $key => $file) {
if (is_numeric($key)) {
$file = (object) $file;
$description = file_create_url($file->filepath);
$description = "<small>" . check_plain($description) . "</small>";
$form['files'][$key]['description'] = array(
'#type' => 'textfield',
'#default_value' => !empty($file->description) ? $file->description : $file->filename,
'#maxlength' => 256,
'#description' => $description,
);
$form['files'][$key]['size'] = array(
'#value' => format_size($file->filesize),
);
$form['files'][$key]['remove'] = array(
'#type' => 'checkbox',
'#default_value' => !empty($file->remove),
);
$form['files'][$key]['list'] = array(
'#type' => 'checkbox',
'#default_value' => $file->list,
);
$form['files'][$key]['weight'] = array(
'#type' => 'weight',
'#delta' => count($files),
'#default_value' => $file->weight,
);
$form['files'][$key]['filename'] = array(
'#type' => 'value',
'#value' => $file->filename,
);
$form['files'][$key]['filepath'] = array(
'#type' => 'value',
'#value' => $file->filepath,
);
$form['files'][$key]['filemime'] = array(
'#type' => 'value',
'#value' => $file->filemime,
);
$form['files'][$key]['filesize'] = array(
'#type' => 'value',
'#value' => $file->filesize,
);
$form['files'][$key]['fid'] = array(
'#type' => 'value',
'#value' => $file->fid,
);
$form['files'][$key]['new'] = array(
'#type' => 'value',
'#value' => $file->new,
);
}
}
}
$limits = _upload_file_limits($user);
$form['new']['#weight'] = 10;
$form['new']['upload'] = array(
'#type' => 'file',
'#title' => t('Attach new file'),
'#size' => 40,
'#description' => ($limits['resolution'] ? t('Images are larger than %resolution will be resized.', array(
'%resolution' => $limits['resolution'],
)) : '') . ' ' . t('The maximum upload size is %filesize. Only files with the following extensions may be uploaded: %extensions.', array(
'%extensions' => $limits['extensions'],
'%filesize' => format_size($limits['file_size']),
)),
);
$form['new']['attach'] = array(
'#type' => 'submit',
'#value' => t('Attach'),
'#name' => 'attach',
'#ahah' => array(
'path' => 'messages/upload/js',
'wrapper' => 'attach-wrapper',
'progress' => array(
'type' => 'bar',
'message' => t('Please wait...'),
),
),
);
return $form;
}