Index: webfm.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webfm/webfm.module,v
retrieving revision 1.31
diff -c -r1.31 webfm.module
*** webfm.module 8 Feb 2009 06:32:30 -0000 1.31
--- webfm.module 30 Mar 2009 16:15:59 -0000
***************
*** 200,208 ****
'access arguments' => array('access webfm'),
'type' => MENU_CALLBACK,
);
! $items['webfm_send'] = array(
'title' => 'File Not Found',
'page callback' => 'webfm_send_file',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
--- 200,209 ----
'access arguments' => array('access webfm'),
'type' => MENU_CALLBACK,
);
! $items[variable_get('webfm_root_dir','webfm_send')."/%"] = array(
'title' => 'File Not Found',
'page callback' => 'webfm_send_file',
+ 'page arguments' => array(1),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
***************
*** 1157,1163 ****
if($file->perm & WEBFM_FILE_ACCESS_PUBLIC_VIEW) {
//permissions allow file to be linked for public view
global $base_url;
! $meta['lk'] = ''.$meta['n'].'';
}
webfm_json(array('status' => TRUE, 'data' => $meta));
} else {
--- 1158,1164 ----
if($file->perm & WEBFM_FILE_ACCESS_PUBLIC_VIEW) {
//permissions allow file to be linked for public view
global $base_url;
! $meta['lk'] = ''.$meta['n'].'';
}
webfm_json(array('status' => TRUE, 'data' => $meta));
} else {
***************
*** 2086,2091 ****
--- 2087,2093 ----
$this->id = $file->fid;
$this->n = strrev(substr(strrev($file->fpath), 0, strpos(strrev($file->fpath), '/')));
$this->p = $dir;
+
$this->e = array_pop(explode('.', $this->n));
$this->s = $file->fsize;
***************
*** 2103,2108 ****
--- 2105,2116 ----
$this->fversion = $file->fversion;
$this->m = (filemtime($readdir)) ? @filemtime($readdir) : "";
+ if(variable_get('webfm_root_dir',NULL)) {
+ $reldir = trim(str_replace(file_directory_path(),"",$this->p),'/\\');
+ $this->frelativedir = trim(str_replace(variable_get('webfm_root_dir',NULL),"",$reldir),'/\\');
+ }
+ else $this->frelativedir = NULL;
+
$this->result = TRUE;
break;
}
***************
*** 2197,2205 ****
* @param bool $download - true=download / false=stream
* @param bool $bypass_invoke true=do no invoke webfm_send hook / false=invoke
*/
! function webfm_send_file($fid, $download = false, $bypass_invoke = false) {
global $user;
!
$match = FALSE;
$f = false;
// User has either admin access, webfm access or view attach access
--- 2205,2232 ----
* @param bool $download - true=download / false=stream
* @param bool $bypass_invoke true=do no invoke webfm_send hook / false=invoke
*/
! //$fid, $download = false, $bypass_invoke = false
! function webfm_send_file() {
global $user;
! $args = func_get_args();
! array_pop($args);
! $max = count($args)-1;
! $bypass_invoke = false;
! $download = false;
! $fid = false;
! if($args[$max] == 1 AND $args[$max-1] == 1 AND is_numeric($args[$max-2])) {
! $fid = $args[$max-2];
! $bypass_invoke = true;
! $download = true;
! }
! elseif($args[$max] == 1 AND is_numeric($args[$max-1])) {
! $fid = $args[$max-1];
! $download = true;
! }
! elseif(is_numeric($args[$max])) {
! $fid = $args[$max];
! }
!
$match = FALSE;
$f = false;
// User has either admin access, webfm access or view attach access
Index: webfm_theme.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webfm/webfm_theme.inc,v
retrieving revision 1.4
diff -c -r1.4 webfm_theme.inc
*** webfm_theme.inc 8 Feb 2009 06:30:30 -0000 1.4
--- webfm_theme.inc 30 Mar 2009 16:15:59 -0000
***************
*** 3,9 ****
/**
* Displays file attachments in table
*/
! function theme_webfm_attachments($files) {
global $base_url;
$header = array(t('Attachment'));
if($enable_date = variable_get('webfm_attach_date', '')) {
--- 3,10 ----
/**
* Displays file attachments in table
*/
! function theme_webfm_attachments($files)
! {
global $base_url;
$header = array(t('Attachment'));
if($enable_date = variable_get('webfm_attach_date', '')) {
***************
*** 20,47 ****
if(variable_get('webfm_attach_desc', '') && !empty($file->fdesc)) {
$description = '
'.$file->fdesc.'
';
}
$filename = $file->ftitle ? $file->ftitle : $file->n;
if(variable_get('webfm_attach_new_window', '')) {
$href = array(
! 'data' => l('
', 'webfm_send/'.$file->id.'/1',
! array('attributes' => array('title' => 'Download '.$filename,'target' => '_blank'), 'html' => TRUE))
! .l($filename, 'webfm_send/'.$file->id, array('attributes' => array('title' => 'Open '.$filename, 'target' => '_blank')))
! .$description, 'class' => 'att-title'
! );
} else {
$href = array(
! 'data' => l('
', 'webfm_send/'.$file->id.'/1',
! array('attributes' => array('title' => 'Download '.$filename), 'html' => TRUE))
! .l($filename, 'webfm_send/'.$file->id, array('attributes' => array('title' => 'Open '.$filename)))
! .$description, 'class' => 'att-title'
);
}
$row = array();
array_push($row, $href);
if($enable_date) {
! $time = $file->fcreatedate ? date(webfm_get_date_format(), $file->fcreatedate) : date(webfm_get_date_format(), @filemtime($file->p . '/'. $file->n));
! array_push($row, array('data' => $time, 'class' => 'att-time'));
}
if($enable_size) {
array_push($row, array('data' => format_size($file->s), 'class' => 'att-size'));
--- 21,79 ----
if(variable_get('webfm_attach_desc', '') && !empty($file->fdesc)) {
$description = ''.$file->fdesc.'
';
}
+ dfb($file);
$filename = $file->ftitle ? $file->ftitle : $file->n;
if(variable_get('webfm_attach_new_window', '')) {
$href = array(
! 'data' => l(
! '
$filename)).'"/> ',
! variable_get('webfm_root_dir','webfm_send').'/'.$file->frelativedir.'/'.$file->id.'/1/'.$file->n,
! array(
! 'attributes' => array(
! 'title' => t("Download !filename",array('!filename' => $filename)),
! 'target' => '_blank'
! ),
! 'html' => TRUE
! )
! ).l(
! $filename,
! variable_get('webfm_root_dir','webfm_send').'/'.$file->frelativedir.'/'.$file->id.'/'.$file->n,
! array(
! 'attributes' => array(
! 'title' => t('Open !filename',array('!filename' => $filename)),
! 'target' => '_blank'
! )
! )
! ).$description,
! 'class' => 'att-title'
! );
} else {
$href = array(
! 'data' => l(
! '
$filename)).'"/> ',
! variable_get('webfm_root_dir','webfm_send').'/'.$file->id.'/1',
! array(
! 'attributes' => array('title' => t("Download !filename",array('!filename' => $filename))),
! 'html' => TRUE
! )
! )
! .l(
! $filename,
! variable_get('webfm_root_dir','webfm_send').'/'.$file->frelativedir.'/'.$file->id.'/'.$file->n,
! array('attributes' => array('title' => t('Open !filename',array('!filename' => $filename))))
! )
! .$description,
! 'class' => 'att-title'
);
}
$row = array();
array_push($row, $href);
if($enable_date) {
! // $time = $file->fcreatedate ? date(webfm_get_date_format(), $file->fcreatedate) : date(webfm_get_date_format(), @filemtime($file->p . '/'. $file->n));
! $time = $file->fcreatedate ? format_date($file->fcreatedate) : format_date(@filemtime($file->p . '/'. $file->n));
!
! array_push($row, array('data' => $time, 'class' => 'att-time'));
}
if($enable_size) {
array_push($row, array('data' => format_size($file->s), 'class' => 'att-size'));
Index: webfm_views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webfm/webfm_views.inc,v
retrieving revision 1.8
diff -c -r1.8 webfm_views.inc
*** webfm_views.inc 8 Apr 2008 06:28:14 -0000 1.8
--- webfm_views.inc 30 Mar 2009 16:15:59 -0000
***************
*** 163,169 ****
if ($fielddata['options'] == 'nolink') {
$links[] = check_plain($fname);
} else {
! $links[] = l(check_plain($fname), 'webfm_send/'.$file->fid);
}
}
return implode(' | ', $links);
--- 163,169 ----
if ($fielddata['options'] == 'nolink') {
$links[] = check_plain($fname);
} else {
! $links[] = l(check_plain($fname), variable_get('webfm_root_dir','webfm_send').'/'.$file->fid);
}
}
return implode(' | ', $links);
***************
*** 176,182 ****
function webfm_views_handler_file_filename_download($fieldinfo, $fielddata, $value, $data){
$name = strrev(substr(strrev($value), 0, strpos(strrev($value), '/')));
! return l(check_plain($name), 'webfm_send/'.$data->webfm_file_fid);
}
function webfm_views_handler_file_size($fieldinfo, $fielddata, $value, $data){
--- 176,182 ----
function webfm_views_handler_file_filename_download($fieldinfo, $fielddata, $value, $data){
$name = strrev(substr(strrev($value), 0, strpos(strrev($value), '/')));
! return l(check_plain($name), variable_get('webfm_root_dir','webfm_send').'/'.$data->webfm_file_fid);
}
function webfm_views_handler_file_size($fieldinfo, $fielddata, $value, $data){
***************
*** 188,194 ****
}
function webfm_views_handler_file_meta_download($fieldinfo, $fielddata, $value, $data){
! return l(check_plain(rawurldecode($value)), 'webfm_send/'.$data->webfm_file_fid);
}
function webfm_views_default_views(){
--- 188,194 ----
}
function webfm_views_handler_file_meta_download($fieldinfo, $fielddata, $value, $data){
! return l(check_plain(rawurldecode($value)), variable_get('webfm_root_dir','webfm_send').'/'.$data->webfm_file_fid);
}
function webfm_views_default_views(){