Merge branch '12.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	htdocs/core/class/html.formfile.class.php
	htdocs/core/lib/files.lib.php
	htdocs/core/tpl/filemanager.tpl.php
This commit is contained in:
Laurent Destailleur 2020-05-27 14:28:20 +02:00
commit 16625af34e
17 changed files with 91 additions and 60 deletions

View File

@ -82,7 +82,7 @@ class Asset extends CommonObject
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1),
'amount_ht' => array('type'=>'double(24,8)', 'label'=>'AmountHTShort', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'isameasure'=>'1', 'help'=>"Help text",), 'amount_ht' => array('type'=>'double(24,8)', 'label'=>'AmountHTShort', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'isameasure'=>'1', 'help'=>"Help text",),
'amount_vat' => array('type'=>'double(24,8)', 'label'=>'AmountVAT', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'isameasure'=>'1', 'help'=>"Help text",), 'amount_vat' => array('type'=>'double(24,8)', 'label'=>'AmountVAT', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'isameasure'=>'1', 'help'=>"Help text",),
'fk_asset_type' => array('type'=>'integer:AssetType:asset/class/asset_type.class.php', 'label'=>'AssetsType', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty",), 'fk_asset_type' => array('type'=>'integer:AssetType:asset/class/asset_type.class.php', 'label'=>'AssetsType', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>1, 'index'=>1, 'searchall'=>1),
'description' => array('type'=>'text', 'label'=>'Description', 'visible'=>-1, 'enabled'=>1, 'position'=>90, 'notnull'=>-1,), 'description' => array('type'=>'text', 'label'=>'Description', 'visible'=>-1, 'enabled'=>1, 'position'=>90, 'notnull'=>-1,),
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>-1, 'enabled'=>1, 'position'=>91, 'notnull'=>-1,), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>-1, 'enabled'=>1, 'position'=>91, 'notnull'=>-1,),
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>-1, 'enabled'=>1, 'position'=>92, 'notnull'=>-1,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>-1, 'enabled'=>1, 'position'=>92, 'notnull'=>-1,),

View File

@ -343,7 +343,7 @@ if ($useajax || $action == 'delete')
$section_id = $section; $section_id = $section;
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
$useglobalvars = 1;
$form = new Form($db); $form = new Form($db);
$formquestion['urlfile'] = array('type'=>'hidden', 'value'=>$urlfile, 'name'=>'urlfile'); // We must always put field, even if empty because it is filled by javascript later $formquestion['urlfile'] = array('type'=>'hidden', 'value'=>$urlfile, 'name'=>'urlfile'); // We must always put field, even if empty because it is filled by javascript later
$formquestion['section'] = array('type'=>'hidden', 'value'=>$section, 'name'=>'section'); // We must always put field, even if empty because it is filled by javascript later $formquestion['section'] = array('type'=>'hidden', 'value'=>$section, 'name'=>'section'); // We must always put field, even if empty because it is filled by javascript later

View File

@ -4050,7 +4050,6 @@ class Form
public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0) public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0)
{ {
global $langs, $conf; global $langs, $conf;
global $useglobalvars;
$more = '<!-- formconfirm -->'; $more = '<!-- formconfirm -->';
$formconfirm = ''; $formconfirm = '';
@ -4190,7 +4189,7 @@ class Form
if (isset($input['inputko']) && $input['inputko'] == 1) array_push($inputko, $input['name']); if (isset($input['inputko']) && $input['inputko'] == 1) array_push($inputko, $input['name']);
} }
} }
// Show JQuery confirm box. Note that global var $useglobalvars is used inside this template // Show JQuery confirm box.
$formconfirm .= '<div id="'.$dialogconfirm.'" title="'.dol_escape_htmltag($title).'" style="display: none;">'; $formconfirm .= '<div id="'.$dialogconfirm.'" title="'.dol_escape_htmltag($title).'" style="display: none;">';
if (!empty($formquestion['text'])) { if (!empty($formquestion['text'])) {
$formconfirm .= '<div class="confirmtext">'.$formquestion['text'].'</div>'."\n"; $formconfirm .= '<div class="confirmtext">'.$formquestion['text'].'</div>'."\n";

View File

@ -1199,8 +1199,11 @@ class FormFile
print '<input type="hidden" name="renamefilefrom" value="'.dol_escape_htmltag($file['name']).'">'; print '<input type="hidden" name="renamefilefrom" value="'.dol_escape_htmltag($file['name']).'">';
print '<input type="text" name="renamefileto" class="quatrevingtpercent" value="'.dol_escape_htmltag($file['name']).'">'; print '<input type="text" name="renamefileto" class="quatrevingtpercent" value="'.dol_escape_htmltag($file['name']).'">';
$editline = 1; $editline = 1;
} else { }
print dol_trunc($file['name'], 200); else
{
$filenametoshow = preg_replace('/\.noexe$/', '', $file['name']);
print dol_trunc($filenametoshow, 200);
print '</a>'; print '</a>';
} }
// Preview link // Preview link

View File

@ -779,7 +779,10 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Ref // Ref
print '<td><a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$projecttmp->id.'">'.img_object($langs->trans("ShowProject"), ($obj->public ? 'projectpub' : 'project'))." ".$obj->ref.'</a></td>'; print '<td>';
print $projecttmp->getNomUrl(1);
print '</td>';
// Label // Label
print '<td>'.$obj->title.'</td>'; print '<td>'.$obj->title.'</td>';
// Date start // Date start

View File

@ -860,7 +860,7 @@ function dol_move($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1, $te
{ {
$rel_filetorenamebefore = preg_replace('/^[\\/]/', '', $rel_filetorenamebefore); $rel_filetorenamebefore = preg_replace('/^[\\/]/', '', $rel_filetorenamebefore);
$rel_filetorenameafter = preg_replace('/^[\\/]/', '', $rel_filetorenameafter); $rel_filetorenameafter = preg_replace('/^[\\/]/', '', $rel_filetorenameafter);
//var_dump($rel_filetorenamebefore.' - '.$rel_filetorenameafter); //var_dump($rel_filetorenamebefore.' - '.$rel_filetorenameafter);exit;
dol_syslog("Try to rename also entries in database for full relative path before = ".$rel_filetorenamebefore." after = ".$rel_filetorenameafter, LOG_DEBUG); dol_syslog("Try to rename also entries in database for full relative path before = ".$rel_filetorenamebefore." after = ".$rel_filetorenameafter, LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
@ -883,6 +883,7 @@ function dol_move($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1, $te
$ecmfile->filepath = $rel_dir; $ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename; $ecmfile->filename = $filename;
$resultecm = $ecmfile->update($user); $resultecm = $ecmfile->update($user);
} elseif ($resultecm == 0) // If no entry were found for src files, create/update target file } elseif ($resultecm == 0) // If no entry were found for src files, create/update target file
{ {
@ -983,7 +984,7 @@ function dolCheckVirus($src_file)
* @param integer $uploaderrorcode Value of PHP upload error code ($_FILES['field']['error']) * @param integer $uploaderrorcode Value of PHP upload error code ($_FILES['field']['error'])
* @param int $nohook Disable all hooks * @param int $nohook Disable all hooks
* @param string $varfiles _FILES var name * @param string $varfiles _FILES var name
* @return int|string >0 if OK, <0 or string if KO * @return int|string 1 if OK, 2 if OK and .noexe appended, <0 or string if KO
* @see dol_move() * @see dol_move()
*/ */
function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan = 0, $uploaderrorcode = 0, $nohook = 0, $varfiles = 'addedfile') function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan = 0, $uploaderrorcode = 0, $nohook = 0, $varfiles = 'addedfile')
@ -993,6 +994,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
$reshook = 0; $reshook = 0;
$file_name = $dest_file; $file_name = $dest_file;
$successcode = 1;
if (empty($nohook)) if (empty($nohook))
{ {
@ -1043,6 +1045,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
if (isAFileWithExecutableContent($dest_file) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED)) if (isAFileWithExecutableContent($dest_file) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED))
{ {
$file_name .= '.noexe'; $file_name .= '.noexe';
$successcode = 2;
} }
// Security: // Security:
@ -1096,14 +1099,14 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
{ {
if (!empty($conf->global->MAIN_UMASK)) @chmod($file_name_osencoded, octdec($conf->global->MAIN_UMASK)); if (!empty($conf->global->MAIN_UMASK)) @chmod($file_name_osencoded, octdec($conf->global->MAIN_UMASK));
dol_syslog("Files.lib::dol_move_uploaded_file Success to move ".$src_file." to ".$file_name." - Umask=".$conf->global->MAIN_UMASK, LOG_DEBUG); dol_syslog("Files.lib::dol_move_uploaded_file Success to move ".$src_file." to ".$file_name." - Umask=".$conf->global->MAIN_UMASK, LOG_DEBUG);
return 1; // Success return $successcode; // Success
} else { } else {
dol_syslog("Files.lib::dol_move_uploaded_file Failed to move ".$src_file." to ".$file_name, LOG_ERR); dol_syslog("Files.lib::dol_move_uploaded_file Failed to move ".$src_file." to ".$file_name, LOG_ERR);
return -3; // Unknown error return -3; // Unknown error
} }
} }
return 1; // Success return $successcode; // Success
} }
/** /**
@ -1156,8 +1159,6 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0,
if ($reshook < 0) return false; if ($reshook < 0) return false;
return true; return true;
} else { } else {
$error = 0;
//print "x".$file." ".$disableglob;exit; //print "x".$file." ".$disableglob;exit;
$file_osencoded = dol_osencode($file); // New filename encoded in OS filesystem encoding charset $file_osencoded = dol_osencode($file); // New filename encoded in OS filesystem encoding charset
if (empty($disableglob) && !empty($file_osencoded)) if (empty($disableglob) && !empty($file_osencoded))
@ -1180,10 +1181,11 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0,
$rel_filetodelete = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filename); $rel_filetodelete = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filename);
if (!preg_match('/(\/temp\/|\/thumbs\/|\.meta$)/', $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);
if (is_object($db) && $indexdatabase) // $db may not be defined when lib is in a context with define('NOREQUIREDB',1) if (is_object($db) && $indexdatabase) // $db may not be defined when lib is in a context with define('NOREQUIREDB',1)
{ {
$rel_filetodelete = preg_replace('/^[\\/]/', '', $rel_filetodelete);
$rel_filetodelete = preg_replace('/\.noexe$/', '', $rel_filetodelete);
dol_syslog("Try to remove also entries in database for full relative path = ".$rel_filetodelete, LOG_DEBUG); dol_syslog("Try to remove also entries in database for full relative path = ".$rel_filetodelete, LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile = new EcmFiles($db); $ecmfile = new EcmFiles($db);
@ -1537,6 +1539,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess
$destfile = dol_string_nohtmltag($destfile); $destfile = dol_string_nohtmltag($destfile);
$destfull = dol_string_nohtmltag($destfull); $destfull = dol_string_nohtmltag($destfull);
// Move file from temp directory to final directory. A .noexe may also be appended on file name.
$resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destfull, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles); $resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destfull, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles);
if (is_numeric($resupload) && $resupload > 0) // $resupload can be 'ErrorFileAlreadyExists' if (is_numeric($resupload) && $resupload > 0) // $resupload can be 'ErrorFileAlreadyExists'
@ -1573,13 +1576,13 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess
// Update index table of files (llx_ecm_files) // Update index table of files (llx_ecm_files)
if ($donotupdatesession == 1) if ($donotupdatesession == 1)
{ {
$result = addFileIntoDatabaseIndex($upload_dir, basename($destfile), $TFile['name'][$i], 'uploaded', 0); $result = addFileIntoDatabaseIndex($upload_dir, basename($destfile).($resupload == 2 ? '.noexe' : ''), $TFile['name'][$i], 'uploaded', 0);
if ($result < 0) if ($result < 0)
{ {
if ($allowoverwrite) { if ($allowoverwrite) {
// Do not show error message. We can have an error due to DB_ERROR_RECORD_ALREADY_EXISTS // Do not show error message. We can have an error due to DB_ERROR_RECORD_ALREADY_EXISTS
} else { } else {
setEventMessages('FailedToAddFileIntoDatabaseIndex', '', 'warnings'); setEventMessages('WarningFailedToAddFileIntoDatabaseIndex', '', 'warnings');
} }
} }
} }
@ -1685,7 +1688,7 @@ function dol_remove_file_process($filenb, $donotupdatesession = 0, $donotdeletef
* See also commonGenerateDocument that also add/update database index when a file is generated. * See also commonGenerateDocument that also add/update database index when a file is generated.
* *
* @param string $dir Directory name (full real path without ending /) * @param string $dir Directory name (full real path without ending /)
* @param string $file File name * @param string $file File name (May end with '.noexe')
* @param string $fullpathorig Full path of origin for file (can be '') * @param string $fullpathorig Full path of origin for file (can be '')
* @param string $mode How file was created ('uploaded', 'generated', ...) * @param string $mode How file was created ('uploaded', 'generated', ...)
* @param int $setsharekey Set also the share key * @param int $setsharekey Set also the share key
@ -1701,7 +1704,7 @@ function addFileIntoDatabaseIndex($dir, $file, $fullpathorig = '', $mode = 'uplo
if (!preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir if (!preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir
{ {
$filename = basename($file); $filename = basename(preg_replace('/\.noexe$/', '', $file));
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);

View File

@ -3025,7 +3025,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'object_phoning', 'object_phoning_mobile', 'object_phoning_fax', 'object_email', 'object_website', 'object_phoning', 'object_phoning_mobile', 'object_phoning_fax', 'object_email', 'object_website',
'off', 'on', 'order', 'off', 'on', 'order',
'paiment', 'play', 'playdisabled', 'poll', 'printer', 'product', 'propal', 'projecttask', 'stock', 'resize', 'service', 'stats', 'trip', 'paiment', 'play', 'playdisabled', 'poll', 'printer', 'product', 'propal', 'projecttask', 'stock', 'resize', 'service', 'stats', 'trip',
'setup', 'sign-out', 'split', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'vcard', 'wrench', 'setup', 'sign-out', 'split', 'stripe-s', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'vcard', 'wrench',
'jabber', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', 'jabber', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp',
'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top',
'home', 'companies', 'products', 'commercial', 'invoicing', 'pencil-ruler', 'preview', 'project', 'projectpub', 'supplier_invoice', 'hrm', 'members', 'ticket', 'generic', 'home', 'companies', 'products', 'commercial', 'invoicing', 'pencil-ruler', 'preview', 'project', 'projectpub', 'supplier_invoice', 'hrm', 'members', 'ticket', 'generic',
@ -3039,7 +3039,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
if (in_array($pictowithouttext, array('object_generic', 'note', 'off', 'on', 'object_bookmark', 'bookmark', 'vcard'))) { if (in_array($pictowithouttext, array('object_generic', 'note', 'off', 'on', 'object_bookmark', 'bookmark', 'vcard'))) {
$fa = 'far'; $fa = 'far';
} }
if (in_array($pictowithouttext, array('skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp'))) { if (in_array($pictowithouttext, array('skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'stripe-s', 'youtube', 'google-plus-g', 'whatsapp'))) {
$fa = 'fab'; $fa = 'fab';
} }

View File

@ -174,8 +174,7 @@ if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg
if ($action == 'deletefile') print $form->formconfirm('eeeee', $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 'deletefile'); if ($action == 'deletefile') print $form->formconfirm('eeeee', $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 'deletefile');
print '</td></tr>'; print '</td></tr>';
} else // Show filtree when ajax is disabled (rare) } else { // Show filtree when ajax is disabled (rare)
{
print '<tr><td style="padding-left: 20px">'; print '<tr><td style="padding-left: 20px">';
$_POST['modulepart'] = $module; $_POST['modulepart'] = $module;
@ -208,7 +207,7 @@ if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg
<div class="pane-in ecm-in-layout-center"> <div class="pane-in ecm-in-layout-center">
<div id="ecmfileview" class="ecmfileview"> <div id="ecmfileview" class="ecmfileview">
<?php <?php
// Start right panel // Start right panel - List of content of a directory
$mode = 'noajax'; $mode = 'noajax';

View File

@ -138,7 +138,7 @@ class EcmFiles extends CommonObject
$this->entity = trim($this->entity); $this->entity = trim($this->entity);
} }
if (isset($this->filename)) { if (isset($this->filename)) {
$this->filename = trim($this->filename); $this->filename = preg_replace('/\.noexe$/', '', trim($this->filename));
} }
if (isset($this->filepath)) { if (isset($this->filepath)) {
$this->filepath = trim($this->filepath); $this->filepath = trim($this->filepath);
@ -341,12 +341,13 @@ class EcmFiles extends CommonObject
$sql .= " t.src_object_id"; $sql .= " t.src_object_id";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE 1 = 1'; $sql .= ' WHERE 1 = 1';
/* Fetching this table depends on filepath+filename, it must not depends on entity /* Fetching this table depends on filepath+filename, it must not depends on entity because filesystem on disk does not know what is Dolibarr entities
if (! empty($conf->multicompany->enabled)) { if (! empty($conf->multicompany->enabled)) {
$sql .= " AND entity IN (" . getEntity('ecmfiles') . ")"; $sql .= " AND entity IN (" . getEntity('ecmfiles') . ")";
}*/ }*/
if ($relativepath) { if ($relativepath) {
$sql .= " AND t.filepath = '".$this->db->escape(dirname($relativepath))."' AND t.filename = '".$this->db->escape(basename($relativepath))."'"; $relativepathwithnoexe = preg_replace('/\.noexe$/', '', $relativepath); // We must never have the .noexe into the database
$sql .= " AND t.filepath = '".$this->db->escape(dirname($relativepath))."' AND t.filename = '".$this->db->escape(basename($relativepathwithnoexe))."'";
$sql .= " AND t.entity = ".$conf->entity; // unique key include the entity so each company has its own index $sql .= " AND t.entity = ".$conf->entity; // unique key include the entity so each company has its own index
} elseif (!empty($ref)) { // hash of file path } elseif (!empty($ref)) { // hash of file path
$sql .= " AND t.ref = '".$this->db->escape($ref)."'"; $sql .= " AND t.ref = '".$this->db->escape($ref)."'";
@ -554,10 +555,11 @@ class EcmFiles extends CommonObject
$this->entity = trim($this->entity); $this->entity = trim($this->entity);
} }
if (isset($this->filename)) { if (isset($this->filename)) {
$this->filename = trim($this->filename); $this->filename = preg_replace('/\.noexe$/', '', trim($this->filename));
} }
if (isset($this->filepath)) { if (isset($this->filepath)) {
$this->filepath = trim($this->filepath); $this->filepath = trim($this->filepath);
$this->filepath = preg_replace('/[\\/]+$/', '', $this->filepath); // Remove last /
} }
if (isset($this->fullpath_orig)) { if (isset($this->fullpath_orig)) {
$this->fullpath_orig = trim($this->fullpath_orig); $this->fullpath_orig = trim($this->fullpath_orig);

View File

@ -138,6 +138,12 @@ if ($action == 'update')
$oldfile = $olddir.$oldlabel; $oldfile = $olddir.$oldlabel;
$newfile = $newdir.$newlabel; $newfile = $newdir.$newlabel;
$newfileformove = $newfile;
// If old file end with .noexe, new file must also end with .noexe
if (preg_match('/\.noexe$/', $oldfile) && ! preg_match('/\.noexe$/', $newfileformove)) {
$newfileformove .= '.noexe';
}
//var_dump($oldfile);var_dump($newfile);exit;
// Now we update index of file // Now we update index of file
$db->begin(); $db->begin();
@ -145,7 +151,7 @@ if ($action == 'update')
//print $oldfile.' - '.$newfile; //print $oldfile.' - '.$newfile;
if ($newlabel != $oldlabel) if ($newlabel != $oldlabel)
{ {
$result = dol_move($oldfile, $newfile); // This include update of database $result = dol_move($oldfile, $newfileformove); // This include update of database
if (!$result) if (!$result)
{ {
$langs->load('errors'); $langs->load('errors');
@ -185,7 +191,7 @@ if ($action == 'update')
$object->entity = $conf->entity; $object->entity = $conf->entity;
$object->filepath = preg_replace('/[\\/]+$/', '', $newdirrelativetodocument); $object->filepath = preg_replace('/[\\/]+$/', '', $newdirrelativetodocument);
$object->filename = $newlabel; $object->filename = $newlabel;
$object->label = md5_file(dol_osencode($newfile)); // hash of file content $object->label = md5_file(dol_osencode($newfileformove)); // hash of file content
$object->fullpath_orig = ''; $object->fullpath_orig = '';
$object->gen_or_uploaded = 'unknown'; $object->gen_or_uploaded = 'unknown';
$object->description = ''; // indexed content $object->description = ''; // indexed content
@ -203,6 +209,11 @@ if ($action == 'update')
$db->commit(); $db->commit();
$urlfile = $newlabel; $urlfile = $newlabel;
// If old file end with .noexe, new file must also end with .noexe
if (preg_match('/\.noexe$/', $newfileformove)) {
$urlfile .= '.noexe';
}
header('Location: '.$_SERVER["PHP_SELF"].'?urlfile='.urlencode($urlfile).'&section='.urlencode($section)); header('Location: '.$_SERVER["PHP_SELF"].'?urlfile='.urlencode($urlfile).'&section='.urlencode($section));
exit; exit;
} else { } else {
@ -255,9 +266,13 @@ while ($tmpecmdir && $result > 0)
$i++; $i++;
} }
$urlfiletoshow = preg_replace('/\.noexe$/', '', $urlfile);
$s = img_picto('', 'object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> '.$s.' -> '; $s = img_picto('', 'object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> '.$s.' -> ';
if ($action == 'edit') $s .= '<input type="text" name="label" class="quatrevingtpercent" value="'.$urlfile.'">'; if ($action == 'edit') $s .= '<input type="text" name="label" class="quatrevingtpercent" value="'.$urlfiletoshow.'">';
else $s .= $urlfile; else $s .= $urlfiletoshow;
$morehtml = '';
$object->ref = ''; // Force to hide ref $object->ref = ''; // Force to hide ref
dol_banner_tab($object, '', $morehtml, 0, '', '', $s); dol_banner_tab($object, '', $morehtml, 0, '', '', $s);
@ -280,10 +295,9 @@ print dol_print_size($totalsize);
print '</td></tr>'; print '</td></tr>';
*/ */
// Hash of file content
print '<tr><td>'.$langs->trans("HashOfFileContent").'</td><td>'; print '<tr><td>'.$langs->trans("HashOfFileContent").'</td><td>';
$object = new EcmFiles($db); $object = new EcmFiles($db);
//$filenametosearch=basename($filepath);
//$filedirtosearch=basedir($filepath);
$object->fetch(0, '', $filepathtodocument); $object->fetch(0, '', $filepathtodocument);
if (!empty($object->label)) if (!empty($object->label))
{ {

View File

@ -124,7 +124,6 @@ if ($action == 'confirm_deletefile')
if (GETPOST('confirm') == 'yes') if (GETPOST('confirm') == 'yes')
{ {
// GETPOST('urlfile','alpha') is full relative URL from ecm root dir. Contains path of all sections. // GETPOST('urlfile','alpha') is full relative URL from ecm root dir. Contains path of all sections.
//var_dump(GETPOST('urlfile'));exit;
$upload_dir = $conf->ecm->dir_output.($relativepath ? '/'.$relativepath : ''); $upload_dir = $conf->ecm->dir_output.($relativepath ? '/'.$relativepath : '');
$file = $upload_dir."/".GETPOST('urlfile', 'alpha'); $file = $upload_dir."/".GETPOST('urlfile', 'alpha');
@ -132,7 +131,9 @@ if ($action == 'confirm_deletefile')
$ret = dol_delete_file($file); // This include also the delete from file index in database. $ret = dol_delete_file($file); // This include also the delete from file index in database.
if ($ret) if ($ret)
{ {
setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile', 'alpha')), null, 'mesgs'); $urlfiletoshow = GETPOST('urlfile', 'alpha');
$urlfiletoshow = preg_replace('/\.noexe$/', '', $urlfiletoshow);
setEventMessages($langs->trans("FileWasRemoved", $urlfiletoshow), null, 'mesgs');
$result = $ecmdir->changeNbOfFiles('-'); $result = $ecmdir->changeNbOfFiles('-');
} else { } else {
setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile', 'alpha')), null, 'errors'); setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile', 'alpha')), null, 'errors');

View File

@ -263,3 +263,4 @@ WarningNumberOfRecipientIsRestrictedInMassAction=Warning, number of different re
WarningDateOfLineMustBeInExpenseReportRange=Warning, the date of line is not in the range of the expense report WarningDateOfLineMustBeInExpenseReportRange=Warning, the date of line is not in the range of the expense report
WarningProjectClosed=Project is closed. You must re-open it first. WarningProjectClosed=Project is closed. You must re-open it first.
WarningSomeBankTransactionByChequeWereRemovedAfter=Some bank transaction were removed after that the receipt including them were generated. So nb of cheques and total of receipt may differ from number and total in list. WarningSomeBankTransactionByChequeWereRemovedAfter=Some bank transaction were removed after that the receipt including them were generated. So nb of cheques and total of receipt may differ from number and total in list.
WarningFailedToAddFileIntoDatabaseIndex=Warnin, failed to add file entry into ECM database index table

View File

@ -214,7 +214,7 @@ print '<input type="hidden" name="action" value="update">';
$head = opensurvey_prepare_head($object); $head = opensurvey_prepare_head($object);
dol_fiche_head($head, 'general', $langs->trans("Survey"), -1, DOL_URL_ROOT.'/opensurvey/img/object_opensurvey.png', 1); dol_fiche_head($head, 'general', $langs->trans("Survey"), -1, 'poll');
$morehtmlref = ''; $morehtmlref = '';

View File

@ -367,8 +367,8 @@ div.cadre td.vide {
/*Case de tableau contenant les noms dans affichage de sondage*/ /*Case de tableau contenant les noms dans affichage de sondage*/
div.cadre td.nom { div.cadre td.nom {
background-color: #DDDDDD; background-color: #DDDDDD;
font-size:12px;
text-align:center; text-align:center;
padding: 8px;
} }
div.cadre td.casevide { div.cadre td.casevide {
background-color: white; background-color: white;

View File

@ -413,10 +413,11 @@ $toutsujet = str_replace("°", "'", $toutsujet);
print '<form name="formulaire4" action="#" method="POST">'."\n"; print '<form name="formulaire4" action="#" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'">';
$head = opensurvey_prepare_head($object); $head = opensurvey_prepare_head($object);
dol_fiche_head($head, 'preview', $langs->trans("Survey"), -1, DOL_URL_ROOT.'/opensurvey/img/object_opensurvey.png', 1); dol_fiche_head($head, 'preview', $langs->trans("Survey"), -1, 'poll');
$morehtmlref = ''; $morehtmlref = '';
@ -510,6 +511,7 @@ if (GETPOST('ajoutsujet'))
if (!$user->rights->opensurvey->write) accessforbidden(); if (!$user->rights->opensurvey->write) accessforbidden();
print '<form name="formulaire" action="" method="POST">'."\n"; print '<form name="formulaire" action="" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="backtopage" value="'.GETPOST('backtopage', 'alpha').'">'; print '<input type="hidden" name="backtopage" value="'.GETPOST('backtopage', 'alpha').'">';
print '<div class="center">'."\n"; print '<div class="center">'."\n";
@ -594,6 +596,7 @@ if ($user->rights->opensurvey->write) {
$nbcolonnes = substr_count($object->sujet, ',') + 1; $nbcolonnes = substr_count($object->sujet, ',') + 1;
print '<form name="formulaire" action="" method="POST">'."\n"; print '<form name="formulaire" action="" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<div class="cadre"> '."\n"; print '<div class="cadre"> '."\n";
@ -753,7 +756,7 @@ if ($object->format == "D")
print '<td class="sujet">'.dol_htmlentities($tmp[0]).'</td>'."\n"; print '<td class="sujet">'.dol_htmlentities($tmp[0]).'</td>'."\n";
} }
print '<td class="sujet"><a href="'.$_SERVER["PHP_SELF"].'?id='.$numsondage.'&ajoutsujet=1&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_picto('', dol_buildpath('/opensurvey/img/add-16.png', 1), '', 1).'</a></td>'."\n"; print '<td class="sujet"><a href="'.$_SERVER["PHP_SELF"].'?id='.$numsondage.'&ajoutsujet=1&backtopage='.urlencode($_SERVER["PHP_SELF"]).'"><span class="fa fa-plus-circle valignmiddle btnTitle-icon"></span></a></td>'."\n";
print '</tr>'."\n"; print '</tr>'."\n";
} }

View File

@ -31,6 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'thirdpartylist';
// Security check // Security check
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid; if ($user->socid) $socid = $user->socid;
@ -147,6 +149,7 @@ if ($conf->ficheinter->enabled && $user->rights->ficheinter->lire) $elementTypeA
if ($object->fournisseur) if ($object->fournisseur)
{ {
$langs->load("supplier_proposal");
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
print $langs->trans('SupplierCode').'</td><td colspan="3">'; print $langs->trans('SupplierCode').'</td><td colspan="3">';
print $object->code_fournisseur; print $object->code_fournisseur;
@ -352,14 +355,14 @@ if ($sql_select)
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$param = "&socid=".$socid."&type_element=".$type_element; $param = "&socid=".urlencode($socid)."&type_element=".urlencode($type_element);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($sprod_fulldescr) $param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr); if ($sprod_fulldescr) $param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr);
if ($sref) $param .= "&sref=".urlencode($sref); if ($sref) $param .= "&sref=".urlencode($sref);
if ($month) $param .= "&month=".$month; if ($month) $param .= "&month=".urlencode($month);
if ($year) $param .= "&year=".$year; if ($year) $param .= "&year=".urlencode($year);
if ($optioncss != '') $param .= '&optioncss='.$optioncss; if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, '', 0, '', '', $limit); print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, '', 0, '', '', $limit);

View File

@ -924,7 +924,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
{ {
$morehtmlright .= dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&amp;action=createcard'); $morehtmlright .= dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&amp;action=createcard');
} }
print load_fiche_titre($langs->trans('StripePaymentModes').($stripeacc ? ' (Stripe connection with StripeConnect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, ''); print load_fiche_titre($langs->trans('StripePaymentModes').($stripeacc ? ' (Stripe connection with StripeConnect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, 'stripe-s');
$listofsources = array(); $listofsources = array();
if (is_object($stripe)) if (is_object($stripe))