Merge pull request #2273 from monishdeb/CRM-13977
[civicrm-core.git] / CRM / Core / BAO / Phone.php
index 4189aa06535edaad2210dd199652e4c3c37823be..b27d7d6711ac61e3e99003ded16ef121d2338422 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.4                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2013                                |
  +--------------------------------------------------------------------+
@@ -45,6 +45,9 @@ class CRM_Core_BAO_Phone extends CRM_Core_DAO_Phone {
    * @param array $params input parameters
    */
   static function create($params) {
+    // Ensure mysql phone function exists
+    CRM_Core_DAO::checkSqlFunctionsExist();
+
     if (is_numeric(CRM_Utils_Array::value('is_primary', $params)) ||
       // if id is set & is_primary isn't we can assume no change
       empty($params['id'])
@@ -66,6 +69,9 @@ class CRM_Core_BAO_Phone extends CRM_Core_DAO_Phone {
    * @static
    */
   static function add(&$params) {
+    // Ensure mysql phone function exists
+    CRM_Core_DAO::checkSqlFunctionsExist();
+
     $hook = empty($params['id']) ? 'create' : 'edit';
     CRM_Utils_Hook::pre($hook, 'Phone', CRM_Utils_Array::value('id', $params), $params);
 
@@ -229,6 +235,8 @@ ORDER BY ph.is_primary DESC, phone_id ASC ";
     if (!$optionId) {
       return;
     }
+    // Ensure mysql phone function exists
+    CRM_Core_DAO::checkSqlFunctionsExist();
 
     $tables = array(
       'civicrm_phone',
@@ -252,6 +260,8 @@ ORDER BY ph.is_primary DESC, phone_id ASC ";
    * Call common delete function
    */
   static function del($id) {
+    // Ensure mysql phone function exists
+    CRM_Core_DAO::checkSqlFunctionsExist();
     return CRM_Contact_BAO_Contact::deleteObjectWithPrimary('Phone', $id);
   }
 }