Merge pull request #1707 from lcdservices/CRM-13455
[civicrm-core.git] / CRM / Case / BAO / Case.php
index 904e0bee92ecb874972c1443dde3da9c624f0f59..27b3324a8fb3012f04b620744e9df99b6aa01569 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.4                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2013                                |
  +--------------------------------------------------------------------+
@@ -34,7 +34,7 @@
  */
 
 /**
- * This class contains the funtions for Case Management
+ * This class contains the functions for Case Management
  *
  */
 class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
@@ -1429,7 +1429,7 @@ SELECT case_status.label AS case_status, status_id, case_type.label AS case_type
 
       $displayName = CRM_Utils_Array::value('display_name', $info);
 
-      list($result[CRM_Utils_Array::value('contact_id', $info)], $subject, $message, $html) = CRM_Core_BAO_MessageTemplates::sendTemplate(
+      list($result[CRM_Utils_Array::value('contact_id', $info)], $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(
         array(
           'groupName' => 'msg_tpl_workflow_case',
           'valueName' => 'case_activity',
@@ -1604,7 +1604,7 @@ SELECT case_status.label AS case_status, status_id, case_type.label AS case_type
   }
 
   /**
-   * Function to retrive the scheduled activity type and date
+   * Function to retrieve the scheduled activity type and date
    *
    * @param  array $cases  Array of contact and case id
    *
@@ -1814,7 +1814,7 @@ SELECT case_status.label AS case_status, status_id, case_type.label AS case_type
    *
    * @param int $caseID case id
    * @param int $relationshipId relationship id
-   * @param int $relContactId case role assigne contactId.
+   * @param int $relContactId case role assignee contactId.
    *
    * @return void on success creates activity and case activity
    *
@@ -3095,17 +3095,20 @@ WHERE id IN (' . implode(',', $copiedActivityIds) . ')';
    * Used during case component enablement and during ugprade
    */
   static function createCaseViews() {
+    $dao = new CRM_Core_DAO();
+
     $sql = self::createCaseViewsQuery('upcoming');
     CRM_Core_Error::ignoreException();
-    $dao = new CRM_Core_DAO();
     $dao->query($sql);
+    CRM_Core_Error::setCallback();
     if (PEAR::getStaticProperty('DB_DataObject', 'lastError')) {
-      CRM_Core_Error::setCallback();
       return FALSE;
     }
 
     // Above error doesn't get caught?
+    CRM_Core_Error::ignoreException();
     $doublecheck = $dao->singleValueQuery("SELECT count(id) FROM civicrm_view_case_activity_upcoming");
+    CRM_Core_Error::setCallback();
     if (is_null($doublecheck)) {
       return FALSE;
     }
@@ -3113,13 +3116,15 @@ WHERE id IN (' . implode(',', $copiedActivityIds) . ')';
     $sql = self::createCaseViewsQuery('recent');
     CRM_Core_Error::ignoreException();
     $dao->query($sql);
+    CRM_Core_Error::setCallback();
     if (PEAR::getStaticProperty('DB_DataObject', 'lastError')) {
-      CRM_Core_Error::setCallback();
       return FALSE;
     }
 
     // Above error doesn't get caught?
+    CRM_Core_Error::ignoreException();
     $doublecheck = $dao->singleValueQuery("SELECT count(id) FROM civicrm_view_case_activity_recent");
+    CRM_Core_Error::setCallback();
     if (is_null($doublecheck)) {
       return FALSE;
     }
@@ -3216,5 +3221,25 @@ WHERE id IN (' . implode(',', $copiedActivityIds) . ')';
 
     return $clients;
   }
+
+  /**
+   * Get options for a given case field.
+   * @see CRM_Core_DAO::buildOptions
+   *
+   * @param String $fieldName
+   * @param String $context: @see CRM_Core_DAO::buildOptionsContext
+   * @param Array  $props: whatever is known about this dao object
+   */
+  public static function buildOptions($fieldName, $context = NULL, $props = array()) {
+    $className = __CLASS__;
+    $params = array();
+    switch ($fieldName) {
+      // This field is not part of this object but the api supports it
+      case 'medium_id':
+        $className = 'CRM_Activity_BAO_Activity';
+        break;
+    }
+    return CRM_Core_PseudoConstant::get($className, $fieldName, $params, $context);
+  }
 }