| ';
-if ($action != 'edit') print $langs->trans("DirectDownloadLink");
-else print $langs->trans("FileSharedViaALink");
+if ($action != 'edit') {
+ print $langs->trans("DirectDownloadLink");
+} else {
+ print $langs->trans("FileSharedViaALink");
+}
print ' | ';
-if (!empty($object->share))
-{
- if ($action != 'edit')
- {
+if (!empty($object->share)) {
+ if ($action != 'edit') {
$forcedownload = 0;
$paramlink = '';
- if (!empty($object->share)) $paramlink .= ($paramlink ? '&' : '').'hashp='.$object->share; // Hash for public share
- if ($forcedownload) $paramlink .= ($paramlink ? '&' : '').'attachment=1';
+ if (!empty($object->share)) {
+ $paramlink .= ($paramlink ? '&' : '').'hashp='.$object->share; // Hash for public share
+ }
+ if ($forcedownload) {
+ $paramlink .= ($paramlink ? '&' : '').'attachment=1';
+ }
$fulllink = $urlwithroot.'/document.php'.($paramlink ? '?'.$paramlink : '');
//if (! empty($object->ref)) $fulllink.='&hashn='.$object->ref; // Hash of file path
//elseif (! empty($object->label)) $fulllink.='&hashc='.$object->label; // Hash of file content
print img_picto('', 'globe').' ';
- if ($action != 'edit') print '';
- else print $fulllink;
- if ($action != 'edit') print ' '.$langs->trans("Download").''; // No target here
+ if ($action != 'edit') {
+ print '';
+ } else {
+ print $fulllink;
+ }
+ if ($action != 'edit') {
+ print ' '.$langs->trans("Download").''; // No target here
+ }
} else {
print 'share ? ' checked="checked"' : '').' /> ';
}
} else {
- if ($action != 'edit')
- {
+ if ($action != 'edit') {
print ''.$langs->trans("FileNotShared").'';
} else {
print 'share ? ' checked="checked"' : '').' /> ';
@@ -390,8 +398,7 @@ print ajax_autoselect('downloadlink');
print dol_get_fiche_end();
-if ($action == 'edit')
-{
+if ($action == 'edit') {
print '';
print ' ';
print ' ';
@@ -403,18 +410,15 @@ if ($action == 'edit')
// Confirmation de la suppression d'une ligne categorie
-if ($action == 'delete_file')
-{
+if ($action == 'delete_file') {
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.urlencode($section), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile', $urlfile), 'confirm_deletefile', '', 1, 1);
}
-if ($action != 'edit')
-{
+if ($action != 'edit') {
// Actions buttons
print ' ';
}
diff --git a/htdocs/ecm/file_note.php b/htdocs/ecm/file_note.php
new file mode 100644
index 00000000000..dba96710f60
--- /dev/null
+++ b/htdocs/ecm/file_note.php
@@ -0,0 +1,184 @@
+
+ * Copyright (C) 2004-2016 Laurent Destailleur
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2013 Florian Henry
+ * Copyright (C) 2017 Ferran Marcet
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/ecm/file_note.php
+ * \ingroup ecm
+ * \brief Fiche de notes sur une ecm file
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
+require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
+
+// Load translation files required by the page
+$langs->loadLangs(array('ecm'));
+
+$id = GETPOST('id', 'int');
+$ref = GETPOST('ref', 'alpha');
+$socid = GETPOST('socid', 'int');
+$action = GETPOST('action', 'aZ09');
+
+if (!$user->rights->ecm->setup) {
+ accessforbidden();
+}
+
+// Get parameters
+$socid = GETPOST("socid", "int");
+// Security check
+if ($user->socid > 0) {
+ $action = '';
+ $socid = $user->socid;
+}
+
+$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
+$sortfield = GETPOST("sortfield", 'alpha');
+$sortorder = GETPOST("sortorder", 'alpha');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
+if (empty($page) || $page == -1) {
+ $page = 0;
+} // If $page is not defined, or '' or -1
+$offset = $limit * $page;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+if (!$sortorder) {
+ $sortorder = "ASC";
+}
+if (!$sortfield) {
+ $sortfield = "label";
+}
+
+$section = GETPOST("section", 'alpha');
+if (!$section) {
+ dol_print_error('', 'Error, section parameter missing');
+ exit;
+}
+$urlfile = GETPOST("urlfile");
+if (!$urlfile) {
+ dol_print_error('', "ErrorParamNotDefined");
+ exit;
+}
+
+// Load ecm object
+$ecmdir = new EcmDirectory($db);
+$result = $ecmdir->fetch(GETPOST("section", 'alpha'));
+if (!$result > 0) {
+ dol_print_error($db, $ecmdir->error);
+ exit;
+}
+$relativepath = $ecmdir->getRelativePath();
+$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
+
+$fullpath = $conf->ecm->dir_output.'/'.$relativepath.$urlfile;
+
+$relativetodocument = 'ecm/'.$relativepath; // $relativepath is relative to ECM dir, we need relative to document
+$filepath = $relativepath.$urlfile;
+$filepathtodocument = $relativetodocument.$urlfile;
+
+// Try to load object from index
+$object = new ECMFiles($db);
+$extrafields = new ExtraFields($db);
+// fetch optionals attributes and labels
+$extrafields->fetch_name_optionals_label($object->table_element);
+
+$result = $object->fetch(0, '', $filepathtodocument);
+if ($result < 0) {
+ dol_print_error($db, $object->error, $object->errors);
+ exit;
+}
+
+$permissionnote = $user->rights->ecm->setup; // Used by the include of actions_setnotes.inc.php
+
+/*
+ * Actions
+ */
+
+include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
+
+
+/*
+ * View
+ */
+
+llxHeader('', $langs->trans('EcmFiles'));
+
+$form = new Form($db);
+
+$object->section_id = $ecmdir->id;
+$object->label = $urlfile;
+$head = ecm_file_prepare_head($object);
+
+print dol_get_fiche_head($head, 'note', $langs->trans("File"), -1, 'generic');
+
+$s = '';
+$tmpecmdir = new EcmDirectory($db); // Need to create a new one
+$tmpecmdir->fetch($ecmdir->id);
+$result = 1;
+$i = 0;
+while ($tmpecmdir && $result > 0) {
+ $tmpecmdir->ref = $tmpecmdir->label;
+ $s = $tmpecmdir->getNomUrl(1).$s;
+ if ($tmpecmdir->fk_parent) {
+ $s = ' -> '.$s;
+ $result = $tmpecmdir->fetch($tmpecmdir->fk_parent);
+ } else {
+ $tmpecmdir = 0;
+ }
+ $i++;
+}
+
+$urlfiletoshow = preg_replace('/\.noexe$/', '', $urlfile);
+
+$s = img_picto('', 'object_dir').' '.$langs->trans("ECMRoot").' -> '.$s.' -> ';
+if ($action == 'edit') {
+ $s .= '';
+} else {
+ $s .= $urlfiletoshow;
+}
+
+$linkback = '';
+if ($backtopage) {
+ $linkback = ''.$langs->trans("BackToTree").'';
+}
+
+$object->ref = ''; // Force to hide ref
+dol_banner_tab($object, '', $linkback, 0, '', '', $s);
+
+
+
+print '';
+print ' ';
+
+
+$cssclass = "titlefield";
+$moreparam = '§ion='.$section.'&urlfile='.$urlfile;
+include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
+
+print ' ';
+
+print dol_get_fiche_end();
+
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql
index 309d4d4b170..4cdc36195db 100644
--- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql
+++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql
@@ -399,6 +399,8 @@ CREATE TABLE llx_ecm_files_extrafields
) ENGINE=innodb;
ALTER TABLE llx_ecm_files_extrafields ADD INDEX idx_ecm_files_extrafields (fk_object);
+ALTER TABLE llx_ecm_files ADD COLUMN note_private text AFTER fk_user_m;
+ALTER TABLE llx_ecm_files ADD COLUMN note_public text AFTER note_private;
CREATE TABLE llx_ecm_directories_extrafields
(
@@ -409,6 +411,9 @@ CREATE TABLE llx_ecm_directories_extrafields
) ENGINE=innodb;
ALTER TABLE llx_ecm_directories_extrafields ADD INDEX idx_ecm_directories_extrafields (fk_object);
+ALTER TABLE llx_ecm_directories ADD COLUMN note_private text AFTER fk_user_m;
+ALTER TABLE llx_ecm_directories ADD COLUMN note_public text AFTER note_private;
+
ALTER TABLE llx_website_page ADD COLUMN allowed_in_frames integer DEFAULT 0;
ALTER TABLE llx_website_page ADD COLUMN object_type varchar(255);
ALTER TABLE llx_website_page ADD COLUMN fk_object varchar(255);
diff --git a/htdocs/install/mysql/tables/llx_ecm_directories.sql b/htdocs/install/mysql/tables/llx_ecm_directories.sql
index 4616a763b81..3ef599df05e 100644
--- a/htdocs/install/mysql/tables/llx_ecm_directories.sql
+++ b/htdocs/install/mysql/tables/llx_ecm_directories.sql
@@ -33,5 +33,7 @@ CREATE TABLE llx_ecm_directories
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_user_c integer,
fk_user_m integer,
+ note_private text,
+ note_public text,
acl text
) ENGINE=innodb;
diff --git a/htdocs/install/mysql/tables/llx_ecm_files.sql b/htdocs/install/mysql/tables/llx_ecm_files.sql
index 635945a256d..cf9f3a8f148 100644
--- a/htdocs/install/mysql/tables/llx_ecm_files.sql
+++ b/htdocs/install/mysql/tables/llx_ecm_files.sql
@@ -38,5 +38,7 @@ CREATE TABLE llx_ecm_files
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_user_c integer,
fk_user_m integer,
+ note_private text,
+ note_public text,
acl text -- for future permission 'per file'
) ENGINE=innodb;
|