forked from Wavyzz/dolibarr
Fix: tons of bugs into ecm module
This commit is contained in:
@@ -39,7 +39,13 @@ END
|
||||
|
||||
|
||||
# To use Alioth.debian.org
|
||||
* Create a login
|
||||
* Create an account login
|
||||
* Update your ~/.ssh/config file to add:
|
||||
Host svn.debian.org git.debian.org bzr.debian.org hg.debian.org darcs.debian.org arch.debian.org
|
||||
User eldy-guest
|
||||
IdentityFile ~/.ssh/id_rsa
|
||||
* Check login on page https://alioth.debian.org/users/login
|
||||
Ex: https://alioth.debian.org/users/eldy-guest
|
||||
* Setup your ssh as described into page: http://wiki.debian.org/Alioth/SSH
|
||||
* Ask to be included into project collab-maint: http://alioth.debian.org/projects/collab-maint/
|
||||
|
||||
@@ -192,8 +198,7 @@ To update dolibarr debian package
|
||||
* You can git clone debian git repo
|
||||
> git clone git.debian.org:/git/collab-maint/dolibarr.git [dolibarr-debian]
|
||||
or better
|
||||
> mkdir gitdebian
|
||||
> cd gitdebian
|
||||
> cd ~; mkdir git-debian; cd git-debian
|
||||
> gbp-clone git.debian.org:/git/collab-maint/dolibarr.git
|
||||
|
||||
* You can then create a PHP project from Eclipse called dolibarr-debian
|
||||
|
||||
@@ -207,6 +207,7 @@ if (file_exists($fullpathselecteddir))
|
||||
// Enable jquery handlers on new generated HTML objects
|
||||
print '<script type="text/javascript">';
|
||||
print 'jQuery(".classfortooltip").tipTip({ maxWidth: "600px", edgeOffset: 10, delay: 50, fadeIn: 50, fadeOut: 50});';
|
||||
// TODO Remove this. Is replaced with function as 3rd parameter of fileTree
|
||||
print 'jQuery(".fmdirlia").click(function(e) {
|
||||
id=jQuery(this).attr(\'id\').substr(12);
|
||||
jQuery("#formuserfile_section_dir").val(jQuery(this).attr(\'rel\'));
|
||||
@@ -221,7 +222,7 @@ if (file_exists($fullpathselecteddir))
|
||||
else print "PermissionDenied";
|
||||
}
|
||||
|
||||
// This ajax service is called only when a directory $selecteddir is opened but not closed.
|
||||
// This ajax service is called only when a directory $selecteddir is opened but not when closed.
|
||||
//print '<script language="javascript">';
|
||||
//print "loadandshowpreview('".dol_escape_js($selecteddir)."');";
|
||||
//print '</script>';
|
||||
|
||||
@@ -64,9 +64,10 @@ class FormFile
|
||||
* @param boolean $useajax Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option). 2 should never be used.
|
||||
* @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__'
|
||||
* @param string $linkfiles 1=Also add form to link files, 0=Do not show form to link files
|
||||
* @param string $htmlname Name and id of HTML form
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function form_attach_new_file($url, $title='', $addcancel=0, $sectionid=0, $perm=1, $size=50, $object='', $options='', $useajax=1, $savingdocmask='', $linkfiles=1)
|
||||
function form_attach_new_file($url, $title='', $addcancel=0, $sectionid=0, $perm=1, $size=50, $object='', $options='', $useajax=1, $savingdocmask='', $linkfiles=1, $htmlname='formuserfile')
|
||||
{
|
||||
global $conf,$langs, $hookmanager;
|
||||
$hookmanager->initHooks(array('formfile'));
|
||||
@@ -90,9 +91,9 @@ class FormFile
|
||||
if (empty($title)) $title=$langs->trans("AttachANewFile");
|
||||
if ($title != 'none') print_titre($title);
|
||||
|
||||
$out .= '<form name="formuserfile" action="'.$url.'" enctype="multipart/form-data" method="POST">';
|
||||
$out .= '<input type="hidden" id="formuserfile_section_dir" name="section_dir" value="">';
|
||||
$out .= '<input type="hidden" id="formuserfile_section_id" name="section_id" value="'.$sectionid.'">';
|
||||
$out .= '<form name="'.$htmlname.'" id="'.$htmlname.'" action="'.$url.'" enctype="multipart/form-data" method="POST">';
|
||||
$out .= '<input type="hidden" id="'.$htmlname.'_section_dir" name="section_dir" value="">';
|
||||
$out .= '<input type="hidden" id="'.$htmlname.'_section_id" name="section_id" value="'.$sectionid.'">';
|
||||
$out .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
|
||||
$out .= '<table width="100%" class="nobordernopadding">';
|
||||
@@ -165,9 +166,9 @@ class FormFile
|
||||
$langs->load('link');
|
||||
$title = $langs->trans("LinkANewFile");
|
||||
$out .= load_fiche_titre($title, null, null);
|
||||
$out .= '<form name="formuserfile" action="'.$url.'" method="POST">';
|
||||
$out .= '<input type="hidden" id="formuserfile_section_dir" name="section_dir" value="">';
|
||||
$out .= '<input type="hidden" id="formuserfile_section_id" name="section_id" value="'.$sectionid.'">';
|
||||
$out .= '<form name="'.$htmlname.'_link" id="'.$htmlname.'_link" action="'.$url.'" method="POST">';
|
||||
$out .= '<input type="hidden" id="'.$htmlname.'_link_section_dir" name="link_section_dir" value="">';
|
||||
$out .= '<input type="hidden" id="'.$htmlname.'_link_section_id" name="link_section_id" value="'.$sectionid.'">';
|
||||
$out .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
|
||||
$out .= '<table width="100%" class="nobordernopadding">';
|
||||
@@ -770,14 +771,14 @@ class FormFile
|
||||
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart;
|
||||
if ($forcedownload) print '&attachment=1';
|
||||
if (! empty($object->entity)) print '&entity='.$object->entity;
|
||||
print '&file='.urlencode($relativepath.$file['name']);
|
||||
/* Restore old code: When file is at level 2+, full relative path must be in url, not only level1
|
||||
$filepath=$relativepath.$file['name'];
|
||||
/* Restore old code: When file is at level 2+, full relative path (and not only level1) must be into url
|
||||
if ($file['level1name'] <> $object->id)
|
||||
$filepath=urlencode($object->id.'/'.$file['level1name'].'/'.$file['name']);
|
||||
$filepath=$object->id.'/'.$file['level1name'].'/'.$file['name'];
|
||||
else
|
||||
$filepath=urlencode($object->id.'/'.$file['name']);
|
||||
print '&file='.$filepath;
|
||||
$filepath=$object->id.'/'.$file['name'];
|
||||
*/
|
||||
print '&file='.urlencode($filepath);
|
||||
print '">';
|
||||
|
||||
print img_mime($file['name'],$file['name'].' ('.dol_print_size($file['size'],0,0).')').' ';
|
||||
@@ -800,14 +801,16 @@ class FormFile
|
||||
// Delete or view link
|
||||
// ($param must start with &)
|
||||
print '<td align="right">';
|
||||
if ($useinecm) print '<a href="'.DOL_URL_ROOT.'/ecm/docfile.php?urlfile='.urlencode($file['name']).$param.'" class="editfilelink" rel="'.urlencode($file['name']).$param.'">'.img_view().'</a> ';
|
||||
if ($useinecm) print '<a href="'.DOL_URL_ROOT.'/ecm/docfile.php?urlfile='.urlencode($file['name']).$param.'" class="editfilelink" rel="'.urlencode($file['name']).'">'.img_view().'</a> ';
|
||||
if ($permtodelete)
|
||||
{
|
||||
/*
|
||||
if ($file['level1name'] <> $object->id)
|
||||
$filepath=urlencode($file['level1name'].'/'.$file['name']);
|
||||
$filepath=$file['level1name'].'/'.$file['name'];
|
||||
else
|
||||
$filepath=urlencode($file['name']);
|
||||
print '<a href="'.(($useinecm && ! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':$url.'?action=delete&urlfile='.$filepath.$param).'" class="deletefilelink" rel="'.$filepath.$param.'">'.img_delete().'</a>';
|
||||
$filepath=$file['name'];
|
||||
*/
|
||||
print '<a href="'.(($useinecm && ! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':$url.'?action=delete&urlfile='.urlencode($filepath).$param).'" class="deletefilelink" rel="'.$filepath.'">'.img_delete().'</a>';
|
||||
}
|
||||
else print ' ';
|
||||
print "</td>";
|
||||
|
||||
@@ -53,6 +53,7 @@ $action=GETPOST("action");
|
||||
$section=GETPOST("section")?GETPOST("section","int"):GETPOST("section_id","int");
|
||||
$module=GETPOST("module");
|
||||
if (! $section) $section=0;
|
||||
$section_dir=GETPOST('section_dir');
|
||||
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
@@ -93,7 +94,7 @@ if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
// Define relativepath and upload_dir
|
||||
$relativepath='';
|
||||
if ($ecmdir->id) $relativepath=$ecmdir->getRelativePath();
|
||||
else $relativepath=GETPOST('section_dir');
|
||||
else $relativepath=$section_dir;
|
||||
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
|
||||
|
||||
if (empty($_FILES['userfile']['tmp_name']))
|
||||
@@ -168,6 +169,8 @@ if ($action == 'confirm_deletefile')
|
||||
if (GETPOST('confirm') == 'yes')
|
||||
{
|
||||
$langs->load("other");
|
||||
if ($section)
|
||||
{
|
||||
$result=$ecmdir->fetch($section);
|
||||
if (! ($result > 0))
|
||||
{
|
||||
@@ -175,8 +178,10 @@ if ($action == 'confirm_deletefile')
|
||||
exit;
|
||||
}
|
||||
$relativepath=$ecmdir->getRelativePath();
|
||||
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
|
||||
$file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
|
||||
}
|
||||
else $relativepath='';
|
||||
$upload_dir = $conf->ecm->dir_output.($relativepath?'/'.$relativepath:'');
|
||||
$file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_POST are already decoded by PHP).
|
||||
|
||||
$ret=dol_delete_file($file);
|
||||
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
|
||||
@@ -461,7 +466,6 @@ if ($action == 'delete_section')
|
||||
// End confirm
|
||||
|
||||
|
||||
|
||||
if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$action) || $action == 'delete')
|
||||
{
|
||||
print '<table width="100%" class="nobordernopadding">';
|
||||
@@ -774,8 +778,19 @@ include_once DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php';
|
||||
// To attach new file
|
||||
if ((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) || ! empty($section))
|
||||
{
|
||||
if (empty($section) || $section == -1)
|
||||
{
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function() {
|
||||
jQuery('#formuserfile').hide();
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
$formfile=new FormFile($db);
|
||||
$formfile->form_attach_new_file(DOL_URL_ROOT.'/ecm/index.php', 'none', 0, ($section?$section:-1), $user->rights->ecm->upload, 48, null, '', 0, '', 0);
|
||||
$formfile->form_attach_new_file(DOL_URL_ROOT.'/ecm/index.php', 'none', 0, ($section?$section:-1), $user->rights->ecm->upload, 48, null, '', 0, '', 0, 'formuserfile');
|
||||
}
|
||||
else print ' ';
|
||||
|
||||
@@ -789,6 +804,8 @@ else print ' ';
|
||||
<?php
|
||||
// End of page
|
||||
|
||||
|
||||
|
||||
if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
|
||||
include 'tpl/builddatabase.tpl.php';
|
||||
}
|
||||
|
||||
@@ -14,27 +14,38 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Output javascript for interactions code of ecm module
|
||||
*/
|
||||
|
||||
$openeddir='/';
|
||||
|
||||
// TODO: just use ajaxdirtree.php for load database after ajax refresh and not scan directories
|
||||
// too slow every page loaded !
|
||||
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE FOR JQUERY -->
|
||||
<!-- BEGIN PHP TEMPLATE ecm/tpl/builddatabase.tpl.php -->
|
||||
<!-- Doc of fileTree plugin at http://www.abeautifulsite.net/blog/2008/03/jquery-file-tree/ -->
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready( function() {
|
||||
$('#filetree').fileTree({ root: '<?php print dol_escape_js($openeddir); ?>',
|
||||
// Called if we click on a file (not a dir)
|
||||
|
||||
<?php
|
||||
$openeddir='/';
|
||||
?>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#filetree').fileTree({
|
||||
root: '<?php print dol_escape_js($openeddir); ?>',
|
||||
// Ajax called if we click to expand a dir (not a file). Parameter of dir is provided as a POST parameter.
|
||||
script: '<?php echo DOL_URL_ROOT.'/core/ajax/ajaxdirtree.php?modulepart=ecm&openeddir='.urlencode($openeddir); ?>',
|
||||
folderEvent: 'click',
|
||||
folderEvent: 'click', // 'dblclick'
|
||||
multiFolder: false },
|
||||
// Called if we click on a file (not a dir)
|
||||
function(file) {
|
||||
$("#mesg").hide();
|
||||
loadandshowpreview(file,0);
|
||||
},
|
||||
// Called if we click on a dir (not a file)
|
||||
function(elem) {
|
||||
id=elem.attr('id').substr(12);
|
||||
jQuery("#formuserfile_section_dir").val(elem.attr('rel'));
|
||||
jQuery("#formuserfile_section_id").val(id);
|
||||
jQuery('#formuserfile').show();
|
||||
}
|
||||
);
|
||||
|
||||
@@ -78,5 +89,6 @@ ecmBuildDatabase = function() {
|
||||
location.href="<?php echo $_SERVER['PHP_SELF']; ?>";
|
||||
});
|
||||
};
|
||||
|
||||
</script>
|
||||
<!-- END PHP TEMPLATE FOR JQUERY -->
|
||||
<!-- END PHP TEMPLATE ecm/tpl/builddatabase.tpl.php -->
|
||||
@@ -33,7 +33,7 @@
|
||||
if(jQuery) (function($){
|
||||
|
||||
$.extend($.fn, {
|
||||
fileTree: function(o, h) {
|
||||
fileTree: function(o, h, hd) { // CHANGE DOL_LDR add hd param
|
||||
// Defaults
|
||||
if( !o ) var o = {};
|
||||
if( o.root == undefined ) o.root = '/';
|
||||
@@ -77,6 +77,8 @@ if(jQuery) (function($){
|
||||
$(this).parent().find('UL').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing });
|
||||
$(this).parent().removeClass('expanded').addClass('collapsed');
|
||||
}
|
||||
// CHANGE DOL_LDR use hd function provided in param
|
||||
if (hd != null) hd($(this));
|
||||
} else {
|
||||
h($(this).attr('rel'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user