From a92db7db399a29e784a8d9e1e8a09a37be8653fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Dec 2019 13:02:30 +0100 Subject: [PATCH] Look and feel v11 --- htdocs/core/class/html.formother.class.php | 36 ++++++++++++++++------ htdocs/imports/import.php | 4 +-- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index ee8ca51ac90..a73621faa32 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -75,7 +75,7 @@ class FormOther $sql = "SELECT rowid, label, fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."export_model"; - $sql .= " WHERE type = '".$type."'"; + $sql .= " WHERE type = '".$this->db->escape($type)."'"; if (!empty($fk_user)) $sql .= " AND fk_user IN (0, ".$fk_user.")"; // An export model $sql .= " ORDER BY rowid"; $result = $this->db->query($sql); @@ -94,10 +94,13 @@ class FormOther $obj = $this->db->fetch_object($result); $label = $obj->label; - if (! empty($conf->global->EXPORTS_SHARE_MODELS) && empty($fk_user) && is_object($user) && $user->id != $obj->fk_user) { + if ($obj->fk_user == 0) { + $label .= ' ('.$langs->trans("Everybody").')'; + } + elseif (! empty($conf->global->EXPORTS_SHARE_MODELS) && empty($fk_user) && is_object($user) && $user->id != $obj->fk_user) { $tmpuser = new User($this->db); $tmpuser->fetch($obj->fk_user); - $label .= ' ('.$tmpuser->getFullName($langs).')'; + $label .= ' ('.$tmpuser->getFullName($langs).')'; } if ($selected == $obj->rowid) @@ -129,14 +132,18 @@ class FormOther * @param string $htmlname Nom de la zone select * @param string $type Type des modeles recherches * @param int $useempty Affiche valeur vide dans liste + * @param int $fk_user User that has created the template (this is set to null to get all export model when EXPORTS_SHARE_MODELS is on) * @return void */ - public function select_import_model($selected = '', $htmlname = 'importmodelid', $type = '', $useempty = 0) + public function select_import_model($selected = '', $htmlname = 'importmodelid', $type = '', $useempty = 0, $fk_user = null) { // phpcs:enable - $sql = "SELECT rowid, label"; + global $conf, $langs, $user; + + $sql = "SELECT rowid, label, fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."import_model"; - $sql .= " WHERE type = '".$type."'"; + $sql .= " WHERE type = '".$this->db->escape($type)."'"; + if (!empty($fk_user)) $sql .= " AND fk_user IN (0, ".$fk_user.")"; // An export model $sql .= " ORDER BY rowid"; $result = $this->db->query($sql); if ($result) @@ -152,15 +159,26 @@ class FormOther while ($i < $num) { $obj = $this->db->fetch_object($result); + + $label = $obj->label; + if ($obj->fk_user == 0) { + $label .= ' ('.$langs->trans("Everybody").')'; + } + elseif (! empty($conf->global->EXPORTS_SHARE_MODELS) && empty($fk_user) && is_object($user) && $user->id != $obj->fk_user) { + $tmpuser = new User($this->db); + $tmpuser->fetch($obj->fk_user); + $label .= ' ('.$tmpuser->getFullName($langs).')'; + } + if ($selected == $obj->rowid) { - print ''; $i++; } diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 606eddeeb20..6f4a1092194 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -862,8 +862,8 @@ if ($step == 4 && $datatoimport) print ''; print ''; - print '
'; - print $langs->trans("SelectImportFields", img_picto('', 'grip_title', '', false, 0, 0, '', '', 0)).' '; + print '
'; + print ''.$langs->trans("SelectImportFields", img_picto('', 'grip_title', '', false, 0, 0, '', '', 0)).' '; $htmlother->select_import_model($importmodelid, 'importmodelid', $datatoimport, 1); print ''; print '
';