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('ext' => 'civicrm', 'files' => array('js/angular-crmCaseType.js'));
64 // docs inherited from interface
65 public function getManagedEntities() {
66 // Use hook_civicrm_caseTypes to build a list of OptionValues
67 // In the long run, we may want more specialized logic for this, but
68 // this design is fairly convenient and will allow us to replace it
69 // without changing the hook_civicrm_caseTypes interface.
73 CRM_Utils_Hook
::caseTypes($caseTypes);
75 $proc = new CRM_Case_XMLProcessor();
76 foreach ($caseTypes as $name => $caseType) {
77 $xml = $proc->retrieve($name);
79 throw new CRM_Core_Exception("Failed to load XML for case type (" . $name . ")");
82 if (isset($caseType['module'], $caseType['name'], $caseType['file'])) {
84 'module' => $caseType['module'],
85 'name' => $caseType['name'],
86 'entity' => 'CaseType',
89 'name' => $caseType['name'],
90 'title' => (string) $xml->name
,
91 'description' => (string) $xml->description
,
94 'weight' => $xml->weight ?
$xml->weight
: 1,
99 throw new CRM_Core_Exception("Invalid case type");
106 // docs inherited from interface
107 public function getPermissions($getAllUnconditionally = FALSE) {
109 'delete in CiviCase',
110 'administer CiviCase',
111 'access my cases and activities',
112 'access all cases and activities',
117 // docs inherited from interface
118 public function getUserDashboardElement() {
122 // docs inherited from interface
123 public function registerTab() {
124 return array('title' => ts('Cases'),
130 // docs inherited from interface
131 public function registerAdvancedSearchPane() {
132 return array('title' => ts('Cases'),
137 // docs inherited from interface
138 public function getActivityTypes() {
142 // add shortcut to Create New
143 public function creatNewShortcut(&$shortCuts) {
144 if (CRM_Core_Permission
::check('access all cases and activities') ||
145 CRM_Core_Permission
::check('add cases')
147 $atype = CRM_Core_OptionGroup
::getValue('activity_type',
152 $shortCuts = array_merge($shortCuts, array(
153 array('path' => 'civicrm/case/add',
154 'query' => "reset=1&action=add&atype=$atype&context=standalone",
156 'title' => ts('Case'),
164 * Respond to changes in the "enable_components" setting
166 * If CiviCase is being enabled, load the case related sample data
168 * @param array $oldValue List of component names
169 * @param array $newValue List of component names
170 * @param array $metadata Specification of the setting (per *.settings.php)
172 public static function onToggleComponents($oldValue, $newValue, $metadata) {
174 in_array('CiviCase', $newValue)
176 (!$oldValue ||
!in_array('CiviCase', $oldValue))
178 $config = CRM_Core_Config
::singleton();
179 CRM_Admin_Form_Setting_Component
::loadCaseSampleData($config->dsn
, $config->sqlDir
. 'case_sample.mysql');
180 if (!CRM_Case_BAO_Case
::createCaseViews()) {
181 $msg = ts("Could not create the MySQL views for CiviCase. Your mysql user needs to have the 'CREATE VIEW' permission");
182 CRM_Core_Error
::fatal($msg);