3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
29 * This class introduces component to the system and provides all the
30 * information about it. It needs to extend CRM_Core_Component_Info
34 * @copyright CiviCRM LLC (c) 2004-2014
38 class CRM_Case_Info
extends CRM_Core_Component_Info
{
41 // docs inherited from interface
42 protected $keyword = 'case';
44 // docs inherited from interface
45 public function getInfo() {
48 'translatedName' => ts('CiviCase'),
49 'title' => ts('CiviCase Engine'),
51 'showActivitiesInCore' => 0,
58 public function getAngularModules() {
60 $result['crmCaseType'] = array(
62 'js' => array('js/angular-crmCaseType.js'),
63 'css' => array('css/angular-crmCaseType.css'),
65 // Need full OptionValue records
66 $actStatuses = civicrm_api3('OptionValue', 'get', array('option_group_id' => 'activity_status'));
67 $actTypes = civicrm_api3('OptionValue', 'get', array('option_group_id' => 'activity_type'));
68 CRM_Core_Resources
::singleton()->addSetting(array(
69 'crmCaseType' => array(
70 'actStatuses' => array_values($actStatuses['values']),
71 'actTypes' => array_values($actTypes['values']),
72 //CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name'),
78 // docs inherited from interface
79 public function getManagedEntities() {
80 // Use hook_civicrm_caseTypes to build a list of OptionValues
81 // In the long run, we may want more specialized logic for this, but
82 // this design is fairly convenient and will allow us to replace it
83 // without changing the hook_civicrm_caseTypes interface.
87 CRM_Utils_Hook
::caseTypes($caseTypes);
89 $proc = new CRM_Case_XMLProcessor();
90 foreach ($caseTypes as $name => $caseType) {
91 $xml = $proc->retrieve($name);
93 throw new CRM_Core_Exception("Failed to load XML for case type (" . $name . ")");
96 if (isset($caseType['module'], $caseType['name'], $caseType['file'])) {
98 'module' => $caseType['module'],
99 'name' => $caseType['name'],
100 'entity' => 'CaseType',
103 'name' => $caseType['name'],
104 'title' => (string) $xml->name
,
105 'description' => (string) $xml->description
,
108 'weight' => $xml->weight ?
$xml->weight
: 1,
113 throw new CRM_Core_Exception("Invalid case type");
120 // docs inherited from interface
121 public function getPermissions($getAllUnconditionally = FALSE) {
123 'delete in CiviCase',
124 'administer CiviCase',
125 'access my cases and activities',
126 'access all cases and activities',
131 // docs inherited from interface
132 public function getUserDashboardElement() {
136 // docs inherited from interface
137 public function registerTab() {
138 return array('title' => ts('Cases'),
144 // docs inherited from interface
145 public function registerAdvancedSearchPane() {
146 return array('title' => ts('Cases'),
151 // docs inherited from interface
152 public function getActivityTypes() {
156 // add shortcut to Create New
157 public function creatNewShortcut(&$shortCuts) {
158 if (CRM_Core_Permission
::check('access all cases and activities') ||
159 CRM_Core_Permission
::check('add cases')
161 $atype = CRM_Core_OptionGroup
::getValue('activity_type',
166 $shortCuts = array_merge($shortCuts, array(
167 array('path' => 'civicrm/case/add',
168 'query' => "reset=1&action=add&atype=$atype&context=standalone",
170 'title' => ts('Case'),
178 * Respond to changes in the "enable_components" setting
180 * If CiviCase is being enabled, load the case related sample data
182 * @param array $oldValue List of component names
183 * @param array $newValue List of component names
184 * @param array $metadata Specification of the setting (per *.settings.php)
186 public static function onToggleComponents($oldValue, $newValue, $metadata) {
188 in_array('CiviCase', $newValue)
190 (!$oldValue ||
!in_array('CiviCase', $oldValue))
192 $config = CRM_Core_Config
::singleton();
193 CRM_Admin_Form_Setting_Component
::loadCaseSampleData($config->dsn
, $config->sqlDir
. 'case_sample.mysql');
194 if (!CRM_Case_BAO_Case
::createCaseViews()) {
195 $msg = ts("Could not create the MySQL views for CiviCase. Your mysql user needs to have the 'CREATE VIEW' permission");
196 CRM_Core_Error
::fatal($msg);