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,
55 // docs inherited from interface
56 public function getManagedEntities() {
57 // Use hook_civicrm_caseTypes to build a list of OptionValues
58 // In the long run, we may want more specialized logic for this, but
59 // this design is fairly convenient and will allow us to replace it
60 // without changing the hook_civicrm_caseTypes interface.
64 CRM_Utils_Hook
::caseTypes($caseTypes);
66 $proc = new CRM_Case_XMLProcessor();
67 foreach ($caseTypes as $name => $caseType) {
68 $xml = $proc->retrieve($name);
70 throw new CRM_Core_Exception("Failed to load XML for case type (" . $name . ")");
73 if (isset($caseType['module'], $caseType['name'], $caseType['file'])) {
75 'module' => $caseType['module'],
76 'name' => $caseType['name'],
77 'entity' => 'CaseType',
80 'name' => $caseType['name'],
81 'title' => (string) $xml->name
,
82 'description' => (string) $xml->description
,
85 'weight' => $xml->weight ?
$xml->weight
: 1,
90 throw new CRM_Core_Exception("Invalid case type");
97 // docs inherited from interface
98 public function getPermissions($getAllUnconditionally = FALSE) {
100 'delete in CiviCase',
101 'administer CiviCase',
102 'access my cases and activities',
103 'access all cases and activities',
108 // docs inherited from interface
109 public function getUserDashboardElement() {
113 // docs inherited from interface
114 public function registerTab() {
115 return array('title' => ts('Cases'),
121 // docs inherited from interface
122 public function registerAdvancedSearchPane() {
123 return array('title' => ts('Cases'),
128 // docs inherited from interface
129 public function getActivityTypes() {
133 // add shortcut to Create New
134 public function creatNewShortcut(&$shortCuts) {
135 if (CRM_Core_Permission
::check('access all cases and activities') ||
136 CRM_Core_Permission
::check('add cases')
138 $atype = CRM_Core_OptionGroup
::getValue('activity_type',
143 $shortCuts = array_merge($shortCuts, array(
144 array('path' => 'civicrm/case/add',
145 'query' => "reset=1&action=add&atype=$atype&context=standalone",
147 'title' => ts('Case'),
155 * Respond to changes in the "enable_components" setting
157 * If CiviCase is being enabled, load the case related sample data
159 * @param array $oldValue List of component names
160 * @param array $newValue List of component names
161 * @param array $metadata Specification of the setting (per *.settings.php)
163 public static function onToggleComponents($oldValue, $newValue, $metadata) {
165 in_array('CiviCase', $newValue)
167 (!$oldValue ||
!in_array('CiviCase', $oldValue))
169 $config = CRM_Core_Config
::singleton();
170 CRM_Admin_Form_Setting_Component
::loadCaseSampleData($config->dsn
, $config->sqlDir
. 'case_sample.mysql');
171 if (!CRM_Case_BAO_Case
::createCaseViews()) {
172 $msg = ts("Could not create the MySQL views for CiviCase. Your mysql user needs to have the 'CREATE VIEW' permission");
173 CRM_Core_Error
::fatal($msg);