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
* @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,6 +78,7 @@ 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
......@@ -155,7 +157,11 @@ class FormFile
$out .= '</form>';
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');
$title = $langs->trans("LinkANewFile");
$out .= load_fiche_titre($title, null, null);
......@@ -173,7 +179,7 @@ class FormFile
$out .= '<input type="text" name="label" id="label">';
$out .= '<input type="hidden" name="objecttype" value="' . $object->element . '">';
$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 .= '>';
$out .= '</td></tr>';
......@@ -182,10 +188,15 @@ class FormFile
$out .= '</form><br>';
$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<!-- End form attach new file -->\n";
}
if (empty($res))
{
print $out;
}
print $hookmanager->resPrint;
return 1;
......@@ -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)
{
global $user, $conf, $langs, $user;
global $bc;
global $sortfield, $sortorder;
......
......@@ -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 '&nbsp;';
......
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment