--- include/class.attachment.php	2009-01-12 23:15:12.042086912 +0200
+++ /usr/share/eventum/include/class.attachment.php	2009-02-05 02:04:13.534063686 +0200
@@ -28,15 +28,6 @@
 //
 
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.auth.php");
-require_once(APP_INC_PATH . "class.user.php");
-require_once(APP_INC_PATH . "class.history.php");
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.date.php");
-require_once(APP_INC_PATH . "class.status.php");
-require_once(APP_INC_PATH . "class.issue.php");
-require_once(APP_INC_PATH . "class.workflow.php");
 
 /**
  * Class designed to handle all business logic related to attachments being
@@ -176,7 +167,7 @@
             $stmt .= " AND
                     iat_usr_id=$usr_id";
         }
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -193,7 +184,7 @@
                          WHERE
                             iaf_id=$iaf_id AND
                             iaf_iat_id=iat_id";
-                $attachment_id = $GLOBALS["db_api"]->dbh->getOne($stmt);
+                $attachment_id = Db_Helper::getInstance()->getOne($stmt);
 
                 $res = Attachment::getFileList($attachment_id);
                 if (@count($res) > 1) {
@@ -225,7 +216,7 @@
                  WHERE
                     iat_id=iaf_iat_id AND
                     iaf_id=$file_id";
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -258,7 +249,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_attachment
                  WHERE
                     iat_iss_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -293,7 +284,7 @@
             $stmt .= " AND
                     iat_usr_id=$usr_id";
         }
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -308,7 +299,7 @@
                          WHERE
                             iat_id=$iat_id AND
                             iat_iss_id=$issue_id";
-                $res = $GLOBALS["db_api"]->dbh->query($stmt);
+                $res = Db_Helper::getInstance()->query($stmt);
                 if (PEAR::isError($res)) {
                     Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                     return -1;
@@ -341,7 +332,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_attachment_file
                  WHERE
                     iaf_id=" . $iaf_id;
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -367,7 +358,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_attachment_file
                  WHERE
                     iaf_iat_id=$attachment_id";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -414,7 +405,7 @@
         $stmt .= "
                  ORDER BY
                     iat_created_date ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -422,7 +413,7 @@
             for ($i = 0; $i < count($res); $i++) {
                 $res[$i]["iat_description"] = Link_Filter::processText(Issue::getProjectID($issue_id), nl2br(htmlspecialchars($res[$i]["iat_description"])));
                 $res[$i]["files"] = Attachment::getFileList($res[$i]["iat_id"]);
-                $res[$i]["iat_created_date"] = Date_API::getFormattedDate($res[$i]["iat_created_date"]);
+                $res[$i]["iat_created_date"] = Date_Helper::getFormattedDate($res[$i]["iat_created_date"]);
 
                 // if there is an unknown user, user that instead of the user_full_name
                 if (!empty($res[$i]["iat_unknown_user"])) {
@@ -530,7 +521,7 @@
                     '" . Misc::escapeString($filetype) . "',
                     '" . Misc::escapeString($blob) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -577,7 +568,7 @@
         $stmt .=") VALUES (
                     $issue_id,
                     $usr_id,
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     '" . Misc::escapeString($description) . "',
                     '" . Misc::escapeString($attachment_status) . "'";
         if ($unknown_user != false) {
@@ -587,7 +578,7 @@
             $stmt .= ", " . Misc::escapeInteger($associated_note_id);
         }
         $stmt .= " )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
--- include/class.authorized_replier.php	2009-01-12 23:15:12.032084245 +0200
+++ /usr/share/eventum/include/class.authorized_replier.php	2009-02-05 02:15:18.594196189 +0200
@@ -29,7 +29,6 @@
 // @(#) $Id: class.authorized_replier.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.user.php");
 
 /**
  * Class designed to handle adding, removing and viewing authorized repliers for an issue.
@@ -67,7 +66,7 @@
                  WHERE
                     iur_iss_id=" . Misc::escapeInteger($issue_id) . " AND
                     iur_usr_id=usr_id";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array(
@@ -113,7 +112,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user_replier
                  WHERE
                     iur_id IN(" . join(",", $iur_ids) . ")";
-        $issue_id = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $issue_id = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($issue_id)) {
             Error_Handler::logError(array($issue_id->getMessage(), $issue_id->getDebugInfo()), __FILE__, __LINE__);
         }
@@ -124,7 +123,7 @@
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user_replier
                      WHERE
                         iur_id IN(" . join(",", $iur_ids) . ")";
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return "";
@@ -149,7 +148,7 @@
         if (Authorized_Replier::isAuthorizedReplier($issue_id, $email)) {
             return -1;
         } else {
-            $email = strtolower(Mail_API::getEmailAddress($email));
+            $email = strtolower(Mail_Helper::getEmailAddress($email));
 
             $workflow = Workflow::handleAuthorizedReplierAdded(Issue::getProjectID($issue_id), $issue_id, $email);
             if ($workflow === false) {
@@ -174,7 +173,7 @@
                         " . APP_SYSTEM_USER_ID . ",
                         '" . Misc::escapeString($email) . "'
                      )";
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return -1;
@@ -214,7 +213,7 @@
                     " . Misc::escapeInteger($issue_id) . ",
                     " . Misc::escapeInteger($usr_id) . "
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -241,7 +240,7 @@
     {
         // XXX: Add caching
 
-        $email = strtolower(Mail_API::getEmailAddress($email));
+        $email = strtolower(Mail_Helper::getEmailAddress($email));
         // first check if this is an actual user or just an email address
         $usr_id = User::getUserIDByEmail($email, true);
         if (!empty($usr_id)) {
@@ -261,7 +260,7 @@
                  WHERE
                     iur_iss_id=" . Misc::escapeInteger($issue_id) . " AND
                     iur_email='" . Misc::escapeString($email) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -292,7 +291,7 @@
                  WHERE
                     iur_iss_id = " . Misc::escapeInteger($issue_id) . " AND
                     iur_usr_id = " . Misc::escapeInteger($usr_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -323,7 +322,7 @@
                  WHERE
                     iur_usr_id = usr_id AND
                     iur_id = " . Misc::escapeInteger($iur_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -353,7 +352,7 @@
                  WHERE
                     iur_iss_id = " . Misc::escapeInteger($issue_id) . " AND
                     (iur_email = '" . Misc::escapeString($email) . "' OR usr_email = '" . Misc::escapeString($email) . "')";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return 0;
--- include/class.auth.php	2009-01-12 23:15:12.049164418 +0200
+++ /usr/share/eventum/include/class.auth.php	2009-02-05 02:10:43.107351422 +0200
@@ -29,12 +29,8 @@
 // @(#) $Id: class.auth.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.project.php");
-require_once(APP_INC_PATH . "class.user.php");
-require_once(APP_INC_PATH . "class.customer.php");
-require_once(APP_INC_PATH . "class.date.php");
-require_once(APP_CONFIG_PATH . "private_key.php");
+global $private_key;
+require_once APP_CONFIG_PATH . "/private_key.php";
 
 /**
  * Class to handle authentication issues.
@@ -56,7 +52,7 @@
      */
     function saveLoginAttempt($email, $type, $extra = false)
     {
-        $msg = Date_API::getCurrentDateGMT() . " - Login attempt by '$email' was ";
+        $msg = Date_Helper::getCurrentDateGMT() . " - Login attempt by '$email' was ";
         if ($type == 'success') {
             $msg .= "successful.\n";
         } else {
--- include/class.category.php	2009-01-12 23:15:12.055441962 +0200
+++ /usr/share/eventum/include/class.category.php	2009-02-05 02:03:28.770738529 +0200
@@ -29,9 +29,6 @@
 // @(#) $Id: class.category.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.validation.php");
 
 /**
  * Class to handle project category related issues.
@@ -57,7 +54,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_category
                  WHERE
                     prc_id=" . Misc::escapeInteger($prc_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -82,7 +79,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_category
                  WHERE
                     prc_prj_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -106,7 +103,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_category
                  WHERE
                     prc_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -136,7 +133,7 @@
                  WHERE
                     prc_prj_id=" . Misc::escapeInteger($_POST["prj_id"]) . " AND
                     prc_id=" . Misc::escapeInteger($_POST["id"]);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -166,7 +163,7 @@
                     " . Misc::escapeInteger($_POST["prj_id"]) . ",
                     '" . Misc::escapeString($_POST["title"]) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -195,7 +192,7 @@
                     prc_prj_id=" . Misc::escapeInteger($prj_id) . "
                  ORDER BY
                     prc_title ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -230,7 +227,7 @@
                     prc_prj_id=" . Misc::escapeInteger($prj_id) . "
                  ORDER BY
                     prc_title ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -256,7 +253,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_category
                  WHERE
                     prc_id=" . Misc::escapeInteger($prc_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
--- include/class.customer.php	2009-01-12 23:15:12.035414975 +0200
+++ /usr/share/eventum/include/class.customer.php	2009-02-05 02:04:13.541563871 +0200
@@ -29,7 +29,6 @@
 // @(#) $Id: class.customer.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . 'class.misc.php');
 
 // Constants used by customer class.
 define("CUSTOMER_EXCLUDE_EXPIRED", 1);
@@ -86,7 +85,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project
                  ORDER BY
                     prj_id";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -117,7 +116,6 @@
                 $file_name_chunks = explode(".", $backend_class);
                 $class_name = $file_name_chunks[1] . "_Customer_Backend";
 
-                require_once(APP_INC_PATH . "customer/$backend_class");
 
                 $setup_backends[$prj_id] = new $class_name;
                 $setup_backends[$prj_id]->connect();
@@ -1027,7 +1025,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user
                  WHERE
                     cam_usr_id=usr_id";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -1063,7 +1061,7 @@
                     " . Misc::escapeInteger($_POST['manager']) . ",
                     '" . Misc::escapeString($_POST['type']) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1088,7 +1086,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "customer_account_manager
                  WHERE
                     cam_id=" . Misc::escapeInteger($cam_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -1115,7 +1113,7 @@
                     cam_type='" . Misc::escapeString($_POST['type']) . "'
                  WHERE
                     cam_id=" . $_POST['id'];
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1139,7 +1137,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "customer_account_manager
                  WHERE
                     cam_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -1170,7 +1168,7 @@
                     cam_usr_id=usr_id AND
                     cam_prj_id=" . Misc::escapeInteger($prj_id) . " AND
                     cam_customer_id=" . Misc::escapeInteger($customer_id);
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -1286,7 +1284,7 @@
                     cno_note='" . Misc::escapeString($note) . "',
                     cno_prj_id=" . Misc::escapeInteger($prj_id) . ",
                     cno_customer_id=" . Misc::escapeInteger($customer_id) . ",
-                    cno_updated_date='" . Date_API::getCurrentDateGMT() . "'
+                    cno_updated_date='" . Date_Helper::getCurrentDateGMT() . "'
                  WHERE
                     cno_id=" . Misc::escapeInteger($cno_id);
         $res = $GLOBALS['db_api']->dbh->query($stmt);
@@ -1320,8 +1318,8 @@
                  ) VALUES (
                     " . Misc::escapeInteger($prj_id) . ",
                     " . Misc::escapeInteger($customer_id) . ",
-                    '" . Date_API::getCurrentDateGMT() . "',
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     '" . Misc::escapeString($note) . "'
                  )";
         $res = $GLOBALS['db_api']->dbh->query($stmt);
--- include/class.customer_stats_report.php	2009-01-12 23:15:12.052089091 +0200
+++ /usr/share/eventum/include/class.customer_stats_report.php	2009-02-05 02:03:28.787387782 +0200
@@ -29,9 +29,6 @@
 // @(#) $Id: class.customer_stats_report.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.time_tracking.php");
-require_once(APP_PEAR_PATH . "Math/Stats.php");
 
 /**
  * The Customer Stats report will be too complex to group with the rest of
@@ -329,7 +326,7 @@
                     " . $this->getWhereClause("iss_customer_id", "iss_created_date") . "
                  GROUP BY
                     iss_customer_id";
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -367,7 +364,7 @@
                     " . $this->getWhereClause("iss_customer_id", "sup_date") . "
                  GROUP BY
                     sup_iss_id";
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -402,7 +399,7 @@
                     " . $this->getWhereClause("iss_customer_id", "sup_date") . "
                  GROUP BY
                     sup_iss_id";
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -475,7 +472,7 @@
             $stmt .= "\n AND ttr_ttc_id = $ttc_id";
         }
         $stmt .= "\nAND " . $this->getWhereClause("iss_customer_id", "ttr_created_date");
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -516,7 +513,7 @@
                  WHERE
                     iss_closed_date IS NOT NULL AND
                     " . $this->getWhereClause("iss_customer_id", array("iss_created_date", "iss_closed_date"));
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -556,7 +553,7 @@
                  WHERE
                     iss_first_response_date IS NOT NULL AND
                     " . $this->getWhereClause("iss_customer_id", array("iss_created_date", "iss_closed_date"));
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
--- include/class.custom_field.php	2009-01-12 23:15:12.089164963 +0200
+++ /usr/share/eventum/include/class.custom_field.php	2009-02-05 02:03:28.777388676 +0200
@@ -29,12 +29,6 @@
 // @(#) $Id: class.custom_field.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.issue.php");
-require_once(APP_INC_PATH . "class.user.php");
-require_once(APP_INC_PATH . "class.auth.php");
-require_once(APP_INC_PATH . "class.history.php");
 
 /**
  * Class to handle the business logic related to the administration
@@ -68,7 +62,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field_option
                  WHERE
                     cfo_id IN (" . implode(",", $cfo_id) . ")";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -80,7 +74,7 @@
                      WHERE
                         icf_fld_id IN (" . implode(", ", $fld_id) . ") AND
                         icf_value IN (" . implode(", ", $cfo_id) . ")";
-            $GLOBALS["db_api"]->dbh->query($stmt);
+            Db_Helper::getInstance()->query($stmt);
             return true;
         }
     }
@@ -110,7 +104,7 @@
                         $fld_id,
                         '" . Misc::escapeString($option) . "'
                      )";
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return -1;
@@ -137,7 +131,7 @@
                     cfo_value='" . Misc::escapeString($cfo_value) . "'
                  WHERE
                     cfo_id=" . $cfo_id;
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -170,7 +164,7 @@
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field
                      WHERE
                         fld_id IN (" . implode(", ", Misc::escapeInteger(@array_keys($_POST['custom_fields']))) . ")";
-            $field_types = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+            $field_types = Db_Helper::getInstance()->getAssoc($stmt);
 
             // get the titles for all of the custom fields being submitted
             $stmt = "SELECT
@@ -180,7 +174,7 @@
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field
                      WHERE
                         fld_id IN (" . implode(", ", Misc::escapeInteger(@array_keys($_POST['custom_fields']))) . ")";
-            $field_titles = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+            $field_titles = Db_Helper::getInstance()->getAssoc($stmt);
 
             $updated_fields = array();
             foreach ($_POST["custom_fields"] as $fld_id => $value) {
@@ -194,7 +188,7 @@
                             " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field
                         WHERE
                             fld_id = $fld_id";
-                $min_role = $GLOBALS["db_api"]->dbh->getOne($sql);
+                $min_role = Db_Helper::getInstance()->getOne($sql);
                 if ($min_role > Auth::getCurrentRole()) {
                     continue;
                 }
@@ -219,7 +213,7 @@
                              WHERE
                                 icf_iss_id=" . $issue_id . " AND
                                 icf_fld_id=$fld_id";
-                    $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+                    $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
                     if (PEAR::isError($res)) {
                         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                         return -1;
@@ -250,7 +244,7 @@
                                     $fld_id,
                                     $value
                                  )";
-                        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+                        $res = Db_Helper::getInstance()->query($stmt);
                         if (PEAR::isError($res)) {
                             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                             return -1;
@@ -263,7 +257,7 @@
                                     $fld_db_name=$value
                                  WHERE
                                     icf_id=$icf_id";
-                        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+                        $res = Db_Helper::getInstance()->query($stmt);
                         if (PEAR::isError($res)) {
                             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                             return -1;
@@ -358,7 +352,7 @@
                         " . Misc::escapeInteger($fld_id) . ",
                         $item
                      )";
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return false;
@@ -407,7 +401,7 @@
         $stmt .= "
                  ORDER BY
                     fld_rank ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -490,7 +484,7 @@
                      WHERE
                         cfo_fld_id=" .  Misc::escapeInteger($fld_id) . " AND
                         cfo_id=" .  Misc::escapeInteger($value);
-            $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+            $res = Db_Helper::getInstance()->getOne($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return "";
@@ -541,7 +535,7 @@
                      WHERE
                         cfo_fld_id=" .  Misc::escapeInteger($fld_id) . " AND
                         cfo_value='" .  Misc::escapeString($value) . "'";
-            $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+            $res = Db_Helper::getInstance()->getOne($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return "";
@@ -619,7 +613,7 @@
         $stmt .= "
                  ORDER BY
                     fld_rank ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -742,7 +736,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field
                  WHERE
                     fld_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -751,7 +745,7 @@
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_custom_field
                      WHERE
                         pcf_fld_id IN ($items)";
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return false;
@@ -760,7 +754,7 @@
                             " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_custom_field
                          WHERE
                             icf_fld_id IN ($items)";
-                $res = $GLOBALS["db_api"]->dbh->query($stmt);
+                $res = Db_Helper::getInstance()->query($stmt);
                 if (PEAR::isError($res)) {
                     Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                     return false;
@@ -769,7 +763,7 @@
                                 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field_option
                              WHERE
                                 cfo_fld_id IN ($items)";
-                    $res = $GLOBALS["db_api"]->dbh->query($stmt);
+                    $res = Db_Helper::getInstance()->query($stmt);
                     if (PEAR::isError($res)) {
                         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                         return false;
@@ -848,7 +842,7 @@
                     " . Misc::escapeInteger($_POST['rank']) . ",
                     '" . Misc::escapeString(@$_POST['custom_field_backend']) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -888,7 +882,7 @@
                     " . Misc::escapeInteger($prj_id) . ",
                     " . Misc::escapeInteger($fld_id) . "
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -913,7 +907,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field
                  ORDER BY
                     fld_rank ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -956,7 +950,7 @@
                     pcf_fld_id=" . Misc::escapeInteger($fld_id) . "
                  ORDER BY
                     prj_title ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -988,7 +982,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field
                  WHERE
                     fld_id=" . Misc::escapeInteger($fld_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -1050,7 +1044,7 @@
             $stmt .= "
                      ORDER BY
                         cfo_id ASC";
-            $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+            $res = Db_Helper::getInstance()->getAssoc($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return "";
@@ -1145,7 +1139,7 @@
                     fld_backend = '" . Misc::escapeString(@$_POST['custom_field_backend']) . "'
                  WHERE
                     fld_id=" . Misc::escapeInteger($_POST["id"]);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1158,7 +1152,7 @@
                             " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field_option
                          WHERE
                             cfo_fld_id=" . Misc::escapeInteger($_POST["id"]);
-                $current_options = $GLOBALS["db_api"]->dbh->getCol($stmt);
+                $current_options = Db_Helper::getInstance()->getCol($stmt);
             }
             if ($old_details["fld_type"] != $_POST["field_type"]) {
                 // gotta remove all custom field options if the field is being changed from a combo box to a text field
@@ -1210,7 +1204,7 @@
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_custom_field
                      WHERE
                         pcf_fld_id=" . Misc::escapeInteger($_POST["id"]);
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return -1;
@@ -1240,7 +1234,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_custom_field
                  WHERE
                     pcf_prj_id=" . Misc::escapeInteger($prj_id);
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -1290,7 +1284,7 @@
         if (count($issues) > 0) {
             $stmt .= " AND icf_iss_id IN(" . join(', ', Misc::escapeInteger($issues)) . ")";
         }
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -1320,7 +1314,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field_option
                  WHERE
                     cfo_fld_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -1346,7 +1340,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_custom_field
                  WHERE
                     icf_iss_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -1371,7 +1365,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_custom_field
                  WHERE
                     pcf_prj_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -1403,7 +1397,7 @@
                     fld_min_role <= " . Auth::getCurrentRole() . "
                 ORDER BY
                     fld_rank ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($sql);
+        $res = Db_Helper::getInstance()->getAssoc($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -1428,7 +1422,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field
                 WHERE
                     fld_title = '" . Misc::escapeString($title) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($sql);
+        $res = Db_Helper::getInstance()->getOne($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return 0;
@@ -1464,7 +1458,7 @@
                     fld_id=icf_fld_id AND
                     icf_iss_id=" .  Misc::escapeInteger($iss_id) . " AND
                     fld_id = " . Misc::escapeInteger($fld_id);
-        $res = $GLOBALS["db_api"]->dbh->getAll($sql, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($sql, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -1502,7 +1496,7 @@
                     max(fld_rank)
                 FROM
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field";
-        return $GLOBALS["db_api"]->dbh->getOne($sql);
+        return Db_Helper::getInstance()->getOne($sql);
     }
 
 
@@ -1565,7 +1559,7 @@
                     fld_rank = $rank
                 WHERE
                     fld_id = $fld_id";
-        $res = $GLOBALS["db_api"]->dbh->query($sql);
+        $res = Db_Helper::getInstance()->query($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1633,12 +1627,11 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field
                 WHERE
                     fld_id = " . Misc::escapeInteger($fld_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($sql);
+        $res = Db_Helper::getInstance()->getOne($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
         } elseif (!empty($res)) {
-            require_once(APP_INC_PATH . "custom_field/$res");
 
             $file_name_chunks = explode(".", $res);
             $class_name = $file_name_chunks[1] . "_Custom_Field_Backend";
@@ -1672,7 +1665,7 @@
                         icf_value_integer LIKE '%" . Misc::escapeInteger($search) . "%' OR
                         icf_value_date LIKE '%" . Misc::escapeString($search) . "%'
                     )";
-        $res = $GLOBALS["db_api"]->dbh->getCol($sql);
+        $res = Db_Helper::getInstance()->getCol($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -1779,7 +1772,7 @@
                 WHERE
                     $db_field_name IS NULL AND
                     icf_fld_id = " . Misc::escapeInteger($fld_id);
-        $res = $GLOBALS["db_api"]->dbh->query($sql);
+        $res = Db_Helper::getInstance()->query($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
--- include/class.display_column.php	2009-01-12 23:15:12.059166108 +0200
+++ /usr/share/eventum/include/class.display_column.php	2009-02-05 02:03:28.790732690 +0200
@@ -128,7 +128,7 @@
                     ctd_page = '$page'
                 ORDER BY
                     ctd_rank";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt, false, array(), DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAssoc($stmt, false, array(), DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -230,7 +230,10 @@
                 ),
                 "iss_expected_resolution_date"  =>  array(
                     "title" =>  ev_gettext("Expected Resolution Date")
-                )
+                ),
+                "isu_order" => array(
+                    "title" => ev_gettext("Order")
+                ),
             )
         );
         return $columns[$page];
@@ -257,7 +260,7 @@
                 WHERE
                     ctd_prj_id = $prj_id AND
                     ctd_page = '$page'";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -272,7 +275,7 @@
                         ctd_field = '$field_name',
                         ctd_min_role = " . $_REQUEST['min_role'][$field_name] . ",
                         ctd_rank = $rank";
-            $res = $GLOBALS["db_api"]->dbh->query($sql);
+            $res = Db_Helper::getInstance()->query($sql);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return -1;
@@ -307,7 +310,7 @@
                         ctd_field = '$field_name',
                         ctd_min_role = $min_role,
                         ctd_rank = $rank";
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return -1;
--- include/class.draft.php	2009-01-12 23:15:12.045423021 +0200
+++ /usr/share/eventum/include/class.draft.php	2009-02-05 02:04:13.544068030 +0200
@@ -27,7 +27,6 @@
 // +----------------------------------------------------------------------+
 //
 
-require_once(APP_INC_PATH . "class.email_account.php");
 
 class Draft
 {
@@ -90,7 +89,7 @@
             $stmt .= ", emd_unknown_user";
         }
         $stmt .= ") VALUES (
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     $usr_id,
                     $issue_id,
                     $parent_id,
@@ -100,7 +99,7 @@
             $stmt .= ", '" . Misc::escapeString($unknown_user) . "'";
         }
         $stmt .= ")";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -148,11 +147,11 @@
         $stmt = "UPDATE
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_draft
                  SET
-                    emd_updated_date='" . Date_API::getCurrentDateGMT() . "',
+                    emd_updated_date='" . Date_Helper::getCurrentDateGMT() . "',
                     emd_status = 'edited'
                  WHERE
                     emd_id=$emd_id";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -181,7 +180,7 @@
                     emd_status = 'sent'
                  WHERE
                     emd_id=$emd_id";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -206,7 +205,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_draft_recipient
                  WHERE
                     edr_emd_id=$emd_id";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -246,7 +245,7 @@
                     $is_cc,
                     '" . Misc::escapeString($email) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -272,12 +271,12 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_draft
                  WHERE
                     emd_id=$emd_id";
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
         } else {
-            $res["emd_updated_date"] = Date_API::getFormattedDate($res["emd_updated_date"]);
+            $res["emd_updated_date"] = Date_Helper::getFormattedDate($res["emd_updated_date"]);
             if (!empty($res['emd_unknown_user'])) {
                 $res['from'] = $res["emd_unknown_user"];
             } else {
@@ -316,13 +315,13 @@
         }
         $stmt .= "ORDER BY
                     emd_id";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
         } else {
             for ($i = 0; $i < count($res); $i++) {
-                $res[$i]["emd_updated_date"] = Date_API::getFormattedDate($res[$i]["emd_updated_date"]);
+                $res[$i]["emd_updated_date"] = Date_Helper::getFormattedDate($res[$i]["emd_updated_date"]);
                 if (!empty($res[$i]['emd_unknown_user'])) {
                     $res[$i]['from'] = $res[$i]["emd_unknown_user"];
                 } else {
@@ -356,7 +355,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_draft_recipient
                  WHERE
                     edr_emd_id=$emd_id";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array('', '');
@@ -400,7 +399,7 @@
                 ORDER BY
                     emd_id ASC
                 LIMIT " . ($sequence - 1) . ", 1";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -457,7 +456,7 @@
                  WHERE
                     emd_updated_date BETWEEN '$start' AND '$end' AND
                     emd_usr_id = $usr_id";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
--- include/class.email_account.php	2009-01-12 23:15:12.068965748 +0200
+++ /usr/share/eventum/include/class.email_account.php	2009-02-05 02:03:28.794055808 +0200
@@ -30,7 +30,6 @@
 //
 
 
-require_once(APP_INC_PATH . "class.error_handler.php");
 
 class Email_Account
 {
@@ -50,7 +49,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_account
                  WHERE
                     ema_id=$ema_id";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -79,7 +78,7 @@
                     ema_issue_auto_creation_options='" . @serialize($options) . "'
                  WHERE
                     ema_id=" . Misc::escapeInteger($ema_id);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -105,7 +104,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email
                  WHERE
                     sup_id=$sup_id";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -134,7 +133,7 @@
                     ema_username='" . Misc::escapeString($username) . "' AND
                     ema_hostname='" . Misc::escapeString($hostname) . "' AND
                     ema_folder='" . Misc::escapeString($mailbox) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return 0;
@@ -179,7 +178,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_account
                  WHERE
                     ema_id=$ema_id";
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -207,7 +206,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_account
                  WHERE
                     ema_prj_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -217,7 +216,7 @@
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_account
                      WHERE
                         ema_prj_id IN ($items)";
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return false;
@@ -241,7 +240,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_account
                  WHERE
                     ema_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -297,7 +296,7 @@
                     " . Misc::escapeInteger($_POST["leave_copy"]) . ",
                     " . Misc::escapeInteger($_POST["use_routing"]) . "
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -342,7 +341,7 @@
                     ema_use_routing=" . Misc::escapeInteger($_POST["use_routing"]) . "
                  WHERE
                     ema_id=" . $_POST["id"];
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -367,7 +366,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_account
                  ORDER BY
                     ema_hostname";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -410,7 +409,7 @@
                     ema_prj_id IN (" . join(',', $projects) . ")
                  ORDER BY
                     ema_title";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -441,7 +440,7 @@
                     ema_prj_id=" . Misc::escapeInteger($prj_id) . "
                  LIMIT
                     0, 1";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -469,7 +468,7 @@
                  WHERE
                     ema_prj_id=iss_prj_id AND
                     iss_id=$issue_id";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
--- include/class.email_response.php	2009-01-12 23:15:12.068965748 +0200
+++ /usr/share/eventum/include/class.email_response.php	2009-02-05 02:03:28.797391218 +0200
@@ -29,8 +29,6 @@
 // @(#) $Id: class.email_response.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.misc.php");
 
 /**
  * Class to handle the business logic related to the administration
@@ -62,7 +60,7 @@
                     " . Misc::escapeInteger($ere_id) . ",
                     " . Misc::escapeInteger($prj_id) . "
                  )";
-        $GLOBALS["db_api"]->dbh->query($stmt);
+        Db_Helper::getInstance()->query($stmt);
     }
 
 
@@ -86,7 +84,7 @@
                     '" . Misc::escapeString($_POST["title"]) . "',
                     '" . Misc::escapeString($_POST["response_body"]) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -114,7 +112,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_response
                  WHERE
                     ere_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -148,7 +146,7 @@
         if ($prj_id) {
             $stmt .= " AND per_prj_id=$prj_id";
         }
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -178,7 +176,7 @@
                     ere_response_body='" . Misc::escapeString($_POST["response_body"]) . "'
                  WHERE
                     ere_id=" . $_POST["id"];
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -210,7 +208,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_response
                  WHERE
                     ere_id=$ere_id";
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -242,7 +240,7 @@
                  WHERE
                     prj_id=per_prj_id AND
                     per_ere_id=$ere_id";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -268,7 +266,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_response
                  ORDER BY
                     ere_title ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -303,7 +301,7 @@
                     per_prj_id=" . Misc::escapeInteger($prj_id) . "
                  ORDER BY
                     ere_title ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -332,7 +330,7 @@
                  WHERE
                     per_ere_id=ere_id AND
                     per_prj_id=" . Misc::escapeInteger($prj_id);
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
--- include/class.error_handler.php	2009-01-25 05:39:02.157369722 +0200
+++ /usr/share/eventum/include/class.error_handler.php	2009-02-05 02:15:18.594196189 +0200
@@ -29,9 +29,6 @@
 // @(#) $Id: class.error_handler.php 3809 2009-01-25 03:40:17Z glen $
 //
 
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.mail.php");
-require_once(APP_INC_PATH . "class.setup.php");
 
 /**
  * Class to manage all tasks related to error conditions of the site, such as
@@ -130,7 +127,7 @@
         $subject = APP_SITE_NAME . ' - Error found! - ' . $date;
 
         foreach ($notify_list as $notify_email) {
-            $mail = new Mail_API;
+            $mail = new Mail_Helper;
             $mail->setTextBody($msg);
             $mail->send($notify_from, $notify_email, $subject, 0, false, 'error');
         }
--- include/class.faq.php	2009-01-12 23:15:12.052089091 +0200
+++ /usr/share/eventum/include/class.faq.php	2009-02-05 02:04:13.547383186 +0200
@@ -66,7 +66,7 @@
                      ORDER BY
                         faq_rank ASC";
         }
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -75,7 +75,7 @@
                 if (empty($res[$i]['faq_updated_date'])) {
                     $res[$i]['faq_updated_date'] = $res[$i]['faq_created_date'];
                 }
-                $res[$i]['faq_updated_date'] = Date_API::getSimpleDate($res[$i]["faq_updated_date"]);
+                $res[$i]['faq_updated_date'] = Date_Helper::getSimpleDate($res[$i]["faq_updated_date"]);
             }
             return $res;
         }
@@ -95,7 +95,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "faq
                  WHERE
                     faq_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -125,7 +125,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "faq_support_level
                  WHERE
                     fsl_faq_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -155,13 +155,13 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "faq
                  SET
                     faq_prj_id=" . $_POST['project'] . ",
-                    faq_updated_date='" . Date_API::getCurrentDateGMT() . "',
+                    faq_updated_date='" . Date_Helper::getCurrentDateGMT() . "',
                     faq_title='" . Misc::escapeString($_POST["title"]) . "',
                     faq_message='" . Misc::escapeString($_POST["message"]) . "',
                     faq_rank=" . $_POST['rank'] . "
                  WHERE
                     faq_id=" . $_POST["id"];
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -204,12 +204,12 @@
                  ) VALUES (
                     " . $_POST['project'] . ",
                     " . Auth::getUserID() . ",
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     '" . Misc::escapeString($_POST["title"]) . "',
                     '" . Misc::escapeString($_POST["message"]) . "',
                     " . $_POST['rank'] . "
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -245,7 +245,7 @@
                     " . Misc::escapeInteger($faq_id) . ",
                     " . Misc::escapeInteger($support_level_id) . "
                  )";
-        $GLOBALS["db_api"]->dbh->query($stmt);
+        Db_Helper::getInstance()->query($stmt);
     }
 
 
@@ -264,7 +264,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "faq
                  WHERE
                     faq_id=" . Misc::escapeInteger($faq_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -276,7 +276,7 @@
             if (empty($res['faq_updated_date'])) {
                 $res['faq_updated_date'] = $res['faq_created_date'];
             }
-            $res['faq_updated_date'] = Date_API::getFormattedDate($res['faq_updated_date']);
+            $res['faq_updated_date'] = Date_Helper::getFormattedDate($res['faq_updated_date']);
             $res['message'] = Misc::activateLinks(nl2br(htmlspecialchars($res['faq_message'])));
             return $res;
         }
@@ -300,7 +300,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "faq
                  ORDER BY
                     faq_rank ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -333,7 +333,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "faq_support_level
                  WHERE
                     fsl_faq_id=" . Misc::escapeInteger($faq_id);
-        $ids = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $ids = Db_Helper::getInstance()->getCol($stmt);
 
         $t = array();
         $levels = Customer::getSupportLevelAssocList(Misc::escapeInteger($prj_id));
@@ -384,7 +384,7 @@
                         faq_rank=" . $ranking[$faq_id] . "
                      WHERE
                         faq_id=" . $replaced_faq_id;
-            $GLOBALS["db_api"]->dbh->query($stmt);
+            Db_Helper::getInstance()->query($stmt);
         }
         $stmt = "UPDATE
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "faq
@@ -392,7 +392,7 @@
                     faq_rank=" . $new_rank . "
                  WHERE
                     faq_id=" . $faq_id;
-        $GLOBALS["db_api"]->dbh->query($stmt);
+        Db_Helper::getInstance()->query($stmt);
         return true;
     }
 
@@ -413,7 +413,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "faq
                  ORDER BY
                     faq_rank ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
--- include/class.filter.php	2009-01-26 15:12:31.987364874 +0200
+++ /usr/share/eventum/include/class.filter.php	2009-02-05 02:03:28.804058755 +0200
@@ -29,10 +29,6 @@
 // @(#) $Id: class.filter.php 3813 2009-01-26 13:13:53Z glen $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.auth.php");
-require_once(APP_INC_PATH . "class.date.php");
 
 /**
  * Class to handle the business logic related to the custom filters.
@@ -60,7 +56,7 @@
                  WHERE
                     cst_id=" . Misc::escapeInteger($cst_id) . " AND
                     cst_is_global=1";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -92,7 +88,7 @@
                  WHERE
                     cst_id=" . Misc::escapeInteger($cst_id) . " AND
                     cst_usr_id=" . Misc::escapeInteger($usr_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -290,7 +286,7 @@
                         '" . Misc::escapeString($custom_field_string) . "'
                      )";
         }
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -318,7 +314,7 @@
                     cst_usr_id=" . Auth::getUserID() . " AND
                     cst_prj_id=" . Auth::getCurrentProject() . " AND
                     cst_title='" . Misc::escapeString($cst_title) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return 0;
@@ -351,7 +347,7 @@
                     )
                  ORDER BY
                     cst_title";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -384,7 +380,7 @@
                     )
                  ORDER BY
                     cst_title";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -496,7 +492,7 @@
         }
         $stmt .= "
                     cst_id=$cst_id";
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -536,7 +532,7 @@
             $stmt .= "
                         cst_prj_id=" . Auth::getCurrentProject() . " AND
                         cst_id=$cst_id";
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return -1;
@@ -561,7 +557,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_filter
                  WHERE
                     cst_prj_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
--- include/class.group.php	2009-01-12 23:15:12.045423021 +0200
+++ /usr/share/eventum/include/class.group.php	2009-02-05 02:03:28.804058755 +0200
@@ -29,12 +29,6 @@
 // @(#) $Id: class.group.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.auth.php");
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.prefs.php");
-require_once(APP_INC_PATH . "class.date.php");
-require_once(APP_INC_PATH . "class.project.php");
 
 /**
  * Class to handle the business logic related to the administration
@@ -67,7 +61,7 @@
                     '" . Misc::escapeString($_POST["description"]) . "',
                     '" . Misc::escapeInteger($_POST["manager"]) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -102,7 +96,7 @@
                     grp_manager_usr_id = '" . Misc::escapeInteger($_POST["manager"]) . "'
                  WHERE
                     grp_id = " . $_POST["id"];
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -138,7 +132,7 @@
                         " . APP_DEFAULT_DB . ".`" . APP_TABLE_PREFIX . "group`
                      WHERE
                         grp_id = $grp_id";
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return -1;
@@ -178,7 +172,7 @@
                         $prj_id,
                         $grp_id
                      )";
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return -1;
@@ -201,7 +195,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_group
                  WHERE
                     pgr_grp_id = " . Misc::escapeInteger($grp_id);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -224,7 +218,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_group
                  WHERE
                     pgr_prj_id IN(" . join(",", Misc::escapeInteger($projects)) . ")";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -258,7 +252,7 @@
                     " . APP_DEFAULT_DB . ".`" . APP_TABLE_PREFIX . "group`
                  WHERE
                     grp_id = $grp_id";
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -316,7 +310,7 @@
                     " . APP_DEFAULT_DB . ".`" . APP_TABLE_PREFIX . "group`
                  ORDER BY
                     grp_name";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -359,7 +353,7 @@
                     pgr_prj_id = $prj_id
                  ORDER BY
                     grp_name";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -386,7 +380,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "group
                  ORDER BY
                     grp_name";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -411,7 +405,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user
                  WHERE
                     usr_grp_id = " . Misc::escapeInteger($grp_id);
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -438,7 +432,7 @@
                  WHERE
                     pgr_prj_id = prj_id AND
                     pgr_grp_id = " . Misc::escapeInteger($grp_id);
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -465,7 +459,7 @@
                     grp_id = pgr_grp_id AND
                     pgr_prj_id = " . Auth::getCurrentProject() . " AND
                     grp_name = '" . Misc::escapeString($name) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
--- include/class.help.php	2009-01-12 23:15:12.065832249 +0200
+++ /usr/share/eventum/include/class.help.php	2009-02-05 01:39:37.047534043 +0200
@@ -29,7 +29,6 @@
 // @(#) $Id: class.help.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
 
 $topics = array(
     "main" => array(
--- include/class.history.php	2009-01-12 23:15:12.035414975 +0200
+++ /usr/share/eventum/include/class.history.php	2009-02-05 02:04:13.547383186 +0200
@@ -29,10 +29,6 @@
 // @(#) $Id: class.history.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.mime_helper.php");
-require_once(APP_INC_PATH . "class.date.php");
 
 /**
  * Class to handle the business logic related to the history information for
@@ -91,14 +87,14 @@
         $stmt .= ") VALUES (
                     " . Misc::escapeInteger($iss_id) . ",
                     " . Misc::escapeInteger($usr_id) . ",
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     '" . Misc::escapeString($summary) . "',
                     $htt_id";
         if ($hide == true) {
             $stmt .= ", 1";
         }
         $stmt .= ")";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -128,13 +124,13 @@
                     htt_role <= " . Auth::getCurrentRole() . "
                  ORDER BY
                     his_id $order_by";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
         } else {
             for ($i = 0; $i < count($res); $i++) {
-                $res[$i]["his_created_date"] = Date_API::getFormattedDate($res[$i]["his_created_date"]);
+                $res[$i]["his_created_date"] = Date_Helper::getFormattedDate($res[$i]["his_created_date"]);
                 $res[$i]["his_summary"] = Mime_Helper::fixEncoding($res[$i]["his_summary"]);
             }
             return $res;
@@ -157,7 +153,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_history
                  WHERE
                     his_iss_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -194,7 +190,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "history_type
                  WHERE
                     htt_name IN('" . join("','", $name) . "')";
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "unknown";
@@ -264,7 +260,7 @@
                     iss_id
                  ORDER BY
                     iss_id ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -339,7 +335,7 @@
                     sta_title
                  ORDER BY
                     sta_rank";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -376,7 +372,7 @@
             $stmt .= "
                     AND his_htt_id IN(" . join(",", Misc::escapeInteger($htt_id)) . ")";
         }
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -403,7 +399,7 @@
                 ORDER BY
                     his_created_date DESC
                 LIMIT 1";
-        $res = $GLOBALS["db_api"]->dbh->getOne($sql);
+        $res = Db_Helper::getInstance()->getOne($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return 0;
@@ -443,7 +439,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_history.his_created_date BETWEEN '" . Misc::escapeString($start) . "' AND '" . Misc::escapeString($end) . "'
                 GROUP BY his_iss_id";
 
-        $result = $GLOBALS["db_api"]->dbh->getAssoc($sql);
+        $result = Db_Helper::getInstance()->getAssoc($sql);
         if (PEAR::isError($result)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         } else {
--- include/class.impact_analysis.php	2009-01-12 23:15:12.075834288 +0200
+++ /usr/share/eventum/include/class.impact_analysis.php	2009-02-05 02:04:13.550721110 +0200
@@ -29,11 +29,6 @@
 // @(#) $Id: class.impact_analysis.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.auth.php");
-require_once(APP_INC_PATH . "class.user.php");
-require_once(APP_INC_PATH . "class.history.php");
-require_once(APP_INC_PATH . "class.date.php");
 
 /**
  * Class to handle the business logic related to the impact analysis section
@@ -67,10 +62,10 @@
                  ) VALUES (
                     " . Misc::escapeInteger($issue_id) . ",
                     $usr_id,
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     '" . Misc::escapeString($_POST["new_requirement"]) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -112,7 +107,7 @@
                  WHERE
                     isr_iss_id=" . Misc::escapeInteger($issue_id) . " AND
                     isr_usr_id=A.usr_id";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -147,7 +142,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_requirement
                  WHERE
                     isr_id=" . Misc::escapeInteger($isr_id);
-        $issue_id = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $issue_id = Db_Helper::getInstance()->getOne($stmt);
 
         // we are storing minutes, not hours
         $dev_time = $_POST["dev_time"] * 60;
@@ -156,12 +151,12 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_requirement
                  SET
                     isr_updated_usr_id=$usr_id,
-                    isr_updated_date='" . Date_API::getCurrentDateGMT() . "',
+                    isr_updated_date='" . Date_Helper::getCurrentDateGMT() . "',
                     isr_dev_time=$dev_time,
                     isr_impact_analysis='" . Misc::escapeString($_POST["impact_analysis"]) . "'
                  WHERE
                     isr_id=" . Misc::escapeInteger($isr_id);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -189,13 +184,13 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_requirement
                  WHERE
                     isr_id IN ($items)";
-        $issue_id = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $issue_id = Db_Helper::getInstance()->getOne($stmt);
 
         $stmt = "DELETE FROM
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_requirement
                  WHERE
                     isr_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -223,7 +218,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_requirement
                  WHERE
                     isr_iss_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
--- include/class.issue_field.php	2009-01-12 23:15:12.045423021 +0200
+++ /usr/share/eventum/include/class.issue_field.php	2009-02-05 01:39:37.074425170 +0200
@@ -27,7 +27,6 @@
 // +----------------------------------------------------------------------+
 //
 
-require_once(APP_INC_PATH . "class.priority.php");
 
 /**
  * Manages fields that are associated with an issue but can be displayed in many different places.
--- include/class.issue.php	2009-01-13 20:09:57.681222753 +0200
+++ /usr/share/eventum/include/class.issue.php	2009-02-05 02:15:18.617317004 +0200
@@ -27,33 +27,6 @@
 // +----------------------------------------------------------------------+
 //
 
-require_once(APP_INC_PATH . "class.validation.php");
-require_once(APP_INC_PATH . "class.time_tracking.php");
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.attachment.php");
-require_once(APP_INC_PATH . "class.auth.php");
-require_once(APP_INC_PATH . "class.user.php");
-require_once(APP_INC_PATH . "class.note.php");
-require_once(APP_INC_PATH . "class.history.php");
-require_once(APP_INC_PATH . "class.notification.php");
-require_once(APP_INC_PATH . "class.pager.php");
-require_once(APP_INC_PATH . "class.date.php");
-require_once(APP_INC_PATH . "class.category.php");
-require_once(APP_INC_PATH . "class.release.php");
-require_once(APP_INC_PATH . "class.resolution.php");
-require_once(APP_INC_PATH . "class.support.php");
-require_once(APP_INC_PATH . "class.scm.php");
-require_once(APP_INC_PATH . "class.impact_analysis.php");
-require_once(APP_INC_PATH . "class.custom_field.php");
-require_once(APP_INC_PATH . "class.phone_support.php");
-require_once(APP_INC_PATH . "class.status.php");
-require_once(APP_INC_PATH . "class.round_robin.php");
-require_once(APP_INC_PATH . "class.authorized_replier.php");
-require_once(APP_INC_PATH . "class.workflow.php");
-require_once(APP_INC_PATH . "class.priority.php");
-require_once(APP_INC_PATH . "class.reminder_action.php");
-require_once(APP_INC_PATH . "class.search_profile.php");
-require_once(APP_INC_PATH . "class.session.php");
 
 /**
  * Class designed to handle all business logic related to the issues in the
@@ -85,7 +58,7 @@
             $stmt .= " AND
                     iss_prj_id = " . Auth::getCurrentProject();
         }
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -185,7 +158,7 @@
                     iss_prj_id=" . Misc::escapeInteger($prj_id) . "
                  ORDER BY
                     iss_id ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -218,7 +191,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  WHERE
                     iss_id=$issue_id";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -241,12 +214,12 @@
         $stmt = "UPDATE
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  SET
-                    iss_last_customer_action_date='" . Date_API::getCurrentDateGMT() . "',
-                    iss_last_public_action_date='" . Date_API::getCurrentDateGMT() . "',
+                    iss_last_customer_action_date='" . Date_Helper::getCurrentDateGMT() . "',
+                    iss_last_public_action_date='" . Date_Helper::getCurrentDateGMT() . "',
                     iss_last_public_action_type='customer action'
                  WHERE
                     iss_id=" . Misc::escapeInteger($issue_id);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -279,7 +252,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  WHERE
                     iss_id=$issue_id";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -313,7 +286,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  WHERE
                     iss_id=$issue_id";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -344,7 +317,7 @@
                     iss_customer_contract_id = " . Misc::escapeInteger($contract_id) . "
                  WHERE
                     iss_id=$issue_id";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -379,7 +352,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  WHERE
                     iss_id=$issue_id";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -413,7 +386,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  WHERE
                     iss_id=$issue_id";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -482,12 +455,12 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  SET
                     iss_sta_id=$status_id,
-                    iss_updated_date='" . Date_API::getCurrentDateGMT() . "',
-                    iss_last_public_action_date='" . Date_API::getCurrentDateGMT() . "',
+                    iss_updated_date='" . Date_Helper::getCurrentDateGMT() . "',
+                    iss_last_public_action_date='" . Date_Helper::getCurrentDateGMT() . "',
                     iss_last_public_action_type='update'
                  WHERE
                     iss_id=$issue_id";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -554,7 +527,7 @@
                         iss_pre_id = $pre_id
                     WHERE
                         iss_id = $issue_id";
-            $res = $GLOBALS["db_api"]->dbh->query($sql);
+            $res = Db_Helper::getInstance()->query($sql);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return -1;
@@ -580,7 +553,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                 WHERE
                     iss_id = " . Misc::escapeInteger($issue_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($sql);
+        $res = Db_Helper::getInstance()->getOne($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return 0;
@@ -610,7 +583,7 @@
                         iss_pri_id = $pri_id
                     WHERE
                         iss_id = $issue_id";
-            $res = $GLOBALS["db_api"]->dbh->query($sql);
+            $res = Db_Helper::getInstance()->query($sql);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return -1;
@@ -636,7 +609,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                 WHERE
                     iss_id = " . Misc::escapeInteger($issue_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($sql);
+        $res = Db_Helper::getInstance()->getOne($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return 0;
@@ -666,7 +639,7 @@
                         iss_prc_id = $prc_id
                     WHERE
                         iss_id = $issue_id";
-            $res = $GLOBALS["db_api"]->dbh->query($sql);
+            $res = Db_Helper::getInstance()->query($sql);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return -1;
@@ -692,7 +665,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                 WHERE
                     iss_id = " . Misc::escapeInteger($issue_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($sql);
+        $res = Db_Helper::getInstance()->getOne($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return 0;
@@ -747,7 +720,7 @@
         }
         $stmt .= "\nGROUP BY
                         iss_id";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -785,13 +758,13 @@
                  WHERE
                     iss_usr_id=usr_id AND
                     iss_id=$issue_id";
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
         } else {
             $res['reply_subject'] = 'Re: [#' . $issue_id . '] ' . $res["sup_subject"];
-            $res['created_date_ts'] = Date_API::getUnixTimestamp($res['iss_created_date'], 'GMT');
+            $res['created_date_ts'] = Date_Helper::getUnixTimestamp($res['iss_created_date'], 'GMT');
             return $res;
         }
     }
@@ -812,19 +785,19 @@
         $stmt = "UPDATE
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  SET
-                    iss_updated_date='" . Date_API::getCurrentDateGMT() . "'\n";
+                    iss_updated_date='" . Date_Helper::getCurrentDateGMT() . "'\n";
         if ($type != false) {
             if (in_array($type, $public)) {
                 $field = "iss_last_public_action_";
             } else {
                 $field = "iss_last_internal_action_";
             }
-            $stmt .= ",\n " . $field . "date = '" . Date_API::getCurrentDateGMT() . "',\n" .
+            $stmt .= ",\n " . $field . "date = '" . Date_Helper::getCurrentDateGMT() . "',\n" .
                 $field . "type  ='" . Misc::escapeString($type) . "'\n";
         }
         $stmt .= "WHERE
                     iss_id=" . Misc::escapeInteger($issue_id);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -834,18 +807,18 @@
                 $stmt = "UPDATE
                             " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                          SET
-                            iss_last_response_date='" . Date_API::getCurrentDateGMT() . "'
+                            iss_last_response_date='" . Date_Helper::getCurrentDateGMT() . "'
                          WHERE
                             iss_id = " . Misc::escapeInteger($issue_id);
-                $GLOBALS["db_api"]->dbh->query($stmt);
+                Db_Helper::getInstance()->query($stmt);
                 $stmt = "UPDATE
                             " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                          SET
-                            iss_first_response_date='" . Date_API::getCurrentDateGMT() . "'
+                            iss_first_response_date='" . Date_Helper::getCurrentDateGMT() . "'
                          WHERE
                             iss_first_response_date IS NULL AND
                             iss_id = " . Misc::escapeInteger($issue_id);
-                $GLOBALS["db_api"]->dbh->query($stmt);
+                Db_Helper::getInstance()->query($stmt);
             }
 
             return true;
@@ -869,7 +842,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  WHERE
                     iss_duplicated_iss_id=" . Misc::escapeInteger($issue_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -903,8 +876,8 @@
         $stmt = "UPDATE
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  SET
-                    iss_updated_date='" . Date_API::getCurrentDateGMT() . "',
-                    iss_last_internal_action_date='" . Date_API::getCurrentDateGMT() . "',
+                    iss_updated_date='" . Date_Helper::getCurrentDateGMT() . "',
+                    iss_last_internal_action_date='" . Date_Helper::getCurrentDateGMT() . "',
                     iss_last_internal_action_type='updated',
                     iss_prc_id=" . Misc::escapeInteger($_POST["category"]) . ",";
         if (@$_POST["keep"] == "no") {
@@ -916,7 +889,7 @@
                     iss_res_id=" . Misc::escapeInteger($_POST["resolution"]) . "
                  WHERE
                     iss_id IN (" . implode(", ", $ids) . ")";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -981,7 +954,7 @@
                  WHERE
                     iss_sta_id=sta_id AND
                     iss_duplicated_iss_id=" . Misc::escapeInteger($issue_id);
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -1005,13 +978,13 @@
         $stmt = "UPDATE
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  SET
-                    iss_updated_date='" . Date_API::getCurrentDateGMT() . "',
-                    iss_last_internal_action_date='" . Date_API::getCurrentDateGMT() . "',
+                    iss_updated_date='" . Date_Helper::getCurrentDateGMT() . "',
+                    iss_last_internal_action_date='" . Date_Helper::getCurrentDateGMT() . "',
                     iss_last_internal_action_type='updated',
                     iss_duplicated_iss_id=NULL
                  WHERE
                     iss_id=$issue_id";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1040,13 +1013,13 @@
         $stmt = "UPDATE
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  SET
-                    iss_updated_date='" . Date_API::getCurrentDateGMT() . "',
-                    iss_last_internal_action_date='" . Date_API::getCurrentDateGMT() . "',
+                    iss_updated_date='" . Date_Helper::getCurrentDateGMT() . "',
+                    iss_last_internal_action_date='" . Date_Helper::getCurrentDateGMT() . "',
                     iss_last_internal_action_type='updated',
                     iss_duplicated_iss_id=" . Misc::escapeInteger($_POST["duplicated_issue"]) . "
                  WHERE
                     iss_id=$issue_id";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1074,7 +1047,7 @@
                 WHERE
                     iss_id = " . Misc::escapeInteger($issue_id) . " AND
                     iss_duplicated_iss_id IS NULL";
-        $res = $GLOBALS["db_api"]->dbh->getOne($sql);
+        $res = Db_Helper::getInstance()->getOne($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -1106,7 +1079,7 @@
                  WHERE
                     isu_iss_id=" . Misc::escapeInteger($issue_id) . " AND
                     isu_usr_id=usr_id";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -1131,7 +1104,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  WHERE
                     iss_id=" . Misc::escapeInteger($issue_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -1156,7 +1129,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  WHERE
                     iss_summary='" . Misc::escapeString($summary) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return 0;
@@ -1208,14 +1181,14 @@
             $stmt .= "$initial_status,";
         }
         $stmt .= "
-                    '" . Date_API::getCurrentDateGMT() . "',
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     'created',
                     '" . Misc::escapeString($_POST["summary"]) . "',
                     '" . Misc::escapeString($_POST["description"]) . "',
-                    '" . Misc::escapeString(Mail_API::generateMessageID()) . "'
+                    '" . Misc::escapeString(Mail_Helper::generateMessageID()) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return $res;
@@ -1289,7 +1262,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  WHERE
                     iss_prj_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -1312,7 +1285,7 @@
                             " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                          WHERE
                             iss_id IN ($items)";
-                $GLOBALS["db_api"]->dbh->query($stmt);
+                Db_Helper::getInstance()->query($stmt);
             }
             return true;
         }
@@ -1342,21 +1315,22 @@
         $stmt = "UPDATE
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  SET
-                    iss_updated_date='" . Date_API::getCurrentDateGMT() . "',
-                    iss_last_public_action_date='" . Date_API::getCurrentDateGMT() . "',
+                    iss_updated_date='" . Date_Helper::getCurrentDateGMT() . "',
+                    iss_last_public_action_date='" . Date_Helper::getCurrentDateGMT() . "',
                     iss_last_public_action_type='closed',
-                    iss_closed_date='" . Date_API::getCurrentDateGMT() . "',\n";
+                    iss_closed_date='" . Date_Helper::getCurrentDateGMT() . "',\n";
         if (!empty($resolution_id)) {
             $stmt .= "iss_res_id=$resolution_id,\n";
         }
         $stmt .= "iss_sta_id=$status_id
                  WHERE
                     iss_id=$issue_id";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
         } else {
+            Issue::moveOrderForAllUsers($issue_id, 1000);
             $prj_id = Issue::getProjectID($issue_id);
 
             // record the change
@@ -1375,7 +1349,7 @@
                     'ema_id'        =>  Email_Account::getEmailAccount(Issue::getProjectID($issue_id)),
                     'issue_id'      =>  $issue_id,
                     'message_id'    =>  $message_id,
-                    'date'          =>  Date_API::getCurrentDateGMT(),
+                    'date'          =>  Date_Helper::getCurrentDateGMT(),
                     'subject'       =>  'Issue closed comments',
                     'from'          =>  $from,
                     'has_attachment'=>  0,
@@ -1402,7 +1376,7 @@
                                 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                              WHERE
                                 iss_id=$issue_id";
-                    $customer_contact_id = $GLOBALS["db_api"]->dbh->getOne($stmt);
+                    $customer_contact_id = Db_Helper::getInstance()->getOne($stmt);
                     if (!empty($customer_contact_id)) {
                         Customer::notifyIssueClosed($prj_id, $issue_id, $customer_contact_id, $send_notification, $resolution_id, $status_id, $reason);
                     }
@@ -1510,8 +1484,8 @@
         $stmt = "UPDATE
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  SET
-                    iss_updated_date='" . Date_API::getCurrentDateGMT() . "',
-                    iss_last_public_action_date='" . Date_API::getCurrentDateGMT() . "',
+                    iss_updated_date='" . Date_Helper::getCurrentDateGMT() . "',
+                    iss_last_public_action_date='" . Date_Helper::getCurrentDateGMT() . "',
                     iss_last_public_action_type='updated',";
         if (!empty($_POST["category"])) {
             $stmt .= "iss_prc_id=" . Misc::escapeInteger($_POST["category"]) . ",";
@@ -1542,7 +1516,7 @@
         $stmt .= "
                  WHERE
                     iss_id=$issue_id";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1660,6 +1634,180 @@
         }
     }
 
+    /**
+     * Method used to update the a single detail field of a specific issue.
+     *
+     * @param integer $issue_id
+     * @param string $field_name
+     * @param string $field_value
+     * @param string $field_type string or integer (for escape)
+     * @return integer 1 on success, -1 otherwise
+     */
+    function updateField($issue_id, $field_name, $filed_value) {
+
+        $issue_id = Misc::escapeInteger($issue_id);
+
+        $usr_id = Auth::getUserID();
+        $prj_id = Issue::getProjectID($issue_id);
+
+        // get all of the 'current' information of this issue
+        $current = Issue::getDetails($issue_id);
+
+        $stmt = "UPDATE
+                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
+                 SET
+                    iss_updated_date='" . Date_Helper::getCurrentDateGMT() . "',
+                    iss_last_public_action_date='" . Date_Helper::getCurrentDateGMT() . "',
+                    iss_last_public_action_type='updated'";
+
+        switch ($field_name) {
+            case 'category':
+                $stmt .= ", iss_prc_id = " . Misc::escapeInteger($filed_value);
+            break;
+            case 'release':
+                $stmt .= ", iss_pre_id = " . Misc::escapeInteger($filed_value);
+            break;
+            case 'expected_resolution_date':
+                if (is_null($filed_value)) {
+                    $stmt .= ", iss_expected_resolution_date = null";
+                } else {
+                    $stmt .= ", iss_expected_resolution_date = '" . Misc::escapeString($filed_value) . "'";
+                }
+            break;
+            case 'release':
+                $stmt .= ", iss_pre_id = " . Misc::escapeInteger($filed_value);
+            break;
+            case 'priority':
+                $stmt .= ", iss_pri_id = " . Misc::escapeInteger($filed_value);
+            break;
+            case 'status':
+                $stmt .= ", iss_sta_id = " . Misc::escapeInteger($filed_value);
+            break;
+            case 'resolution':
+                $stmt .= ", iss_res_id = " . Misc::escapeInteger($filed_value);
+            break;
+            case 'summary':
+                $stmt .= ", iss_summary = '" . Misc::escapeString($filed_value) . "'";
+            break;
+            case 'description':
+                $stmt .= ", iss_description = '" . Misc::escapeString($filed_value) . "'";
+            break;
+            case 'estimated_dev_time':
+                $stmt .= ", iss_dev_time = '" . Misc::escapeString($filed_value) . "'";
+            break;
+            case 'percent_complete':
+                $stmt .= ", iss_percent_complete = '" . Misc::escapeString($filed_value) . "'";
+            break;
+            case 'trigger_reminders':
+                $stmt .= ", iss_trigger_reminders = " . Misc::escapeInteger($filed_value);
+            break;
+            case 'group':
+                $stmt .= ", iss_grp_id = " . Misc::escapeInteger($filed_value);
+            break;
+            case 'private':
+                $stmt .= ", iss_private = " . Misc::escapeInteger($filed_value);
+            break;
+            default:
+                Error_Handler::logError("Unknown field name $field_name", __FILE__, __LINE__);
+                return -1;
+            break;
+        }
+
+        $stmt .= "
+                 WHERE
+                    iss_id=$issue_id";
+
+        $res = Db_Helper::getInstance()->query($stmt);
+        if (PEAR::isError($res)) {
+            Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
+            return -1;
+        } else {
+            $new = array(
+                'category' => $current['iss_prc_id'],
+                'release' => $current['iss_pre_id'],
+                'expected_resolution_date' => $current['iss_expected_resolution_date'],
+                'release' => $current['iss_pre_id'],
+                'priority' => $current['iss_pri_id'],
+                'status' => $current['iss_sta_id'],
+                'resolution' => $current['iss_res_id'],
+                'summary' => $current['iss_summary'],
+                'description' => $current['iss_description'],
+                'estimated_dev_time' => $current['iss_dev_time'],
+                'percent_complete' => $current['iss_percent_complete'],
+                'trigger_reminders' => $current['iss_trigger_reminders'],
+                'group' => $current['iss_grp_id'],
+                'iss_private' => $current['private']
+            );
+            $new[$field_name] = $filed_value;
+
+            // add change to the history (only for changes on specific fields?)
+            $updated_fields = array();
+            if ($field_name == 'expected_resolution_date' && $current["iss_expected_resolution_date"] != $filed_value) {
+                $updated_fields["Expected Resolution Date"] = History::formatChanges($current["iss_expected_resolution_date"], $filed_value);
+            }
+            if ($field_name == 'category' && $current["iss_prc_id"] != $filed_value) {
+                $updated_fields["Category"] = History::formatChanges(Category::getTitle($current["iss_prc_id"]), Category::getTitle($filed_value));
+            }
+            if ($field_name == 'release' && $current["iss_pre_id"] != $filed_value) {
+                $updated_fields["Release"] = History::formatChanges(Release::getTitle($current["iss_pre_id"]), Release::getTitle($filed_value));
+            }
+            if ($field_name == 'priority' && $current["iss_pri_id"] != $filed_value) {
+                $updated_fields["Priority"] = History::formatChanges(Priority::getTitle($current["iss_pri_id"]), Priority::getTitle($filed_value));
+                Workflow::handlePriorityChange($prj_id, $issue_id, $usr_id, $current, $new);
+            }
+            if ($field_name == 'status' && $current["iss_sta_id"] != $filed_value) {
+                // clear out the last-triggered-reminder flag when changing the status of an issue
+                Reminder_Action::clearLastTriggered($issue_id);
+
+                // if old status was closed and new status is not, clear closed data from issue.
+                $old_status_details = Status::getDetails($current['iss_sta_id']);
+                if ($old_status_details['sta_is_closed'] == 1) {
+                    $new_status_details = Status::getDetails($filed_value);
+                    if ($new_status_details['sta_is_closed'] != 1) {
+                        Issue::clearClosed($issue_id);
+                    }
+                }
+                $updated_fields["Status"] = History::formatChanges(Status::getStatusTitle($current["iss_sta_id"]), Status::getStatusTitle($filed_value));
+            }
+            if ($field_name == 'resolution' && $current["iss_res_id"] != $filed_value) {
+                $updated_fields["Resolution"] = History::formatChanges(Resolution::getTitle($current["iss_res_id"]), Resolution::getTitle($filed_value));
+            }
+            if ($field_name == 'estimated_dev_time' && $current["iss_dev_time"] != $filed_value) {
+                $updated_fields["Estimated Dev. Time"] = History::formatChanges(Misc::getFormattedTime(($current["iss_dev_time"]*60)), Misc::getFormattedTime(($filed_value*60)));
+            }
+            if ($field_name == 'summary' && $current["iss_summary"] != $filed_value) {
+                $updated_fields["Summary"] = '';
+            }
+            if ($field_name == 'description' && $current["iss_description"] != $filed_value) {
+                $updated_fields["Description"] = '';
+            }
+            if ($field_name == 'private' && ($filed_value != $current['iss_private'])) {
+                $updated_fields["Private"] = History::formatChanges(Misc::getBooleanDisplayValue($current['iss_private']), Misc::getBooleanDisplayValue($filed_value));
+            }
+            if (count($updated_fields) > 0) {
+                // log the changes
+                $changes = '';
+                $i = 0;
+                foreach ($updated_fields as $key => $value) {
+                    if ($i > 0) {
+                        $changes .= "; ";
+                    }
+                    if (($key != "Summary") && ($key != "Description")) {
+                        $changes .= "$key: $value";
+                    } else {
+                        $changes .= "$key";
+                    }
+                    $i++;
+                }
+
+                History::add($issue_id, $usr_id, History::getTypeID('issue_updated'), "Issue updated ($changes) by " . User::getFullName($usr_id));
+                // send notifications for the issue being updated
+                Notification::notifyIssueUpdated($issue_id, $current, $new);
+            }
+        }
+        return 1;
+    }
+
 
     /**
      * Move the issue to a new project
@@ -1676,7 +1824,7 @@
               iss_prj_id = " . Misc::escapeInteger($new_prj_id) . "
           WHERE
               iss_id = " . Misc::escapeInteger($issue_id);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1710,7 +1858,7 @@
                   iss_pri_id=" . $new_pri_id . "
               WHERE
                   iss_id=$issue_id";
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             }
@@ -1742,7 +1890,7 @@
                     $issue_id,
                     $associated_id
                  )";
-        $GLOBALS["db_api"]->dbh->query($stmt);
+        Db_Helper::getInstance()->query($stmt);
         History::add($issue_id, $usr_id, History::getTypeID('issue_associated'), "Issue associated to #$associated_id by " . User::getFullName($usr_id));
         // link the associated issue back to this one
         if ($link_issues) {
@@ -1769,7 +1917,7 @@
                  WHERE
                     isa_issue_id IN ($issue_id) OR
                     isa_associated_id IN ($issue_id)";
-        $GLOBALS["db_api"]->dbh->query($stmt);
+        Db_Helper::getInstance()->query($stmt);
         if ($usr_id) {
             History::add($issue_id, $usr_id, History::getTypeID('issue_all_unassociated'), 'Issue associations removed by ' . User::getFullName($usr_id));
         }
@@ -1799,7 +1947,7 @@
                         isa_issue_id = $associated_id AND
                         isa_associated_id = $issue_id
                     )";
-        $GLOBALS["db_api"]->dbh->query($stmt);
+        Db_Helper::getInstance()->query($stmt);
         History::add($issue_id, Auth::getUserID(), History::getTypeID('issue_unassociated'),
                 "Issue association #$associated_id removed by " . User::getFullName(Auth::getUserID()));
         History::add($associated_id, Auth::getUserID(), History::getTypeID('issue_unassociated'),
@@ -1821,18 +1969,35 @@
     {
         $issue_id = Misc::escapeInteger($issue_id);
         $assignee_usr_id = Misc::escapeInteger($assignee_usr_id);
+        $order = 1;
+        // move all orders down to free "order space" for this new association
+        $stmt = "UPDATE 
+                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
+                 SET
+                    isu_order = isu_order + 1
+                 WHERE
+                    isu_usr_id = $assignee_usr_id AND
+                    isu_order >= $order";
+        $res = Db_Helper::getInstance()->query($stmt);
+        if (PEAR::isError($res)) {
+            Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
+            return -1;
+        }
+        // insert the new association
         $stmt = "INSERT INTO
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
                  (
                     isu_iss_id,
                     isu_usr_id,
-                    isu_assigned_date
+                    isu_assigned_date,
+                    isu_order
                  ) VALUES (
                     $issue_id,
                     $assignee_usr_id,
-                    '" . Date_API::getCurrentDateGMT() . "'
+                    '" . Date_Helper::getCurrentDateGMT() . "',
+                    $order
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1845,6 +2010,78 @@
         }
     }
 
+    /**
+     * Method used to get the order list to be rearranged
+     * 
+     * @access  private
+     * @param   string $issue_id The issue ID or a comma seperated list of IDs already prepared for giving to mysql
+     * @param   string $usr_id The user to remove. When not specified, all users are taken as to be removed for that issue
+     * @return  mixed delete order list to be rearranged. Used as a parameter to the method of rearranging the order.
+     */
+    function getDeleteUserAssociationOrderList($issue_id, $usr_id = "")
+    {
+        // find all affected associantion orders
+        $stmt = "SELECT isu_usr_id, isu_order FROM
+                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
+                 WHERE
+                 isu_iss_id IN ($issue_id)";
+        if (!empty($usr_id)) {
+            $stmt.= " AND isu_usr_id IN ($usr_id)";
+        }
+        $stmt.= "ORDER BY isu_order";
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
+        if (PEAR::isError($res)) {
+            Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
+            return -1;
+        } else {
+            $deleted_orders = array();
+            foreach ($res as $row) {
+                if (empty($deleted_orders[$row['isu_usr_id']])) {
+                    $deleted_orders[$row['isu_usr_id']] = array();
+                }
+                $deleted_orders[$row['isu_usr_id']] [] = $row['isu_order'];
+            }
+            return $deleted_orders;
+        }
+    }
+
+    /**
+     *
+     * Method used to rearrange order list in the db according to known deleted records
+     *
+     * @access  private
+     * @param   mixed  deleteorder list
+     * @return void
+     */
+    function rearrangeDeleteUserAssociationOrderList($delete_order_list)
+    {
+        if (empty($delete_order_list) || (!is_array($delete_order_list))) {
+            return -1;
+        }
+        foreach ($delete_order_list as $isu_usr_id => $orders) {
+            for ($i = 0; $i < count($orders); $i++) { // traverse all deleted orders
+                // move the orders after them up to take the "order space" of the deleted records
+                $stmt = "UPDATE
+                            " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
+                         SET
+                            isu_order = isu_order - " . ($i+1) . "
+                         WHERE
+                            isu_usr_id = $isu_usr_id AND
+                            isu_order > " . $orders[$i];
+                if ($i < count($orders) - 1) {
+                    $stmt.=  " AND
+                            isu_order < " . $orders[$i+1];
+                }
+                $res = Db_Helper::getInstance()->query($stmt);
+                if (PEAR::isError($res)) {
+                    Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
+                    return -1;
+                }
+            }
+        }
+        return 1;
+    }
+
 
     /**
      * Method used to delete all user assignments for a specific issue.
@@ -1860,11 +2097,12 @@
         if (is_array($issue_id)) {
             $issue_id = implode(", ", $issue_id);
         }
+        $deleted_order_list = Issue::getDeleteUserAssociationOrderList($issue_id);
         $stmt = "DELETE FROM
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
                  WHERE
                     isu_iss_id IN ($issue_id)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1890,12 +2128,13 @@
     {
         $issue_id = Misc::escapeInteger($issue_id);
         $usr_id = Misc::escapeInteger($usr_id);
+        $delete_order_list = Issue::getDeleteUserAssociationOrderList($issue_id, $usr_id);
         $stmt = "DELETE FROM
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
                  WHERE
                     isu_iss_id = $issue_id AND
                     isu_usr_id = $usr_id";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1904,6 +2143,7 @@
                 History::add($issue_id, Auth::getUserID(), History::getTypeID('user_unassociated'),
                     User::getFullName($usr_id) . ' removed from issue by ' . User::getFullName(Auth::getUserID()));
             }
+            Issue::rearrangeDeleteUserAssociationOrderList($delete_order_list);
             return 1;
         }
     }
@@ -1928,7 +2168,7 @@
     function createFromEmail($prj_id, $usr_id, $sender, $summary, $description, $category, $priority, $assignment, $date, $msg_id)
     {
         $exclude_list = array();
-        $sender_email = Mail_API::getEmailAddress($sender);
+        $sender_email = Mail_Helper::getEmailAddress($sender);
         $sender_usr_id = User::getUserIDByEmail($sender_email, true);
         if (!empty($sender_usr_id)) {
             $reporter = $sender_usr_id;
@@ -1940,7 +2180,7 @@
                 $contact = Customer::getContactDetails($prj_id, $customer_contact_id);
                 // overwrite the reporter with the customer contact
                 $reporter = User::getUserIDByContactID($customer_contact_id);
-                $contact_timezone = Date_API::getPreferredTimezone($reporter);
+                $contact_timezone = Date_Helper::getPreferredTimezone($reporter);
             }
         } else {
             $customer_id = FALSE;
@@ -2001,14 +2241,14 @@
                     '" . Misc::escapeString($contact_timezone) . "',";
         }
         $stmt .= "
-                    '" . Date_API::getCurrentDateGMT() . "',
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     'created',
                     '" . Misc::escapeString($summary) . "',
                     '" . Misc::escapeString($description) . "',
                     '" . Misc::escapeString($msg_id) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -2194,16 +2434,16 @@
                     '" . Misc::escapeString($_POST["contact_timezone"]) . "',";
         }
         $stmt .= "
-                    '" . Date_API::getCurrentDateGMT() . "',
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     'created',
                     '" . Misc::escapeString($_POST["summary"]) . "',
                     '" . Misc::escapeString($_POST["description"]) . "',
                     " . Misc::escapeString($_POST["estimated_dev_time"]) . ",
                     " . Misc::escapeInteger($_POST["private"]) . " ,
-                    '" . Misc::escapeString(Mail_API::generateMessageID()) . "'
+                    '" . Misc::escapeString(Mail_Helper::generateMessageID()) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -2380,6 +2620,11 @@
     {
         $sort_by = Issue::getParam('sort_by');
         $sort_order = Issue::getParam('sort_order');
+        $users = Issue::getParam('users');
+        if (empty($users) && ($sort_by == 'isu_order')) { // Sorting by isu_order is impossible when no user specified
+            unset($sort_by);
+            unset($sort_order);
+        }
         $rows = Issue::getParam('rows');
         $hide_closed = Issue::getParam('hide_closed');
         if ($hide_closed === '') {
@@ -2484,6 +2729,7 @@
             "last_action_date" => "desc",
             "usr_full_name" => "asc",
             "iss_expected_resolution_date" => "desc",
+            "isu_order" => "desc",
         );
 
         foreach ($custom_fields as $fld_id => $fld_name) {
@@ -2669,7 +2915,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_quarantine
                  ON
                     iss_id=iqu_iss_id AND
-                    (iqu_expiration > '" . Date_API::getCurrentDateGMT() . "' OR iqu_expiration IS NULL)
+                    (iqu_expiration > '" . Date_Helper::getCurrentDateGMT() . "' OR iqu_expiration IS NULL)
                  WHERE
                     iss_prj_id= " . Misc::escapeInteger($prj_id);
         $stmt .= Issue::buildWhereClause($options);
@@ -2691,7 +2937,7 @@
         $stmt .= "
                  LIMIT
                     " . Misc::escapeInteger($start) . ", " . Misc::escapeInteger($max);
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array(
@@ -2722,8 +2968,8 @@
             $csv[] = @implode("\t", $column_headings);
             for ($i = 0; $i < count($res); $i++) {
                 $res[$i]["time_spent"] = Misc::getFormattedTime($res[$i]["time_spent"]);
-                $res[$i]["iss_created_date"] = Date_API::getFormattedDate($res[$i]["iss_created_date"]);
-                $res[$i]["iss_expected_resolution_date"] = Date_API::getSimpleDate($res[$i]["iss_expected_resolution_date"], false);
+                $res[$i]["iss_created_date"] = Date_Helper::getFormattedDate($res[$i]["iss_created_date"]);
+                $res[$i]["iss_expected_resolution_date"] = Date_Helper::getSimpleDate($res[$i]["iss_expected_resolution_date"], false);
                 $fields = array(
                     $res[$i]['pri_title'],
                     $res[$i]['iss_id'],
@@ -2811,9 +3057,9 @@
                 $last_date = $result[$i]["iss_last_public_action_date"];
             }
             $date = new Date($last_date);
-            $current = new Date(Date_API::getCurrentDateGMT());
+            $current = new Date(Date_Helper::getCurrentDateGMT());
             $result[$i]['last_action_date'] = sprintf("%s: %s ago", ucwords($label),
-                    Date_API::getFormattedDateDiff($current->getDate(DATE_FORMAT_UNIXTIME), $date->getDate(DATE_FORMAT_UNIXTIME)));
+                    Date_Helper::getFormattedDateDiff($current->getDate(DATE_FORMAT_UNIXTIME), $date->getDate(DATE_FORMAT_UNIXTIME)));
         }
     }
 
@@ -2845,7 +3091,7 @@
                     $result[$i]['status_change_date'] = '';
                     continue;
                 }
-                $current = new Date(Date_API::getCurrentDateGMT());
+                $current = new Date(Date_Helper::getCurrentDateGMT());
                 $desc = "$label: %s ago";
                 $target_date = $result[$i][$date_field_name];
                 if (empty($target_date)) {
@@ -2853,7 +3099,7 @@
                     continue;
                 }
                 $date = new Date($target_date);
-                $result[$i]['status_change_date'] = sprintf($desc, Date_API::getFormattedDateDiff($current->getDate(DATE_FORMAT_UNIXTIME), $date->getDate(DATE_FORMAT_UNIXTIME)));
+                $result[$i]['status_change_date'] = sprintf($desc, Date_Helper::getFormattedDateDiff($current->getDate(DATE_FORMAT_UNIXTIME), $date->getDate(DATE_FORMAT_UNIXTIME)));
             }
         }
     }
@@ -2975,7 +3221,7 @@
                         if (strlen($options[$field_name]['time_period']) == 0) {
                             $options[$field_name]['time_period'] = 0;
                         }
-                        $stmt .= " AND (UNIX_TIMESTAMP('" . Date_API::getCurrentDateGMT() . "') - UNIX_TIMESTAMP(iss_$field_name)) <= (" .
+                        $stmt .= " AND (UNIX_TIMESTAMP('" . Date_Helper::getCurrentDateGMT() . "') - UNIX_TIMESTAMP(iss_$field_name)) <= (" .
                             Misc::escapeInteger($options[$field_name]['time_period']) . "*3600)";
                         break;
                 }
@@ -3151,7 +3397,7 @@
                  ORDER BY
                     " . $sort_by . " " . Misc::escapeString($options["sort_order"]) . ",
                     iss_id DESC";
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -3190,7 +3436,7 @@
                  WHERE
                     isu_iss_id=" . Misc::escapeInteger($issue_id) . " AND
                     isu_usr_id=usr_id";
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -3243,7 +3489,7 @@
                  WHERE
                     iss_usr_id=usr_id AND
                     iss_id IN ($ids)";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         } else {
@@ -3276,6 +3522,8 @@
         $ids = implode(", ", $ids);
         $stmt = "SELECT
                     isu_iss_id,
+                    isu_order,
+                    isu_usr_id,
                     usr_full_name
                  FROM
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user,
@@ -3283,10 +3531,11 @@
                  WHERE
                     isu_usr_id=usr_id AND
                     isu_iss_id IN ($ids)";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         } else {
+            // gather names of the users assigned to each issue
             $t = array();
             for ($i = 0; $i < count($res); $i++) {
                 if (!empty($t[$res[$i]['isu_iss_id']])) {
@@ -3295,9 +3544,18 @@
                     $t[$res[$i]['isu_iss_id']] = $res[$i]['usr_full_name'];
                 }
             }
+            // gather orders
+            $o = array();
+            for ($i = 0; $i < count($res); $i++) {
+                if (empty($o[$res[$i]['isu_iss_id']])) {
+                    $o[$res[$i]['isu_iss_id']] = array();
+                }
+                $o[$res[$i]['isu_iss_id']][$res[$i]['isu_usr_id']] = $res[$i]['isu_order'];
+            }
             // now populate the $result variable again
             for ($i = 0; $i < count($result); $i++) {
                 @$result[$i]['assigned_users'] = $t[$result[$i]['iss_id']];
+                @$result[$i]['assigned_users_order'] = $o[$result[$i]['iss_id']];
             }
         }
     }
@@ -3329,7 +3587,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  WHERE
                     iss_id in ($ids)";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         } else {
@@ -3358,7 +3616,7 @@
                  WHERE
                     isu_iss_id=" . Misc::escapeInteger($issue_id) . " AND
                     isu_usr_id=usr_id";
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -3424,7 +3682,7 @@
                  WHERE
                     iss_id=$issue_id AND
                     iss_prj_id=prj_id";
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -3432,21 +3690,21 @@
             if (empty($res)) {
                 return "";
             } else {
-                $created_date_ts = Date_API::getUnixTimestamp($res['iss_created_date'], Date_API::getDefaultTimezone());
+                $created_date_ts = Date_Helper::getUnixTimestamp($res['iss_created_date'], Date_Helper::getDefaultTimezone());
                 // get customer information, if any
                 if ((!empty($res['iss_customer_id'])) && (Customer::hasCustomerIntegration($res['iss_prj_id']))) {
                     $res['customer_business_hours'] = Customer::getBusinessHours($res['iss_prj_id'], $res['iss_customer_id']);
-                    $res['contact_local_time'] = Date_API::getFormattedDate(Date_API::getCurrentDateGMT(), $res['iss_contact_timezone']);
+                    $res['contact_local_time'] = Date_Helper::getFormattedDate(Date_Helper::getCurrentDateGMT(), $res['iss_contact_timezone']);
                     $res['customer_info'] = Customer::getDetails($res['iss_prj_id'], $res['iss_customer_id'], false, $res['iss_customer_contract_id']);
                     $res['redeemed_incidents'] = Customer::getRedeemedIncidentDetails($res['iss_prj_id'], $res['iss_id']);
                     $max_first_response_time = Customer::getMaximumFirstResponseTime($res['iss_prj_id'], $res['iss_customer_id'], $res['iss_customer_contract_id']);
                     $res['max_first_response_time'] = Misc::getFormattedTime($max_first_response_time / 60);
                     if (empty($res['iss_first_response_date'])) {
                         $first_response_deadline = $created_date_ts + $max_first_response_time;
-                        if (Date_API::getCurrentUnixTimestampGMT() <= $first_response_deadline) {
-                            $res['max_first_response_time_left'] = Date_API::getFormattedDateDiff($first_response_deadline, Date_API::getCurrentUnixTimestampGMT());
+                        if (Date_Helper::getCurrentUnixTimestampGMT() <= $first_response_deadline) {
+                            $res['max_first_response_time_left'] = Date_Helper::getFormattedDateDiff($first_response_deadline, Date_Helper::getCurrentUnixTimestampGMT());
                         } else {
-                            $res['overdue_first_response_time'] = Date_API::getFormattedDateDiff(Date_API::getCurrentUnixTimestampGMT(), $first_response_deadline);
+                            $res['overdue_first_response_time'] = Date_Helper::getFormattedDateDiff(Date_Helper::getCurrentUnixTimestampGMT(), $first_response_deadline);
                         }
                     }
                 }
@@ -3456,7 +3714,7 @@
                     $res["iss_resolution"] = Resolution::getTitle($res["iss_res_id"]);
                 }
                 $res["iss_impact_analysis"] = nl2br(htmlspecialchars($res["iss_impact_analysis"]));
-                $res["iss_created_date"] = Date_API::getFormattedDate($res["iss_created_date"]);
+                $res["iss_created_date"] = Date_Helper::getFormattedDate($res["iss_created_date"]);
                 $res['iss_created_date_ts'] = $created_date_ts;
                 $res["assignments"] = @implode(", ", array_values(Issue::getAssignedUsers($res["iss_id"])));
                 list($res['authorized_names'], $res['authorized_repliers']) = Authorized_Replier::getAuthorizedRepliers($res["iss_id"]);
@@ -3483,7 +3741,7 @@
                 if (empty($res["iss_updated_date"])) {
                     $res["iss_updated_date"] = 'not updated yet';
                 } else {
-                    $res["iss_updated_date"] = Date_API::getFormattedDate($res["iss_updated_date"]);
+                    $res["iss_updated_date"] = Date_Helper::getFormattedDate($res["iss_updated_date"]);
                 }
                 $res["estimated_formatted_time"] = Misc::getFormattedTime($res["iss_dev_time"]);
                 if (Release::isAssignable($res["iss_pre_id"])) {
@@ -3533,7 +3791,7 @@
                  WHERE
                     iss_sta_id=sta_id AND
                     iss_id=$issue_id";
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -3585,7 +3843,7 @@
                          WHERE
                             isu_usr_id = usr_id AND
                             isu_iss_id = " . $items[$i];
-                $current_assignees = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+                $current_assignees = Db_Helper::getInstance()->getAssoc($stmt);
                 if (PEAR::isError($current_assignees)) {
                     Error_Handler::logError(array($current_assignees->getMessage(), $current_assignees->getDebugInfo()), __FILE__, __LINE__);
                     return -1;
@@ -3608,7 +3866,7 @@
                              WHERE
                                 isu_iss_id=" . $items[$i] . " AND
                                 isu_usr_id=" . $usr_id;
-                    $total = $GLOBALS["db_api"]->dbh->getOne($stmt);
+                    $total = Db_Helper::getInstance()->getOne($stmt);
                     if ($total > 0) {
                         continue;
                     } else {
@@ -3689,14 +3947,14 @@
         $stmt = "UPDATE
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  SET
-                    iss_updated_date='" . Date_API::getCurrentDateGMT() . "',
-                    iss_last_internal_action_date='" . Date_API::getCurrentDateGMT() . "',
+                    iss_updated_date='" . Date_Helper::getCurrentDateGMT() . "',
+                    iss_last_internal_action_date='" . Date_Helper::getCurrentDateGMT() . "',
                     iss_last_internal_action_type='update',
                     iss_developer_est_time=" . Misc::escapeInteger($_POST["dev_time"]) . ",
                     iss_impact_analysis='" . Misc::escapeString($_POST["impact_analysis"]) . "'
                  WHERE
                     iss_id=" . Misc::escapeInteger($issue_id);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -3731,7 +3989,7 @@
         $stmt .= "
                  ORDER BY
                     iss_id DESC";
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -3764,7 +4022,7 @@
         $stmt .= "
                  ORDER BY
                     iss_id ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -3821,7 +4079,7 @@
                     isa_associated_id=iss_id AND
                     iss_sta_id=sta_id AND
                     isa_issue_id=$issue_id";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -3850,7 +4108,7 @@
                     iss_id=" . Misc::escapeInteger($issue_id) . " AND
                     iss_sta_id=sta_id AND
                     sta_is_closed=1";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -3882,9 +4140,9 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_quarantine
                  WHERE
                     iqu_iss_id=iss_id AND
-                    iqu_expiration >= '" . Date_API::getCurrentDateGMT() . "' AND
+                    iqu_expiration >= '" . Date_Helper::getCurrentDateGMT() . "' AND
                     iqu_expiration IS NOT NULL";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -3910,16 +4168,16 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_quarantine
                  WHERE
                     iqu_iss_id = " . Misc::escapeInteger($issue_id) . " AND
-                        (iqu_expiration > '" . Date_API::getCurrentDateGMT() . "' OR
+                        (iqu_expiration > '" . Date_Helper::getCurrentDateGMT() . "' OR
                         iqu_expiration IS NULL)";
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
         } else {
             if (!empty($res["iqu_expiration"])) {
-                $expiration_ts = Date_API::getUnixTimestamp($res['iqu_expiration'], Date_API::getDefaultTimezone());
-                $res["time_till_expiration"] = Date_API::getFormattedDateDiff($expiration_ts, Date_API::getCurrentUnixTimestampGMT());
+                $expiration_ts = Date_Helper::getUnixTimestamp($res['iqu_expiration'], Date_Helper::getDefaultTimezone());
+                $res["time_till_expiration"] = Date_Helper::getFormattedDateDiff($expiration_ts, Date_Helper::getCurrentUnixTimestampGMT());
             }
             return $res;
         }
@@ -3947,7 +4205,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_quarantine
                  WHERE
                     iqu_iss_id = $issue_id";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -3963,7 +4221,7 @@
             }
             $stmt .= "\nWHERE
                         iqu_iss_id = $issue_id";
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return -1;
@@ -3991,7 +4249,7 @@
                 $stmt .= ",\n'" . Misc::escapeString($expiration) . "'\n";
             }
             $stmt .= ")";
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return -1;
@@ -4024,7 +4282,7 @@
                     iss_grp_id = $group_id
                  WHERE
                     iss_id = $issue_id";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -4054,7 +4312,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  WHERE
                     iss_id=" . Misc::escapeInteger($issue_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return 0;
@@ -4116,7 +4374,7 @@
                      sup_id = seb_sup_id AND
                      MATCH(seb_body) AGAINST ('" . Misc::escapeString($options['keywords']) . "' IN BOOLEAN MODE)
                  )";
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array(-1);
@@ -4127,7 +4385,7 @@
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_custom_field
                     WHERE
                         MATCH (icf_value) AGAINST ('" . Misc::escapeString($options['keywords']) . "' IN BOOLEAN MODE)";
-            $custom_res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+            $custom_res = Db_Helper::getInstance()->getCol($stmt);
             if (PEAR::isError($custom_res)) {
                 Error_Handler::logError(array($custom_res->getMessage(), $custom_res->getDebugInfo()), __FILE__, __LINE__);
                 return array(-1);
@@ -4229,7 +4487,7 @@
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                     WHERE
                         iss_id=$issue_id";
-            $res = $GLOBALS["db_api"]->dbh->getOne($sql);
+            $res = Db_Helper::getInstance()->getOne($sql);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return true;
@@ -4260,11 +4518,12 @@
                     iss_res_id = null
                  WHERE
                     iss_id=" . Misc::escapeInteger($issue_id);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
         }
+        Issue::moveOrderForAllUsers($issue_id, 1);
     }
 
 
@@ -4282,7 +4541,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                 WHERE
                     iss_id=" . Misc::escapeInteger($issue_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($sql);
+        $res = Db_Helper::getInstance()->getOne($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -4311,7 +4570,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                 WHERE
                     iss_root_message_id = '" . Misc::escapeString($msg_id) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($sql);
+        $res = Db_Helper::getInstance()->getOne($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -4364,8 +4623,127 @@
         History::add($issue_id, Auth::getUserID(), History::getTypeID('user_associated'),
                         "Issue assignment to changed (" . History::formatChanges(join(', ', $old_assignee_names), join(', ', $assignee_names)) . ") by " . User::getFullName(Auth::getUserID()));
     }
+
+    /**
+     * Reorders user's issues as requested by user
+     * @access public
+     * @param $usr_id User to be reordered
+     * @param $issue_id Issue or array of issues to be moved
+     * @param $neworder The new order of the issues
+     * @return void
+     */
+    function reorderUserIssues($usr_id, $issue_id, $neworder)
+    {
+        if (!isset($usr_id) || !isset($issue_id) || !isset($neworder)) {
+            return false;
+        }
+        if (!is_numeric($usr_id) || !is_numeric($neworder)) {
+            return false;
+        }
+        $usr_id = Misc::escapeInteger($usr_id);
+        $issue_id = Misc::escapeInteger($issue_id);
+        $neworder = Misc::escapeInteger($neworder);
+        if (is_array($issue_id)) {
+            $issue_count = count($issue_id);
+            $issue_id_str = implode(", ", $issue_id);
+        } else {
+            $issue_count = 1;
+            $issue_id_str = $issue_id;
+            $issue_id = array($issue_id);
+        }
+        // do a nasty pretending to be deleting stuff so that reordering happens as if these elements were deleted
+        $orderlist = Issue::getDeleteUserAssociationOrderList($issue_id_str, $usr_id);
+        Issue::rearrangeDeleteUserAssociationOrderList($orderlist);
+        // move down the orders to free the "order space" needed
+        $stmt = "UPDATE 
+                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
+                 SET
+                    isu_order = isu_order + $issue_count
+                 WHERE
+                    isu_usr_id = $usr_id AND
+                    isu_order >= $neworder";
+        $res = Db_Helper::getInstance()->query($stmt);
+        if (PEAR::isError($res)) {
+            Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
+            return -1;
+        }
+        //update the order for the issues being moved
+        $i = 0;
+        foreach ($issue_id as $iss_id) {
+            $stmt = "UPDATE
+                        " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
+                     SET
+                        isu_order = " . ($neworder + $i) . "
+                     WHERE
+                        isu_usr_id = $usr_id AND
+                        isu_iss_id = $iss_id";
+            $res = Db_Helper::getInstance()->query($stmt);
+            if (PEAR::isError($res)) {
+                Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
+                return -1;
+            }
+            $i++;
+        }
+    }
+
+
+    /**
+     * Get users issue order list
+     * @access public
+     * @param $user_id User
+     * @param $order_list Order of the issues
+     * @return void
+     */
+    function getIssueOrderByUser($usr_id) {
+
+        if (!is_numeric($usr_id)) {
+            return false;
+        }
+
+        $stmt = "SELECT
+                    isu_iss_id, isu_order
+                FROM
+                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
+                WHERE
+                    isu_usr_id = " . $usr_id ;
+
+        $order_list = array();
+
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
+
+        if (PEAR::isError($res)) {
+            Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
+            return array();
+        } else {
+            foreach ($res as $row) {
+                $order_list[$row["isu_iss_id"]] = $row["isu_order"];
+            }
+        }
+        return $order_list;
+    }
+
+    function moveOrderForAllUsers($issue_id, $neworder)
+    {
+        // Move the issue to the top priority for the ppl it's assigned to
+        $stmt = "SELECT isu_usr_id FROM
+                    "  . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
+                 WHERE
+                    isu_iss_id = " . Misc::escapeInteger($issue_id);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
+        if (PEAR::isError($res)) {
+            Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
+            return -1;
+        }
+        foreach ($res as $row) {
+            Issue::reorderUserIssues($row["isu_usr_id"], $issue_id, $neworder);
+        }
+    }
+    
 }
 
+
+
+
 // benchmarking the included file (aka setup time)
 if (APP_BENCHMARK) {
     $GLOBALS['bench']->setMarker('Included Issue Class');
--- include/class.language.php	2009-01-12 23:15:12.038752480 +0200
+++ /usr/share/eventum/include/class.language.php	2009-02-05 01:39:37.074425170 +0200
@@ -176,7 +176,6 @@
 
 // if there is no gettext support built into PHP, or we are running in language compatability mode include PHP-gettext
 if (!function_exists('gettext') || (defined('APP_GETTEXT_MODE') && APP_GETTEXT_MODE == 'php')) {
-    require_once(APP_INC_PATH . 'php-gettext/gettext.inc');
 
 	function ev_gettext($string) {
 		if (func_num_args() > 1) {
@@ -230,7 +229,6 @@
 }
 
 // this won't change over the request. so set it once and permanently
-_bindtextdomain('eventum', APP_PATH . 'misc/localization/');
 _bind_textdomain_codeset('eventum', APP_CHARSET);
 _textdomain('eventum');
 
--- include/class.link_filter.php	2009-01-12 23:15:12.068965748 +0200
+++ /usr/share/eventum/include/class.link_filter.php	2009-02-05 02:03:28.834056353 +0200
@@ -29,7 +29,6 @@
 // @(#) $Id: class.link_filter.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.user.php");
 
 /**
  * Class to handle parsing content for links.
@@ -58,7 +57,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "link_filter
                 WHERE
                     lfi_id = " . Misc::escapeInteger($lfi_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($sql, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($sql, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -69,7 +68,7 @@
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_link_filter
                     WHERE
                         plf_lfi_id = " . $res['lfi_id'];
-            $projects = $GLOBALS["db_api"]->dbh->getCol($sql);
+            $projects = Db_Helper::getInstance()->getCol($sql);
             if (PEAR::isError($projects)) {
                 Error_Handler::logError(array($projects->getMessage(), $projects->getDebugInfo()), __FILE__, __LINE__);
                 $projects = array();
@@ -99,7 +98,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "link_filter
                 ORDER BY
                     lfi_id";
-        $res = $GLOBALS["db_api"]->dbh->getAll($sql, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($sql, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -114,7 +113,7 @@
                     WHERE
                         prj_id = plf_prj_id AND
                         plf_lfi_id = " . $res[$i]['lfi_id'];
-            $projects = $GLOBALS["db_api"]->dbh->getAssoc($sql);
+            $projects = Db_Helper::getInstance()->getAssoc($sql);
             if (PEAR::isError($projects)) {
                 Error_Handler::logError(array($projects->getMessage(), $projects->getDebugInfo()), __FILE__, __LINE__);
                 $projects = array();
@@ -149,7 +148,7 @@
                     '" . Misc::escapeInteger($_REQUEST["usr_role"]) . "',
                     '" . Misc::escapeString($_REQUEST["description"]) . "'
                 )";
-        $res = $GLOBALS["db_api"]->dbh->query($sql);
+        $res = Db_Helper::getInstance()->query($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -165,7 +164,7 @@
                             $prj_id,
                             $lfi_id
                         )";
-                $res = $GLOBALS["db_api"]->dbh->query($sql);
+                $res = Db_Helper::getInstance()->query($sql);
                 if (PEAR::isError($res)) {
                     Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                     return -1;
@@ -187,7 +186,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "link_filter
                 WHERE
                     lfi_id IN(" . join(',', Misc::escapeInteger($_REQUEST["items"])) . ")";
-        $res = $GLOBALS["db_api"]->dbh->query($sql);
+        $res = Db_Helper::getInstance()->query($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -196,7 +195,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_link_filter
                 WHERE
                     plf_lfi_id IN(" . join(',', Misc::escapeInteger($_REQUEST["items"])) . ")";
-        $res = $GLOBALS["db_api"]->dbh->query($sql);
+        $res = Db_Helper::getInstance()->query($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -221,7 +220,7 @@
                     lfi_description = '" . Misc::escapeString($_REQUEST["description"]) . "'
                 WHERE
                     lfi_id = " . $_REQUEST["id"];
-        $res = $GLOBALS["db_api"]->dbh->query($sql);
+        $res = Db_Helper::getInstance()->query($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -230,7 +229,7 @@
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_link_filter
                     WHERE
                         plf_lfi_id = " . Misc::escapeInteger($_REQUEST["id"]);
-            $res = $GLOBALS["db_api"]->dbh->query($sql);
+            $res = Db_Helper::getInstance()->query($sql);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return -1;
@@ -245,7 +244,7 @@
                             $prj_id,
                             " . Misc::escapeInteger($_REQUEST["id"]) . "
                         )";
-                $res = $GLOBALS["db_api"]->dbh->query($sql);
+                $res = Db_Helper::getInstance()->query($sql);
                 if (PEAR::isError($res)) {
                     Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                     return -1;
@@ -327,7 +326,7 @@
                     plf_prj_id = $prj_id
                 ORDER BY
                     lfi_id";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt);
+        $res = Db_Helper::getInstance()->getAll($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -348,7 +347,6 @@
      */
     function callbackIssueLinks($matches)
     {
-        require_once(APP_INC_PATH . "class.issue.php");
         // check if the issue is still open
         if (Issue::isClosed($matches[5])) {
             $class = 'closed_link';
--- include/class.mail_queue.php	2009-01-12 23:15:12.042086912 +0200
+++ /usr/share/eventum/include/class.mail_queue.php	2009-02-05 02:15:18.620863055 +0200
@@ -28,13 +28,6 @@
 //
 
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.date.php");
-require_once(APP_INC_PATH . "class.mime_helper.php");
-require_once(APP_INC_PATH . "class.setup.php");
-require_once(APP_INC_PATH . "class.lock.php");
-require_once(APP_INC_PATH . "class.user.php");
-require_once(APP_PEAR_PATH . 'Mail.php');
 
 class Mail_Queue
 {
@@ -81,7 +74,7 @@
         Workflow::modifyMailQueue(Auth::getCurrentProject(), $recipient, $headers, $body, $issue_id, $type, $sender_usr_id, $type_id);
 
         // avoid sending emails out to users with inactive status
-        $recipient_email = Mail_API::getEmailAddress($recipient);
+        $recipient_email = Mail_Helper::getEmailAddress($recipient);
         $usr_id = User::getUserIDByEmail($recipient_email);
         if (!empty($usr_id)) {
             $user_status = User::getStatusByEmail($recipient_email);
@@ -92,14 +85,14 @@
         }
 
         $to_usr_id = User::getUserIDByEmail($recipient_email);
-        $recipient = Mail_API::fixAddressQuoting($recipient);
+        $recipient = Mail_Helper::fixAddressQuoting($recipient);
 
         $reminder_addresses = Reminder::_getReminderAlertAddresses();
 
         // add specialized headers
         if ((!empty($issue_id)) && ((!empty($to_usr_id)) && (User::getRoleByUser($to_usr_id, Issue::getProjectID($issue_id)) != User::getRoleID("Customer"))) ||
-                (@in_array(Mail_API::getEmailAddress($to), $reminder_addresses))) {
-            $headers += Mail_API::getSpecializedHeaders($issue_id, $type, $headers, $sender_usr_id);
+                (@in_array(Mail_Helper::getEmailAddress($to), $reminder_addresses))) {
+            $headers += Mail_Helper::getSpecializedHeaders($issue_id, $type, $headers, $sender_usr_id);
         }
         $headers['precedence'] = 'bulk';
 
@@ -112,12 +105,12 @@
             $headers['Date'] = MIME_Helper::encode(date('D, j M Y H:i:s O'));
         }
         if (!empty($headers['To'])) {
-            $headers['To'] = Mail_API::fixAddressQuoting($headers['To']);
+            $headers['To'] = Mail_Helper::fixAddressQuoting($headers['To']);
         }
         // encode headers and add special mime headers
         $headers = Mime_Helper::encodeHeaders($headers);
 
-        $res = Mail_API::prepareHeaders($headers);
+        $res = Mail_Helper::prepareHeaders($headers);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return $res;
@@ -146,7 +139,7 @@
         }
         $stmt .= ") VALUES (
                     $save_email_copy,
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     '" . @$_SERVER['REMOTE_ADDR'] . "',
                     '" . Misc::escapeString($recipient) . "',
                     '" . Misc::escapeString($text_headers) . "',
@@ -161,7 +154,7 @@
             $stmt .= ",\n" . $type_id;
         }
         $stmt .= ")";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return $res;
@@ -197,7 +190,7 @@
                 Mail_Queue::_saveLog($emails[$i]['id'], 'sent', '');
                 if ($emails[$i]['save_copy']) {
                     // send a copy of this email to eventum_sent@
-                    Mail_API::saveEmailInformation($emails[$i]);
+                    Mail_Helper::saveEmailInformation($emails[$i]);
                 }
             }
         }
@@ -241,7 +234,7 @@
             unset($headers['Mime-Version']);
             $headers['MIME-Version'] = '1.0';
         }
-        $mail =& Mail::factory('smtp', Mail_API::getSMTPSettings());
+        $mail =& Mail::factory('smtp', Mail_Helper::getSMTPSettings());
         $res = $mail->send($recipient, $headers, $body);
         if (PEAR::isError($res)) {
             // special handling of errors when the mail server is down
@@ -299,7 +292,7 @@
                     maq_id ASC
                  LIMIT
                     0, $limit";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -330,11 +323,11 @@
                     mql_server_message
                  ) VALUES (
                     $maq_id,
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     '" . Misc::escapeString($status) . "',
                     '" . Misc::escapeString($server_message) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -345,7 +338,7 @@
                         maq_status='" . Misc::escapeString($status) . "'
                      WHERE
                         maq_id=$maq_id";
-            $GLOBALS["db_api"]->dbh->query($stmt);
+            Db_Helper::getInstance()->query($stmt);
             return true;
         }
     }
@@ -387,7 +380,7 @@
                     maq_iss_id = " . Misc::escapeInteger($issue_id) . "
                  ORDER BY
                     maq_queued_date ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -395,7 +388,7 @@
         if (count($res) > 0) {
             for ($i = 0; $i < count($res); $i++) {
                 $res[$i]['maq_recipient'] = Mime_Helper::decodeAddress($res[$i]['maq_recipient']);
-                $res[$i]['maq_queued_date'] = Date_API::getFormattedDate(Date_API::getUnixTimestamp($res[$i]['maq_queued_date'], 'GMT'));
+                $res[$i]['maq_queued_date'] = Date_Helper::getFormattedDate(Date_Helper::getUnixTimestamp($res[$i]['maq_queued_date'], 'GMT'));
                 $res[$i]['maq_subject'] = Mime_Helper::fixEncoding($res[$i]['maq_subject']);
             }
         }
@@ -424,7 +417,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "mail_queue
                  WHERE
                     maq_id = " . Misc::escapeInteger($maq_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -447,7 +440,7 @@
                 WHERE
                     maq_type IN('" . join("', '", $types) . "') AND
                     maq_type_id = " . Misc::escapeInteger($type_id);
-        $res = $GLOBALS["db_api"]->dbh->getCol($sql);
+        $res = Db_Helper::getInstance()->getCol($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
--- include/class.mime_helper.php	2009-01-27 11:45:43.136619000 +0200
+++ /usr/share/eventum/include/class.mime_helper.php	2009-02-05 02:15:18.624196789 +0200
@@ -39,8 +39,6 @@
 *
 */
 
-require_once(APP_PEAR_PATH . "Mail/mimeDecode.php");
-require_once(APP_INC_PATH . "class.error_handler.php");
 
 /**
  * Class to handle the business logic related to the MIME email
@@ -789,7 +787,7 @@
     function splitHeaderBody($message, $unfold = true)
     {
         if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $message, $match)) {
-            return array(($unfold) ? Mail_API::unfold($match[1]) : $match[1], $match[2]);
+            return array(($unfold) ? Mail_Helper::unfold($match[1]) : $match[1], $match[2]);
         }
         return array();
     }
--- include/class.misc.php	2009-01-12 23:15:12.032084245 +0200
+++ /usr/share/eventum/include/class.misc.php	2009-02-05 02:04:13.577383996 +0200
@@ -27,8 +27,6 @@
 // +----------------------------------------------------------------------+
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.setup.php");
 
 /**
  * Class to hold methods and algorythms that woudln't fit in other classes, such
@@ -371,7 +369,7 @@
                 $input[$key] = Misc::escapeString($value);
             }
         } else {
-            $input = $GLOBALS["db_api"]->escapeString($input);
+            $input = Db_Helper::escapeString($input);
         }
         return $input;
     }
@@ -556,7 +554,7 @@
     function formatReplyDate($ts)
     {
         // On Fri, 01 Apr 2005, 17:07:44 GMT
-        return Date_API::getFormattedDate($ts);
+        return Date_Helper::getFormattedDate($ts);
     }
 
 
@@ -617,7 +615,6 @@
      */
     function highlightQuotedReply($text)
     {
-        require_once(APP_SMARTY_PATH . "plugins/modifier.highlight_quoted.php");
         return smarty_modifier_highlight_quoted($text);
     }
 
--- include/class.news.php	2009-01-12 23:15:12.085433204 +0200
+++ /usr/share/eventum/include/class.news.php	2009-02-05 02:04:13.580717590 +0200
@@ -55,13 +55,13 @@
                     nws_created_date DESC
                  LIMIT
                     0, 3";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
         } else {
             for ($i = 0; $i < count($res); $i++) {
-                $res[$i]['nws_created_date'] = Date_API::getSimpleDate($res[$i]["nws_created_date"]);
+                $res[$i]['nws_created_date'] = Date_Helper::getSimpleDate($res[$i]["nws_created_date"]);
                 if ((!$show_full_message) && (strlen($res[$i]['nws_message']) > 300)) {
                     $next_space = strpos($res[$i]['nws_message'], ' ', 254);
                     if (empty($next_space)) {
@@ -100,7 +100,7 @@
                     " . Misc::escapeInteger($nws_id) . ",
                     " . Misc::escapeInteger($prj_id) . "
                  )";
-        $GLOBALS["db_api"]->dbh->query($stmt);
+        Db_Helper::getInstance()->query($stmt);
     }
 
 
@@ -128,12 +128,12 @@
                     nws_status
                  ) VALUES (
                     " . Auth::getUserID() . ",
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     '" . Misc::escapeString($_POST["title"]) . "',
                     '" . Misc::escapeString($_POST["message"]) . "',
                     '" . Misc::escapeString($_POST["status"]) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -161,7 +161,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "news
                  WHERE
                     nws_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -194,7 +194,7 @@
         if ($prj_id) {
             $stmt .= " AND prn_prj_id=" . Misc::escapeInteger($prj_id);
         }
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -226,7 +226,7 @@
                     nws_status='" . Misc::escapeString($_POST["status"]) . "'
                  WHERE
                     nws_id=" . Misc::escapeInteger($_POST["id"]);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -256,7 +256,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "news
                  WHERE
                     nws_id=" . Misc::escapeInteger($nws_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -284,7 +284,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "news
                  WHERE
                     nws_id=" . Misc::escapeInteger($nws_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -312,7 +312,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "news
                  ORDER BY
                     nws_title ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -345,7 +345,7 @@
                  WHERE
                     prj_id=prn_prj_id AND
                     prn_nws_id=" . Misc::escapeInteger($nws_id);
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
--- include/class.note.php	2009-01-12 23:15:12.038752480 +0200
+++ /usr/share/eventum/include/class.note.php	2009-02-05 02:15:18.627317367 +0200
@@ -27,16 +27,6 @@
 // +----------------------------------------------------------------------+
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.validation.php");
-require_once(APP_INC_PATH . "class.auth.php");
-require_once(APP_INC_PATH . "class.history.php");
-require_once(APP_INC_PATH . "class.user.php");
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.issue.php");
-require_once(APP_INC_PATH . "class.date.php");
-require_once(APP_INC_PATH . "class.draft.php");
-require_once(APP_INC_PATH . "class.authorized_replier.php");
 
 /**
  * Class to handle the business logic related to adding, updating or
@@ -70,7 +60,7 @@
                     not_removed = 0
                  ORDER BY
                     not_created_date ASC";
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -111,14 +101,14 @@
                  WHERE
                     not_usr_id=usr_id AND
                     not_id='$note_id'";
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
         } else {
             if (count($res) > 0) {
-                $res['timestamp'] = Date_API::getUnixTimestamp($res['not_created_date'], 'GMT');
-                $res['not_created_date'] = Date_API::getFormattedDate($res['not_created_date']);
+                $res['timestamp'] = Date_Helper::getUnixTimestamp($res['not_created_date'], 'GMT');
+                $res['not_created_date'] = Date_Helper::getFormattedDate($res['not_created_date']);
                 if ($res['not_is_blocked'] == 1) {
                     $res['has_blocked_message'] = true;
                 } else {
@@ -163,7 +153,7 @@
                     not_iss_id = " . Misc::escapeInteger($issue_id) . "
                 ORDER BY
                     not_created_date ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt,  DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt,  DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -199,7 +189,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "note
                  WHERE
                     not_id=$note_id";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -225,7 +215,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "note
                  WHERE
                     not_id=$note_id";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -257,7 +247,7 @@
                  ORDER BY
                     not_created_date ASC
                 LIMIT " . ($sequence - 1) . ", 1";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -282,7 +272,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "note
                  WHERE
                     not_id=$note_id";
-        $res = $GLOBALS["db_api"]->dbh->getOne($sql);
+        $res = Db_Helper::getInstance()->getOne($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -344,7 +334,7 @@
             return -2;
         }
         if (empty($_POST['message_id'])) {
-            $_POST['message_id'] = Mail_API::generateMessageID();
+            $_POST['message_id'] = Mail_Helper::generateMessageID();
         }
         $stmt = "INSERT INTO
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "note
@@ -374,7 +364,7 @@
                  ) VALUES (
                     $issue_id,
                     $usr_id,
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     '" . Misc::escapeString($_POST["note"]) . "',
                     '" . Misc::escapeString($_POST["title"]) . "'";
         if (!@empty($_POST['full_message'])) {
@@ -395,7 +385,7 @@
         }
         $stmt .= "
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -438,7 +428,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "note
                  WHERE
                     not_iss_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -467,7 +457,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "note
                  WHERE
                     not_id=$note_id";
-        $details = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $details = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (($details['not_usr_id'] != Auth::getUserID()) && ($details['has_blocked_message'] != 1) && (Auth::getCurrentRole() < User::getRoleID("Manager"))) {
             return -2;
         }
@@ -478,7 +468,7 @@
                     not_removed = 1
                  WHERE
                     not_id=$note_id";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -489,7 +479,7 @@
                      WHERE
                         iat_not_id=$note_id AND
                         iat_status='internal'";
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             }
@@ -533,7 +523,7 @@
                     not_removed = 0
                  ORDER BY
                     not_created_date ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -552,7 +542,7 @@
                     $res[$i]["usr_full_name"] = $res[$i]["not_unknown_user"];
                 }
 
-                $res[$i]["not_created_date"] = Date_API::getFormattedDate($res[$i]["not_created_date"]);
+                $res[$i]["not_created_date"] = Date_Helper::getFormattedDate($res[$i]["not_created_date"]);
                 $t[] = $res[$i];
             }
             return $t;
@@ -577,19 +567,19 @@
         $unknown_user = Note::getUnknownUser($note_id);
         $structure = Mime_Helper::decode($blocked_message, true, true);
         $body = $structure->body;
-        $sender_email = strtolower(Mail_API::getEmailAddress($structure->headers['from']));
+        $sender_email = strtolower(Mail_Helper::getEmailAddress($structure->headers['from']));
         if ($target == 'email') {
             if (Mime_Helper::hasAttachments($structure)) {
                 $has_attachments = 1;
             } else {
                 $has_attachments = 0;
             }
-            list($blocked_message, $headers) = Mail_API::rewriteThreadingHeaders($issue_id, $blocked_message, @$structure->headers);
+            list($blocked_message, $headers) = Mail_Helper::rewriteThreadingHeaders($issue_id, $blocked_message, @$structure->headers);
             $t = array(
                 'issue_id'       => $issue_id,
                 'ema_id'         => $email_account_id,
                 'message_id'     => @$structure->headers['message-id'],
-                'date'           => Date_API::getCurrentDateGMT(),
+                'date'           => Date_Helper::getCurrentDateGMT(),
                 'from'           => @$structure->headers['from'],
                 'to'             => @$structure->headers['to'],
                 'cc'             => @$structure->headers['cc'],
@@ -678,7 +668,7 @@
                     not_created_date BETWEEN '$start' AND '$end' AND
                     not_usr_id = $usr_id AND
                     not_removed = 0";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -703,7 +693,7 @@
                     not_has_attachment=1
                  WHERE
                     not_id=$note_id";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -729,7 +719,7 @@
                  WHERE
                     not_iss_id=$issue_id AND
                     not_removed = 0";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return 0;
@@ -755,7 +745,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "note
                  WHERE
                     not_message_id='" . Misc::escapeString($message_id) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -782,7 +772,7 @@
                 WHERE
                     parent.not_id = child.not_parent_id AND
                     child.not_message_id = '" . Misc::escapeString($msg_id) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($sql);
+        $res = Db_Helper::getInstance()->getOne($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -812,7 +802,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "note
                  WHERE
                     not_message_id='" . Misc::escapeString($message_id) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -842,7 +832,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "note
                  WHERE
                     not_id=" . Misc::escapeInteger($id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
--- include/class.notification.php	2009-01-12 23:15:12.082081730 +0200
+++ /usr/share/eventum/include/class.notification.php	2009-02-05 02:15:18.637536613 +0200
@@ -36,20 +36,6 @@
  * @author João Prado Maia <jpm@mysql.com>
  */
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.setup.php");
-require_once(APP_INC_PATH . "class.auth.php");
-require_once(APP_INC_PATH . "class.user.php");
-require_once(APP_INC_PATH . "class.prefs.php");
-require_once(APP_INC_PATH . "class.custom_field.php");
-require_once(APP_INC_PATH . "class.template.php");
-require_once(APP_INC_PATH . "class.mail.php");
-require_once(APP_INC_PATH . "class.date.php");
-require_once(APP_INC_PATH . "class.project.php");
-require_once(APP_INC_PATH . "class.history.php");
-require_once(APP_INC_PATH . "class.issue.php");
-require_once(APP_INC_PATH . "class.priority.php");
 
 class Notification
 {
@@ -64,7 +50,7 @@
      */
     function isSubscribedToEmails($issue_id, $email)
     {
-        $email = strtolower(Mail_API::getEmailAddress($email));
+        $email = strtolower(Mail_Helper::getEmailAddress($email));
         if ($email == '@') {
             // broken address, don't send the email...
             return true;
@@ -113,7 +99,7 @@
         }
         $stmt .= "
                     sub_iss_id=" . Misc::escapeInteger($issue_id);
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -152,11 +138,11 @@
 
             // if no project name, use eventum wide sender name
             if (empty($info['sender_name'])) {
-                $setup_sender_info = Mail_API::getAddressInfo($setup['smtp']['from']);
+                $setup_sender_info = Mail_Helper::getAddressInfo($setup['smtp']['from']);
                 $info['sender_name'] = $setup_sender_info['sender_name'];
             }
         } else {
-            $info = Mail_API::getAddressInfo($sender);
+            $info = Mail_Helper::getAddressInfo($sender);
         }
         // allow flags even without routing enabled
         if (!empty($setup[$routing]['recipient_type_flag'])) {
@@ -200,7 +186,7 @@
                 $info['sender_name'] = '"' . $info['sender_name'] . ' ' . trim($flag) . '"';
             }
         }
-        $from = Mail_API::getFormattedName($info['sender_name'], $from_email);
+        $from = Mail_Helper::getFormattedName($info['sender_name'], $from_email);
 
         return MIME_Helper::encodeAddress(trim($from));
     }
@@ -236,8 +222,8 @@
     function isIssueRoutingSender($issue_id, $sender)
     {
         $check = Notification::getFixedFromHeader($issue_id, $sender, 'issue');
-        $check_email = strtolower(Mail_API::getEmailAddress($check));
-        $sender_email = strtolower(Mail_API::getEmailAddress($sender));
+        $check_email = strtolower(Mail_Helper::getEmailAddress($check));
+        $sender_email = strtolower(Mail_Helper::getEmailAddress($sender));
         if ($check_email == $sender_email) {
             return true;
         } else {
@@ -265,7 +251,7 @@
 
         $full_message = $message['full_email'];
         $sender = $message['from'];
-        $sender_email = strtolower(Mail_API::getEmailAddress($sender));
+        $sender_email = strtolower(Mail_Helper::getEmailAddress($sender));
         $structure = Mime_Helper::decode($full_message, true);
 
         // get ID of whoever is sending this.
@@ -310,7 +296,7 @@
             if (!empty($email)) {
                 // don't send the email to the same person who sent it
                 if ((($sender_usr_id != false) && (!empty($users[$i]["sub_usr_id"])) && ($sender_usr_id == $users[$i]["sub_usr_id"])) ||
-                        (strtolower(Mail_API::getEmailAddress($email)) == $sender_email)) {
+                        (strtolower(Mail_Helper::getEmailAddress($email)) == $sender_email)) {
                     continue;
                 }
                 $emails[] = $email;
@@ -328,7 +314,7 @@
         list($_headers, $body) = Mime_Helper::splitBodyHeader($full_message);
         $header_names = Mime_Helper::getHeaderNames($_headers);
 
-        $current_headers = Mail_API::stripHeaders($message['headers']);
+        $current_headers = Mail_Helper::stripHeaders($message['headers']);
         $headers = array();
         // build the headers array required by the smtp library
         foreach ($current_headers as $header_name => $value) {
@@ -342,7 +328,7 @@
             }
         }
 
-        $headers["Subject"] = Mail_API::formatSubject($issue_id, $headers['Subject']);
+        $headers["Subject"] = Mail_Helper::formatSubject($issue_id, $headers['Subject']);
 
         if (empty($type)) {
             if (($sender_usr_id != false) && (User::getRoleByUser($sender_usr_id, Issue::getProjectID($issue_id)) == User::getRoleID("Customer"))) {
@@ -352,11 +338,10 @@
             }
         }
 
-        @require_once(APP_PEAR_PATH . 'Mail/mime.php');
         foreach ($emails as $to) {
-            $recipient_usr_id = User::getUserIDByEmail(Mail_API::getEmailAddress($to));
+            $recipient_usr_id = User::getUserIDByEmail(Mail_Helper::getEmailAddress($to));
             // add the warning message about replies being blocked or not
-            $fixed_body = Mail_API::addWarningMessage($issue_id, $to, $body, $headers);
+            $fixed_body = Mail_Helper::addWarningMessage($issue_id, $to, $body, $headers);
             $headers['To'] = Mime_Helper::encodeAddress($to);
 
             Mail_Queue::add($to, $headers, $fixed_body, 1, $issue_id, $type, $sender_usr_id, $sup_id);
@@ -415,7 +400,7 @@
                     iss_id=" . Misc::escapeInteger($issue_id) . " AND
                     iss_prj_id=prj_id AND
                     iss_usr_id=usr_id";
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -458,7 +443,7 @@
                  WHERE
                     not_id=" . Misc::escapeInteger($note_id) . " AND
                     not_usr_id=usr_id";
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -504,7 +489,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email
                  WHERE
                     sup_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -543,7 +528,7 @@
                     iat_usr_id=usr_id AND
                     iat_iss_id=" . Misc::escapeInteger($issue_id) . " AND
                     iat_id=" . Misc::escapeInteger($attachment_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -590,7 +575,7 @@
                         sub_id=sbt_sub_id AND
                         sbt_type='" . Misc::escapeString($type) . "'";
         }
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -807,11 +792,11 @@
                             " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                          WHERE
                             iss_id=" . Misc::escapeInteger($issue_id);
-                $customer_contact_id = $GLOBALS["db_api"]->dbh->getOne($stmt);
+                $customer_contact_id = Db_Helper::getInstance()->getOne($stmt);
                 if (!empty($customer_contact_id)) {
                     list($contact_email,,) = Customer::getContactLoginDetails($prj_id, $customer_contact_id);
                     for ($i = 0; $i < count($emails); $i++) {
-                        $email = Mail_API::getEmailAddress($emails[$i]);
+                        $email = Mail_Helper::getEmailAddress($emails[$i]);
                         if ($email == $contact_email) {
                             unset($emails[$i]);
                             $emails = array_values($emails);
@@ -847,7 +832,7 @@
                     } else {
                         $headers['In-Reply-To'] = Issue::getRootMessageID($issue_id);
                     }
-                    $headers['References'] = Mail_API::fold(join(' ', Mail_API::getReferences($issue_id, @$data['note']['reference_msg_id'], 'note')));
+                    $headers['References'] = Mail_Helper::fold(join(' ', Mail_Helper::getReferences($issue_id, @$data['note']['reference_msg_id'], 'note')));
                     $subject = 'Note';
                     break;
                 case 'emails':
@@ -907,7 +892,7 @@
         global $_EVENTUM_LAST_NOTIFIED_LIST;
 
         // open text template
-        $tpl = new Template_API;
+        $tpl = new Template_Helper();
         $tpl->setTemplate('notifications/' . $type . '.tpl.text');
         $tpl->bulkAssign(array(
             "app_title"    => Misc::getToolCaption(),
@@ -918,12 +903,12 @@
         $setup = Setup::load();
         $final_type = $type;
         $sender_usr_id = false;
-        $threading_headers = Mail_API::getBaseThreadingHeaders($issue_id);
+        $threading_headers = Mail_Helper::getBaseThreadingHeaders($issue_id);
         $emails = array_unique($emails);
         for ($i = 0; $i < count($emails); $i++) {
 
             $can_access = true;
-            $recipient_usr_id = User::getUserIDByEmail(Mail_API::getEmailAddress($emails[$i]));
+            $recipient_usr_id = User::getUserIDByEmail(Mail_Helper::getEmailAddress($emails[$i]));
             if (!empty($recipient_usr_id)) {
                 if (!Issue::canAccess($issue_id, $recipient_usr_id)) {
                     $can_access = false;
@@ -954,7 +939,7 @@
             }
 
             // send email (use PEAR's classes)
-            $mail = new Mail_API;
+            $mail = new Mail_Helper;
             $mail->setTextBody($tpl->getTemplateContents());
             if ($headers != false) {
                 $mail->setHeaders($headers);
@@ -974,7 +959,7 @@
                 } else {
                     $sender = User::getFromHeader($data["note"]["not_usr_id"]);
                 }
-                $sender_usr_id = User::getUserIDByEmail(Mail_API::getEmailAddress($sender));
+                $sender_usr_id = User::getUserIDByEmail(Mail_Helper::getEmailAddress($sender));
                 if (empty($sender_usr_id)) {
                     $sender_usr_id = false;
                 }
@@ -1046,11 +1031,11 @@
             $stmt .= " AND
                     usr_id NOT IN (" . join(', ', $exclude_list) . ")";
         }
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         $emails = array();
         for ($i = 0; $i < count($res); $i++) {
             @$res[$i]['usr_preferences'] = unserialize($res[$i]['usr_preferences']);
-            $subscriber = Mail_API::getFormattedName($res[$i]['usr_full_name'], $res[$i]['usr_email']);
+            $subscriber = Mail_Helper::getFormattedName($res[$i]['usr_full_name'], $res[$i]['usr_email']);
             // don't send these emails to customers
             if (($res[$i]['pru_role'] == User::getRoleID('Customer')) || (!empty($res[$i]['usr_customer_id']))
                     || (!empty($res[$i]['usr_customer_contact_id']))) {
@@ -1076,10 +1061,10 @@
                     isu_iss_id=$issue_id AND
                     usr_id=isu_usr_id AND
                     usr_status = 'active'";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         for ($i = 0; $i < count($res); $i++) {
             @$res[$i]['usr_preferences'] = unserialize($res[$i]['usr_preferences']);
-            $subscriber = Mail_API::getFormattedName($res[$i]['usr_full_name'], $res[$i]['usr_email']);
+            $subscriber = Mail_Helper::getFormattedName($res[$i]['usr_full_name'], $res[$i]['usr_email']);
 
             if ((!empty($res[$i]['usr_preferences']['receive_assigned_emails'][$prj_id])) &&
             (@$res[$i]['usr_preferences']['receive_assigned_emails'][$prj_id]) && (!in_array($subscriber, $emails))) {
@@ -1148,26 +1133,26 @@
                 $recipient = $sender;
                 $is_message_sender = true;
             }
-            $recipient_usr_id = User::getUserIDByEmail(Mail_API::getEmailAddress($recipient));
+            $recipient_usr_id = User::getUserIDByEmail(Mail_Helper::getEmailAddress($recipient));
 
-            if (!Workflow::shouldEmailAddress($prj_id, Mail_API::getEmailAddress($recipient), $issue_id, 'auto_created')) {
+            if (!Workflow::shouldEmailAddress($prj_id, Mail_Helper::getEmailAddress($recipient), $issue_id, 'auto_created')) {
                 return;
             }
             $data = Issue::getDetails($issue_id);
 
             // open text template
-            $tpl = new Template_API;
+            $tpl = new Template_Helper();
             $tpl->setTemplate('notifications/new_auto_created_issue.tpl.text');
             $tpl->bulkAssign(array(
                 "app_title"   => Misc::getToolCaption(),
                 "data"        => $data,
-                "sender_name" => Mail_API::getName($sender),
-                'recipient_name'    => Mail_API::getName($recipient),
+                "sender_name" => Mail_Helper::getName($sender),
+                'recipient_name'    => Mail_Helper::getName($recipient),
                 'is_message_sender' =>  $is_message_sender
             ));
 
             // figure out if sender has a real account or not
-            $sender_usr_id = User::getUserIDByEmail(Mail_API::getEmailAddress($sender));
+            $sender_usr_id = User::getUserIDByEmail(Mail_Helper::getEmailAddress($sender));
             if ((!empty($sender_usr_id)) && (Issue::canAccess($issue_id, $sender_usr_id))) {
                 $can_access = 1;
             } else {
@@ -1193,9 +1178,9 @@
             $text_message = $tpl->getTemplateContents();
 
             // send email (use PEAR's classes)
-            $mail = new Mail_API;
+            $mail = new Mail_Helper;
             $mail->setTextBody($text_message);
-            $mail->setHeaders(Mail_API::getBaseThreadingHeaders($issue_id));
+            $mail->setHeaders(Mail_Helper::getBaseThreadingHeaders($issue_id));
             $setup = $mail->getSMTPSettings();
             $from = Notification::getFixedFromHeader($issue_id, $setup["from"], 'issue');
             $recipient = Mime_Helper::fixEncoding($recipient);
@@ -1229,7 +1214,7 @@
             for ($i = 0; $i < count($sup_ids); $i++) {
                 $senders = Support::getSender(array($sup_ids[$i]));
                 if (count($senders) > 0) {
-                    $sender_email = Mail_API::getEmailAddress($senders[0]);
+                    $sender_email = Mail_Helper::getEmailAddress($senders[0]);
                     $recipients[$sup_ids[$i]] = $senders[0];
                     $recipient_emails[] = $sender_email;
                 }
@@ -1241,16 +1226,16 @@
             $data = Issue::getDetails($issue_id);
             foreach ($recipients as $sup_id => $recipient) {
 
-                $recipient_usr_id = User::getUserIDByEmail(Mail_API::getEmailAddress($recipient));
+                $recipient_usr_id = User::getUserIDByEmail(Mail_Helper::getEmailAddress($recipient));
 
                 // open text template
-                $tpl = new Template_API;
+                $tpl = new Template_Helper();
                 $tpl->setTemplate('notifications/new_auto_created_issue.tpl.text');
                 $tpl->bulkAssign(array(
                     "data"        => $data,
-                    "sender_name" => Mail_API::getName($recipient),
+                    "sender_name" => Mail_Helper::getName($recipient),
                     "app_title"   => Misc::getToolCaption(),
-                    'recipient_name'    => Mail_API::getName($recipient),
+                    'recipient_name'    => Mail_Helper::getName($recipient),
                 ));
                 $email_details = Support::getEmailDetails(Email_Account::getAccountByEmail($sup_id), $sup_id);
                 $tpl->assign(array(
@@ -1271,11 +1256,11 @@
                 $text_message = $tpl->getTemplateContents();
 
                 // send email (use PEAR's classes)
-                $mail = new Mail_API;
+                $mail = new Mail_Helper;
                 $mail->setTextBody($text_message);
                 $setup = $mail->getSMTPSettings();
                 $from = Notification::getFixedFromHeader($issue_id, $setup["from"], 'issue');
-                $mail->setHeaders(Mail_API::getBaseThreadingHeaders($issue_id));
+                $mail->setHeaders(Mail_Helper::getBaseThreadingHeaders($issue_id));
                 $mail->send($from, $recipient, "[#$issue_id] Issue Created: " . $data['iss_summary'], 1, $issue_id, 'email_converted_to_issue');
             }
             Language::restore();
@@ -1334,14 +1319,14 @@
         }
         $stmt .= ") VALUES (
                     " . Misc::escapeInteger($project_id) . ",
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     'pending',
                     '" . Misc::escapeString($notice) . "'";
         if ($issue_id != false) {
             $stmt .= ",\n $issue_id";
         }
         $stmt .= ")";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -1364,7 +1349,7 @@
         $info = User::getDetails($usr_id);
         $info["projects"] = Project::getAssocList($usr_id, true, true);
         // open text template
-        $tpl = new Template_API;
+        $tpl = new Template_Helper();
         $tpl->setTemplate('notifications/updated_account.tpl.text');
         $tpl->bulkAssign(array(
             "app_title"    => Misc::getToolCaption(),
@@ -1377,7 +1362,7 @@
         $text_message = $tpl->getTemplateContents();
 
         // send email (use PEAR's classes)
-        $mail = new Mail_API;
+        $mail = new Mail_Helper;
         $mail->setTextBody($text_message);
         $setup = $mail->getSMTPSettings();
         $mail->send($setup["from"], $mail->getFormattedName($info["usr_full_name"], $info["usr_email"]), APP_SHORT_NAME . ": " . ev_gettext("User account information updated"));
@@ -1401,7 +1386,7 @@
         $info["usr_password"] = $password;
         $info["projects"] = Project::getAssocList($usr_id, true, true);
         // open text template
-        $tpl = new Template_API;
+        $tpl = new Template_Helper();
         $tpl->setTemplate('notifications/updated_password.tpl.text');
         $tpl->bulkAssign(array(
             "app_title"    => Misc::getToolCaption(),
@@ -1414,7 +1399,7 @@
         $text_message = $tpl->getTemplateContents();
 
         // send email (use PEAR's classes)
-        $mail = new Mail_API;
+        $mail = new Mail_Helper;
         $mail->setTextBody($text_message);
         $setup = $mail->getSMTPSettings();
         $mail->send($setup["from"], $mail->getFormattedName($info["usr_full_name"], $info["usr_email"]), APP_SHORT_NAME . ": " . ev_gettext("User account password changed"));
@@ -1438,7 +1423,7 @@
         $info["usr_password"] = $password;
         $info["projects"] = Project::getAssocList($usr_id, true, true);
         // open text template
-        $tpl = new Template_API;
+        $tpl = new Template_Helper();
         $tpl->setTemplate('notifications/new_user.tpl.text');
         $tpl->bulkAssign(array(
             "app_title"    => Misc::getToolCaption(),
@@ -1451,7 +1436,7 @@
         $text_message = $tpl->getTemplateContents();
 
         // send email (use PEAR's classes)
-        $mail = new Mail_API;
+        $mail = new Mail_Helper;
         $mail->setTextBody($text_message);
         $setup = $mail->getSMTPSettings();
         $mail->send($setup["from"], $mail->getFormattedName($info["usr_full_name"], $info["usr_email"]), APP_SHORT_NAME . ": " . ev_gettext("New User information"));
@@ -1477,7 +1462,7 @@
             // get issue details
             $issue = Notification::getIssueDetails($issue_id);
             // open text template
-            $tpl = new Template_API;
+            $tpl = new Template_Helper();
             $tpl->setTemplate('notifications/' . $type . '.tpl.text');
             $tpl->bulkAssign(array(
                 "app_title"    => Misc::getToolCaption(),
@@ -1486,7 +1471,7 @@
             ));
 
             for ($i = 0; $i < count($assignees); $i++) {
-                if (!Workflow::shouldEmailAddress($prj_id, Mail_API::getEmailAddress(User::getFromHeader($assignees[$i])))) {
+                if (!Workflow::shouldEmailAddress($prj_id, Mail_Helper::getEmailAddress(User::getFromHeader($assignees[$i])))) {
                     continue;
                 }
 
@@ -1495,9 +1480,9 @@
                 $text_message = $tpl->getTemplateContents();
 
                 // send email (use PEAR's classes)
-                $mail = new Mail_API;
+                $mail = new Mail_Helper;
                 $mail->setTextBody($text_message);
-                $mail->setHeaders(Mail_API::getBaseThreadingHeaders($issue_id));
+                $mail->setHeaders(Mail_Helper::getBaseThreadingHeaders($issue_id));
                 $mail->send(Notification::getFixedFromHeader($issue_id, '', 'issue'), User::getFromHeader($assignees[$i]), "[#$issue_id] $title: " . $issue['iss_summary'], TRUE, $issue_id, $type);
             }
             Language::restore();
@@ -1535,7 +1520,7 @@
         // get issue details
         $issue = Notification::getIssueDetails($issue_id);
         // open text template
-        $tpl = new Template_API;
+        $tpl = new Template_Helper();
         $tpl->setTemplate('notifications/assigned.tpl.text');
         $tpl->bulkAssign(array(
             "app_title"    => Misc::getToolCaption(),
@@ -1545,12 +1530,12 @@
 
         for ($i = 0; $i < count($emails); $i++) {
             $text_message = $tpl->getTemplateContents();
-            Language::set(User::getLang(User::getUserIDByEmail(Mail_API::getEmailAddress($emails[$i]))));
+            Language::set(User::getLang(User::getUserIDByEmail(Mail_Helper::getEmailAddress($emails[$i]))));
 
             // send email (use PEAR's classes)
-            $mail = new Mail_API;
+            $mail = new Mail_Helper;
             $mail->setTextBody($text_message);
-            $mail->setHeaders(Mail_API::getBaseThreadingHeaders($issue_id));
+            $mail->setHeaders(Mail_Helper::getBaseThreadingHeaders($issue_id));
             $mail->send(Notification::getFixedFromHeader($issue_id, '', 'issue'), $emails[$i], "[#$issue_id] New Assignment: " . $issue['iss_summary'], TRUE, $issue_id, 'assignment');
         }
         Language::restore();
@@ -1569,7 +1554,7 @@
         $info = User::getDetails($usr_id);
         $info["projects"] = Project::getAssocList($usr_id, true, true);
         // open text template
-        $tpl = new Template_API;
+        $tpl = new Template_Helper();
         $tpl->setTemplate('notifications/account_details.tpl.text');
         $tpl->bulkAssign(array(
             "app_title"    => Misc::getToolCaption(),
@@ -1580,7 +1565,7 @@
         $text_message = $tpl->getTemplateContents();
 
         // send email (use PEAR's classes)
-        $mail = new Mail_API;
+        $mail = new Mail_Helper;
         $mail->setTextBody($text_message);
         $setup = $mail->getSMTPSettings();
         $mail->send($setup["from"], $mail->getFormattedName($info["usr_full_name"], $info["usr_email"]), APP_SHORT_NAME . ": " . ev_gettext("Your User Account Details"));
@@ -1637,7 +1622,7 @@
             $stmt .= " AND\nsbt_sub_id = sub_id AND
                       sbt_type = '" . Misc::escapeString($type) . "'";
         }
-        $users = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $users = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($users)) {
             Error_Handler::logError(array($users->getMessage(), $users->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -1676,7 +1661,7 @@
             if ($type != false) {
                 $stmt .= " AND\nsbt_type = '" . Misc::escapeString($type) . "'";
             }
-            $emails = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+            $emails = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
             if (PEAR::isError($emails)) {
                 Error_Handler::logError(array($emails->getMessage(), $emails->getDebugInfo()), __FILE__, __LINE__);
                 return array();
@@ -1716,7 +1701,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "subscription
                  WHERE
                     sub_id=" . Misc::escapeInteger($sub_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -1747,7 +1732,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "subscription_type
                  WHERE
                     sbt_sub_id=" . Misc::escapeInteger($sub_id);
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -1775,7 +1760,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "subscription
                  WHERE
                     sub_iss_id=" . Misc::escapeInteger($issue_id);
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -1810,7 +1795,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "subscription
                  WHERE
                     sub_iss_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -1838,7 +1823,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "subscription
                  WHERE
                     sub_id IN (" . implode(", ", $items) . ")";
-        $issue_id = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $issue_id = Db_Helper::getInstance()->getOne($stmt);
 
         for ($i = 0; $i < count($items); $i++) {
             $sub_id = $items[$i];
@@ -1847,12 +1832,12 @@
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "subscription
                      WHERE
                         sub_id=$sub_id";
-            $GLOBALS["db_api"]->dbh->query($stmt);
+            Db_Helper::getInstance()->query($stmt);
             $stmt = "DELETE FROM
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "subscription_type
                      WHERE
                         sbt_sub_id=$sub_id";
-            $GLOBALS["db_api"]->dbh->query($stmt);
+            Db_Helper::getInstance()->query($stmt);
             // need to save a history entry for this
             History::add($issue_id, Auth::getUserID(), History::getTypeID('notification_removed'),
                             ev_gettext('Notification list entry (%1$s) removed by %2$s', $subscriber, User::getFullName(Auth::getUserID())));
@@ -1879,7 +1864,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "subscription
                  WHERE
                     sub_id=" . Misc::escapeInteger($sub_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -1982,7 +1967,7 @@
                  WHERE
                     sub_iss_id=$issue_id AND
                     sub_usr_id=$subscriber_usr_id";
-        $total = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $total = Db_Helper::getInstance()->getOne($stmt);
         if ($total > 0) {
             return -1;
         }
@@ -1997,11 +1982,11 @@
                  ) VALUES (
                     $issue_id,
                     $subscriber_usr_id,
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     'issue',
                     ''
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -2035,7 +2020,7 @@
      */
     function subscribeEmail($usr_id, $issue_id, $form_email, $actions)
     {
-        $form_email = Mail_API::getEmailAddress($form_email);
+        $form_email = Mail_Helper::getEmailAddress($form_email);
         if (!is_string($form_email)) {
             return -1;
         }
@@ -2068,7 +2053,7 @@
                      WHERE
                         sub_iss_id=$issue_id AND
                         sub_email='$email'";
-            $total = $GLOBALS["db_api"]->dbh->getOne($stmt);
+            $total = Db_Helper::getInstance()->getOne($stmt);
             if ($total > 0) {
                 return -1;
             }
@@ -2084,11 +2069,11 @@
                  ) VALUES (
                     $issue_id,
                     0,
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     'issue',
                     '$email'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -2127,7 +2112,7 @@
                     " . Misc::escapeInteger($sub_id) . ",
                     '" . Misc::escapeString($type) . "'
                  )";
-        $GLOBALS["db_api"]->dbh->query($stmt);
+        Db_Helper::getInstance()->query($stmt);
     }
 
 
@@ -2149,9 +2134,9 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "subscription
                  WHERE
                     sub_id=$sub_id";
-        list($issue_id, $usr_id) = $GLOBALS["db_api"]->dbh->getRow($stmt);
+        list($issue_id, $usr_id) = Db_Helper::getInstance()->getRow($stmt);
 
-        $email = strtolower(Mail_API::getEmailAddress($_POST["email"]));
+        $email = strtolower(Mail_Helper::getEmailAddress($_POST["email"]));
         $usr_id = User::getUserIDByEmail($email, true);
         if (!empty($usr_id)) {
             $email = '';
@@ -2179,7 +2164,7 @@
                     sub_usr_id=$usr_id
                  WHERE
                     sub_id=$sub_id";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -2188,7 +2173,7 @@
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "subscription_type
                      WHERE
                         sbt_sub_id=$sub_id";
-            $GLOBALS["db_api"]->dbh->query($stmt);
+            Db_Helper::getInstance()->query($stmt);
             // now add them all again
             for ($i = 0; $i < count($_POST["actions"]); $i++) {
                 Notification::addType($sub_id, $_POST["actions"][$i]);
--- include/class.pager.php	2009-01-12 23:15:12.045423021 +0200
+++ /usr/share/eventum/include/class.pager.php	2009-02-05 02:03:28.854054215 +0200
@@ -29,7 +29,6 @@
 // @(#) $Id: class.pager.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
 
 /**
  * Class to manage paginated links on the frontend pages.
@@ -63,7 +62,7 @@
         }
         // remove any order by clauses
         $stmt = preg_replace("/(.*)(ORDER BY\s+\w+\s+\w+)[,\s+\w+\s+\w+]*(.*)/sei", "'\\1\\3'", $stmt);
-        $rows = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $rows = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($rows)) {
             Error_Handler::logError(array($rows->getMessage(), $rows->getDebugInfo()), __FILE__, __LINE__);
             return 0;
--- include/class.phone_support.php	2009-01-12 23:15:12.082081730 +0200
+++ /usr/share/eventum/include/class.phone_support.php	2009-02-05 02:04:13.597383954 +0200
@@ -29,13 +29,6 @@
 // @(#) $Id: class.phone_support.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.auth.php");
-require_once(APP_INC_PATH . "class.user.php");
-require_once(APP_INC_PATH . "class.history.php");
-require_once(APP_INC_PATH . "class.issue.php");
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.date.php");
 
 /**
  * Class to handle the business logic related to the phone support
@@ -67,7 +60,7 @@
                     " . Misc::escapeInteger($_POST["prj_id"]) . ",
                     '" . Misc::escapeString($_POST["title"]) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -97,7 +90,7 @@
                  WHERE
                     phc_prj_id=" . Misc::escapeInteger($_POST["prj_id"]) . " AND
                     phc_id=" . Misc::escapeInteger($_POST["id"]);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -121,7 +114,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_phone_category
                  WHERE
                     phc_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -146,7 +139,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_phone_category
                  WHERE
                     phc_id=" . Misc::escapeInteger($phc_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -175,7 +168,7 @@
                     phc_prj_id=" . Misc::escapeInteger($prj_id) . "
                  ORDER BY
                     phc_title ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -204,7 +197,7 @@
                     phc_prj_id=" . Misc::escapeInteger($prj_id) . "
                  ORDER BY
                     phc_id ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -229,7 +222,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "phone_support
                  WHERE
                     phs_id=" . Misc::escapeInteger($phs_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -267,7 +260,7 @@
                     phs_iss_id=" .  Misc::escapeInteger($issue_id) . "
                  ORDER BY
                     phs_created_date ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -275,7 +268,7 @@
             for ($i = 0; $i < count($res); $i++) {
                 $res[$i]["phs_description"] = Misc::activateLinks(nl2br(htmlspecialchars($res[$i]["phs_description"])));
                 $res[$i]["phs_description"] = Link_Filter::processText($res[$i]['iss_prj_id'], $res[$i]["phs_description"]);
-                $res[$i]["phs_created_date"] = Date_API::getFormattedDate($res[$i]["phs_created_date"]);
+                $res[$i]["phs_created_date"] = Date_Helper::getFormattedDate($res[$i]["phs_created_date"]);
             }
             return $res;
         }
@@ -298,7 +291,7 @@
             $_POST["date"]["Day"], $_POST["date"]["Hour"],
             $_POST["date"]["Minute"], 0);
         // convert the date to GMT timezone
-        $created_date = Date_API::convertDateGMT($created_date);
+        $created_date = Date_Helper::convertDateGMT($created_date);
         $stmt = "INSERT INTO
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "phone_support
                  (
@@ -328,7 +321,7 @@
                     '" . Misc::escapeString($_POST["to_lname"]) . "',
                     '" . Misc::escapeString($_POST["to_fname"]) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -346,7 +339,7 @@
                      WHERE
                         ttr_iss_id = " . Misc::escapeInteger($_POST["issue_id"]) . " AND
                         ttr_usr_id = $usr_id";
-            $ttr_id = $GLOBALS["db_api"]->dbh->getOne($stmt);
+            $ttr_id = Db_Helper::getInstance()->getOne($stmt);
 
             Issue::markAsUpdated($_POST['issue_id'], 'phone call');
             // need to save a history entry for this
@@ -362,7 +355,7 @@
                             phs_ttr_id = $ttr_id
                          WHERE
                             phs_id = " . Misc::escapeInteger($phs_id);
-                $res = $GLOBALS["db_api"]->dbh->query($stmt);
+                $res = Db_Helper::getInstance()->query($stmt);
                 if (PEAR::isError($res)) {
                     Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                     return -1;
@@ -393,7 +386,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "phone_support
                  WHERE
                     phs_id=$phone_id";
-        $details = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $details = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if ($details['phs_usr_id'] != Auth::getUserID()) {
             return -2;
         }
@@ -402,7 +395,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "phone_support
                  WHERE
                     phs_id=$phone_id";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -441,7 +434,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "phone_support
                  WHERE
                     phs_iss_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -472,7 +465,7 @@
                     iss_prj_id = " . Auth::getCurrentProject() . " AND
                     phs_created_date BETWEEN '" . Misc::escapeString($start) . "' AND '" . Misc::escapeString($end) . "' AND
                     phs_usr_id = " . Misc::escapeInteger($usr_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
--- include/class.prefs.php	2009-01-12 23:15:12.055441962 +0200
+++ /usr/share/eventum/include/class.prefs.php	2009-02-05 02:04:13.597383954 +0200
@@ -29,9 +29,6 @@
 // @(#) $Id: class.prefs.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.user.php");
-require_once(APP_INC_PATH . "class.date.php");
 
 /**
  * Class to handle the business logic related to the user preferences
@@ -55,7 +52,7 @@
         $prefs = array(
             'receive_assigned_emails' => array(),
             'receive_new_emails'      => array(),
-            'timezone'                => Date_API::getDefaultTimezone(),
+            'timezone'                => Date_Helper::getDefaultTimezone(),
             'list_refresh_rate'       => APP_DEFAULT_REFRESH_RATE,
             'emails_refresh_rate'     => APP_DEFAULT_REFRESH_RATE,
             'email_signature'         => '',
@@ -93,7 +90,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user
                  WHERE
                     usr_id=$usr_id";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -144,7 +141,7 @@
                     usr_preferences='" . Misc::escapeString($data) . "'
                  WHERE
                     usr_id=" . Misc::escapeInteger($usr_id);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
--- include/class.priority.php	2009-01-12 23:15:12.089164963 +0200
+++ /usr/share/eventum/include/class.priority.php	2009-02-05 02:03:28.857395632 +0200
@@ -29,9 +29,6 @@
 // @(#) $Id: class.priority.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.validation.php");
 
 /**
  * Class to handle project priority related issues.
@@ -81,7 +78,7 @@
                      WHERE
                         pri_prj_id=" . Misc::escapeInteger($prj_id) . " AND
                         pri_id=" . Misc::escapeInteger($replaced_pri_id);
-            $GLOBALS["db_api"]->dbh->query($stmt);
+            Db_Helper::getInstance()->query($stmt);
         }
         $stmt = "UPDATE
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_priority
@@ -90,7 +87,7 @@
                  WHERE
                     pri_prj_id=" . Misc::escapeInteger($prj_id) . " AND
                     pri_id=" . Misc::escapeInteger($pri_id);
-        $GLOBALS["db_api"]->dbh->query($stmt);
+        Db_Helper::getInstance()->query($stmt);
         return true;
     }
 
@@ -114,7 +111,7 @@
                     pri_prj_id=" . Misc::escapeInteger($prj_id) . "
                  ORDER BY
                     pri_rank ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -139,7 +136,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_priority
                  WHERE
                     pri_id=" . Misc::escapeInteger($pri_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -164,7 +161,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_priority
                  WHERE
                     pri_prj_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -188,7 +185,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_priority
                  WHERE
                     pri_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -219,7 +216,7 @@
                  WHERE
                     pri_prj_id=" . Misc::escapeInteger($_POST["prj_id"]) . " AND
                     pri_id=" . Misc::escapeInteger($_POST["id"]);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -251,7 +248,7 @@
                     '" . Misc::escapeString($_POST["title"]) . "',
                     " . Misc::escapeInteger($_POST['rank']) . "
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -281,7 +278,7 @@
                     pri_prj_id=" . Misc::escapeInteger($prj_id) . "
                  ORDER BY
                     pri_rank ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -306,7 +303,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_priority
                  WHERE
                     pri_id=" . Misc::escapeInteger($pri_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -341,7 +338,7 @@
                     pri_prj_id=" . Misc::escapeInteger($prj_id) . "
                  ORDER BY
                     pri_rank ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -370,7 +367,7 @@
                     pri_prj_id=" . Misc::escapeInteger($prj_id) . "
 					AND pri_title = '" . Misc::escapeString($pri_title) . "'";
 
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return null;
--- include/class.project.php	2009-01-12 23:15:12.082081730 +0200
+++ /usr/share/eventum/include/class.project.php	2009-02-05 02:15:18.643983522 +0200
@@ -29,18 +29,6 @@
 // @(#) $Id: class.project.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.group.php");
-require_once(APP_INC_PATH . "class.validation.php");
-require_once(APP_INC_PATH . "class.date.php");
-require_once(APP_INC_PATH . "class.category.php");
-require_once(APP_INC_PATH . "class.release.php");
-require_once(APP_INC_PATH . "class.filter.php");
-require_once(APP_INC_PATH . "class.support.php");
-require_once(APP_INC_PATH . "class.issue.php");
-require_once(APP_INC_PATH . "class.status.php");
-require_once(APP_INC_PATH . "class.display_column.php");
 
 /**
  * Class to handle the business logic related to the administration
@@ -69,7 +57,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project
                  WHERE
                     prj_id=" . Misc::escapeInteger($prj_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array(
@@ -108,7 +96,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project
                  WHERE
                     prj_id=" . Misc::escapeInteger($prj_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -134,7 +122,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project
                  WHERE
                     prj_id=" . Misc::escapeInteger($prj_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -163,7 +151,7 @@
                     prj_anonymous_post_options='" . Misc::escapeString(@serialize($_POST["options"])) . "'
                  WHERE
                     prj_id=" . Misc::escapeInteger($prj_id);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -191,7 +179,7 @@
                     prj_anonymous_post='enabled'
                  ORDER BY
                     prj_title";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -216,7 +204,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project
                  WHERE
                     prj_id=" . Misc::escapeInteger($prj_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -245,7 +233,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project
                  WHERE
                     prj_title='" . Misc::escapeString($prj_title) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -276,7 +264,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project
                  WHERE
                     prj_id=" . Misc::escapeInteger($prj_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -308,7 +296,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project
                  WHERE
                     prj_id="  . Misc::escapeInteger($prj_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return true;
@@ -339,7 +327,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project
                  WHERE
                     prj_id=" . Misc::escapeInteger($prj_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -364,7 +352,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project
                  WHERE
                     prj_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -405,7 +393,7 @@
         if ($users_to_not_remove != false) {
             $stmt .= " AND\n pru_usr_id NOT IN(" . join(', ', Misc::escapeInteger($users_to_not_remove)) . ")";
         }
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -442,7 +430,7 @@
                     prj_workflow_backend='" . Misc::escapeString($_POST["workflow_backend"]) . "'
                  WHERE
                     prj_id=" . Misc::escapeInteger($_POST["id"]);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -490,7 +478,7 @@
                 WHERE
                     pru_prj_id = $prj_id AND
                     pru_usr_id = $usr_id";
-        $res = $GLOBALS["db_api"]->dbh->getOne($sql);
+        $res = Db_Helper::getInstance()->getOne($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -507,7 +495,7 @@
                             $prj_id,
                             " . Misc::escapeInteger($role) . "
                          )";
-                $res = $GLOBALS["db_api"]->dbh->query($stmt);
+                $res = Db_Helper::getInstance()->query($stmt);
                 if (PEAR::isError($res)) {
                     Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                     return false;
@@ -546,7 +534,7 @@
                     prj_customer_backend,
                     prj_workflow_backend
                  ) VALUES (
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     '" . Misc::escapeString($_POST["title"]) . "',
                     '" . Misc::escapeString($_POST["status"]) . "',
                     " . Misc::escapeInteger($_POST["lead_usr_id"]) . ",
@@ -558,7 +546,7 @@
                     '" . Misc::escapeString($_POST["customer_backend"]) . "',
                     '" . Misc::escapeString($_POST["workflow_backend"]) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -603,7 +591,7 @@
                     prj_lead_usr_id=usr_id
                  ORDER BY
                     prj_title";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -647,9 +635,9 @@
                  ORDER BY
                     prj_title";
         if ($include_role) {
-            $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt, true, array(), DB_FETCHMODE_ASSOC);
+            $res = Db_Helper::getInstance()->getAssoc($stmt, true, array(), DB_FETCHMODE_ASSOC);
         } else {
-            $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+            $res = Db_Helper::getInstance()->getAssoc($stmt);
         }
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
@@ -696,7 +684,7 @@
         $stmt .= "
                  ORDER BY
                     usr_full_name ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -726,7 +714,7 @@
                     pru_usr_id=usr_id
                  ORDER BY
                     usr_full_name ASC";
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -757,7 +745,7 @@
         $stmt .= "
                  ORDER BY
                     prj_title";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -781,7 +769,7 @@
         $list = Project::getAddressBook($prj_id, $issue_id);
         $emails = array();
         foreach ($list as $address => $name) {
-            $emails[] = Mail_API::getEmailAddress($address);
+            $emails[] = Mail_Helper::getEmailAddress($address);
         }
         return $emails;
     }
@@ -854,7 +842,7 @@
                  ORDER BY
                     usr_customer_id DESC,
                     usr_full_name ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -882,7 +870,7 @@
                     prj_remote_invocation='enabled'
                  ORDER BY
                     prj_title";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -925,7 +913,7 @@
         $stmt .= "
                  ORDER BY
                     prj_title";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -973,7 +961,7 @@
         $stmt .= "
                  ORDER BY
                     usr_email ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -1009,7 +997,7 @@
                     usr_id = iss_usr_id
                  ORDER BY
                     usr_full_name ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -1034,7 +1022,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_field_display
                  WHERE
                     pfd_prj_id = " . Misc::escapeInteger($prj_id);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1053,7 +1041,7 @@
                         '" . Misc::escapeString($field) . "',
                         " . Misc::escapeInteger($min_role) . "
                      )";
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return -1;
@@ -1079,7 +1067,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_field_display
                  WHERE
                     pfd_prj_id = " . Misc::escapeInteger($prj_id);
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
--- include/class.release.php	2009-01-12 23:15:12.075834288 +0200
+++ /usr/share/eventum/include/class.release.php	2009-02-05 02:03:28.864057652 +0200
@@ -29,9 +29,6 @@
 // @(#) $Id: class.release.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.validation.php");
 
 /**
  * Class to handle the business logic related to the administration
@@ -59,7 +56,7 @@
                  WHERE
                     pre_id=" . Misc::escapeInteger($pre_id) . " AND
                     pre_status='available'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -90,7 +87,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_release
                  WHERE
                     pre_id=" . Misc::escapeInteger($pre_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -115,7 +112,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_release
                  WHERE
                     pre_id=" . Misc::escapeInteger($pre_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -140,7 +137,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_release
                  WHERE
                     pre_prj_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -167,7 +164,7 @@
                     iss_pre_id=0
                  WHERE
                     iss_pre_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -176,7 +173,7 @@
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_release
                      WHERE
                         pre_id IN ($items)";
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return false;
@@ -209,7 +206,7 @@
                  WHERE
                     pre_prj_id=" . Misc::escapeInteger($_POST["prj_id"]) . " AND
                     pre_id=" . Misc::escapeInteger($_POST["id"]);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -245,7 +242,7 @@
                     '" . Misc::escapeString($scheduled_date) . "',
                     '" . Misc::escapeString($_POST["status"]) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -276,7 +273,7 @@
                     pre_prj_id=" . Misc::escapeInteger($prj_id) . "
                  ORDER BY
                     pre_scheduled_date ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -314,7 +311,7 @@
                     )
                  ORDER BY
                     pre_scheduled_date ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
--- include/class.reminder_action.php	2009-01-12 23:15:12.068965748 +0200
+++ /usr/share/eventum/include/class.reminder_action.php	2009-02-05 02:15:18.647322564 +0200
@@ -29,14 +29,6 @@
 // @(#) $Id: class.reminder_action.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.reminder_condition.php");
-require_once(APP_INC_PATH . "class.notification.php");
-require_once(APP_INC_PATH . "class.user.php");
-require_once(APP_INC_PATH . "class.group.php");
-require_once(APP_INC_PATH . "class.mail.php");
-require_once(APP_INC_PATH . "class.issue.php");
-require_once(APP_INC_PATH . "class.validation.php");
 
 /**
  * Class to handle the business logic related to the reminder emails
@@ -87,7 +79,7 @@
                         rma_rank=" . Misc::escapeInteger($ranking[$rma_id]) . "
                      WHERE
                         rma_id=" . Misc::escapeInteger($replaced_rma_id);
-            $GLOBALS["db_api"]->dbh->query($stmt);
+            Db_Helper::getInstance()->query($stmt);
         }
         $stmt = "UPDATE
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_action
@@ -95,7 +87,7 @@
                     rma_rank=" . Misc::escapeInteger($new_rank) . "
                  WHERE
                     rma_id=" . Misc::escapeInteger($rma_id);
-        $GLOBALS["db_api"]->dbh->query($stmt);
+        Db_Helper::getInstance()->query($stmt);
         return true;
     }
 
@@ -119,7 +111,7 @@
                     rma_rem_id = " . Misc::escapeInteger($rem_id) . "
                  ORDER BY
                     rma_rank ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -144,7 +136,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_action
                  WHERE
                     rma_id=" . Misc::escapeInteger($rma_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -169,7 +161,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_action
                  WHERE
                     rma_id=" . Misc::escapeInteger($rma_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -205,14 +197,14 @@
                  ) VALUES (
                     " . Misc::escapeInteger($_POST['rem_id']) . ",
                     " . Misc::escapeInteger($_POST['type']) . ",
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     '" . Misc::escapeString($_POST['title']) . "',
                     '" . Misc::escapeInteger($_POST['rank']) . "',
                     " . Misc::escapeInteger($_POST['alert_irc']) . ",
                     " . Misc::escapeInteger($_POST['alert_group_leader']) . ",
                     '" . Misc::escapeString($_POST['boilerplate']) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -244,7 +236,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_action_list
                  WHERE
                     ral_rma_id=" . Misc::escapeInteger($rma_id);
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -292,7 +284,7 @@
                         " . Misc::escapeInteger($usr_id) . ",
                         '" . Misc::escapeString($email) . "'
                      )";
-            $GLOBALS["db_api"]->dbh->query($stmt);
+            Db_Helper::getInstance()->query($stmt);
         }
     }
 
@@ -308,7 +300,7 @@
         $stmt = "UPDATE
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_action
                  SET
-                    rma_last_updated_date='" . Date_API::getCurrentDateGMT() . "',
+                    rma_last_updated_date='" . Date_Helper::getCurrentDateGMT() . "',
                     rma_rank='" . Misc::escapeInteger($_POST['rank']) . "',
                     rma_title='" . Misc::escapeString($_POST['title']) . "',
                     rma_rmt_id=" . Misc::escapeInteger($_POST['type']) . ",
@@ -317,7 +309,7 @@
                     rma_boilerplate='" . Misc::escapeString($_POST['boilerplate']) . "'
                  WHERE
                     rma_id=" . Misc::escapeInteger($_POST['id']);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -349,7 +341,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_action_type
                  WHERE
                     rmt_id=" . Misc::escapeInteger($rmt_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -384,7 +376,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_action_list
                  WHERE
                     ral_rma_id IN ($items)";
-        $GLOBALS["db_api"]->dbh->query($stmt);
+        Db_Helper::getInstance()->query($stmt);
     }
 
 
@@ -402,17 +394,17 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_action
                  WHERE
                     rma_id IN ($items)";
-        $GLOBALS["db_api"]->dbh->query($stmt);
+        Db_Helper::getInstance()->query($stmt);
         $stmt = "DELETE FROM
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_history
                  WHERE
                     rmh_rma_id IN ($items)";
-        $GLOBALS["db_api"]->dbh->query($stmt);
+        Db_Helper::getInstance()->query($stmt);
         $stmt = "DELETE FROM
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_level_condition
                  WHERE
                     rlc_rma_id IN ($items)";
-        $GLOBALS["db_api"]->dbh->query($stmt);
+        Db_Helper::getInstance()->query($stmt);
         Reminder_Action::clearActionUserList($action_ids);
     }
 
@@ -432,7 +424,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_action_type
                  ORDER BY
                     rmt_title ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -468,7 +460,7 @@
                     rma_rem_id=" . Misc::escapeInteger($rem_id) . "
                  ORDER BY
                     rma_rank ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -505,7 +497,7 @@
                     rma_rem_id=" . Misc::escapeInteger($reminder_id) . "
                  ORDER BY
                     rma_rank ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -534,7 +526,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_action_type
                  WHERE
                     rmt_id=" . Misc::escapeInteger($rmt_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -564,9 +556,9 @@
                  ) VALUES (
                     " . Misc::escapeInteger($issue_id) . ",
                     " . Misc::escapeInteger($rma_id) . ",
-                    '" . Date_API::getCurrentDateGMT() . "'
+                    '" . Date_Helper::getCurrentDateGMT() . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -744,7 +736,7 @@
                     $to = array_merge($to, $addresses);
                 }
             }
-            $tpl = new Template_API;
+            $tpl = new Template_Helper();
             $tpl->setTemplate('reminders/' . $type . '_alert.tpl.text');
             $tpl->bulkAssign(array(
                 "data"                     => $data,
@@ -756,7 +748,7 @@
             $text_message = $tpl->getTemplateContents();
             foreach ($to as $address) {
                 // send email (use PEAR's classes)
-                $mail = new Mail_API;
+                $mail = new Mail_Helper;
                 $mail->setTextBody($text_message);
                 $setup = $mail->getSMTPSettings();
                 $mail->send($setup["from"], $address, "[#$issue_id] " . ev_gettext("Reminder") . ": " . $action['rma_title'], 0, $issue_id, 'reminder');
@@ -783,7 +775,7 @@
     {
         $to = Reminder::_getReminderAlertAddresses();
         if (count($to) > 0) {
-            $tpl = new Template_API;
+            $tpl = new Template_Helper();
             $tpl->setTemplate('reminders/alert_no_recipients.tpl.text');
             $tpl->bulkAssign(array(
                 "type"                     => $type,
@@ -796,7 +788,7 @@
             $text_message = $tpl->getTemplateContents();
             foreach ($to as $address) {
                 // send email (use PEAR's classes)
-                $mail = new Mail_API;
+                $mail = new Mail_Helper;
                 $mail->setTextBody($text_message);
                 $setup = $mail->getSMTPSettings();
                 $mail->send($setup["from"], $address, "[#$issue_id] " . ev_gettext("Reminder Not Triggered") . ": " . $action['rma_title'], 0, $issue_id);
@@ -827,7 +819,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_triggered_action
                  WHERE
                     rta_iss_id IN (" . implode(', ', Misc::escapeInteger($issues)) . ")";
-        $triggered_actions = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $triggered_actions = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($triggered_actions)) {
             Error_Handler::logError(array($triggered_actions->getMessage(), $triggered_actions->getDebugInfo()), __FILE__, __LINE__);
             return $issues;
@@ -864,7 +856,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_triggered_action
                  WHERE
                     rta_iss_id=$issue_id";
-        $total = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $total = Db_Helper::getInstance()->getOne($stmt);
         if ($total == 1) {
             $stmt = "UPDATE
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_triggered_action
@@ -883,7 +875,7 @@
                         $rma_id
                      )";
         }
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -906,7 +898,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_triggered_action
                  WHERE
                     rta_iss_id=" . Misc::escapeInteger($issue_id);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
--- include/class.reminder_condition.php	2009-01-12 23:15:12.085433204 +0200
+++ /usr/share/eventum/include/class.reminder_condition.php	2009-02-05 02:04:13.614052693 +0200
@@ -29,8 +29,6 @@
 // @(#) $Id: class.reminder_condition.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.status.php");
 
 /**
  * Class to handle the business logic related to the reminder emails
@@ -57,7 +55,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_level_condition
                  WHERE
                     rlc_id=" . Misc::escapeInteger($rlc_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -85,14 +83,14 @@
                     rlc_value,
                     rlc_comparison_rmf_id
                  ) VALUES (
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     " . Misc::escapeInteger($_POST['rma_id']) . ",
                     " . Misc::escapeInteger($_POST['field']) . ",
                     " . Misc::escapeInteger($_POST['operator']) . ",
                     '" . Misc::escapeString(@$_POST['value']) . "',
                     '" . Misc::escapeInteger(@$_POST['comparison_field']) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -113,14 +111,14 @@
         $stmt = "UPDATE
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_level_condition
                  SET
-                    rlc_last_updated_date='" . Date_API::getCurrentDateGMT() . "',
+                    rlc_last_updated_date='" . Date_Helper::getCurrentDateGMT() . "',
                     rlc_rmf_id=" . Misc::escapeInteger($_POST['field']) . ",
                     rlc_rmo_id=" . Misc::escapeInteger($_POST['operator']) . ",
                     rlc_value='" . Misc::escapeString(@$_POST['value']) . "',
                     rlc_comparison_rmf_id = '" . Misc::escapeInteger(@$_POST['comparison_field']) . "'
                  WHERE
                     rlc_id=" . Misc::escapeInteger($_POST['id']);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -144,7 +142,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_level_condition
                  WHERE
                     rlc_id IN ($items)";
-        $GLOBALS["db_api"]->dbh->query($stmt);
+        Db_Helper::getInstance()->query($stmt);
     }
 
 
@@ -168,7 +166,7 @@
                     rlc_rma_id=" . Misc::escapeInteger($action_id) . " AND
                     rlc_rmf_id=rmf_id AND
                     rlc_rmo_id=rmo_id";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -208,7 +206,7 @@
                     rlc_rma_id=" . Misc::escapeInteger($rma_id) . "
                  ORDER BY
                     rlc_id ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -244,7 +242,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_field
                  WHERE
                     rmf_id=" . Misc::escapeInteger($field_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -269,7 +267,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_field
                  WHERE
                     rmf_id=" . Misc::escapeInteger($field_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -299,7 +297,7 @@
         }
         $stmt .= "ORDER BY
                     rmf_title ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -325,7 +323,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_operator
                  ORDER BY
                     rmo_title ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -350,7 +348,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_field
                  WHERE
                     rmf_id=" . Misc::escapeInteger($field_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
--- include/class.reminder.php	2009-01-12 23:15:12.049164418 +0200
+++ /usr/share/eventum/include/class.reminder.php	2009-02-05 02:04:13.608840787 +0200
@@ -29,9 +29,6 @@
 // @(#) $Id: class.reminder.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.reminder_action.php");
-require_once(APP_INC_PATH . "class.priority.php");
 
 /**
  * Class to handle the business logic related to the reminder emails
@@ -95,7 +92,7 @@
                         rem_rank=" . Misc::escapeInteger($ranking[$rem_id]) . "
                      WHERE
                         rem_id=" . Misc::escapeInteger($replaced_rem_id);
-            $GLOBALS["db_api"]->dbh->query($stmt);
+            Db_Helper::getInstance()->query($stmt);
         }
         $stmt = "UPDATE
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_level
@@ -103,7 +100,7 @@
                     rem_rank=" . Misc::escapeInteger($new_rank) . "
                  WHERE
                     rem_id=" . Misc::escapeInteger($rem_id);
-        $GLOBALS["db_api"]->dbh->query($stmt);
+        Db_Helper::getInstance()->query($stmt);
         return true;
     }
 
@@ -124,7 +121,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_level
                  ORDER BY
                     rem_rank ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -167,7 +164,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_level
                  WHERE
                     rem_id=" . Misc::escapeInteger($rem_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -192,7 +189,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_level
                  WHERE
                     rem_id=" . Misc::escapeInteger($rem_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -217,7 +214,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_level
                  WHERE
                     rem_id=" . Misc::escapeInteger($rem_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -259,7 +256,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_priority
                  WHERE
                     rep_rem_id=" . Misc::escapeInteger($rem_id);
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -289,7 +286,7 @@
                     " . Misc::escapeInteger($rem_id) . ",
                     " . Misc::escapeInteger($support_level_id) . "
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -318,7 +315,7 @@
                     " . Misc::escapeInteger($rem_id) . ",
                     " . Misc::escapeInteger($issue_id) . "
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -348,7 +345,7 @@
                     " . Misc::escapeInteger($rem_id) . ",
                     " . Misc::escapeInteger($customer_id) . "
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -376,7 +373,7 @@
                     " . Misc::escapeInteger($rem_id) . ",
                     1
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -405,7 +402,7 @@
                     " . Misc::escapeInteger($rem_id) . ",
                     " . Misc::escapeInteger($priority_id) . "
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -432,12 +429,12 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_requirement
                  WHERE
                     rer_rem_id IN (" . implode(',', $rem_id) . ")";
-        $GLOBALS["db_api"]->dbh->query($stmt);
+        Db_Helper::getInstance()->query($stmt);
         $stmt = "DELETE FROM
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_priority
                  WHERE
                     rep_rem_id IN (" . implode(',', $rem_id) . ")";
-        $GLOBALS["db_api"]->dbh->query($stmt);
+        Db_Helper::getInstance()->query($stmt);
     }
 
 
@@ -458,13 +455,13 @@
                     rem_prj_id,
                     rem_skip_weekend
                  ) VALUES (
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     " . Misc::escapeInteger($_POST['rank']) . ",
                     '" . Misc::escapeString($_POST['title']) . "',
                     " . Misc::escapeInteger($_POST['project']) . ",
                     " . Misc::escapeInteger($_POST['skip_weekend']) . "
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -507,14 +504,14 @@
         $stmt = "UPDATE
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_level
                  SET
-                    rem_last_updated_date='" . Date_API::getCurrentDateGMT() . "',
+                    rem_last_updated_date='" . Date_Helper::getCurrentDateGMT() . "',
                     rem_rank=" . Misc::escapeInteger($_POST['rank']) . ",
                     rem_title='" . Misc::escapeString($_POST['title']) . "',
                     rem_prj_id=" . Misc::escapeInteger($_POST['project']) . ",
                     rem_skip_weekend=" . Misc::escapeInteger($_POST['skip_weekend']) . "
                  WHERE
                     rem_id=" . Misc::escapeInteger($_POST['id']);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -560,7 +557,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_level
                  WHERE
                     rem_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -572,7 +569,7 @@
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_action
                      WHERE
                         rma_rem_id IN ($items)";
-            $actions = $GLOBALS["db_api"]->dbh->getCol($stmt);
+            $actions = Db_Helper::getInstance()->getCol($stmt);
             if (count($actions) > 0) {
                 Reminder_Action::remove($actions);
             }
@@ -600,7 +597,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_requirement
                  WHERE
                     rer_rem_id=" . Misc::escapeInteger($rem_id);
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -648,13 +645,13 @@
                     rem_prj_id=prj_id
                  ORDER BY
                     rem_rank ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
         } else {
             for ($i = 0; $i < count($res); $i++) {
-                $res[$i]['rem_created_date'] = Date_API::getFormattedDate($res[$i]["rem_created_date"]);
+                $res[$i]['rem_created_date'] = Date_Helper::getFormattedDate($res[$i]["rem_created_date"]);
                 $actions = Reminder_Action::getList($res[$i]['rem_id']);
                 $res[$i]['total_actions'] = count($actions);
                 $priorities = Reminder::getAssociatedPriorities($res[$i]['rem_id']);
@@ -689,7 +686,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_level
                  ORDER BY
                     rem_rank ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -731,8 +728,8 @@
         $stmt .= Reminder::getWhereClause($reminder, $conditions);
         $stmt .= ' AND iss_trigger_reminders=1 ';
         // can't rely on the mysql server's timezone setting, so let's use gmt dates throughout
-        $stmt = str_replace('UNIX_TIMESTAMP()', "UNIX_TIMESTAMP('" . Date_API::getCurrentDateGMT() . "')", $stmt);
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $stmt = str_replace('UNIX_TIMESTAMP()', "UNIX_TIMESTAMP('" . Date_Helper::getCurrentDateGMT() . "')", $stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -801,7 +798,7 @@
                         $conditions[$i]['rlc_value'] = $conditions[$i]['rlc_value'] * 60 * 60;
                         if (@$reminder["rem_skip_weekend"] == 1) {
                             $sql_field = Reminder_Condition::getSQLField($conditions[$i]['rlc_rmf_id']);
-                            $conditions[$i]['rmf_sql_representation'] = DB_API::getNoWeekendDateDiffSQL($sql_field);
+                            $conditions[$i]['rmf_sql_representation'] = DB_Helper::getNoWeekendDateDiffSQL($sql_field);
                         }
                     }
                 }
@@ -834,7 +831,7 @@
                     " . APP_TABLE_PREFIX . "issue";
         $stmt .= Reminder::getWhereClause($reminder, $conditions);
         // can't rely on the mysql server's timezone setting, so let's use gmt dates throughout
-        $stmt = str_replace('UNIX_TIMESTAMP()', "UNIX_TIMESTAMP('" . Date_API::getCurrentDateGMT() . "')", $stmt);
+        $stmt = str_replace('UNIX_TIMESTAMP()', "UNIX_TIMESTAMP('" . Date_Helper::getCurrentDateGMT() . "')", $stmt);
         return $stmt;
     }
 
@@ -860,13 +857,13 @@
                     rmh_rma_id=rma_id
                  ORDER BY
                     rmh_created_date DESC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
         } else {
             for ($i = 0; $i < count($res); $i++) {
-                $res[$i]["rmh_created_date"] = Date_API::getFormattedDate($res[$i]["rmh_created_date"]);
+                $res[$i]["rmh_created_date"] = Date_Helper::getFormattedDate($res[$i]["rmh_created_date"]);
             }
             return $res;
         }
--- include/class.report.php	2009-01-13 20:28:10.187782176 +0200
+++ /usr/share/eventum/include/class.report.php	2009-02-05 02:04:13.620733709 +0200
@@ -29,15 +29,6 @@
 // @(#) $Id: class.report.php 3803 2009-01-13 18:28:04Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.user.php");
-require_once(APP_INC_PATH . "class.date.php");
-require_once(APP_INC_PATH . "class.status.php");
-require_once(APP_INC_PATH . "class.history.php");
-require_once(APP_INC_PATH . "class.phone_support.php");
-require_once(APP_INC_PATH . "class.prefs.php");
-require_once(APP_PEAR_PATH . "Math/Stats.php");
 
 /**
  * Class to handle the business logic related to all aspects of the
@@ -61,7 +52,7 @@
     function getStalledIssuesByUser($prj_id, $users, $status, $before_date, $after_date, $sort_order)
     {
         $prj_id = Misc::escapeInteger($prj_id);
-        $ts = Date_API::getCurrentUnixTimestampGMT();
+        $ts = Date_Helper::getCurrentUnixTimestampGMT();
         $before_ts = strtotime($before_date);
         $after_ts = strtotime($after_date);
 
@@ -115,7 +106,7 @@
                  ORDER BY
                     usr_full_name,
                     iss_last_response_date " . Misc::escapeString($sort_order);
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -132,12 +123,12 @@
                 $issues[$res[$i]['usr_full_name']][$res[$i]['iss_id']] = array(
                     'iss_summary'         => $res[$i]['iss_summary'],
                     'sta_title'           => $res[$i]['sta_title'],
-                    'iss_created_date'    => Date_API::getFormattedDate($res[$i]['iss_created_date']),
-                    'iss_last_response_date'    => Date_API::getFormattedDate($res[$i]['iss_last_response_date']),
+                    'iss_created_date'    => Date_Helper::getFormattedDate($res[$i]['iss_created_date']),
+                    'iss_last_response_date'    => Date_Helper::getFormattedDate($res[$i]['iss_last_response_date']),
                     'time_spent'          => Misc::getFormattedTime($res[$i]['time_spent']),
                     'status_color'        => $res[$i]['sta_color'],
-                    'last_update'         => Date_API::getFormattedDateDiff($ts, Date_API::getUnixTimestamp($res[$i]['iss_updated_date'], Date_API::getDefaultTimezone())),
-                    'last_email_response' => Date_API::getFormattedDateDiff($ts, Date_API::getUnixTimestamp($res[$i]['iss_last_response_date'], Date_API::getDefaultTimezone()))
+                    'last_update'         => Date_Helper::getFormattedDateDiff($ts, Date_Helper::getUnixTimestamp($res[$i]['iss_updated_date'], Date_Helper::getDefaultTimezone())),
+                    'last_email_response' => Date_Helper::getFormattedDateDiff($ts, Date_Helper::getUnixTimestamp($res[$i]['iss_last_response_date'], Date_Helper::getDefaultTimezone()))
                 );
             }
             return $issues;
@@ -156,7 +147,7 @@
     {
         $prj_id = Misc::escapeInteger($prj_id);
         $cutoff_days = Misc::escapeInteger($cutoff_days);
-        $ts = Date_API::getCurrentUnixTimestampGMT();
+        $ts = Date_Helper::getCurrentUnixTimestampGMT();
         $ts_diff = $cutoff_days * DAY;
 
 
@@ -195,7 +186,7 @@
         } else {
             $stmt .= "assignee.usr_full_name";
         }
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             print_r($res);
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
@@ -218,11 +209,11 @@
                 $issues[$name][$res[$i]['iss_id']] = array(
                     'iss_summary'         => $res[$i]['iss_summary'],
                     'sta_title'           => $res[$i]['sta_title'],
-                    'iss_created_date'    => Date_API::getFormattedDate($res[$i]['iss_created_date']),
+                    'iss_created_date'    => Date_Helper::getFormattedDate($res[$i]['iss_created_date']),
                     'time_spent'          => Misc::getFormattedTime($res[$i]['time_spent']),
                     'status_color'        => $res[$i]['sta_color'],
-                    'last_update'         => Date_API::getFormattedDateDiff($ts, Date_API::getUnixTimestamp($res[$i]['iss_updated_date'], Date_API::getDefaultTimezone())),
-                    'last_email_response' => Date_API::getFormattedDateDiff($ts, Date_API::getUnixTimestamp($res[$i]['iss_last_response_date'], Date_API::getDefaultTimezone()))
+                    'last_update'         => Date_Helper::getFormattedDateDiff($ts, Date_Helper::getUnixTimestamp($res[$i]['iss_updated_date'], Date_Helper::getDefaultTimezone())),
+                    'last_email_response' => Date_Helper::getFormattedDateDiff($ts, Date_Helper::getUnixTimestamp($res[$i]['iss_last_response_date'], Date_Helper::getDefaultTimezone()))
                 );
             }
             return $issues;
@@ -264,7 +255,7 @@
                     isu_usr_id=usr_id
                  ORDER BY
                     usr_full_name";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -275,7 +266,7 @@
                 $issues[$res[$i]['usr_full_name']][$res[$i]['iss_id']] = array(
                     'iss_summary'      => $res[$i]['iss_summary'],
                     'sta_title'        => $res[$i]['sta_title'],
-                    'iss_created_date' => Date_API::getFormattedDate($res[$i]['iss_created_date']),
+                    'iss_created_date' => Date_Helper::getFormattedDate($res[$i]['iss_created_date']),
                     'time_spent'       => Misc::getFormattedTime($res[$i]['time_spent']),
                     'status_color'     => $res[$i]['sta_color']
                 );
@@ -345,7 +336,7 @@
                     isu_usr_id = $usr_id AND
                     iss_prj_id = " . Auth::getCurrentProject() . " AND
                     isu_assigned_date BETWEEN '$start_ts' AND '$end_ts'";
-        $newly_assigned = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $newly_assigned = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($newly_assigned)) {
             Error_Handler::logError(array($newly_assigned->getMessage(), $newly_assigned->getDebugInfo()), __FILE__, __LINE__);
         }
@@ -409,7 +400,7 @@
                     time_period, performer
                  ORDER BY
                     time_period";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -487,7 +478,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email
                  GROUP BY
                     time_period";
-        $total = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $total = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($total)) {
             Error_Handler::logError(array($total->getMessage(), $total->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -510,7 +501,7 @@
                     sup_from IN('" . join("','", $emails) . "')
                  GROUP BY
                     time_period";
-        $dev_stats = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $dev_stats = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($dev_stats)) {
             Error_Handler::logError(array($dev_stats->getMessage(), $dev_stats->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -697,7 +688,7 @@
             }
             $sql .= "
                         row_count DESC";
-            $res = $GLOBALS["db_api"]->dbh->getAll($sql, DB_FETCHMODE_ASSOC);
+            $res = Db_Helper::getInstance()->getAll($sql, DB_FETCHMODE_ASSOC);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return array();
@@ -752,7 +743,7 @@
                         $label_field ASC";
                 $res = $GLOBALS['db_api']->dbh->getAssoc($stmt);
             } else {
-                $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+                $res = Db_Helper::getInstance()->getOne($stmt);
             }
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
@@ -773,7 +764,7 @@
                     icf_iss_id = iss_id AND
                     icf_fld_id = $fld_id AND
                     cfo_id NOT IN(" . join(",", $cfo_ids) . ")";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -853,7 +844,7 @@
         if (!empty($order_by)) {
             $stmt .= "\nORDER BY " . sprintf($order_by, 'iss_created_date');
         }
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -907,7 +898,7 @@
         if (!empty($order_by)) {
             $stmt .= "\nORDER BY " . sprintf($order_by, 'sup_date');
         }
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
--- include/class.resolution.php	2009-01-12 23:15:12.082081730 +0200
+++ /usr/share/eventum/include/class.resolution.php	2009-02-05 02:04:13.620733709 +0200
@@ -29,8 +29,6 @@
 // @(#) $Id: class.resolution.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.misc.php");
 
 /**
  * Class to handle the business logic related to the administration
@@ -57,7 +55,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "resolution
                  WHERE
                     res_id=" . Misc::escapeInteger($res_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -84,7 +82,7 @@
                     iss_res_id=0
                  WHERE
                     iss_res_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -93,7 +91,7 @@
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "resolution
                      WHERE
                         res_id IN ($items)";
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return false;
@@ -122,7 +120,7 @@
                     res_title='" . Misc::escapeString($_POST["title"]) . "'
                  WHERE
                     res_id=" . Misc::escapeInteger($_POST["id"]);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -147,7 +145,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "resolution
                  WHERE
                     res_id=" . Misc::escapeInteger($res_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -172,7 +170,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "resolution
                  ORDER BY
                     res_title ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -198,7 +196,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "resolution
                  ORDER BY
                     res_id ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -227,9 +225,9 @@
                     res_created_date
                  ) VALUES (
                     '" . Misc::escapeString($_POST["title"]) . "',
-                    '" . Date_API::getCurrentDateGMT() . "'
+                    '" . Date_Helper::getCurrentDateGMT() . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
--- include/class.round_robin.php	2009-01-12 23:15:12.059166108 +0200
+++ /usr/share/eventum/include/class.round_robin.php	2009-02-05 02:04:13.624053894 +0200
@@ -29,8 +29,6 @@
 // @(#) $Id: class.round_robin.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . 'class.date.php');
-require_once(APP_INC_PATH . 'class.error_handler.php');
 
 class Round_Robin
 {
@@ -57,11 +55,11 @@
         // if start is PM and end is PM (and end is bigger than start), then use only today
         // if start is PM and end is AM, then use today and tomorrow
         //   - if date is between zero and the end, then use yesterday and today
-        if ((Date_API::isAM($start)) && (Date_API::isPM($end))) {
+        if ((Date_Helper::isAM($start)) && (Date_Helper::isPM($end))) {
             $first = 0;
             $second = 0;
         }
-        if ((Date_API::isAM($start)) && (Date_API::isAM($end)) && ($end < $start)) {
+        if ((Date_Helper::isAM($start)) && (Date_Helper::isAM($end)) && ($end < $start)) {
             if (($user->getHour() >= 0) && ($user->getHour() <= $end)) {
                 $first = -DAY;
                 $second = 0;
@@ -70,11 +68,11 @@
                 $second = DAY;
             }
         }
-        if ((Date_API::isAM($start)) && (Date_API::isAM($end)) && ($end > $start)) {
+        if ((Date_Helper::isAM($start)) && (Date_Helper::isAM($end)) && ($end > $start)) {
             $first = 0;
             $second = 0;
         }
-        if ((Date_API::isPM($start)) && (Date_API::isPM($end)) && ($end < $start)) {
+        if ((Date_Helper::isPM($start)) && (Date_Helper::isPM($end)) && ($end < $start)) {
             if (($user->getHour() >= 0) && ($user->getHour() <= $end)) {
                 $first = -DAY;
                 $second = 0;
@@ -83,11 +81,11 @@
                 $second = DAY;
             }
         }
-        if ((Date_API::isPM($start)) && (Date_API::isPM($end)) && ($end > $start)) {
+        if ((Date_Helper::isPM($start)) && (Date_Helper::isPM($end)) && ($end > $start)) {
             $first = 0;
             $second = 0;
         }
-        if ((Date_API::isPM($start)) && (Date_API::isAM($end))) {
+        if ((Date_Helper::isPM($start)) && (Date_Helper::isAM($end))) {
             if (($user->getHour() >= 0) && ($user->getHour() <= $end)) {
                 $first = -DAY;
                 $second = 0;
@@ -135,7 +133,7 @@
             $ignored_users = 0;
             // check the blackout hours
             do {
-                $user = new Date(Date_API::getCurrentUnixTimestampGMT());
+                $user = new Date(Date_Helper::getCurrentUnixTimestampGMT());
                 $user->convertTZById($users[$next_usr_id]['timezone']);
                 list($today, $tomorrow) = Round_Robin::getBlackoutDates($user, $blackout_start, $blackout_end);
                 $first = new Date($today . ' ' . $blackout_start);
@@ -200,7 +198,7 @@
                     rru_next=0
                  WHERE
                     rru_prr_id=$prr_id";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -212,7 +210,7 @@
                      WHERE
                         rru_usr_id=" . Misc::escapeInteger($usr_id) . " AND
                         rru_prr_id=$prr_id";
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return false;
@@ -238,7 +236,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_round_robin
                  WHERE
                     prr_prj_id=" . Misc::escapeInteger($prj_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -274,7 +272,7 @@
                     rru_usr_id=usr_id
                  ORDER BY
                     usr_id ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -321,7 +319,7 @@
                     '" . Misc::escapeString($blackout_start) . "',
                     '" . Misc::escapeString($blackout_end) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -357,7 +355,7 @@
                     " . Misc::escapeInteger($usr_id) . ",
                     0
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -386,7 +384,7 @@
                     prr_prj_id=prj_id
                  ORDER BY
                     prj_title ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -421,7 +419,7 @@
                     rru_prr_id=" . Misc::escapeInteger($prr_id) . "
                  ORDER BY
                     usr_id ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -446,7 +444,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_round_robin
                  WHERE
                     prr_id=" . Misc::escapeInteger($prr_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -476,7 +474,7 @@
                     prr_blackout_end='" . Misc::escapeString($blackout_end) . "'
                  WHERE
                     prr_id=" . Misc::escapeInteger($_POST["id"]);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -509,7 +507,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "round_robin_user
                  WHERE
                     rru_prr_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -532,7 +530,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_round_robin
                  WHERE
                     prr_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
--- include/class.routing.php	2009-01-12 23:15:12.062088686 +0200
+++ /usr/share/eventum/include/class.routing.php	2009-02-05 02:15:18.650649872 +0200
@@ -27,19 +27,6 @@
 // +----------------------------------------------------------------------+
 //
 
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.mail.php");
-require_once(APP_INC_PATH . "class.support.php");
-require_once(APP_INC_PATH . "class.issue.php");
-require_once(APP_INC_PATH . "class.mime_helper.php");
-require_once(APP_INC_PATH . "class.date.php");
-require_once(APP_INC_PATH . "class.setup.php");
-require_once(APP_INC_PATH . "class.notification.php");
-require_once(APP_INC_PATH . "class.user.php");
-require_once(APP_INC_PATH . "class.note.php");
-require_once(APP_INC_PATH . "class.project.php");
-require_once(APP_INC_PATH . "class.status.php");
-require_once(APP_INC_PATH . "class.history.php");
 
 /**
  * Class to handle all routing functionality
@@ -135,13 +122,13 @@
         Mime_Helper::parse_output($structure, $parts);
 
         // get the sender's email address
-        $sender_email = strtolower(Mail_API::getEmailAddress($structure->headers['from']));
+        $sender_email = strtolower(Mail_Helper::getEmailAddress($structure->headers['from']));
 
         // strip out the warning message sent to staff users
         if (($setup['email_routing']['status'] == 'enabled') &&
                 ($setup['email_routing']['warning']['status'] == 'enabled')) {
-            $full_message = Mail_API::stripWarningMessage($full_message);
-            $body = Mail_API::stripWarningMessage($body);
+            $full_message = Mail_Helper::stripWarningMessage($full_message);
+            $body = Mail_Helper::stripWarningMessage($body);
         }
 
         $prj_id = Issue::getProjectID($issue_id);
@@ -157,7 +144,7 @@
         if ((!empty($structure->headers['cc'])) && (@$setup['smtp']['save_outgoing_email'] == 'yes')) {
             $ccs = explode(",", @$structure->headers['cc']);
             for ($i = 0; $i < count($ccs); $i++) {
-                if (Mail_API::getEmailAddress($ccs[$i]) == $setup['smtp']['save_address']) {
+                if (Mail_Helper::getEmailAddress($ccs[$i]) == $setup['smtp']['save_address']) {
                     unset($ccs[$i]);
                 }
             }
@@ -165,13 +152,13 @@
         }
 
         // Remove excess Re's
-        @$structure->headers['subject'] = Mail_API::removeExcessRe(@$structure->headers['subject'], true);
+        @$structure->headers['subject'] = Mail_Helper::removeExcessRe(@$structure->headers['subject'], true);
 
         $t = array(
             'issue_id'       => $issue_id,
             'ema_id'         => $email_account_id,
             'message_id'     => @$structure->headers['message-id'],
-            'date'           => Date_API::getCurrentDateGMT(),
+            'date'           => Date_Helper::getCurrentDateGMT(),
             'from'           => @$structure->headers['from'],
             'to'             => @$structure->headers['to'],
             'cc'             => @$structure->headers['cc'],
@@ -199,7 +186,7 @@
         }
 
         // re-write Threading headers if needed
-        list($t['full_email'], $t['headers']) = Mail_API::rewriteThreadingHeaders($t['issue_id'], $t['full_email'], $t['headers'], "email");
+        list($t['full_email'], $t['headers']) = Mail_Helper::rewriteThreadingHeaders($t['issue_id'], $t['full_email'], $t['headers'], "email");
         $res = Support::insertEmail($t, $structure, $sup_id);
         if ($res != -1) {
             Support::extractAttachments($issue_id, $structure);
@@ -215,7 +202,7 @@
             }
             Notification::notifyNewEmail(Auth::getUserID(), $issue_id, $t, $internal_only, $assignee_only, '', $sup_id);
             // try to get usr_id of sender, if not, use system account
-            $usr_id = User::getUserIDByEmail(Mail_API::getEmailAddress($structure->headers['from']));
+            $usr_id = User::getUserIDByEmail(Mail_Helper::getEmailAddress($structure->headers['from']));
             if (!$usr_id) {
                 $usr_id = APP_SYSTEM_USER_ID;
             }
@@ -296,7 +283,7 @@
 
         $prj_id = Issue::getProjectID($issue_id);
         // check if the sender is allowed in this issue' project and if it is an internal user
-        $sender_usr_id = User::getUserIDByEmail(strtolower(Mail_API::getEmailAddress($structure->headers['from'])), true);
+        $sender_usr_id = User::getUserIDByEmail(strtolower(Mail_Helper::getEmailAddress($structure->headers['from'])), true);
         if ((empty($sender_usr_id)) || (User::getRoleByUser($sender_usr_id, $prj_id) < User::getRoleID('Standard User'))) {
             return array(77, ev_gettext("Error: The sender of this email is not allowed in the project associated with issue #$issue_id.") . "\n");
         }
@@ -305,11 +292,11 @@
 
         // parse the Cc: list, if any, and add these internal users to the issue notification list
         $addresses = array();
-        $to_addresses = Mail_API::getEmailAddresses(@$structure->headers['to']);
+        $to_addresses = Mail_Helper::getEmailAddresses(@$structure->headers['to']);
         if (count($to_addresses)) {
             $addresses = $to_addresses;
         }
-        $cc_addresses = Mail_API::getEmailAddresses(@$structure->headers['cc']);
+        $cc_addresses = Mail_Helper::getEmailAddresses(@$structure->headers['cc']);
         if (count($cc_addresses)) {
             $addresses = array_merge($addresses, $cc_addresses);
         }
@@ -322,7 +309,7 @@
         }
 
         $body = $structure->body;
-        $reference_msg_id = Mail_API::getReferenceMessageID($headers);
+        $reference_msg_id = Mail_Helper::getReferenceMessageID($headers);
         if (!empty($reference_msg_id)) {
             $parent_id = Note::getIDByMessageID($reference_msg_id);
         } else {
@@ -413,7 +400,7 @@
 
         $prj_id = Issue::getProjectID($issue_id);
         // check if the sender is allowed in this issue' project and if it is an internal user
-        $sender_usr_id = User::getUserIDByEmail(strtolower(Mail_API::getEmailAddress($structure->headers['from'])), true);
+        $sender_usr_id = User::getUserIDByEmail(strtolower(Mail_Helper::getEmailAddress($structure->headers['from'])), true);
         if (!empty($sender_usr_id)) {
             $sender_role = User::getRoleByUser($sender_usr_id, $prj_id);
             if ($sender_role < User::getRoleID('Standard User')) {
--- include/class.scm.php	2009-01-12 23:15:12.059166108 +0200
+++ /usr/share/eventum/include/class.scm.php	2009-02-05 02:04:13.627392307 +0200
@@ -29,14 +29,6 @@
 // @(#) $Id: class.scm.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.issue.php");
-require_once(APP_INC_PATH . "class.auth.php");
-require_once(APP_INC_PATH . "class.user.php");
-require_once(APP_INC_PATH . "class.history.php");
-require_once(APP_INC_PATH . "class.date.php");
-require_once(APP_INC_PATH . "class.setup.php");
 
 /**
  * Class to handle the business logic related to the source control management
@@ -62,7 +54,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_checkin
                  WHERE
                     isc_iss_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -87,13 +79,13 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_checkin
                  WHERE
                     isc_id IN ($items)";
-        $issue_id = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $issue_id = Db_Helper::getInstance()->getOne($stmt);
 
         $stmt = "DELETE FROM
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_checkin
                  WHERE
                     isc_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -153,7 +145,7 @@
                     isc_iss_id=" . Misc::escapeInteger($issue_id) . "
                  ORDER BY
                     isc_created_date ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -172,7 +164,7 @@
             $res[$i]["checkout_url"] = SCM::parseURL($setup["checkout_url"], $res[$i]);
             $res[$i]["diff_url"] = SCM::parseURL($setup["diff_url"], $res[$i]);
             $res[$i]["scm_log_url"] = SCM::parseURL($setup["scm_log_url"], $res[$i]);
-            $res[$i]["isc_created_date"] = Date_API::getFormattedDate($res[$i]["isc_created_date"]);
+            $res[$i]["isc_created_date"] = Date_Helper::getFormattedDate($res[$i]["isc_created_date"]);
         }
         return $res;
     }
@@ -205,11 +197,11 @@
                     '" . Misc::escapeString($_GET["files"][$i]) . "',
                     '" . Misc::escapeString($_GET["old_versions"][$i]) . "',
                     '" . Misc::escapeString($_GET["new_versions"][$i]) . "',
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     '" . Misc::escapeString($_GET["username"]) . "',
                     '" . Misc::escapeString($_GET["commit_msg"]) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
--- include/class.search_profile.php	2009-01-12 23:15:12.042086912 +0200
+++ /usr/share/eventum/include/class.search_profile.php	2009-02-05 02:03:28.887392531 +0200
@@ -29,8 +29,6 @@
 // @(#) $Id: class.search_profile.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.misc.php");
 
 
 class Search_Profile
@@ -53,7 +51,7 @@
                     sep_usr_id=" . Misc::escapeInteger($usr_id) . " AND
                     sep_prj_id=" . Misc::escapeInteger($prj_id) . " AND
                     sep_type='" . Misc::escapeString($type) . "'";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -89,7 +87,7 @@
                     sep_usr_id=" . Misc::escapeInteger($usr_id) . " AND
                     sep_prj_id=" . Misc::escapeInteger($prj_id) . " AND
                     sep_type='" . Misc::escapeString($type) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -124,7 +122,7 @@
                     sep_usr_id=" . Misc::escapeInteger($usr_id) . " AND
                     sep_prj_id=" . Misc::escapeInteger($prj_id) . " AND
                     sep_type='" . Misc::escapeString($type) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -185,7 +183,7 @@
                     '" . Misc::escapeString($type) . "',
                     '" . Misc::escapeString(serialize($profile)) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -216,7 +214,7 @@
                     sep_usr_id=" . Misc::escapeInteger($usr_id) . " AND
                     sep_prj_id=" . Misc::escapeInteger($prj_id) . " AND
                     sep_type='" . Misc::escapeString($type) . "'";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
--- include/class.session.php	2009-01-12 23:15:12.089164963 +0200
+++ /usr/share/eventum/include/class.session.php	2009-02-05 01:39:37.144199052 +0200
@@ -29,8 +29,6 @@
 // @(#) $Id: class.session.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.setup.php");
 
 /**
  * Wrapper class for sessions. This is an initial bare bones implementation.
--- include/class.stats.php	2009-01-12 23:15:12.065832249 +0200
+++ /usr/share/eventum/include/class.stats.php	2009-02-05 02:03:28.890723611 +0200
@@ -29,14 +29,6 @@
 // @(#) $Id: class.stats.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.auth.php");
-require_once(APP_INC_PATH . "class.release.php");
-require_once(APP_INC_PATH . "class.priority.php");
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.user.php");
-require_once(APP_INC_PATH . "class.project.php");
-require_once(APP_INC_PATH . "class.status.php");
 
 /**
  * Class to handle the business logic related to the generation of the
@@ -110,7 +102,7 @@
                 $stmt .= " AND
                         sta_is_closed = 0";
             }
-            $res = (integer) $GLOBALS["db_api"]->dbh->getOne($stmt);
+            $res = (integer) Db_Helper::getInstance()->getOne($stmt);
             if ($res > 0) {
                 $stats[$prc_title] = $res;
             }
@@ -147,7 +139,7 @@
                 $stmt .= " AND
                         sta_is_closed = 0";
             }
-            $res = (integer) $GLOBALS["db_api"]->dbh->getOne($stmt);
+            $res = (integer) Db_Helper::getInstance()->getOne($stmt);
             if ($res > 0) {
                 $stats[$pre_title] = $res;
             }
@@ -184,7 +176,7 @@
                 $stmt .= " AND
                         sta_is_closed = 0";
             }
-            $res = (integer) $GLOBALS["db_api"]->dbh->getOne($stmt);
+            $res = (integer) Db_Helper::getInstance()->getOne($stmt);
             if ($res > 0) {
                 $stats[$sta_title] = $res;
             }
@@ -224,7 +216,7 @@
                     iss_sta_id
                  ORDER BY
                     total_items DESC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -267,7 +259,7 @@
                     iss_prc_id
                  ORDER BY
                     total_open_items";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -310,7 +302,7 @@
                     iss_pre_id
                  ORDER BY
                     total_open_items DESC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -347,7 +339,7 @@
                 $stmt .= " AND
                         sta_is_closed = 0";
             }
-            $res = (integer) $GLOBALS["db_api"]->dbh->getOne($stmt);
+            $res = (integer) Db_Helper::getInstance()->getOne($stmt);
             if ($res > 0) {
                 $stats[$pri_title] = $res;
             }
@@ -390,7 +382,7 @@
                     iss_pri_id
                  ORDER BY
                     total_open_items DESC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -429,7 +421,7 @@
                 $stmt .= " AND
                         sta_is_closed = 0";
             }
-            $res = (integer) $GLOBALS["db_api"]->dbh->getOne($stmt);
+            $res = (integer) Db_Helper::getInstance()->getOne($stmt);
             if ($res > 0) {
                 $stats[$usr_full_name] = $res;
             }
@@ -474,7 +466,7 @@
                     isu_usr_id
                  ORDER BY
                     total_open_items DESC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -506,7 +498,7 @@
                     sup_removed=0
                  GROUP BY
                     type";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -526,7 +518,7 @@
                     sup_ema_id=ema_id AND
                     ema_prj_id=$prj_id AND
                     sup_removed=1";
-        $res3 = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res3 = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res3)) {
             Error_Handler::logError(array($res3->getMessage(), $res3->getDebugInfo()), __FILE__, __LINE__);
             return "";
--- include/class.status.php	2009-01-12 23:15:12.078747298 +0200
+++ /usr/share/eventum/include/class.status.php	2009-02-05 02:03:28.894056716 +0200
@@ -29,7 +29,6 @@
 // @(#) $Id: class.status.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
 
 /**
  * Class to handle all business logic related to the way statuses
@@ -62,7 +61,7 @@
                  WHERE
                     psd_prj_id=" . Misc::escapeInteger($prj_id) . " AND
                     psd_sta_id IN (" . implode(', ', Misc::escapeInteger($sta_ids)) . ")";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -87,7 +86,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_status_date
                  WHERE
                     psd_id=" . Misc::escapeInteger($psd_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -111,7 +110,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_status_date
                  WHERE
                     psd_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -143,7 +142,7 @@
                     psd_label='" . Misc::escapeString($label) . "'
                  WHERE
                     psd_id=" . Misc::escapeInteger($psd_id);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -178,7 +177,7 @@
                     '" . Misc::escapeString($date_field) . "',
                     '" . Misc::escapeString($label) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -213,7 +212,7 @@
                     sta_id=psd_sta_id
                  ORDER BY
                     prj_title ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -242,7 +241,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status
                  WHERE
                     sta_id=" . Misc::escapeInteger($sta_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -282,7 +281,7 @@
                     '" . Misc::escapeString($_POST['color']) . "',
                     " . Misc::escapeInteger($_POST['is_closed']) . "
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -318,7 +317,7 @@
                     sta_is_closed=" . Misc::escapeInteger($_POST['is_closed']) . "
                  WHERE
                     sta_id=" . Misc::escapeInteger($_POST["id"]);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -345,7 +344,7 @@
                          WHERE
                             iss_sta_id=" . Misc::escapeInteger($_POST['id']) . " AND
                             iss_prj_id IN (" . implode(', ', $removed_projects) . ")";
-                $res = $GLOBALS["db_api"]->dbh->query($stmt);
+                $res = Db_Helper::getInstance()->query($stmt);
                 if (PEAR::isError($res)) {
                     Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 }
@@ -368,7 +367,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status
                  WHERE
                     sta_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -381,7 +380,7 @@
                         iss_sta_id=0
                      WHERE
                         iss_sta_id IN ($items)";
-            $GLOBALS["db_api"]->dbh->query($stmt);
+            Db_Helper::getInstance()->query($stmt);
             return true;
         }
     }
@@ -406,7 +405,7 @@
                     " . Misc::escapeInteger($sta_id) . ",
                     " . Misc::escapeInteger($prj_id) . "
                  )";
-        $GLOBALS["db_api"]->dbh->query($stmt);
+        Db_Helper::getInstance()->query($stmt);
     }
 
 
@@ -432,7 +431,7 @@
         if ($prj_id) {
             $stmt .= " AND prs_prj_id=" . Misc::escapeInteger($prj_id);
         }
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -457,7 +456,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status
                  WHERE
                     sta_id=" . Misc::escapeInteger($sta_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -484,7 +483,7 @@
                  ORDER BY
                     sta_rank ASC,
                     sta_title";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -517,7 +516,7 @@
                  WHERE
                     prj_id=prs_prj_id AND
                     prs_sta_id=" . Misc::escapeInteger($sta_id);
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -548,7 +547,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status
                  WHERE
                     sta_title='" . Misc::escapeString($sta_title) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -574,7 +573,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status
                  WHERE
                     sta_id=" . Misc::escapeInteger($sta_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -610,7 +609,7 @@
                     sta_is_closed=1
                  ORDER BY
                     sta_rank ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -650,7 +649,7 @@
         $stmt .= "
                  ORDER BY
                     sta_rank ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -690,7 +689,7 @@
         $stmt .= "
                  ORDER BY
                     sta_rank ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -716,7 +715,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status
                  ORDER BY
                     sta_rank ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -749,7 +748,7 @@
                     sta_is_closed=1
                  ORDER BY
                     sta_rank ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -774,7 +773,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status
                  ORDER BY
                     sta_rank ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
--- include/class.support.php	2009-01-18 23:08:52.000000000 +0200
+++ /usr/share/eventum/include/class.support.php	2009-02-05 02:15:18.663988299 +0200
@@ -27,20 +27,6 @@
 // +----------------------------------------------------------------------+
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.auth.php");
-require_once(APP_INC_PATH . "class.user.php");
-require_once(APP_INC_PATH . "class.pager.php");
-require_once(APP_INC_PATH . "class.mail.php");
-require_once(APP_INC_PATH . "class.note.php");
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.mime_helper.php");
-require_once(APP_INC_PATH . "class.date.php");
-require_once(APP_INC_PATH . "class.history.php");
-require_once(APP_INC_PATH . "class.issue.php");
-require_once(APP_INC_PATH . "class.email_account.php");
-require_once(APP_INC_PATH . "class.search_profile.php");
-require_once(APP_INC_PATH . "class.routing.php");
 
 /**
  * Class to handle the business logic related to the email feature of
@@ -72,7 +58,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email
                  WHERE
                     sup_id IN (" . implode(', ', Misc::escapeInteger($sup_ids)) . ")";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -124,7 +110,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email
                  WHERE
                     sup_id=" . Misc::escapeInteger($sup_id);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -133,7 +119,7 @@
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email_body
                      WHERE
                         seb_sup_id=" . Misc::escapeInteger($sup_id);
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return false;
@@ -175,7 +161,7 @@
         $stmt .= "
                  ORDER BY
                     " . $options["sort_by"] . " " . $options["sort_order"];
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -223,7 +209,7 @@
                     sup_iss_id=" . Misc::escapeInteger($issue_id) . "
                  ORDER BY
                     sup_id ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -284,7 +270,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email
                  WHERE
                     sup_id IN (" . implode(", ", Misc::escapeInteger($sup_ids)) . ")";
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -326,7 +312,7 @@
                     sup_removed=0
                  WHERE
                     sup_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -357,13 +343,13 @@
                     ema_prj_id=" . Auth::getCurrentProject() . " AND
                     ema_id=sup_ema_id AND
                     sup_removed=1";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
         } else {
             for ($i = 0; $i < count($res); $i++) {
-                $res[$i]["sup_date"] = Date_API::getFormattedDate($res[$i]["sup_date"]);
+                $res[$i]["sup_date"] = Date_Helper::getFormattedDate($res[$i]["sup_date"]);
                 $res[$i]["sup_subject"] = Mime_Helper::fixEncoding($res[$i]["sup_subject"]);
                 $res[$i]["sup_from"] = Mime_Helper::fixEncoding($res[$i]["sup_from"]);
             }
@@ -390,7 +376,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email
                  WHERE
                     sup_ema_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -467,7 +453,7 @@
     function bounceMessage($message, $error)
     {
         // open text template
-        $tpl = new Template_API;
+        $tpl = new Template_Helper();
         $tpl->setTemplate('notifications/bounced_email.tpl.text');
         $tpl->bulkAssign(array(
             'error_code'        => $error[0],
@@ -479,7 +465,7 @@
             'cc'                => Mime_Helper::fixEncoding(@$message->ccaddress),
         ));
 
-        $sender_email = Mail_API::getEmailAddress($message->fromaddress);
+        $sender_email = Mail_Helper::getEmailAddress($message->fromaddress);
         $usr_id = User::getUserIDByEmail($sender_email);
         // change the current locale
         if ($usr_id) {
@@ -489,7 +475,7 @@
         $text_message = $tpl->getTemplateContents();
 
         // send email (use PEAR's classes)
-        $mail = new Mail_API;
+        $mail = new Mail_Helper;
         $mail->setTextBody($text_message);
         $setup = $mail->getSMTPSettings();
         $mail->send($setup['from'], $sender_email,
@@ -532,7 +518,7 @@
             // XXX do some error reporting?
             return;
         }
-        $message_id = Mail_API::getMessageID($headers, $body);
+        $message_id = Mail_Helper::getMessageID($headers, $body);
         $message = $headers . $body;
         // we don't need $body anymore -- free memory
         unset($body);
@@ -551,7 +537,7 @@
         }
         // we can't trust the in-reply-to from the imap c-client, so let's
         // try to manually parse that value from the full headers
-        $reference_msg_id = Mail_API::getReferenceMessageID($headers);
+        $reference_msg_id = Mail_Helper::getReferenceMessageID($headers);
 
         // pass in $email by reference so it can be modified
         $workflow = Workflow::preEmailDownload($info['ema_prj_id'], $info, $mbox, $num, $message, $email, $structure);
@@ -643,7 +629,7 @@
             return;
         }
 
-        $sender_email = Mail_API::getEmailAddress($email->fromaddress);
+        $sender_email = Mail_Helper::getEmailAddress($email->fromaddress);
         if (PEAR::isError($sender_email)) {
             $sender_email = 'Error Parsing Email <>';
         }
@@ -651,7 +637,7 @@
         $t = array(
             'ema_id'         => $info['ema_id'],
             'message_id'     => $message_id,
-            'date'           => Date_API::convertDateGMTByTS($email->udate),
+            'date'           => Date_Helper::convertDateGMTByTS($email->udate),
             'from'           => $sender_email,
             'to'             => @$email->toaddress,
             'cc'             => @$email->ccaddress,
@@ -706,11 +692,11 @@
                         $users = array_flip($users);
 
                         $addresses = array();
-                        $to_addresses = Mail_API::getEmailAddresses(@$structure->headers['to']);
+                        $to_addresses = Mail_Helper::getEmailAddresses(@$structure->headers['to']);
                         if (count($to_addresses)) {
                             $addresses = $to_addresses;
                         }
-                        $cc_addresses = Mail_API::getEmailAddresses(@$structure->headers['cc']);
+                        $cc_addresses = Mail_Helper::getEmailAddresses(@$structure->headers['cc']);
                         if (count($cc_addresses)) {
                             $addresses = array_merge($addresses, $cc_addresses);
                         }
@@ -723,7 +709,7 @@
 
                         // XXX FIXME, this is not nice thing to do
                         $_POST = array(
-                            'title'                => Mail_API::removeExcessRe($t['subject']),
+                            'title'                => Mail_Helper::removeExcessRe($t['subject']),
                             'note'                 => $t['body'],
                             'note_cc'              => $cc_users,
                             'add_extra_recipients' => 'yes',
@@ -738,7 +724,7 @@
             // check if we need to block this email
             if (($should_create_issue == true) || (!Support::blockEmailIfNeeded($t))) {
                 if (!empty($t['issue_id'])) {
-                    list($t['full_email'], $t['headers']) = Mail_API::rewriteThreadingHeaders($t['issue_id'], $t['full_email'], $t['headers'], 'email');
+                    list($t['full_email'], $t['headers']) = Mail_Helper::rewriteThreadingHeaders($t['issue_id'], $t['full_email'], $t['headers'], 'email');
                 }
 
                 // make variable available for workflow to be able to detect whether this email created new issue
@@ -771,7 +757,7 @@
                         Notification::notifyNewEmail(Auth::getUserID(), $t['issue_id'], $t, $internal_only, $assignee_only, '', $sup_id);
 
                         // try to get usr_id of sender, if not, use system account
-                        $addr = Mail_API::getEmailAddress($structure->headers['from']);
+                        $addr = Mail_Helper::getEmailAddress($structure->headers['from']);
                         if (PEAR::isError($addr)) {
                             // XXX should we log or is this expected?
                             Error_Handler::logError(array($addr->getMessage()." addr: $addr", $addr->getDebugInfo()), __FILE__, __LINE__);
@@ -840,9 +826,9 @@
 
         // we can't trust the in-reply-to from the imap c-client, so let's
         // try to manually parse that value from the full headers
-        $references = Mail_API::getAllReferences($headers);
+        $references = Mail_Helper::getAllReferences($headers);
 
-        $message_id = Mail_API::getMessageID($headers, $message_body);
+        $message_id = Mail_Helper::getMessageID($headers, $message_body);
         $workflow = Workflow::getIssueIDforNewEmail($info['ema_prj_id'], $info, $headers, $message_body, $date, $from, $subject, $to, $cc);
         if ($workflow == 'new') {
             $should_create_issue = true;
@@ -909,7 +895,7 @@
             }
         }
 
-        $sender_email = Mail_API::getEmailAddress($from);
+        $sender_email = Mail_Helper::getEmailAddress($from);
         if (PEAR::isError($sender_email)) {
             $sender_email = 'Error Parsing Email <>';
         }
@@ -949,7 +935,7 @@
             array_push($addresses_not_too_add, $project_details['prj_outgoing_sender_email']);
 
             if (!empty($to)) {
-                $to_addresses = Mail_API::getAddressInfo($to, true);
+                $to_addresses = Mail_Helper::getAddressInfo($to, true);
                 foreach ($to_addresses as $address) {
                     if ((in_array($address['email'], $addresses_not_too_add)) || (!Workflow::shouldEmailAddress($prj_id, $address['email']) ||
                             (!Workflow::shouldAutoAddToNotificationList($prj_id)))) {
@@ -958,14 +944,14 @@
                     if (empty($address['sender_name'])) {
                         $recipient = $address['email'];
                     } else {
-                        $recipient = Mail_API::getFormattedName($address['sender_name'], $address['email']);
+                        $recipient = Mail_Helper::getFormattedName($address['sender_name'], $address['email']);
                     }
                     Notification::subscribeEmail(Auth::getUserID(), $issue_id, $address['email'], Notification::getDefaultActions($issue_id, $recipient, 'issue_from_email'));
                     Notification::notifyAutoCreatedIssue($prj_id, $issue_id, $from, $date, $subject, $recipient);
                 }
             }
             if (!empty($cc)) {
-                $cc_addresses = Mail_API::getAddressInfo($cc, true);
+                $cc_addresses = Mail_Helper::getAddressInfo($cc, true);
                 foreach ($cc_addresses as $address) {
                     if ((in_array($address['email'], $addresses_not_too_add)) || (!Workflow::shouldEmailAddress($prj_id, $address['email']) ||
                             (!Workflow::shouldAutoAddToNotificationList($prj_id)))) {
@@ -974,7 +960,7 @@
                     if (empty($address['sender_name'])) {
                         $recipient = $address['email'];
                     } else {
-                        $recipient = Mail_API::getFormattedName($address['sender_name'], $address['email']);
+                        $recipient = Mail_Helper::getFormattedName($address['sender_name'], $address['email']);
                     }
                     Notification::subscribeEmail(Auth::getUserID(), $issue_id, $address['email'], Notification::getDefaultActions($issue_id, $recipient, 'issue_from_email'));
                     Notification::notifyAutoCreatedIssue($prj_id, $issue_id, $from, $date, $subject, $recipient);
@@ -1030,7 +1016,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email
                  WHERE
                     sup_ema_id=" . Misc::escapeInteger($ema_id);
-        $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $res = Db_Helper::getInstance()->getCol($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -1055,7 +1041,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email
                 WHERE
                     sup_message_id = '" . Misc::escapeString($message_id) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($sql);
+        $res = Db_Helper::getInstance()->getOne($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -1081,7 +1067,7 @@
     function insertEmail($row, &$structure, &$sup_id, $closing = false)
     {
         // get usr_id from FROM header
-        $usr_id = User::getUserIDByEmail(Mail_API::getEmailAddress($row['from']));
+        $usr_id = User::getUserIDByEmail(Mail_Helper::getEmailAddress($row['from']));
         if (!empty($usr_id) && !empty($row["customer_id"])) {
             $row["customer_id"] = User::getCustomerID($usr_id);
         }
@@ -1090,7 +1076,7 @@
         }
 
         // try to get the parent ID
-        $reference_message_id = Mail_API::getReferenceMessageID($row['full_email']);
+        $reference_message_id = Mail_Helper::getReferenceMessageID($row['full_email']);
         $parent_id = '';
         if (!empty($reference_message_id)) {
             $parent_id = Support::getIDByMessageID($reference_message_id);
@@ -1139,7 +1125,7 @@
                     '" . Misc::escapeString($row["subject"]) . "',
                     '" . Misc::escapeString($row["has_attachment"]) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1159,7 +1145,7 @@
                         '" . Misc::escapeString($row["body"]) . "',
                         '" . Misc::escapeString($row["full_email"]) . "'
                      )";
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return -1;
@@ -1336,7 +1322,7 @@
         $stmt .= "
                  LIMIT
                     " . Misc::escapeInteger($start) . ", " . Misc::escapeInteger($max);
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array(
@@ -1360,13 +1346,13 @@
                 }
             }
             for ($i = 0; $i < count($res); $i++) {
-                $res[$i]["sup_date"] = Date_API::getFormattedDate($res[$i]["sup_date"]);
+                $res[$i]["sup_date"] = Date_Helper::getFormattedDate($res[$i]["sup_date"]);
                 $res[$i]["sup_subject"] = Mime_Helper::fixEncoding($res[$i]["sup_subject"]);
-                $res[$i]["sup_from"] = join(', ', Mail_API::getName($res[$i]["sup_from"], true));
+                $res[$i]["sup_from"] = join(', ', Mail_Helper::getName($res[$i]["sup_from"], true));
                 if ((empty($res[$i]["sup_to"])) && (!empty($res[$i]["sup_iss_id"]))) {
                     $res[$i]["sup_to"] = "Notification List";
                 } else {
-                    $to = Mail_API::getName($res[$i]["sup_to"]);
+                    $to = Mail_Helper::getName($res[$i]["sup_to"]);
                     if (PEAR::isError($to)) {
                         // ignore unformattable headers
                     } else {
@@ -1467,7 +1453,7 @@
         }
 
         // figure out who should be the 'owner' of this attachment
-        $sender_email = strtolower(Mail_API::getEmailAddress($input->headers['from']));
+        $sender_email = strtolower(Mail_Helper::getEmailAddress($input->headers['from']));
         $usr_id = User::getUserIDByEmail($sender_email);
         $unknown_user = false;
         if (empty($usr_id)) {
@@ -1524,7 +1510,7 @@
                     sup_iss_id=$issue_id
                  WHERE
                     sup_id IN (" . @implode(", ", Misc::escapeInteger($items)) . ")";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1541,7 +1527,7 @@
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email
                      WHERE
                         sup_id IN (" . @implode(", ", Misc::escapeInteger($items)) . ")";
-            $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+            $res = Db_Helper::getInstance()->getCol($stmt);
             for ($i = 0; $i < count($res); $i++) {
                 History::add($issue_id, $usr_id, History::getTypeID('email_associated'),
                        ev_gettext('Email (subject: \'%1$s\') associated by %2$s', $res[$i], User::getFullName($usr_id)));
@@ -1575,7 +1561,7 @@
                      WHERE
                         sup_id=seb_sup_id AND
                         sup_id IN (" . @implode(", ", Misc::escapeInteger($items)) . ")";
-            $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+            $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
             for ($i = 0; $i < count($res); $i++) {
                 // since downloading email should make the emails 'public', send 'false' below as the 'internal_only' flag
                 $structure = Mime_Helper::decode($res[$i]['seb_full_email'], true, false);
@@ -1599,7 +1585,7 @@
                 );
                 Notification::notifyNewEmail($usr_id, $issue_id, $t, false, false, '', $res[$i]['sup_id']);
                 if ($authorize) {
-                    Authorized_Replier::manualInsert($issue_id, Mail_API::getEmailAddress(@$structure->headers['from']), false);
+                    Authorized_Replier::manualInsert($issue_id, Mail_Helper::getEmailAddress(@$structure->headers['from']), false);
                 }
             }
             return 1;
@@ -1629,22 +1615,22 @@
                     sup_id=seb_sup_id AND
                     sup_id=" . Misc::escapeInteger($sup_id) . " AND
                     sup_ema_id=" . Misc::escapeInteger($ema_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
         } else {
             $res['message'] = $res['seb_body'];
             $res["attachments"] = Mime_Helper::getAttachmentCIDs($res["seb_full_email"]);
-            $res["timestamp"] = Date_API::getUnixTimestamp($res['sup_date'], 'GMT');
-            $res["sup_date"] = Date_API::getFormattedDate($res["sup_date"]);
+            $res["timestamp"] = Date_Helper::getUnixTimestamp($res['sup_date'], 'GMT');
+            $res["sup_date"] = Date_Helper::getFormattedDate($res["sup_date"]);
             $res["sup_subject"] = Mime_Helper::fixEncoding($res["sup_subject"]);
-            $res['reply_subject'] = Mail_API::removeExcessRe('Re: ' . $res["sup_subject"], true);
+            $res['reply_subject'] = Mail_Helper::removeExcessRe('Re: ' . $res["sup_subject"], true);
             $res["sup_from"] = Mime_Helper::fixEncoding($res["sup_from"]);
             $res["sup_to"] = Mime_Helper::fixEncoding($res["sup_to"]);
 
             if (!empty($res['sup_iss_id'])) {
-                $res['reply_subject'] = Mail_API::formatSubject($res['sup_iss_id'], $res['reply_subject']);
+                $res['reply_subject'] = Mail_Helper::formatSubject($res['sup_iss_id'], $res['reply_subject']);
             }
 
             return $res;
@@ -1672,7 +1658,7 @@
                 ORDER BY
                     sup_id
                 LIMIT " . (Misc::escapeInteger($sequence) - 1) . ", 1";
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt);
+        $res = Db_Helper::getInstance()->getRow($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -1706,7 +1692,7 @@
                     ema_id=sup_ema_id AND
                     ema_prj_id=" . Auth::getCurrentProject() . " AND
                     sup_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -1736,7 +1722,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email_body
                  WHERE
                     seb_sup_id=" . Misc::escapeInteger($sup_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -1762,7 +1748,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email_body
                  WHERE
                     seb_sup_id=" . Misc::escapeInteger($sup_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -1799,7 +1785,7 @@
                     sup_iss_id=" . Misc::escapeInteger($issue_id) . "
                  ORDER BY
                     sup_id ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -1808,7 +1794,7 @@
                 return "";
             } else {
                 for ($i = 0; $i < count($res); $i++) {
-                    $res[$i]["sup_date"] = Date_API::getFormattedDate($res[$i]["sup_date"]);
+                    $res[$i]["sup_date"] = Date_Helper::getFormattedDate($res[$i]["sup_date"]);
                     $res[$i]["sup_subject"] = Mime_Helper::fixEncoding($res[$i]["sup_subject"]);
                     $res[$i]["sup_from"] = Mime_Helper::fixEncoding($res[$i]["sup_from"]);
                     $res[$i]["sup_to"] = Mime_Helper::fixEncoding($res[$i]["sup_to"]);
@@ -1836,7 +1822,7 @@
                     sup_removed=1
                  WHERE
                     sup_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1862,7 +1848,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email
                  WHERE
                     sup_id IN ($items)";
-        $issue_id = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $issue_id = Db_Helper::getInstance()->getOne($stmt);
 
         $stmt = "UPDATE
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email
@@ -1870,7 +1856,7 @@
                     sup_iss_id=0
                  WHERE
                     sup_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1884,7 +1870,7 @@
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email
                      WHERE
                         sup_id IN ($items)";
-            $subjects = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+            $subjects = Db_Helper::getInstance()->getAssoc($stmt);
             for ($i = 0; $i < count($_POST["item"]); $i++) {
                 History::add($issue_id, Auth::getUserID(), History::getTypeID('email_disassociated'),
                                 ev_gettext('Email (subject: \'%1$s\') disassociated by %2$s', $subjects[$_POST["item"][$i]], User::getFullName(Auth::getUserID())));
@@ -1969,7 +1955,7 @@
     function buildFullHeaders($issue_id, $message_id, $from, $to, $cc, $subject, $body, $in_reply_to, $attachments = null)
     {
         // hack needed to get the full headers of this web-based email
-        $mail = new Mail_API;
+        $mail = new Mail_Helper;
         $mail->setTextBody($body);
 
         $body = $mail->mime->get(array('text_charset' => APP_CHARSET, 'head_charset' => APP_CHARSET, 'text_encoding' => APP_EMAIL_ENCODING));
@@ -2031,20 +2017,20 @@
     function sendDirectEmail($issue_id, $from, $to, $cc, $subject, $body, $attachment, $message_id, $sender_usr_id = false)
     {
         $prj_id = Issue::getProjectID($issue_id);
-        $subject = Mail_API::formatSubject($issue_id, $subject);
+        $subject = Mail_Helper::formatSubject($issue_id, $subject);
         $recipients = Support::getRecipientsCC($cc);
         $recipients[] = $to;
         // send the emails now, one at a time
         foreach ($recipients as $recipient) {
-            $mail = new Mail_API;
+            $mail = new Mail_Helper;
             if (!empty($issue_id)) {
                 // add the warning message to the current message' body, if needed
-                $fixed_body = Mail_API::addWarningMessage($issue_id, $recipient, $body, array());
+                $fixed_body = Mail_Helper::addWarningMessage($issue_id, $recipient, $body, array());
                 $mail->setHeaders(array(
                     "Message-Id" => $message_id
                 ));
                 // skip users who don't have access to this issue (but allow non-users and users without access to this project) to get emails
-                $recipient_usr_id = User::getUserIDByEmail(Mail_API::getEmailAddress($recipient), true);
+                $recipient_usr_id = User::getUserIDByEmail(Mail_Helper::getEmailAddress($recipient), true);
                 if ((((!empty($recipient_usr_id)) && ((!Issue::canAccess($issue_id, $recipient_usr_id)) && (User::getRoleByUser($recipient_usr_id, $prj_id) != NULL)))) ||
                         (empty($recipient_usr_id)) && (Issue::isPrivate($issue_id))) {
                     continue;
@@ -2052,7 +2038,7 @@
             } else {
                 $fixed_body = $body;
             }
-            if (User::getRoleByUser(User::getUserIDByEmail(Mail_API::getEmailAddress($from)), Issue::getProjectID($issue_id)) == User::getRoleID("Customer")) {
+            if (User::getRoleByUser(User::getUserIDByEmail(Mail_Helper::getEmailAddress($from)), Issue::getProjectID($issue_id)) == User::getRoleID("Customer")) {
                 $type = 'customer_email';
             } else {
                 $type = 'other_email';
@@ -2104,7 +2090,7 @@
         }
 
         // get ID of whoever is sending this.
-        $sender_usr_id = User::getUserIDByEmail(Mail_API::getEmailAddress($_POST["from"]));
+        $sender_usr_id = User::getUserIDByEmail(Mail_Helper::getEmailAddress($_POST["from"]));
         if (empty($sender_usr_id)) {
             $sender_usr_id = false;
         }
@@ -2118,9 +2104,9 @@
 
 
         // remove extra 'Re: ' from subject
-        $_POST['subject'] = Mail_API::removeExcessRe($_POST['subject'], true);
+        $_POST['subject'] = Mail_Helper::removeExcessRe($_POST['subject'], true);
         $internal_only = false;
-        $message_id = Mail_API::generateMessageID();
+        $message_id = Mail_Helper::generateMessageID();
         // hack needed to get the full headers of this web-based email
         $full_email = Support::buildFullHeaders($_POST["issue_id"], $message_id, $_POST["from"],
                 $_POST["to"], $_POST["cc"], $_POST["subject"], $_POST["message"], $in_reply_to, $_FILES["attachment"]);
@@ -2133,7 +2119,7 @@
                 // add the message body as a note
                 $_POST['full_message'] = $full_email;
                 $_POST['title'] = $_POST["subject"];
-                $_POST['note'] = Mail_API::getCannedBlockedMsgExplanation() . $_POST["message"];
+                $_POST['note'] = Mail_Helper::getCannedBlockedMsgExplanation() . $_POST["message"];
                 Note::insert(Auth::getUserID(), $_POST["issue_id"], false, true, false, true, true);
                 Workflow::handleBlockedEmail(Issue::getProjectID($_POST['issue_id']), $_POST['issue_id'], $_POST, 'web');
                 return 1;
@@ -2148,7 +2134,7 @@
                 $recipients = array_merge($recipients, Support::getRecipientsCC($_POST['cc']));
                 for ($i = 0; $i < count($recipients); $i++) {
                     if ((!empty($recipients[$i])) && (!Notification::isIssueRoutingSender($_POST["issue_id"], $recipients[$i]))) {
-                        Notification::subscribeEmail(Auth::getUserID(), $_POST["issue_id"], Mail_API::getEmailAddress($recipients[$i]),
+                        Notification::subscribeEmail(Auth::getUserID(), $_POST["issue_id"], Mail_Helper::getEmailAddress($recipients[$i]),
                                         Notification::getDefaultActions($_POST['issue_id'], $recipients[$i], 'add_unknown_user'));
                     }
                 }
@@ -2190,7 +2176,7 @@
                 $project_info = Project::getOutgoingSenderAddress(Auth::getCurrentProject());
                 // use the project-related outgoing email address, if there is one
                 if (!empty($project_info['email'])) {
-                    $from = Mail_API::getFormattedName(User::getFullName(Auth::getUserID()), $project_info['email']);
+                    $from = Mail_Helper::getFormattedName(User::getFullName(Auth::getUserID()), $project_info['email']);
                 } else {
                     // otherwise, use the real email address for the current user
                     $from = User::getFromHeader(Auth::getUserID());
@@ -2206,7 +2192,7 @@
             'issue_id'       => $_POST["issue_id"] ? $_POST["issue_id"] : 0,
             'ema_id'         => $_POST['ema_id'],
             'message_id'     => $message_id,
-            'date'           => Date_API::getCurrentDateGMT(),
+            'date'           => Date_Helper::getCurrentDateGMT(),
             'from'           => $_POST['from'],
             'to'             => $_POST['to'],
             'cc'             => @$_POST['cc'],
@@ -2267,7 +2253,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email
                  WHERE
                     sup_id=" . Misc::escapeInteger($sup_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -2293,7 +2279,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email
                  WHERE
                     sup_message_id='" . Misc::escapeString($message_id) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -2323,7 +2309,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email
                  WHERE
                     sup_message_id='" . Misc::escapeString($message_id) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -2349,7 +2335,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email
                  WHERE
                     sup_id=" . Misc::escapeInteger($sup_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -2376,7 +2362,7 @@
                 WHERE
                     parent.sup_id = child.sup_parent_id AND
                     child.sup_message_id = '" . Misc::escapeString($msg_id) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($sql);
+        $res = Db_Helper::getInstance()->getOne($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -2419,7 +2405,7 @@
         } else {
             $stmt .= "= 0";
         }
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -2449,7 +2435,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_account
                  WHERE
                     ema_id = " . Misc::escapeInteger($ema_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -2510,7 +2496,7 @@
                 WHERE
                     sup_id = " . Misc::escapeInteger($sup_id) . " AND
                     sup_ema_id = " . Misc::escapeInteger($current_ema_id);
-        $res = $GLOBALS["db_api"]->dbh->query($sql);
+        $res = Db_Helper::getInstance()->query($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -2568,19 +2554,19 @@
 
         $issue_id = $email['issue_id'];
         $prj_id = Issue::getProjectID($issue_id);
-        $sender_email = strtolower(Mail_API::getEmailAddress($email['from']));
+        $sender_email = strtolower(Mail_Helper::getEmailAddress($email['from']));
         list($text_headers, $body) = Mime_Helper::splitHeaderBody($email['full_email']);
-        if ((Mail_API::isVacationAutoResponder($email['headers'])) || (Notification::isBounceMessage($sender_email)) ||
+        if ((Mail_Helper::isVacationAutoResponder($email['headers'])) || (Notification::isBounceMessage($sender_email)) ||
                 (!Support::isAllowedToEmail($issue_id, $sender_email))) {
             // add the message body as a note
             $_POST = array(
                 'full_message'=> $email['full_email'],
                 'title'       => @$email['headers']['subject'],
-                'note'        => Mail_API::getCannedBlockedMsgExplanation($issue_id) . $email['body'],
-                'message_id'  => Mail_API::getMessageID($text_headers, $body),
+                'note'        => Mail_Helper::getCannedBlockedMsgExplanation($issue_id) . $email['body'],
+                'message_id'  => Mail_Helper::getMessageID($text_headers, $body),
             );
             // avoid having this type of message re-open the issue
-            if (Mail_API::isVacationAutoResponder($email['headers'])) {
+            if (Mail_Helper::isVacationAutoResponder($email['headers'])) {
                 $closing = true;
                 $notify = false;
             } else {
@@ -2597,7 +2583,7 @@
             $_POST['from'] = $sender_email;
 
             // avoid having this type of message re-open the issue
-            if (Mail_API::isVacationAutoResponder($email['headers'])) {
+            if (Mail_Helper::isVacationAutoResponder($email['headers'])) {
                 $email_type = 'vacation-autoresponder';
             } else {
                 $email_type = 'routed';
@@ -2605,7 +2591,7 @@
             Workflow::handleBlockedEmail($prj_id, $issue_id, $_POST, $email_type);
 
             // try to get usr_id of sender, if not, use system account
-            $usr_id = User::getUserIDByEmail(Mail_API::getEmailAddress($email['from']), true);
+            $usr_id = User::getUserIDByEmail(Mail_Helper::getEmailAddress($email['from']), true);
             if (!$usr_id) {
                 $usr_id = APP_SYSTEM_USER_ID;
             }
@@ -2632,11 +2618,11 @@
         array_push($addresses_not_too_add, $project_details['prj_outgoing_sender_email']);
 
         $addresses = array();
-        $to_addresses = Mail_API::getEmailAddresses(@$email['to']);
+        $to_addresses = Mail_Helper::getEmailAddresses(@$email['to']);
         if (count($to_addresses)) {
             $addresses = $to_addresses;
         }
-        $cc_addresses = Mail_API::getEmailAddresses(@$email['cc']);
+        $cc_addresses = Mail_Helper::getEmailAddresses(@$email['cc']);
         if (count($cc_addresses)) {
             $addresses = array_merge($addresses, $cc_addresses);
         }
--- include/class.time_tracking.php	2009-01-12 23:15:12.055441962 +0200
+++ /usr/share/eventum/include/class.time_tracking.php	2009-02-05 02:04:13.644067122 +0200
@@ -29,14 +29,6 @@
 // @(#) $Id: class.time_tracking.php 3797 2009-01-12 20:14:39Z balsdorf $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.validation.php");
-require_once(APP_INC_PATH . "class.date.php");
-require_once(APP_INC_PATH . "class.issue.php");
-require_once(APP_INC_PATH . "class.auth.php");
-require_once(APP_INC_PATH . "class.user.php");
-require_once(APP_INC_PATH . "class.history.php");
 
 /**
  * Class to handle the business logic related to the administration
@@ -63,7 +55,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "time_tracking_category
                  WHERE
                     ttc_title='" . Misc::escapeString($ttc_title) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return 0;
@@ -88,7 +80,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "time_tracking_category
                  WHERE
                     ttc_id=" . Misc::escapeInteger($ttc_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -111,7 +103,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "time_tracking_category
                  WHERE
                     ttc_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -138,7 +130,7 @@
                     ttc_title='" . Misc::escapeString($_POST["title"]) . "'
                  WHERE
                     ttc_id=" . Misc::escapeInteger($_POST["id"]);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -166,9 +158,9 @@
                     ttc_created_date
                  ) VALUES (
                     '" . Misc::escapeString($_POST["title"]) . "',
-                    '" . Date_API::getCurrentDateGMT() . "'
+                    '" . Date_Helper::getCurrentDateGMT() . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -196,7 +188,7 @@
                     ttc_title NOT IN ('Note Discussion', 'Email Discussion', 'Telephone Discussion')
                  ORDER BY
                     ttc_title ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -222,7 +214,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "time_tracking_category
                  ORDER BY
                     ttc_title ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -258,7 +250,7 @@
                     ttr_iss_id IN ($ids)
                  GROUP BY
                     ttr_iss_id";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         } else {
@@ -284,7 +276,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "time_tracking
                  WHERE
                     ttr_iss_id=" . Misc::escapeInteger($issue_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return 0;
@@ -322,7 +314,7 @@
                     ttr_iss_id=" . Misc::escapeInteger($issue_id) . "
                  ORDER BY
                     ttr_created_date ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return 0;
@@ -331,7 +323,7 @@
             for ($i = 0; $i < count($res); $i++) {
                 $res[$i]["ttr_summary"] = Link_Filter::processText(Issue::getProjectID($issue_id), nl2br(htmlspecialchars($res[$i]["ttr_summary"])));
                 $res[$i]["formatted_time"] = Misc::getFormattedTime($res[$i]["ttr_time_spent"]);
-                $res[$i]["ttr_created_date"] = Date_API::getFormattedDate($res[$i]["ttr_created_date"]);
+                $res[$i]["ttr_created_date"] = Date_Helper::getFormattedDate($res[$i]["ttr_created_date"]);
 
                 $total_time_spent += $res[$i]["ttr_time_spent"];
             }
@@ -358,7 +350,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "time_tracking
                  WHERE
                     ttr_iss_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -386,7 +378,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "time_tracking
                  WHERE
                     ttr_id=$time_id";
-        $details = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $details = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         // check if the owner is the one trying to remove this entry
         if (($details['owner_usr_id'] != $usr_id) || (!Issue::canAccess($details['issue_id'], $usr_id))) {
             return -1;
@@ -396,7 +388,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "time_tracking
                  WHERE
                     ttr_id=$time_id";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -424,9 +416,9 @@
                 $_POST["date"]["Day"], $_POST["date"]["Hour"],
                 $_POST["date"]["Minute"], 0);
             // convert the date to GMT timezone
-            $created_date = Date_API::convertDateGMT($created_date);
+            $created_date = Date_Helper::convertDateGMT($created_date);
         } else {
-            $created_date = Date_API::getCurrentDateGMT();
+            $created_date = Date_Helper::getCurrentDateGMT();
         }
         $usr_id = Auth::getUserID();
         $stmt = "INSERT INTO
@@ -446,7 +438,7 @@
                     " . Misc::escapeInteger($_POST["time_spent"]) . ",
                     '" . Misc::escapeString($_POST["summary"]) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -485,11 +477,11 @@
                     " . Misc::escapeInteger($cat_id) . ",
                     " . Misc::escapeInteger($issue_id) . ",
                     " . Misc::escapeInteger($usr_id) . ",
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     " . Misc::escapeInteger($time_spent) . ",
                     '" . Misc::escapeString($summary) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -529,7 +521,7 @@
                     ttr_created_date BETWEEN '" . Misc::escapeString($start) . "' AND '" . Misc::escapeString($end) . "'
                  GROUP BY
                     ttc_title";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt, false, array(), DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAssoc($stmt, false, array(), DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -564,7 +556,7 @@
                     ttr_usr_id = " . Misc::escapeInteger($usr_id) . " AND
                     ttr_created_date BETWEEN '" . Misc::escapeString($start) . "' AND '" . Misc::escapeString($end) . "' AND
                     ttr_iss_id=" . Misc::escapeInteger($issue_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return 0;
@@ -600,7 +592,7 @@
                     ttr_created_date BETWEEN '" . Misc::escapeString($start) . "' AND '" . Misc::escapeString($end) . "' AND
                     ttr_iss_id in ($ids)
                  GROUP BY ttr_iss_id";
-        $result = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $result = Db_Helper::getInstance()->getAssoc($stmt);
 
         if (PEAR::isError($result)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
--- include/class.user.php	2009-01-22 12:19:07.582949508 +0200
+++ /usr/share/eventum/include/class.user.php	2009-02-05 02:15:18.670659468 +0200
@@ -29,20 +29,10 @@
 // @(#) $Id: class.user.php 3808 2009-01-22 10:20:10Z glen $
 //
 
-require_once(APP_INC_PATH . "class.error_handler.php");
-require_once(APP_INC_PATH . "class.auth.php");
-require_once(APP_INC_PATH . "class.mail.php");
-require_once(APP_INC_PATH . "class.misc.php");
-require_once(APP_INC_PATH . "class.prefs.php");
-require_once(APP_INC_PATH . "class.notification.php");
-require_once(APP_INC_PATH . "class.validation.php");
-require_once(APP_INC_PATH . "class.date.php");
-require_once(APP_INC_PATH . "class.project.php");
-require_once(APP_INC_PATH . "class.setup.php");
 require_once(APP_CONFIG_PATH . "private_key.php");
 
 // definition of roles
-$roles = array(
+$GLOBALS['roles'] = array(
     1 => "Viewer",
     2 => "Reporter",
     3 => "Customer",
@@ -78,7 +68,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user
                  WHERE
                     usr_customer_contact_id=" . Misc::escapeInteger($customer_contact_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -104,7 +94,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user
                  WHERE
                     usr_customer_contact_id=" . Misc::escapeInteger($customer_contact_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -130,7 +120,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user
                  WHERE
                     usr_id=" . Misc::escapeInteger($usr_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -157,7 +147,7 @@
                     usr_sms_email='" . Misc::escapeString($sms_email) . "'
                  WHERE
                     usr_id=" . Misc::escapeInteger($usr_id);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -183,7 +173,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user
                  WHERE
                     usr_id=" . Misc::escapeInteger($usr_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -215,7 +205,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user
                  WHERE
                     usr_id=" . Misc::escapeInteger($usr_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -241,7 +231,7 @@
                     usr_status='active'
                  WHERE
                     usr_email='" . Misc::escapeString($email) . "'";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -269,7 +259,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user
                  WHERE
                     usr_email='" . Misc::escapeString($email) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -314,14 +304,14 @@
                     usr_preferences,
                     usr_status
                  ) VALUES (
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     '" . Auth::hashPassword(Misc::escapeString($_POST["passwd"])) . "',
                     '" . Misc::escapeString($_POST["full_name"]) . "',
                     '" . Misc::escapeString($_POST["email"]) . "',
                     '" . Misc::escapeString($prefs) . "',
                     'pending'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -334,7 +324,7 @@
             // send confirmation email to user
             $hash = md5($_POST["full_name"] . md5($_POST["email"]) . $GLOBALS["private_key"]);
 
-            $tpl = new Template_API;
+            $tpl = new Template_Helper();
             $tpl->setTemplate('notifications/visitor_account.tpl.text');
             $tpl->bulkAssign(array(
                 "app_title"   => Misc::getToolCaption(),
@@ -344,7 +334,7 @@
             $text_message = $tpl->getTemplateContents();
 
             $setup = Setup::load();
-            $mail = new Mail_API;
+            $mail = new Mail_Helper;
             // need to make this message MIME based
             $mail->setTextBody($text_message);
             $mail->send($setup["smtp"]["from"], $_POST["email"], APP_SHORT_NAME . ": New Account - Confirmation Required");
@@ -367,7 +357,7 @@
         // send confirmation email to user
         $hash = md5($info["usr_full_name"] . md5($info["usr_email"]) . $GLOBALS["private_key"]);
 
-        $tpl = new Template_API;
+        $tpl = new Template_Helper();
         $tpl->setTemplate('notifications/password_confirmation.tpl.text');
         $tpl->bulkAssign(array(
             "app_title" => Misc::getToolCaption(),
@@ -377,7 +367,7 @@
         $text_message = $tpl->getTemplateContents();
 
         $setup = Setup::load();
-        $mail = new Mail_API;
+        $mail = new Mail_Helper;
         // need to make this message MIME based
         $mail->setTextBody($text_message);
         $mail->send($setup["smtp"]["from"], $info["usr_email"], APP_SHORT_NAME . ": New Password - Confirmation Required");
@@ -434,7 +424,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user
                  WHERE
                     usr_email='" . Misc::escapeString($email) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -531,7 +521,7 @@
         $stmt .= "
                  ORDER BY
                     usr_full_name ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -645,7 +635,7 @@
                  WHERE
                     pru_usr_id=" . Misc::escapeInteger($usr_id) . " AND
                     pru_prj_id = " . Misc::escapeInteger($prj_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             return "";
         } else {
@@ -676,7 +666,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user
                  WHERE
                     usr_id=" . Misc::escapeInteger($usr_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -728,9 +718,9 @@
                  WHERE
                     usr_id IN (" . implode(', ', Misc::escapeInteger($items)) . ")";
         if (!is_array($usr_id)) {
-            $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+            $res = Db_Helper::getInstance()->getOne($stmt);
         } else {
-            $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+            $res = Db_Helper::getInstance()->getCol($stmt);
         }
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
@@ -779,9 +769,9 @@
                  WHERE
                     usr_id IN (" . implode(', ', Misc::escapeInteger($items)) . ")";
         if (!is_array($usr_id)) {
-            $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+            $res = Db_Helper::getInstance()->getOne($stmt);
         } else {
-            $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+            $res = Db_Helper::getInstance()->getCol($stmt);
         }
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
@@ -826,9 +816,9 @@
                  WHERE
                     usr_id IN (" . implode(', ', Misc::escapeInteger($items)) . ")";
         if (!is_array($usr_id)) {
-            $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+            $res = Db_Helper::getInstance()->getOne($stmt);
         } else {
-            $res = $GLOBALS["db_api"]->dbh->getCol($stmt);
+            $res = Db_Helper::getInstance()->getCol($stmt);
         }
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
@@ -861,7 +851,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user
                  WHERE
                     usr_email='" . Misc::escapeString($email) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -888,7 +878,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user
                  WHERE
                     usr_status='active'";
-        $total_active = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $total_active = Db_Helper::getInstance()->getOne($stmt);
         if (($total_active < 2) && ($_POST["status"] == "inactive")) {
             return false;
         }
@@ -900,7 +890,7 @@
                     usr_status='" . $_POST["status"] . "'
                  WHERE
                     usr_id IN ($items)";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -929,7 +919,7 @@
                     usr_password='" . Auth::hashPassword($_POST["new_password"]) . "'
                  WHERE
                     usr_id=" . Misc::escapeInteger($usr_id);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -957,7 +947,7 @@
                     usr_full_name='" . Misc::escapeString($_POST["full_name"]) . "'
                  WHERE
                     usr_id=" . Misc::escapeInteger($usr_id);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -983,7 +973,7 @@
                     usr_email='" . Misc::escapeString($_POST["email"]) . "'
                  WHERE
                     usr_id=" . Misc::escapeInteger($usr_id);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1020,7 +1010,7 @@
         $stmt .= "
                  WHERE
                     usr_id=" . Misc::escapeInteger($_POST["id"]);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1030,7 +1020,7 @@
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_user
                      WHERE
                         pru_usr_id=" . Misc::escapeInteger($_POST["id"]);
-            $res = $GLOBALS["db_api"]->dbh->query($stmt);
+            $res = Db_Helper::getInstance()->query($stmt);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return -1;
@@ -1050,7 +1040,7 @@
                                 " . Misc::escapeInteger($_POST["id"]) . ",
                                 " . $role . "
                              )";
-                    $res = $GLOBALS["db_api"]->dbh->query($stmt);
+                    $res = Db_Helper::getInstance()->query($stmt);
                     if (PEAR::isError($res)) {
                         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                         return -1;
@@ -1096,13 +1086,13 @@
                  ) VALUES (
                     NULL,
                     NULL,
-                    '" . Date_API::getCurrentDateGMT() . "',
+                    '" . Date_Helper::getCurrentDateGMT() . "',
                     '" . Auth::hashPassword(Misc::escapeString($_POST["password"])) . "',
                     '" . Misc::escapeString($_POST["full_name"]) . "',
                     '" . Misc::escapeString($_POST["email"]) . "',
                     '" . Misc::escapeString($prefs) . "'
                  )";
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1140,7 +1130,7 @@
                  ORDER BY
                     usr_status ASC,
                     usr_full_name ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -1188,7 +1178,7 @@
                     usr_id
                  FROM
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -1215,7 +1205,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user
                  ORDER BY
                     usr_full_name ASC";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -1248,7 +1238,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user
                  WHERE
                     usr_id=" . Misc::escapeInteger($usr_id);
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getRow($stmt, DB_FETCHMODE_ASSOC);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return "";
@@ -1290,7 +1280,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user
                  WHERE
                     usr_clocked_in=1";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -1314,7 +1304,7 @@
                     usr_clocked_in = 1
                  WHERE
                     usr_id = " . Misc::escapeInteger($usr_id);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1337,7 +1327,7 @@
                     usr_clocked_in = 0
                  WHERE
                     usr_id = " . Misc::escapeInteger($usr_id);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1361,7 +1351,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user
                  WHERE
                     usr_id = " . Misc::escapeInteger($usr_id);
-        $res = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $res = Db_Helper::getInstance()->getOne($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1395,7 +1385,7 @@
                     usr_grp_id = $grp_id
                  WHERE
                     usr_id = " . Misc::escapeInteger($usr_id);
-        $res = $GLOBALS["db_api"]->dbh->query($stmt);
+        $res = Db_Helper::getInstance()->query($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
@@ -1416,7 +1406,7 @@
                         " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user
                     WHERE
                         usr_id = $usr_id";
-            $res = $GLOBALS["db_api"]->dbh->getOne($sql);
+            $res = Db_Helper::getInstance()->getOne($sql);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return APP_DEFAULT_LOCALE;
@@ -1439,7 +1429,7 @@
                     usr_lang = '" . Misc::escapeString($language) . "'
                 WHERE
                     usr_id = " . Misc::escapeInteger($usr_id);
-        $res = $GLOBALS["db_api"]->dbh->query($sql);
+        $res = Db_Helper::getInstance()->query($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -1456,7 +1446,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user_alias
                 WHERE
                     ual_usr_id = " . Misc::escapeInteger($usr_id);
-        $res = $GLOBALS["db_api"]->dbh->getCol($sql);
+        $res = Db_Helper::getInstance()->getCol($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return array();
@@ -1482,7 +1472,7 @@
                 SET
                     ual_usr_id = " . Misc::escapeInteger($usr_id) . ",
                     ual_email = '" . Misc::escapeString($email) . "'";
-        $res = $GLOBALS["db_api"]->dbh->query($sql);
+        $res = Db_Helper::getInstance()->query($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -1498,7 +1488,7 @@
                 WHERE
                     ual_usr_id = " . Misc::escapeInteger($usr_id) . " AND
                     ual_email = '" . Misc::escapeString($email) . "'";
-        $res = $GLOBALS["db_api"]->dbh->query($sql);
+        $res = Db_Helper::getInstance()->query($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
@@ -1515,7 +1505,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user_alias
                 WHERE
                     ual_email = '" . Misc::escapeString($email) . "'";
-        $res = $GLOBALS["db_api"]->dbh->getOne($sql);
+        $res = Db_Helper::getInstance()->getOne($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
--- include/class.workflow.php	2009-01-14 22:04:17.275242314 +0200
+++ /usr/share/eventum/include/class.workflow.php	2009-02-05 02:12:59.364003735 +0200
@@ -75,7 +75,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project
                  ORDER BY
                     prj_id";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return '';
@@ -104,11 +104,9 @@
                 return false;
             }
             $file_name_chunks = explode(".", $backend_class);
-            $class_name = $file_name_chunks[1] . "_Workflow_Backend";
+            $class_name = ucfirst($file_name_chunks[1]) . "_Workflow_Backend";
 
-            require_once(APP_INC_PATH . "workflow/$backend_class");
-
-            $setup_backends[$prj_id] = new $class_name;
+            $setup_backends[$prj_id] = new $class_name();
         }
         return $setup_backends[$prj_id];
     }
@@ -665,4 +663,4 @@
         $backend =& Workflow::_getBackend($prj_id);
         return $backend->getIssueFieldsToDisplay($prj_id, $issue_id, $location);
     }
-}
\ No newline at end of file
+}
--- include/customer/class.example.php	2009-01-12 23:15:11.175414194 +0200
+++ /usr/share/eventum/include/customer/class.example.php	2009-02-05 02:15:18.673989640 +0200
@@ -27,8 +27,6 @@
 // +----------------------------------------------------------------------+
 //
 
-require_once(APP_INC_PATH . "customer/class.abstract_customer_backend.php");
-require_once(APP_INC_PATH . "class.date.php");
 
 /**
  * Example customer backend. This does not cover all functionality, but should provide an idea
@@ -155,7 +153,7 @@
     {
         // active contracts have an expiration date in the future
         $expiration = strtotime($this->data[$customer_id]['expiration_date']);
-        $now = Date_API::getCurrentUnixTimestampGMT();
+        $now = Date_Helper::getCurrentUnixTimestampGMT();
         if ($expiration > $now) {
             return 'active';
         } elseif ($expiration > ($now + (DAY * $this->getExpirationOffset()))) {
@@ -343,7 +341,7 @@
                     iss_sta_id=sta_id
                  WHERE
                     iss_customer_id=$customer_id";
-        $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
+        $res = Db_Helper::getInstance()->getAssoc($stmt);
         if ((PEAR::isError($res)) || (empty($res)) || (count($res) == 0)) {
             return array(
                 'total_issues'           => 0,
@@ -399,7 +397,7 @@
                     sbt_type='emails'
                  WHERE
                     iss_customer_id=$customer_id";
-        $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
+        $res = Db_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
         $persons = array();
         for ($i = 0; $i < count($res); $i++) {
             if ((!empty($res[$i]['sub_usr_id'])) && (!in_array($res[$i]['sub_usr_id'], $persons))) {
@@ -425,7 +423,7 @@
                     pru_prj_id=iss_prj_id AND
                     iss_id=$issue_id AND
                     pru_role <> " . User::getRoleID('Customer');
-        $staff_emails = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $staff_emails = Db_Helper::getInstance()->getCol($stmt);
 
         $stmt = "SELECT
                     sup_from
@@ -433,10 +431,10 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email
                  WHERE
                     sup_iss_id IN (" . implode(", ", $issues) . ")";
-        $emails = $GLOBALS["db_api"]->dbh->getCol($stmt);
+        $emails = Db_Helper::getInstance()->getCol($stmt);
         $total_emails = 0;
         foreach ($emails as $address) {
-            $email = strtolower(Mail_API::getEmailAddress($address));
+            $email = strtolower(Mail_Helper::getEmailAddress($address));
             $staff_emails = array_map('strtolower', $staff_emails);
             if (@in_array($email, $staff_emails)) {
                 $total_emails++;
@@ -449,7 +447,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "phone_support
                  WHERE
                     phs_iss_id IN (" . implode(", ", $issues) . ")";
-        $calls = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $calls = Db_Helper::getInstance()->getOne($stmt);
 
         $stmt = "SELECT
                     AVG(UNIX_TIMESTAMP(iss_first_response_date) - UNIX_TIMESTAMP(iss_created_date)) AS first_response_time
@@ -457,7 +455,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  WHERE
                     iss_id IN (" . implode(", ", $issues) . ")";
-        $avg_first_response = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $avg_first_response = Db_Helper::getInstance()->getOne($stmt);
         if (!empty($avg_first_response)) {
             // format the average into a number of minutes
             $avg_first_response = $avg_first_response / 60;
@@ -469,7 +467,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
                  WHERE
                     iss_id IN (" . implode(", ", $issues) . ")";
-        $avg_close = $GLOBALS["db_api"]->dbh->getOne($stmt);
+        $avg_close = Db_Helper::getInstance()->getOne($stmt);
         if (!empty($avg_close)) {
             // format the average into a number of minutes
             $avg_close = $avg_close / 60;
@@ -707,7 +705,7 @@
         if (count($senders) > 0) {
             $emails = array();
             for ($i = 0; $i < count($senders); $i++) {
-                $emails[] = Mail_API::getEmailAddress($senders[$i]);
+                $emails[] = Mail_Helper::getEmailAddress($senders[$i]);
             }
             list($customer_id, $contact_id) = $this->getCustomerIDByEmails($emails);
             $company = $this->getDetails($customer_id);
@@ -761,7 +759,7 @@
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user
                  WHERE
                     usr_customer_contact_id = $contact_id";
-        $res = $GLOBALS["db_api"]->dbh->getRow($stmt);
+        $res = Db_Helper::getInstance()->getRow($stmt);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return -1;
--- include/custom_field/class.developer_list.php	2009-01-12 23:15:10.975419711 +0200
+++ /usr/share/eventum/include/custom_field/class.developer_list.php	2009-02-05 01:39:37.177533316 +0200
@@ -27,8 +27,6 @@
 // +----------------------------------------------------------------------+
 //
 
-require_once(APP_INC_PATH . "class.user.php");
-require_once(APP_INC_PATH . "db_access.php");
 
 
 /**
--- include/custom_field/class.dynamic.php	2009-01-12 23:15:10.975419711 +0200
+++ /usr/share/eventum/include/custom_field/class.dynamic.php	2009-02-05 01:39:37.180867399 +0200
@@ -27,8 +27,6 @@
 // +----------------------------------------------------------------------+
 //
 
-require_once(APP_INC_PATH . "class.user.php");
-require_once(APP_INC_PATH . "db_access.php");
 
 
 /**
--- include/custom_field/class.reporter_list.php	2009-01-12 23:15:10.975419711 +0200
+++ /usr/share/eventum/include/custom_field/class.reporter_list.php	2009-02-05 01:39:37.180867399 +0200
@@ -27,8 +27,6 @@
 // +----------------------------------------------------------------------+
 //
 
-require_once(APP_INC_PATH . "class.user.php");
-require_once(APP_INC_PATH . "db_access.php");
 
 
 /**
--- include/workflow/class.example.php	2009-01-12 23:15:11.298752775 +0200
+++ /usr/share/eventum/include/workflow/class.example.php	2009-02-05 02:03:28.917395227 +0200
@@ -27,7 +27,6 @@
 // +----------------------------------------------------------------------+
 //
 
-require_once(APP_INC_PATH . "workflow/class.abstract_workflow_backend.php");
 
 /**
  * Example workflow backend class. For example purposes it will print what
@@ -258,7 +257,7 @@
                     iss_percent_complete = '100%'
                 WHERE
                     iss_id = $issue_id";
-        $res = $GLOBALS["db_api"]->dbh->query($sql);
+        $res = Db_Helper::getInstance()->query($sql);
         if (PEAR::isError($res)) {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
             return false;
