remove legacy includes dir
[openemr.git] / library / freeb / DataObjectBase.class.php
blobb47384557b5b9c17802261ad10c6a4d2a6d514f9
1 <?php
2 require (dirname(__FILE__) . "/../sql.inc");
4 class DataObjectBase {
6 var $xmlrpcerruser;
7 var $_func_map;
9 function DataObjectBase($xuser) {
10 $this->xmlrpcerruser = $xuser;
11 $this->_func_map=array();
14 function _handleError($err) {
15 if ($err) {
16 return new xmlrpcresp(0, $this->xmlrpcerruser, $err);
20 function _addFunc($func,$mapping) {
21 if (isset($this->_func_map[$func])) {
22 $trace = debug_backtrace();
23 trigger_error("Function <b>$func</b> already exists in function map in <b>" . $trace[0]['file'] . "</b> on line <b>" . $trace[0]['line'] . "</b>", E_USER_WARNING);
25 elseif (is_callable(array($this,$func))) {
26 $this->_func_map[$func] = $mapping;
27 return 0;
29 else {
30 $trace = debug_backtrace();
31 trigger_error("Cannot add a function <b>$func</b> to function map which is not callable in <b>" . $trace[0]['file'] . "</b> on line <b>" . $trace[0]['line'] . "</b>", E_USER_ERROR);
36 function _isodate ($date) {
38 $format_iso = 'Ymd\TH:i:sO';
39 $format_iso_utc = 'Ymd\TH:i:s';
41 $dt = explode("-",$date);
43 $dt_stamp = $this->_ctime(0,0,0,$dt[1],$dt[2],$dt[0]);
45 return gmdate($format_iso_utc, $dt_stamp);
48 function _ctime() {
50 $objArgs = func_get_args();
51 $nCount = count($objArgs);
52 if ($nCount < 7)
54 $objDate = getdate();
55 if ($nCount < 1)
56 $objArgs[] = $objDate["hours"];
57 if ($nCount < 2)
58 $objArgs[] = $objDate["minutes"];
59 if ($nCount < 3)
60 $objArgs[] = $objDate["seconds"];
61 if ($nCount < 4)
62 $objArgs[] = $objDate["mon"];
63 if ($nCount < 5)
64 $objArgs[] = $objDate["mday"];
65 if ($nCount < 6)
66 $objArgs[] = $objDate["year"];
67 if ($nCount < 7)
68 $objArgs[] = -1;
70 $nYear = $objArgs[5];
71 $nOffset = 0;
72 if ($nYear < 1970)
74 if ($nYear < 1902)
75 return 0;
76 else if ($nYear < 1952)
78 $nOffset = -2650838400;
79 $objArgs[5] += 84;
80 // Apparently dates before 1942 were never DST
81 if ($nYear < 1942)
82 $objArgs[6] = 0;
84 else
86 $nOffset = -883612800;
87 $objArgs[5] += 28;
91 return call_user_func_array("mktime", $objArgs) + $nOffset;