Skip to content
Snippets Groups Projects
Commit cf8ff25d authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Minor enhancement with link feature

parent 27fede88
No related branches found
No related tags found
No related merge requests found
...@@ -60,12 +60,13 @@ class FormFile ...@@ -60,12 +60,13 @@ class FormFile
* @param int $perm Value of permission to allow upload * @param int $perm Value of permission to allow upload
* @param int $size Length of input file area * @param int $size Length of input file area
* @param Object $object Object to use (when attachment is done on an element) * @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 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 $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 * @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; global $conf,$langs, $hookmanager;
$hookmanager->initHooks(array('formfile')); $hookmanager->initHooks(array('formfile'));
...@@ -77,6 +78,7 @@ class FormFile ...@@ -77,6 +78,7 @@ class FormFile
// TODO: Cheeck this works with 2 forms on same page // TODO: Cheeck this works with 2 forms on same page
// TODO: Cheeck this works with GED module, otherwise, force useajax to 0 // TODO: Cheeck this works with GED module, otherwise, force useajax to 0
// TODO: This does not support option savingdocmask // TODO: This does not support option savingdocmask
// TODO: This break feature to upload links too
return $this->_formAjaxFileUpload($object); return $this->_formAjaxFileUpload($object);
} }
else else
...@@ -155,7 +157,11 @@ class FormFile ...@@ -155,7 +157,11 @@ class FormFile
$out .= '</form>'; $out .= '</form>';
if (empty($sectionid)) $out .= '<br>'; if (empty($sectionid)) $out .= '<br>';
$out .= "\n<!-- End form attach new file -->\n\n"; $out .= "\n<!-- End form attach new file -->\n";
if ($linkfiles)
{
$out .= "\n<!-- Start form attach new link -->\n";
$langs->load('link'); $langs->load('link');
$title = $langs->trans("LinkANewFile"); $title = $langs->trans("LinkANewFile");
$out .= load_fiche_titre($title, null, null); $out .= load_fiche_titre($title, null, null);
...@@ -173,7 +179,7 @@ class FormFile ...@@ -173,7 +179,7 @@ class FormFile
$out .= '<input type="text" name="label" id="label">'; $out .= '<input type="text" name="label" id="label">';
$out .= '<input type="hidden" name="objecttype" value="' . $object->element . '">'; $out .= '<input type="hidden" name="objecttype" value="' . $object->element . '">';
$out .= '<input type="hidden" name="objectid" value="' . $object->id . '">'; $out .= '<input type="hidden" name="objectid" value="' . $object->id . '">';
$out .= '<input type="submit" class="button" name="linkit" value="'.$langs->trans("Upload").'"'; $out .= '<input type="submit" class="button" name="linkit" value="'.$langs->trans("ToLink").'"';
$out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled="disabled"':''); $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled="disabled"':'');
$out .= '>'; $out .= '>';
$out .= '</td></tr>'; $out .= '</td></tr>';
...@@ -182,10 +188,15 @@ class FormFile ...@@ -182,10 +188,15 @@ class FormFile
$out .= '</form><br>'; $out .= '</form><br>';
$parameters = array('socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''),'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''), 'url'=>$url, 'perm'=>$perm); $parameters = array('socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''),'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''), 'url'=>$url, 'perm'=>$perm);
$res = $hookmanager->executeHooks('formattachOptions',$parameters,$object); $res = $hookmanager->executeHooks('formattachOptions',$parameters,$object);
$out .= "\n<!-- End form attach new file -->\n";
}
if (empty($res)) if (empty($res))
{ {
print $out; print $out;
} }
print $hookmanager->resPrint; print $hookmanager->resPrint;
return 1; return 1;
...@@ -1019,9 +1030,17 @@ class FormFile ...@@ -1019,9 +1030,17 @@ class FormFile
} }
/**
* 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) public function listOfLinks($object, $permtodelete=1, $action=null, $selected=null)
{ {
global $user, $conf, $langs, $user; global $user, $conf, $langs, $user;
global $bc; global $bc;
global $sortfield, $sortorder; global $sortfield, $sortorder;
......
...@@ -775,7 +775,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php'; ...@@ -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)) if ((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) || ! empty($section))
{ {
$formfile=new FormFile($db); $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 '&nbsp;'; else print '&nbsp;';
......
...@@ -155,6 +155,7 @@ Valid=Valid ...@@ -155,6 +155,7 @@ Valid=Valid
Approve=Approve Approve=Approve
ReOpen=Re-Open ReOpen=Re-Open
Upload=Send file Upload=Send file
ToLink=Link
Select=Select Select=Select
Choose=Choose Choose=Choose
ChooseLangage=Please choose your language ChooseLangage=Please choose your language
......
...@@ -155,6 +155,7 @@ Valid=Valider ...@@ -155,6 +155,7 @@ Valid=Valider
Approve=Approuver Approve=Approuver
ReOpen=Réouvrir ReOpen=Réouvrir
Upload=Envoyer fichier Upload=Envoyer fichier
ToLink=Lier
Select=Sélectionner Select=Sélectionner
Choose=Choisir Choose=Choisir
ChooseLangage=Choisissez votre langue ChooseLangage=Choisissez votre langue
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment