diff --git a/dev/translation/sanity_check_en_langfiles.php b/dev/translation/sanity_check_en_langfiles.php index 17dab085259..b1ccca39dee 100644 --- a/dev/translation/sanity_check_en_langfiles.php +++ b/dev/translation/sanity_check_en_langfiles.php @@ -1,5 +1,5 @@ +/* Copyright (c) 2015 Tommaso Basilici * * 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 @@ -15,8 +15,129 @@ * along with this program. If not, see . */ +echo ""; +echo ""; + +echo ""; + +echo ""; +echo "

If you call this file with the argument \"?unused=true\" it searches for the translation strings that exist in en_US but are never used

"; +echo "

IMPORTANT: that can take quite a lot of time (up to 10 minutes), you need to tune the max_execution_time on your php.ini accordingly

"; +echo "

Happy translating :)

"; + +// directory containing the php and lang files +$htdocs = "../../htdocs/"; // directory containing the english lang files -$workdir = "../../htdocs/langs/en_US/"; +$workdir = $htdocs."langs/en_US/"; $files = scandir($workdir); $exludefiles = array('.','..','README'); @@ -36,6 +157,7 @@ foreach ($files AS $file) { $row_array = explode('=',$row); $langstrings_3d[$path_file['basename']][$line+1]=$row_array[0]; $langstrings_full[]=$row_array[0]; + $langstrings_dist[$row_array[0]]=$row_array[0]; } } } @@ -53,8 +175,48 @@ foreach ($langstrings_3d AS $filename => $file) { } } -echo "

Duplicate strings in lang files in $workdir

"; +echo "

Duplicate strings in lang files in $workdir - ".count($dups)." found

"; echo "
";
-print_r($dups);
 
+echo " ";
+echo "";
+echo "";
+$count = 0;
+foreach ($dups as $string => $pages) {
+	$count++;
+	echo "";
+	echo "";
+	echo "";
+	echo "";
+}
+echo "";
+echo "
#StringFile and lines
$count$string"; + foreach ($pages AS $page => $lines ) { + echo "$page "; + foreach ($lines as $line => $nothing) { + echo "($line) "; + } + echo "
"; + } + echo "
"; + + +if ($_REQUEST['unused'] == 'true') { + + foreach ($langstrings_dist AS $value){ + $search = '\'trans("'.$value.'")\''; + $string = 'grep -R -m 1 -F --include=*.php '.$search.' '.$htdocs.'*'; + exec($string,$output); + if (empty($output)) { + $unused[$value] = true; + echo $value.'
'; + } + } + + echo "

Strings in en_US that are never used

"; + echo "
";
+	print_r($unused);
+}
+echo "";
+echo "";
 ?>
\ No newline at end of file
diff --git a/htdocs/comm/askpricesupplier/card.php b/htdocs/comm/askpricesupplier/card.php
index 3e6abe98b2d..b87a579b0e8 100644
--- a/htdocs/comm/askpricesupplier/card.php
+++ b/htdocs/comm/askpricesupplier/card.php
@@ -1730,7 +1730,7 @@ if ($action == 'create')
 	/*
 	 * Action presend
  	 */
-	if (!empty(GETPOST('modelselected'))) {
+	if (GETPOST('modelselected')) {
 		$action = 'presend';
 	}
 	if ($action == 'presend')
diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index e6876637dcf..c5cd570c241 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -2308,7 +2308,7 @@ if ($action == 'create')
 	 * Action presend
  	 */
 	//Select mail models is same action as presend
-	if (!empty(GETPOST('modelselected'))) {
+	if (GETPOST('modelselected')) {
 		$action = 'presend';
 	}
 	if ($action == 'presend')
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 01df11a61ab..3cf9456fbe7 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -3734,7 +3734,7 @@ if ($action == 'create')
 	print '
'; //Select mail models is same action as presend - if (!empty(GETPOST('modelselected'))) { + if (GETPOST('modelselected')) { $action = 'presend'; } if ($action != 'prerelance' && $action != 'presend') diff --git a/htdocs/compta/facture/mergepdftool.php b/htdocs/compta/facture/mergepdftool.php index efe16af1fb9..3f3315fda04 100644 --- a/htdocs/compta/facture/mergepdftool.php +++ b/htdocs/compta/facture/mergepdftool.php @@ -530,7 +530,7 @@ if ($resql) print '
'; - if (!empty(GETPOST('modelselected'))) { + if (GETPOST('modelselected')) { $action = 'presend'; } if (! empty($mode) && $action == 'presend') diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index c937d5a3621..879b66ebb39 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1514,7 +1514,7 @@ else if ($id || $ref) * Action presend */ //Select mail models is same action as presend - if (!empty(GETPOST('modelselected'))) { + if (GETPOST('modelselected')) { $action = 'presend'; } if ($action == 'presend') diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index d1fb92a33ab..b0f0e2695ec 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1732,7 +1732,7 @@ else if ($id > 0 || ! empty($ref)) /* * Action presend */ - if (!empty(GETPOST('modelselected'))) { + if (GETPOST('modelselected')) { $action = 'presend'; } if ($action == 'presend') diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 07ae3919f57..13b2d8d1669 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -8,6 +8,7 @@ * Copyright (C) 2005 Simon Tosser * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2015 Bahfir Abbes * * 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 @@ -66,15 +67,12 @@ $conffiletoshow = "htdocs/conf/conf.php"; //$conffile = "/etc/dolibarr/conf.php"; //$conffiletoshow = "/etc/dolibarr/conf.php"; -// Replace conf filename with "conf" parameter on url by GET -if (GETPOST('conf')) -{ - setcookie('dolconf', GETPOST('conf'),0,'/'); - $conffile = 'conf/' . dol_sanitizeFileName(GETPOST('conf')) . '.php'; -} -else -{ - $conffile = 'conf/' . dol_sanitizeFileName((!empty($_COOKIE['dolconf']) ? $_COOKIE['dolconf'] : 'conf') . '.php'); +//replace conf filename with "conf" parameter on url by GET +if (!empty($_GET['conf'])) { + setcookie('dolconf', $_GET['conf'],0,'/'); + $conffile = 'conf/' . $_GET['conf'] . '.php'; +} else { + $conffile = 'conf/' . (!empty($_COOKIE['dolconf']) ? $_COOKIE['dolconf'] : 'conf') . '.php'; } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index fd6c076ecf7..fe6751c28f2 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2246,7 +2246,7 @@ elseif (! empty($object->id)) /* * Action presend */ - if (!empty(GETPOST('modelselected'))) { + if (GETPOST('modelselected')) { $action = 'presend'; } if ($action == 'presend') diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 45f300c8a89..4c401c2c540 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2499,7 +2499,7 @@ else /* * Show mail form */ - if (!empty(GETPOST('modelselected'))) { + if (GETPOST('modelselected')) { $action = 'presend'; } if ($action == 'presend') diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index e697b370504..947d80af51c 100644 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -536,4 +536,4 @@ CREATE TABLE IF NOT EXISTS llx_propal_merge_pdf_product ( -- Feature request: A page to merge two thirdparties into one #2613 ALTER TABLE llx_categorie_societe CHANGE COLUMN fk_societe fk_soc INTEGER NOT NULL; ALTER TABLE llx_societe CHANGE COLUMN fk_societe fk_soc INTEGER NOT NULL; - +ALTER TABLE llx_user CHANGE COLUMN fk_societe fk_soc INTEGER NOT NULL; diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index 20b876b6f37..a4c04f4e864 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -52,7 +52,7 @@ create table llx_user admin smallint DEFAULT 0, module_comm smallint DEFAULT 1, module_compta smallint DEFAULT 1, - fk_soc integer, + fk_soc integer, fk_socpeople integer, fk_member integer, fk_user integer, -- Hierarchic parent diff --git a/htdocs/install/pgsql/functions/functions.sql b/htdocs/install/pgsql/functions/functions.sql index 3bf5255a5fc..37d5630fbea 100644 --- a/htdocs/install/pgsql/functions/functions.sql +++ b/htdocs/install/pgsql/functions/functions.sql @@ -119,7 +119,7 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_user FOR EACH ROW EX CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_user_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_usergroup FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_cronjob FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_printer_ipp FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_printing FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE OR REPLACE FUNCTION update_modified_column_date_m() RETURNS TRIGGER AS $$ BEGIN NEW.date_m = now(); RETURN NEW; END; $$ LANGUAGE plpgsql; CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_ecm_directories FOR EACH ROW EXECUTE PROCEDURE update_modified_column_date_m();