From 845cd98ef392dc259ccd89c58343d35f2bb2a8f9 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Sat, 18 Feb 2012 12:54:23 +0100
Subject: [PATCH] Qual: Clean old functions deprecated into 3.0 version Clean
 no more used date function to prepare removing of adodb.

---
 ChangeLog                                    |  1 +
 htdocs/admin/const.php                       |  8 +--
 htdocs/core/lib/functions.lib.php            | 37 +------------
 htdocs/includes/adodbtime/adodb-time.inc.php | 58 ++++----------------
 4 files changed, 20 insertions(+), 84 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e3948a13427..f9160cc63ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -77,6 +77,7 @@ For developers:
 - Qual: Fix a lot of checkstyle warnings.
 - Qual: task #216 : Move /lib into /core/lib directory
 - Qual: task #217 : Move core files into core directory (login, menus, triggers, boxes, modules)
+WARNING: To reduce technic debt, all functions dolibarr_xxx were renamed int dol_xxx.
 
 
 ***** ChangeLog for 3.1.1 compared to 3.1.0 *****
diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php
index 59237e73711..3abb32d20c3 100644
--- a/htdocs/admin/const.php
+++ b/htdocs/admin/const.php
@@ -58,7 +58,7 @@ if ($action == 'add')
 	{
 		if (dolibarr_set_const($db, $_POST["constname"],$_POST["constvalue"],$typeconst[$_POST["consttype"]],1,isset($_POST["constnote"])?$_POST["constnote"]:'',$_POST["entity"]) < 0)
 		{
-			dolibarr_print_error($db);
+			dol_print_error($db);
 		}
 	}
 }
@@ -71,7 +71,7 @@ if (($_POST["const"] && isset($_POST["update"]) && $_POST["update"] == $langs->t
 		{
 			if (dolibarr_set_const($db, $const["name"],$const["value"],$const["type"],1,$const["note"],$const["entity"]) < 0)
 			{
-				dolibarr_print_error($db);
+				dol_print_error($db);
 			}
 		}
 	}
@@ -86,7 +86,7 @@ if ($_POST["const"] && $_POST["delete"] && $_POST["delete"] == $langs->trans("De
 		{
 			if (dolibarr_del_const($db, $const["rowid"], -1) < 0)
 			{
-				dolibarr_print_error($db);
+				dol_print_error($db);
 			}
 		}
 	}
@@ -97,7 +97,7 @@ if ($action == 'delete')
 {
 	if (dolibarr_del_const($db, $_GET["rowid"], $_GET["entity"]) < 0)
 	{
-		dolibarr_print_error($db);
+		dol_print_error($db);
 	}
 }
 
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index b71fe251488..a3f1105946c 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -745,14 +745,6 @@ function dol_get_fiche_end($notab=0)
     else return '';
 }
 
-
-/* For backward compatibility */
-function dolibarr_print_date($time,$format='',$to_gmt=false,$outputlangs='',$encodetooutput=false)
-{
-    return dol_print_date($time,$format,$to_gmt,$outputlangs,$encodetooutput);
-}
-
-
 /**
  *      Return a formated address (part address/zip/town/state) according to country rules
  *
@@ -990,12 +982,6 @@ function dol_getdate($timestamp,$fast=false)
     return $arrayinfo;
 }
 
-/* For backward compatibility */
-function dolibarr_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
-{
-    return dol_mktime($hour,$minute,$second,$month,$day,$year,$gm,$check);
-}
-
 /**
  *	Return a timestamp date built from detailed informations (by default a local PHP server timestamp)
  * 	Replace function mktime not available under Windows if year < 1970
@@ -1203,12 +1189,6 @@ function dol_print_email($email,$cid=0,$socid=0,$addlink=0,$max=64,$showinvalid=
     return $newemail;
 }
 
-/* For backward compatibility */
-function dolibarr_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$separ="&nbsp;")
-{
-    return dol_print_phone($phone,$country,$cid,$socid,$addlink,$separ);
-}
-
 /**
  * 	Format phone numbers according to country
  *
@@ -1476,15 +1456,9 @@ function dol_substr($string,$start,$length,$stringencoding='')
 }
 
 
-/* For backward compatibility */
-function dolibarr_trunc($string,$size=40,$trunc='right',$stringencoding='')
-{
-    return dol_trunc($string,$size,$trunc,$stringencoding);
-}
-
-
 /**
- *  Show a javascript graph
+ *  Show a javascript graph.
+ *  Do not use this function anymore. Use DolGraph class instead.
  *
  *  @param		string	$htmlid			Html id name
  *  @param		int		$width			Width in pixel
@@ -1495,6 +1469,7 @@ function dolibarr_trunc($string,$size=40,$trunc='right',$stringencoding='')
  *  @param		int		$showpercent	Show percent (with type='pie' only)
  *  @param		string	$url			Param to add an url to click values
  *  @return		void
+ *  @deprecated
  */
 function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie',$showpercent=0,$url='')
 {
@@ -2151,12 +2126,6 @@ function info_admin($text,$infoonimgalt=0)
 }
 
 
-/* For backward compatibility */
-function dolibarr_print_error($db='',$error='')
-{
-    return dol_print_error($db, $error);
-}
-
 /**
  *	Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remontee des bugs.
  *	On doit appeler cette fonction quand une erreur technique bloquante est rencontree.
diff --git a/htdocs/includes/adodbtime/adodb-time.inc.php b/htdocs/includes/adodbtime/adodb-time.inc.php
index 7e086300352..76b72300414 100644
--- a/htdocs/includes/adodbtime/adodb-time.inc.php
+++ b/htdocs/includes/adodbtime/adodb-time.inc.php
@@ -1,8 +1,12 @@
 <?php
 /**
-ADOdb Date Library, part of the ADOdb abstraction library
-Download: http://php.weblogs.com/adodb_date_time_library
+ * Copyright (C) 2003-2005 	John Lim
+ * Copyright (C)            Jackbbs
+ *
+ * This file is released under BSD-style license
+ */
 
+/* =============================================================================
 PHP native date functions use integer timestamps for computations.
 Because of this, dates are restricted to the years 1901-2038 on Unix
 and 1970-2038 on Windows due to integer overflow for dates beyond
@@ -55,14 +59,6 @@ adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582)
 
 =============================================================================
 
-COPYRIGHT
-
-(c) 2003-2005 John Lim and released under BSD-style license except for code by
-jackbbs, which includes adodb_mktime, adodb_get_gmt_diff, adodb_is_leap_year
-and originally found at http://www.php.net/manual/en/function.mktime.php
-
-=============================================================================
-
 BUG REPORTS
 
 These should be posted to the ADOdb forums at
@@ -133,34 +129,12 @@ Unsupported:
 </pre>
 
 
-** FUNCTION adodb_date2($fmt, $isoDateString = false)
-Same as adodb_date, but 2nd parameter accepts iso date, eg.
-
-  adodb_date2('d-M-Y H:i','2003-12-25 13:01:34');
-
-
-** FUNCTION adodb_gmdate($fmt, $timestamp = false)
-
-Convert a timestamp to a formatted GMT date. If $timestamp is not defined, the
-current timestamp is used. Unlike the function date(), it supports dates
-outside the 1901 to 2038 range.
-
-
 ** FUNCTION adodb_mktime($hr, $min, $sec[, $month, $day, $year])
 
 Converts a local date to a unix timestamp.  Unlike the function mktime(), it supports
 dates outside the 1901 to 2038 range. All parameters are optional.
 
 
-** FUNCTION adodb_gmmktime($hr, $min, $sec [, $month, $day, $year])
-
-Converts a gmt date to a unix timestamp.  Unlike the function gmmktime(), it supports
-dates outside the 1901 to 2038 range. Differs from gmmktime() in that all parameters
-are currently compulsory.
-
-** FUNCTION adodb_gmstrftime($fmt, $timestamp = false)
-Convert a timestamp to a formatted GMT date.
-
 ** FUNCTION adodb_strftime($fmt, $timestamp = false)
 
 Convert a timestamp to a formatted local date. Internally converts $fmt into
@@ -381,7 +355,7 @@ if (!defined('ADODB_ALLOW_NEGATIVE_TS')) define('ADODB_NO_NEGATIVE_TS',1);
 	Returns day of week, 0 = Sunday,... 6=Saturday.
 	Algorithm from PEAR::Date_Calc
 */
-function adodb_dow($year, $month, $day)
+function _adodb_dow($year, $month, $day)
 {
 /*
 Pope Gregory removed 10 days - October 5 to October 14 - from the year 1582 and
@@ -434,14 +408,6 @@ function _adodb_is_leap_year($year)
 }
 
 
-/**
- checks for leap year, returns true if it is. Has 2-digit year check
-*/
-function adodb_is_leap_year($year)
-{
-	return  _adodb_is_leap_year(adodb_year_digit_check($year));
-}
-
 /**
 	Fix 2-digit years. Works for any century.
  	Assumes that if 2-digit is more than 30 years in future, then previous century.
@@ -665,7 +631,7 @@ function _adodb_getdate($origd=false,$fast=false,$is_gmt=false)
 	}
 
 
-	$dow = adodb_dow($year,$month,$day);
+	$dow = _adodb_dow($year,$month,$day);
 
 	return array(
 		'seconds' => $secs,
@@ -727,7 +693,7 @@ static $daylight;
 
 			// 4.3.11 uses '04 Jun 2004'
 			// 4.3.8 uses  ' 4 Jun 2004'
-			$dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))).', '
+			$dates .= gmdate('D',$_day_power*(3+_adodb_dow($year,$month,$day))).', '
 				. ($day<10?'0'.$day:$day) . ' '.date('M',mktime(0,0,0,$month,2,1971)).' '.$year.' ';
 
 			if ($hour < 10) $dates .= '0'.$hour; else $dates .= $hour;
@@ -750,9 +716,9 @@ static $daylight;
 		// DAY
 		case 't': $dates .= $arr['ndays']; break;
 		case 'z': $dates .= $arr['yday']; break;
-		case 'w': $dates .= adodb_dow($year,$month,$day); break;
-		case 'l': $dates .= gmdate('l',$_day_power*(3+adodb_dow($year,$month,$day))); break;
-		case 'D': $dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))); break;
+		case 'w': $dates .= _adodb_dow($year,$month,$day); break;
+		case 'l': $dates .= gmdate('l',$_day_power*(3+_adodb_dow($year,$month,$day))); break;
+		case 'D': $dates .= gmdate('D',$_day_power*(3+_adodb_dow($year,$month,$day))); break;
 		case 'j': $dates .= $day; break;
 		case 'd': if ($day<10) $dates .= '0'.$day; else $dates .= $day; break;
 		case 'S':
-- 
GitLab