NEW Uploaded files are indexed into database

This commit is contained in:
Laurent Destailleur 2016-12-20 19:42:25 +01:00
parent 08449a2d4f
commit ed0ffd6f5a
8 changed files with 254 additions and 53 deletions

View File

@ -165,7 +165,11 @@ elseif ($action == 'renamefile' && GETPOST('renamefilesave'))
setEventMessages($langs->trans("FileRenamed"), null);
}
else setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors');
else
{
$langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now.
setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors');
}
}
}
}

View File

@ -875,12 +875,13 @@ class FormFile
* @param string $upload_dir Full path directory so we can know dir relative to MAIN_DATA_ROOT. Fill this if you want to complete file data with database indexes.
* @param string $sortfield Sort field ('name', 'size', 'position', ...)
* @param string $sortorder Sort order ('ASC' or 'DESC')
* @param int $disablemove 1=Disable move button, 0=Position move is possible.
* @return int <0 if KO, nb of files shown if OK
*/
function list_of_documents($filearray,$object,$modulepart,$param='',$forcedownload=0,$relativepath='',$permonobject=1,$useinecm=0,$textifempty='',$maxlength=0,$title='',$url='', $showrelpart=0, $permtoeditline=-1,$upload_dir='',$sortfield='',$sortorder='ASC')
function list_of_documents($filearray,$object,$modulepart,$param='',$forcedownload=0,$relativepath='',$permonobject=1,$useinecm=0,$textifempty='',$maxlength=0,$title='',$url='', $showrelpart=0, $permtoeditline=-1,$upload_dir='',$sortfield='',$sortorder='ASC', $disablemove=1)
{
global $user, $conf, $langs, $hookmanager;
global $bc;
global $bc,$bcdd;
global $sortfield, $sortorder, $maxheightmini;
// Define relative path used to store the file
@ -955,17 +956,18 @@ class FormFile
print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="modulepart" value="'.$modulepart.'">';
}
print '<table width="100%" class="'.($useinecm?'liste noborderbottom':'liste').'">'."\n";
print '<table width="100%" id="tablelines" class="'.($useinecm?'liste noborderbottom':'liste').'">'."\n";
print '<tr class="liste_titre">';
print '<tr class="liste_titre nodrag nodrop">';
print_liste_field_titre($langs->trans("Documents2"),$url,"name","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Size"),$url,"size","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Date"),$url,"date","",$param,'align="center"',$sortfield,$sortorder);
if (empty($useinecm)) print_liste_field_titre('',$url,"","",$param,'align="center"');
print_liste_field_titre('');
if (! $disablemove) print_liste_field_titre('');
print "</tr>\n";
// Get list of files stored into database for same directory
// Get list of files stored into database for same relative directory
if ($relativedir)
{
$filearrayindatabase = dol_dir_list_in_database($relativedir, '', null, 'name', SORT_ASC);
@ -985,15 +987,21 @@ class FormFile
$filearray[$key]['position']=$filearrayindatabase[$key2]['position'];
$filearray[$key]['cover']=$filearrayindatabase[$key2]['cover'];
$filearray[$key]['acl']=$filearrayindatabase[$key2]['acl'];
$filearray[$key]['rowid']=$filearrayindatabase[$key2]['rowid'];
$found=1;
break;
}
}
if (! $found)
{
$filearray[$key]['position']=999999; // File not indexed are at end. So if we add a file, it will not replace existing in position
$filearray[$key]['position']=999999; // File not indexed are at end. So if we add a file, it will not replace an existing position
$filearray[$key]['cover']=0;
$filearray[$key]['acl']='';
$filearray[$key]['rowid']=0;
// TODO Add entry into database
//...
}
}
@ -1007,7 +1015,7 @@ class FormFile
$nboffiles=count($filearray);
if ($nboffiles > 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
$var=true;
$var=true; $i=0; $nboflines = 0; $lastrowid=0;
foreach($filearray as $key => $file) // filearray must be only files here
{
if ($file['name'] != '.'
@ -1016,12 +1024,14 @@ class FormFile
{
$var=!$var;
$editline=0;
if ($filearray[$key]['rowid'] > 0) $lastrowid = $filearray[$key]['rowid'];
$editline=0;
$nboflines++;
print '<!-- Line list_of_documents '.$key.' relativepath = '.$relativepath.' -->'."\n";
// Do we have entry into database ?
print '<!-- In database: position='.$filearray[$key]['position'].' -->'."\n";
print '<tr '.$bc[$var].'>';
print '<tr id="row-'.($filearray[$key]['rowid']>0?$filearray[$key]['rowid']:'-AFTER'.$lastrowid.'POS'.($i+1)).'" '.$bcdd[$var].'>';
print '<td class="tdoverflow">';
//print "XX".$file['name']; //$file['name'] must be utf8
@ -1125,6 +1135,24 @@ class FormFile
print '<a href="'.(($useinecm && $useajax)?'#':$url.'?action=delete&urlfile='.urlencode($filepath).$param).'" class="deletefilelink" rel="'.$filepath.'">'.img_delete().'</a>';
}
print "</td>";
if (empty($disablemove))
{
if ($nboffiles > 1 && empty($conf->browser->phone)) {
print '<td align="center" class="linecolmove tdlineupdown">';
if ($i > 0) {
print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=up&amp;rowid='.$line->id.'">'.img_up('default',0,'imgupforline').'</a>';
}
if ($i < $nboffiles-1) {
print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=down&amp;rowid='.$line->id.'">'.img_down('default',0,'imgdownforline').'</a>';
}
print '</td>';
}
else {
print '<td align="center"'.((empty($conf->browser->phone) && empty($disablemove)) ?' class="linecolmove tdlineupdown"':' class="linecolmove"').'>';
print '</td>';
}
}
}
else
{
@ -1132,18 +1160,32 @@ class FormFile
print '<input type="submit" class="button" name="renamefilesave" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
print '</td>';
if (empty($disablemove)) print '<td class="right"></td>';
}
print "</tr>\n";
$i++;
}
}
if ($nboffiles == 0)
{
print '<tr '.$bc[false].'><td colspan="'.(empty($useinecm)?'5':'5').'" class="opacitymedium">';
$colspan=(empty($useinecm)?'5':'5');
if (empty($disablemove)) $colspan++;
print '<tr '.$bc[false].'><td colspan="'.$colspan.'" class="opacitymedium">';
if (empty($textifempty)) print $langs->trans("NoFileFound");
else print $textifempty;
print '</td></tr>';
}
print "</table>";
if (! $editline && $nboflines > 1) {
if (! empty($conf->use_javascript_ajax) && $permtoeditline) {
$table_element_line = 'ecm_files';
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
}
}
if (GETPOST('action') == 'editfile' && $permtoeditline)
{
print '</form>';

View File

@ -223,7 +223,7 @@ function dol_dir_list_in_database($path, $filter="", $excludefilter=null, $sortc
{
global $conf, $db;
$sql=" SELECT label, entity, filename, filepath, fullpath_orig, keywords, cover, gen_or_uploaded, extraparams, date_c, date_m, fk_user_c, fk_user_m, acl, position";
$sql=" SELECT rowid, label, entity, filename, filepath, fullpath_orig, keywords, cover, gen_or_uploaded, extraparams, date_c, date_m, fk_user_c, fk_user_m, acl, position";
if ($mode) $sql.=", description";
$sql.=" FROM ".MAIN_DB_PREFIX."ecm_files";
$sql.=" WHERE filepath = '".$db->escape($path)."'";
@ -243,6 +243,7 @@ function dol_dir_list_in_database($path, $filter="", $excludefilter=null, $sortc
preg_match('/([^\/]+)\/[^\/]+$/',DOL_DATA_ROOT.'/'.$obj->filepath.'/'.$obj->filename,$reg);
$level1name=(isset($reg[1])?$reg[1]:'');
$file_list[] = array(
"rowid" => $obj->rowid,
"name" => $obj->filename,
"path" => DOL_DATA_ROOT.'/'.$obj->filepath,
"level1name" => $level1name,
@ -574,11 +575,19 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists)
*/
function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
{
global $conf;
global $user, $db, $conf;
$result=false;
dol_syslog("files.lib.php::dol_move srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwritifexists=".$overwriteifexists);
$srcexists=dol_is_file($srcfile);
$destexists=dol_is_file($destfile);
if (! $srcexists)
{
dol_syslog("files.lib.php::dol_move srcfile does not exists. we ignore the move request.");
return false;
}
if ($overwriteifexists || ! $destexists)
{
$newpathofsrcfile=dol_osencode($srcfile);
@ -589,13 +598,69 @@ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
{
if ($destexists)
{
dol_syslog("files.lib.php::dol_move failed. We try to delete first and move after.", LOG_WARNING);
dol_syslog("files.lib.php::dol_move Failed. We try to delete target first and move after.", LOG_WARNING);
// We force delete and try again. Rename function sometimes fails to replace dest file with some windows NTFS partitions.
dol_delete_file($destfile);
$result=@rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @
}
else dol_syslog("files.lib.php::dol_move failed", LOG_WARNING);
else dol_syslog("files.lib.php::dol_move Failed.", LOG_WARNING);
}
// Move ok
if ($result)
{
// Rename entry into ecm database
$rel_filetorenamebefore = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $srcfile);
$rel_filetorenameafter = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $destfile);
if (! preg_match('/(\/temp\/|\/thumbs|\.meta$)/', $rel_filetorenameafter)) // If not a tmp file
{
$rel_filetorenamebefore = preg_replace('/^[\\/]/', '', $rel_filetorenamebefore);
$rel_filetorenameafter = preg_replace('/^[\\/]/', '', $rel_filetorenameafter);
//var_dump($rel_filetorenamebefore.' - '.$rel_filetorenameafter);
dol_syslog("Try to rename also entries in database for full relative path before = ".$rel_filetorenamebefore." after = ".$rel_filetorenameafter, LOG_DEBUG);
include DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile=new EcmFiles($db);
$result = $ecmfile->fetch(0, '', $rel_filetorenamebefore);
if ($result > 0) // If found
{
$filename = basename($rel_filetorenameafter);
$rel_dir = dirname($rel_filetorenameafter);
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
$ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename;
$result = $ecmfile->update($user);
}
elseif ($result == 0) // If not found
{
$filename = basename($rel_filetorenameafter);
$rel_dir = dirname($rel_filetorenameafter);
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
$ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename;
$ecmfile->label = md5_file(dol_osencode($destfile)); // $destfile is a full path to file
$ecmfile->fullpath_orig = $srcfile;
$ecmfile->gen_or_uploaded = 'unknown';
$ecmfile->description = ''; // indexed content
$ecmfile->keyword = ''; // keyword content
$result = $ecmfile->create($user);
if ($result < 0)
{
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
}
$result = $ecmfile->create($user);
}
elseif ($result < 0)
{
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
}
}
}
if (empty($newmask)) $newmask=empty($conf->global->MAIN_UMASK)?'0755':$conf->global->MAIN_UMASK;
$newmaskdec=octdec($newmask);
// Currently method is restricted to files (dol_delete_files previously used is for files, and mask usage if for files too)
@ -826,7 +891,7 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n
// Delete entry into ecm database
$rel_filetodelete = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $filename);
if (! preg_match('/\/temp\//', $rel_filetodelete)) // If not a tmp file
if (! preg_match('/(\/temp\/|\/thumbs\/|\.meta$)/', $rel_filetodelete)) // If not a tmp file
{
$rel_filetodelete = preg_replace('/^[\\/]/', '', $rel_filetodelete);
@ -846,7 +911,7 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n
}
else dol_syslog("Failed to remove file ".$filename, LOG_WARNING);
// TODO Failure to remove can be because file was already removed or because of permission
// If error because of not exists, we must can return true but we should return false if this is a permission problem
// If error because of not exists, we must should return true and we should return false if this is a permission problem
}
}
else dol_syslog("No files to delete found", LOG_WARNING);
@ -1095,7 +1160,7 @@ function dol_init_file_process($pathtoscan='', $trackid='')
* All information used are in db, conf, langs, user and _FILES.
* Note: This function can be used only into a HTML page context.
*
* @param string $upload_dir Directory where to store uploaded file (note: also find in first part of dest_file)
* @param string $upload_dir Directory where to store uploaded file (note: used to forge $destpath = $upload_dir + filename)
* @param int $allowoverwrite 1=Allow overwrite existing file
* @param int $donotupdatesession 1=Do no edit _SESSION variable
* @param string $varfiles _FILES var name
@ -1150,6 +1215,21 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio
global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini;
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
// Generate thumbs.
if (image_format_supported($destpath) == 1)
{
// Create thumbs
// We can't use $object->addThumbs here because there is no $object known
// Used on logon for example
$imgThumbSmall = vignette($destpath, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs");
// Create mini thumbs for image (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette($destpath, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs");
}
// Update session
if (empty($donotupdatesession))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
@ -1157,19 +1237,22 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio
$formmail->trackid = $trackid;
$formmail->add_attached_files($destpath, $destfile, $TFile['type'][$i]);
}
else // Update table of files
// Update table of files
if ($donotupdatesession)
{
$rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dir);
$rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $destfile);
if (! preg_match('/[\\/]temp[\\/]/', $rel_dir)) // If not a tmp file
{
$filename = basename($destfile);
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
include DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile=new EcmFiles($db);
$ecmfile->label = md5_file($destpath);
$ecmfile->filename = $destfile;
$ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename;
$ecmfile->label = md5_file(dol_osencode($destpath));
$ecmfile->fullpath_orig = $TFile['name'][$i];
$ecmfile->gen_or_uploaded = 'uploaded';
$ecmfile->description = ''; // indexed content
@ -1181,18 +1264,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio
}
}
}
if (image_format_supported($destpath) == 1)
{
// Create thumbs
// We can't use $object->addThumbs here because there is no $object known
// Used on logon for example
$imgThumbSmall = vignette($destpath, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs");
// Create mini thumbs for image (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette($destpath, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs");
}
setEventMessages($langs->trans("FileTransferComplete"), null, 'mesgs');
}
else

View File

@ -134,11 +134,50 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS
{
$fullpath=$dir."/".$original_file;
$result=dol_imageResizeOrCrop($fullpath,0,$_POST['sizex'],$_POST['sizey']);
if ($result == $fullpath)
{
$object->addThumbs($fullpath);
// Update/create database for file $fullpath
$rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath);
$rel_filename = preg_replace('/^[\\/]/','',$rel_filename);
include DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile=new EcmFiles($db);
$result = $ecmfile->fetch(0, '', $rel_filename);
if ($result > 0) // If found
{
$filename = basename($rel_filename);
$rel_dir = dirname($rel_filename);
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
$ecmfile->label = md5_file(dol_osencode($fullpath));
$result = $ecmfile->update($user);
}
elseif ($result == 0) // If not found
{
$filename = basename($rel_filename);
$rel_dir = dirname($rel_filename);
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
$ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename;
$ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file
$ecmfile->fullpath_orig = $fullpath;
$ecmfile->gen_or_uploaded = 'unknown';
$ecmfile->description = ''; // indexed content
$ecmfile->keyword = ''; // keyword content
$result = $ecmfile->create($user);
if ($result < 0)
{
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
}
$result = $ecmfile->create($user);
}
if ($backtourl)
{
header("Location: ".$backtourl);
@ -168,6 +207,45 @@ if ($action == 'confirm_crop')
{
$object->addThumbs($fullpath);
// Update/create database for file $fullpath
$rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath);
$rel_filename = preg_replace('/^[\\/]/','',$rel_filename);
include DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile=new EcmFiles($db);
$result = $ecmfile->fetch(0, '', $rel_filename);
if ($result > 0) // If found
{
$filename = basename($rel_filename);
$rel_dir = dirname($rel_filename);
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
$ecmfile->label = md5_file(dol_osencode($fullpath));
$result = $ecmfile->update($user);
}
elseif ($result == 0) // If not found
{
$filename = basename($rel_filename);
$rel_dir = dirname($rel_filename);
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
$ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename;
$ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file
$ecmfile->fullpath_orig = $fullpath;
$ecmfile->gen_or_uploaded = 'unknown';
$ecmfile->description = ''; // indexed content
$ecmfile->keyword = ''; // keyword content
$result = $ecmfile->create($user);
if ($result < 0)
{
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
}
$result = $ecmfile->create($user);
}
if ($backtourl)
{
header("Location: ".$backtourl);
@ -197,7 +275,7 @@ llxHeader($head, $langs->trans("Image"), '', '', 0, 0, array('/includes/jquery/p
print load_fiche_titre($langs->trans("ImageEditor"));
$infoarray=dol_getImageSize($dir."/".urldecode($_GET["file"]));
$infoarray=dol_getImageSize($dir."/".GETPOST("file"));
$height=$infoarray['height'];
$width=$infoarray['width'];
print $langs->trans("CurrentInformationOnImage").': ';
@ -218,7 +296,8 @@ print '<legend>'.$langs->trans("Resize").'</legend>';
print $langs->trans("ResizeDesc").'<br>';
print $langs->trans("NewLength").': <input class="flat" name="sizex" size="10" type="text" > px &nbsp; '.$langs->trans("or").' &nbsp; ';
print $langs->trans("NewHeight").': <input class="flat" name="sizey" size="10" type="text" > px &nbsp; <br>';
print '<input type="hidden" name="file" value="'.$_GET['file'].'" />';
print '<input type="hidden" name="file" value="'.dol_escape_htmltag(GETPOST('file')).'" />';
print '<input type="hidden" name="action" value="confirm_resize" />';
print '<input type="hidden" name="product" value="'.$id.'" />';
print '<input type="hidden" name="modulepart" value="'.$modulepart.'" />';
@ -240,7 +319,7 @@ print '<br>'."\n";
if (! empty($conf->use_javascript_ajax))
{
$infoarray=dol_getImageSize($dir."/".urldecode($_GET["file"]));
$infoarray=dol_getImageSize($dir."/".GETPOST("file"));
$height=$infoarray['height'];
$width=$infoarray['width'];
$widthforcrop=$width; $refsizeforcrop='orig'; $ratioforcrop=1;
@ -260,7 +339,7 @@ if (! empty($conf->use_javascript_ajax))
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$object->entity.'&file='.$original_file.'" alt="" id="cropbox" width="'.$widthforcrop.'px"/>';
print '</div>';
print '</div><br>';
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="post">
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="POST">
<div class="jc_coords">
'.$langs->trans("NewSizeAfterCropping").':
<label>X1 <input type="text" size="4" id="x" name="x" /></label>
@ -271,13 +350,13 @@ if (! empty($conf->use_javascript_ajax))
<label>H <input type="text" size="4" id="h" name="h" /></label>
</div>
<input type="hidden" id="file" name="file" value="'.urlencode($original_file).'" />
<input type="hidden" id="file" name="file" value="'.dol_escape_htmltag($original_file).'" />
<input type="hidden" id="action" name="action" value="confirm_crop" />
<input type="hidden" id="product" name="product" value="'.$id.'" />
<input type="hidden" id="product" name="product" value="'.dol_escape_htmltag($id).'" />
<input type="hidden" id="refsizeforcrop" name="refsizeforcrop" value="'.$refsizeforcrop.'" />
<input type="hidden" id="ratioforcrop" name="ratioforcrop" value="'.$ratioforcrop.'" />
<input type="hidden" name="modulepart" value="'.$modulepart.'" />
<input type="hidden" name="id" value="'.$id.'" />
<input type="hidden" name="modulepart" value="'.dol_escape_htmltag($modulepart).'" />
<input type="hidden" name="id" value="'.dol_escape_htmltag($id).'" />
<br>
<input type="submit" id="submitcrop" name="submitcrop" class="button" value="'.dol_escape_htmltag($langs->trans("Recenter")).'" />
&nbsp;

View File

@ -17,16 +17,16 @@
*
* Javascript code to activate drag and drop on lines
* You can use this if you want to be abale to drag and drop rows of a table.
* You must add id="tablelines" on table level tag and have count($object->lines) or count($taskarray) > 0
* You must add id="tablelines" on table level tag and have ($nboflines or count($object->lines) or count($taskarray) > 0)
*/
?>
<!-- BEGIN PHP TEMPLATE AJAXROW.TPL.PHP -->
<!-- BEGIN PHP TEMPLATE AJAXROW.TPL.PHP - Script to enable drag and drop on tables -->
<?php
$id=$object->id;
$fk_element=$object->fk_element;
$table_element_line=$object->table_element_line;
$nboflines=(isset($object->lines)?count($object->lines):(isset($tasksarray)?count($tasksarray):0));
$table_element_line=(empty($table_element_line)?$object->table_element_line:$table_element_line);
$nboflines=(isset($object->lines)?count($object->lines):(isset($tasksarray)?count($tasksarray):(empty($nboflines)?0:$nboflines)));
$forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
$tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
@ -43,6 +43,7 @@ $(document).ready(function(){
$("#<?php echo $tagidfortablednd; ?>").tableDnD({
onDrop: function(table, row) {
var reloadpage = "<?php echo $forcereloadpage; ?>";
console.log($("#<?php echo $tagidfortablednd; ?>").tableDnDSerialize());
var roworder = cleanSerialize($("#<?php echo $tagidfortablednd; ?>").tableDnDSerialize());
var table_element_line = "<?php echo $table_element_line; ?>";
var fk_element = "<?php echo $fk_element; ?>";

View File

@ -72,6 +72,9 @@ $formfile->form_attach_new_file(
$savingdocmask
);
$disablemove=1;
if ($modulepart == 'produit') $disablemove=0;
// List of document
$formfile->list_of_documents(
$filearray,
@ -90,7 +93,8 @@ $formfile->list_of_documents(
$permtoedit,
$upload_dir,
$sortfield,
$sortorder
$sortorder,
$disablemove
);
print "<br>";

View File

@ -55,7 +55,7 @@ class EcmFiles //extends CommonObject
public $keywords;
public $cover;
public $position;
public $gen_or_uploaded;
public $gen_or_uploaded; // can be 'generated', 'uploaded', 'unknown'
public $extraparams;
public $date_c = '';
public $date_m = '';
@ -474,7 +474,6 @@ class EcmFiles //extends CommonObject
$this->acl = trim($this->acl);
}
// Check parameters
// Put here code to add a control on parameters values
@ -493,9 +492,9 @@ class EcmFiles //extends CommonObject
$sql .= ' gen_or_uploaded = '.(isset($this->gen_or_uploaded)?"'".$this->db->escape($this->gen_or_uploaded)."'":"null").',';
$sql .= ' extraparams = '.(isset($this->extraparams)?"'".$this->db->escape($this->extraparams)."'":"null").',';
$sql .= ' date_c = '.(! isset($this->date_c) || dol_strlen($this->date_c) != 0 ? "'".$this->db->idate($this->date_c)."'" : 'null').',';
$sql .= ' date_m = '.(! isset($this->date_m) || dol_strlen($this->date_m) != 0 ? "'".$this->db->idate($this->date_m)."'" : 'null').',';
//$sql .= ' date_m = '.(! isset($this->date_m) || dol_strlen($this->date_m) != 0 ? "'".$this->db->idate($this->date_m)."'" : 'null').','; // Field automatically updated
$sql .= ' fk_user_c = '.(isset($this->fk_user_c)?$this->fk_user_c:"null").',';
$sql .= ' fk_user_m = '.(isset($this->fk_user_m)?$this->fk_user_m:"null").',';
$sql .= ' fk_user_m = '.($this->fk_user_m > 0?$this->fk_user_m:$user->id).',';
$sql .= ' acl = '.(isset($this->acl)?"'".$this->db->escape($this->acl)."'":"null");
$sql .= ' WHERE rowid=' . $this->id;

View File

@ -192,7 +192,7 @@ if ($object->id)
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
// Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);