Merge pull request #4958 from pratikshad/code-cleanup-batch-19
[civicrm-core.git] / CRM / Case / Info.php
index 6cdfb926502d79765ef495e961a1a01dc6f9f194..7ee506fe4a161bcffd79d2073a1185a21abe98a3 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
 class CRM_Case_Info extends CRM_Core_Component_Info {
 
 
-  // docs inherited from interface
+  /**
+   * @inheritDoc
+   */
   protected $keyword = 'case';
 
-  // docs inherited from interface
   /**
+   * @inheritDoc
    * @return array
    */
   public function getInfo() {
@@ -56,7 +58,7 @@ class CRM_Case_Info extends CRM_Core_Component_Info {
   }
 
   /**
-   * {@inheritDoc}
+   * @inheritDoc
    */
   public function getAngularModules() {
     $result = array();
@@ -65,36 +67,17 @@ class CRM_Case_Info extends CRM_Core_Component_Info {
       'js' => array('js/angular-crmCaseType.js'),
       'css' => array('css/angular-crmCaseType.css'),
     );
-    // Need full OptionValue records
-    $actStatuses = civicrm_api3('OptionValue', 'get', array('option_group_id' => 'activity_status'));
-    $actTypes = civicrm_api3('OptionValue', 'get', array(
-      'option_group_id' => 'activity_type',
-      'options' => array(
-        'sort' => 'name',
-        'limit' => 0,
-      ),
-    ));
-    $relTypes = civicrm_api3('RelationshipType', 'get', array(
-      'options' => array(
-        'sort' => CRM_Case_XMLProcessor::REL_TYPE_CNAME,
-        'limit' => 0,
-      )
-    ));
 
     CRM_Core_Resources::singleton()->addSetting(array(
       'crmCaseType' => array(
-        'actStatuses' => array_values($actStatuses['values']),
-        'actTypes' => array_values($actTypes['values']),
-        'relTypes' => array_values($relTypes['values']),
-        //CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name'),
-
+        'REL_TYPE_CNAME' => CRM_Case_XMLProcessor::REL_TYPE_CNAME,
       ),
     ));
     return $result;
   }
 
-  // docs inherited from interface
   /**
+   * @inheritDoc
    * @return array
    * @throws CRM_Core_Exception
    */
@@ -107,8 +90,8 @@ class CRM_Case_Info extends CRM_Core_Component_Info {
     return $entities;
   }
 
-  // docs inherited from interface
   /**
+   * @inheritDoc
    * @param bool $getAllUnconditionally
    *
    * @return array
@@ -124,7 +107,7 @@ class CRM_Case_Info extends CRM_Core_Component_Info {
   }
 
   /**
-   * {@inheritdoc}
+   * @inheritDoc
    */
   public function getReferenceCounts($dao) {
     $result = array();
@@ -158,45 +141,47 @@ class CRM_Case_Info extends CRM_Core_Component_Info {
     return $result;
   }
 
-  // docs inherited from interface
   /**
+   * @inheritDoc
    * @return array
    */
   public function getUserDashboardElement() {
     return array();
   }
 
-  // docs inherited from interface
   /**
+   * @inheritDoc
    * @return array
    */
   public function registerTab() {
-    return array('title' => ts('Cases'),
+    return array(
+      'title' => ts('Cases'),
       'url' => 'case',
       'weight' => 50,
     );
   }
 
-  // docs inherited from interface
   /**
+   * @inheritDoc
    * @return array
    */
   public function registerAdvancedSearchPane() {
-    return array('title' => ts('Cases'),
+    return array(
+      'title' => ts('Cases'),
       'weight' => 50,
     );
   }
 
-  // docs inherited from interface
   /**
+   * @inheritDoc
    * @return null
    */
   public function getActivityTypes() {
     return NULL;
   }
 
-  // add shortcut to Create New
   /**
+   * add shortcut to Create New
    * @param $shortCuts
    */
   public function creatNewShortcut(&$shortCuts) {
@@ -209,11 +194,13 @@ class CRM_Case_Info extends CRM_Core_Component_Info {
       );
       if ($atype) {
         $shortCuts = array_merge($shortCuts, array(
-          array('path' => 'civicrm/case/add',
-              'query' => "reset=1&action=add&atype=$atype&context=standalone",
-              'ref' => 'new-case',
-              'title' => ts('Case'),
-            )));
+          array(
+            'path' => 'civicrm/case/add',
+            'query' => "reset=1&action=add&atype=$atype&context=standalone",
+            'ref' => 'new-case',
+            'title' => ts('Case'),
+          ),
+        ));
       }
     }
   }
@@ -224,9 +211,12 @@ class CRM_Case_Info extends CRM_Core_Component_Info {
    *
    * If CiviCase is being enabled, load the case related sample data
    *
-   * @param array $oldValue List of component names
-   * @param array $newValue List of component names
-   * @param array $metadata Specification of the setting (per *.settings.php)
+   * @param array $oldValue
+   *   List of component names.
+   * @param array $newValue
+   *   List of component names.
+   * @param array $metadata
+   *   Specification of the setting (per *.settings.php).
    */
   public static function onToggleComponents($oldValue, $newValue, $metadata) {
     if (
@@ -234,8 +224,9 @@ class CRM_Case_Info extends CRM_Core_Component_Info {
       &&
       (!$oldValue || !in_array('CiviCase', $oldValue))
     ) {
+      $pathToCaseSampleTpl = __DIR__ . '/xml/configuration.sample/';
       $config = CRM_Core_Config::singleton();
-      CRM_Admin_Form_Setting_Component::loadCaseSampleData($config->dsn, $config->sqlDir . 'case_sample.mysql');
+      CRM_Admin_Form_Setting_Component::loadCaseSampleData($config->dsn, $pathToCaseSampleTpl . 'case_sample.mysql.tpl');
       if (!CRM_Case_BAO_Case::createCaseViews()) {
         $msg = ts("Could not create the MySQL views for CiviCase. Your mysql user needs to have the 'CREATE VIEW' permission");
         CRM_Core_Error::fatal($msg);
@@ -243,4 +234,3 @@ class CRM_Case_Info extends CRM_Core_Component_Info {
     }
   }
 }
-