diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index 984a492aa4d..3beb2eec1ad 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -1018,7 +1018,7 @@ class FormFile
}
- public function list_of_links($object, $permtodelete=1)
+ public function list_of_links($object, $permtodelete=1, $action=null, $selected=null)
{
global $user, $conf, $langs, $hookmanager, $user;
@@ -1057,34 +1057,53 @@ class FormFile
$var = true;
foreach($links as $link) {
- $var=!$var;
+ $var =! $var;
print '
';
- print '| ';
- //print "XX".$file['name']; //$file['name'] must be utf8
- print '';
- print $link->label;
- print '';
- print " | \n";
- print ' | ';
- print ''.dol_print_date($link->datea, "dayhour", "tzuser").' | ';
- // Preview
- /*if (empty($useinecm))
- {
- print '';
- $tmp=explode('.',$file['name']);
- $minifile=$tmp[0].'_mini.'.$tmp[1];
- if (image_format_supported($file['name']) > 0) print ' ';
- else print ' ';
+ //edit mode
+ if ($action == 'update' && $selected === $link->id) {
+ print '';
+ }
+ else {
+ print ' | ';
+ //print "XX".$file['name']; //$file['name'] must be utf8
+ print '';
+ print $link->label;
+ print '';
+ print " | \n";
+ print ' | ';
+ print ''.dol_print_date($link->datea, "dayhour", "tzuser").' | ';
+ // Preview
+ /*if (empty($useinecm))
+ {
+ print '';
+ $tmp=explode('.',$file['name']);
+ $minifile=$tmp[0].'_mini.'.$tmp[1];
+ if (image_format_supported($file['name']) > 0) print ' ';
+ else print ' ';
+ print ' | ';
+ }*/
+ print ' | ';
+ // Delete or view link
+ // ($param must start with &)
+ print '';
+ print ''.img_edit().'';
+ if ($permtodelete) print ''.img_delete().'';
+ else print ' ';
+ print " | ";
+ }
print "
\n";
}
if ($nboflinks == 0)
diff --git a/htdocs/core/tpl/doc2.tpl.php b/htdocs/core/tpl/doc2.tpl.php
index c2ac769b500..37ec4fc1760 100644
--- a/htdocs/core/tpl/doc2.tpl.php
+++ b/htdocs/core/tpl/doc2.tpl.php
@@ -38,5 +38,5 @@ $formfile->list_of_documents($filearray,
print "
";
//List of links
-$formfile->list_of_links($object, $permission);
+$formfile->list_of_links($object, $permission, $action, GETPOST('linkid', 'int'));
print "
";
diff --git a/htdocs/core/tpl/document_actions.tpl.php b/htdocs/core/tpl/document_actions.tpl.php
index bd8e2fde1e3..434c9e9f4ed 100644
--- a/htdocs/core/tpl/document_actions.tpl.php
+++ b/htdocs/core/tpl/document_actions.tpl.php
@@ -47,5 +47,24 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') {
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id);
exit;
}
+} elseif ($action == 'confirm_updateline' && GETPOST('save') && GETPOST('link', 'alpha')) {
+ require_once DOL_DOCUMENT_ROOT . '/link/class/link.class.php';
+ $langs->load('link');
+ $link = new Link($db);
+ $link->id = GETPOST('linkid', 'int');
+ $f = $link->fetch();
+ if ($f) {
+ $link->url = GETPOST('link', 'alpha');
+ if (substr($link->url, 0, 7) != 'http://' && substr($link->url, 0, 8) != 'https://') {
+ $link->url = 'http://' . $link->url;
+ }
+ $link->label = GETPOST('label', 'alpha');
+ $res = $link->update($user);
+ if (!$res) {
+ setEventMessage($langs->trans("ErrorFailedToUpdateLink", $link->label));
+ }
+ } else {
+ //error fetching
+ }
}