diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index aea0a5909cb..c467f7aaa84 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -60,12 +60,13 @@ class FormFile
* @param int $perm Value of permission to allow upload
* @param int $size Length of input file area
* @param Object $object Object to use (when attachment is done on an element)
- * @param string $options Options
+ * @param string $options Add an option column
* @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
* @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='')
+ function form_attach_new_file($url, $title='', $addcancel=0, $sectionid=0, $perm=1, $size=50, $object='', $options='', $useajax=1, $savingdocmask='', $linkfiles=1)
{
global $conf,$langs, $hookmanager;
$hookmanager->initHooks(array('formfile'));
@@ -77,10 +78,11 @@ class FormFile
// TODO: Cheeck this works with 2 forms on same page
// TODO: Cheeck this works with GED module, otherwise, force useajax to 0
// TODO: This does not support option savingdocmask
+ // TODO: This break feature to upload links too
return $this->_formAjaxFileUpload($object);
}
else
- {
+ {
$maxlength=$size;
$out = "\n\n\n";
@@ -155,37 +157,46 @@ class FormFile
$out .= '';
if (empty($sectionid)) $out .= '
';
- $out .= "\n\n\n";
- $langs->load('link');
- $title = $langs->trans("LinkANewFile");
- $out .= load_fiche_titre($title, null, null);
- $out .= '
';
+ $parameters = array('socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''),'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''), 'url'=>$url, 'perm'=>$perm);
+ $res = $hookmanager->executeHooks('formattachOptions',$parameters,$object);
+
+ $out .= "\n\n";
+ }
- $out .= '
';
- $parameters = array('socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''),'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''), 'url'=>$url, 'perm'=>$perm);
- $res = $hookmanager->executeHooks('formattachOptions',$parameters,$object);
if (empty($res))
{
print $out;
}
+
print $hookmanager->resPrint;
return 1;
@@ -1018,10 +1029,18 @@ class FormFile
include DOL_DOCUMENT_ROOT.'/core/tpl/ajax/fileupload_view.tpl.php';
}
-
+
+ /**
+ * Show array with linked files
+ *
+ * @param Object $object Object
+ * @param int $permtodelete Deletion is allowed
+ * @param string $action Action
+ * @param string $selected ???
+ * @return int Number of links
+ */
public function listOfLinks($object, $permtodelete=1, $action=null, $selected=null)
{
-
global $user, $conf, $langs, $user;
global $bc;
global $sortfield, $sortorder;
diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php
index 85eddf47624..5368c1b52be 100644
--- a/htdocs/ecm/index.php
+++ b/htdocs/ecm/index.php
@@ -406,7 +406,7 @@ print '';
if ($action == 'delete' && empty($conf->use_javascript_ajax))
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile','','',1);
-
+
}
dol_htmloutput_mesg($mesg);
@@ -456,7 +456,7 @@ print '';
if ($action == 'delete_section')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section, $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection','','',1);
-
+
}
// End confirm
@@ -775,7 +775,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php';
if ((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) || ! empty($section))
{
$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);
+ $formfile->form_attach_new_file(DOL_URL_ROOT.'/ecm/index.php', 'none', 0, ($section?$section:-1), $user->rights->ecm->upload, 48, null, '', 0, '', 0);
}
else print ' ';
diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang
index 613598fa68f..dc05a09916f 100644
--- a/htdocs/langs/en_US/main.lang
+++ b/htdocs/langs/en_US/main.lang
@@ -155,6 +155,7 @@ Valid=Valid
Approve=Approve
ReOpen=Re-Open
Upload=Send file
+ToLink=Link
Select=Select
Choose=Choose
ChooseLangage=Please choose your language
diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang
index d73598447ee..85372bb18d2 100644
--- a/htdocs/langs/fr_FR/main.lang
+++ b/htdocs/langs/fr_FR/main.lang
@@ -155,6 +155,7 @@ Valid=Valider
Approve=Approuver
ReOpen=Réouvrir
Upload=Envoyer fichier
+ToLink=Lier
Select=Sélectionner
Choose=Choisir
ChooseLangage=Choisissez votre langue