3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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-2019
36 class CRM_Case_Info
extends CRM_Core_Component_Info
{
43 protected $keyword = 'case';
49 public function getInfo() {
52 'translatedName' => ts('CiviCase'),
53 'title' => ts('CiviCase Engine'),
55 'showActivitiesInCore' => 0,
62 public function getAngularModules() {
66 $result['crmCaseType'] = include "$civicrm_root/ang/crmCaseType.ang.php";
73 * @throws CRM_Core_Exception
75 public function getManagedEntities() {
76 $entities = array_merge(
77 CRM_Case_ManagedEntities
::createManagedCaseTypes(),
78 CRM_Case_ManagedEntities
::createManagedActivityTypes(CRM_Case_XMLRepository
::singleton(), CRM_Core_ManagedEntities
::singleton()),
79 CRM_Case_ManagedEntities
::createManagedRelationshipTypes(CRM_Case_XMLRepository
::singleton(), CRM_Core_ManagedEntities
::singleton())
86 * @param bool $getAllUnconditionally
87 * @param bool $descriptions
88 * Whether to return permission descriptions
92 public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) {
94 'delete in CiviCase' => [
95 ts('delete in CiviCase'),
98 'administer CiviCase' => [
99 ts('administer CiviCase'),
100 ts('Define case types, access deleted cases'),
102 'access my cases and activities' => [
103 ts('access my cases and activities'),
104 ts('View and edit only those cases managed by this user'),
106 'access all cases and activities' => [
107 ts('access all cases and activities'),
108 ts('View and edit all cases (for visible contacts)'),
112 ts('Open a new case'),
116 if (!$descriptions) {
117 foreach ($permissions as $name => $attr) {
118 $permissions[$name] = array_shift($attr);
128 public function getReferenceCounts($dao) {
130 if ($dao instanceof CRM_Core_DAO_OptionValue
) {
131 /** @var $dao CRM_Core_DAO_OptionValue */
132 $activity_type_gid = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', 'activity_type', 'id', 'name');
133 if ($activity_type_gid == $dao->option_group_id
) {
134 $count = CRM_Case_XMLRepository
::singleton()
135 ->getActivityReferenceCount($dao->name
);
138 'name' => 'casetypexml:activities',
139 'type' => 'casetypexml',
145 elseif ($dao instanceof CRM_Contact_DAO_RelationshipType
) {
146 /** @var $dao CRM_Contact_DAO_RelationshipType */
147 $count = CRM_Case_XMLRepository
::singleton()
148 ->getRelationshipReferenceCount($dao->{CRM_Case_XMLProcessor
::REL_TYPE_CNAME
});
151 'name' => 'casetypexml:relationships',
152 'type' => 'casetypexml',
164 public function getUserDashboardElement() {
172 public function registerTab() {
174 'title' => ts('Cases'),
184 public function getIcon() {
185 return 'crm-i fa-folder-open-o';
192 public function registerAdvancedSearchPane() {
194 'title' => ts('Cases'),
203 public function getActivityTypes() {
208 * add shortcut to Create New.
211 public function creatNewShortcut(&$shortCuts) {
212 if (CRM_Core_Permission
::check('access all cases and activities') ||
213 CRM_Core_Permission
::check('add cases')
215 $activityType = CRM_Core_PseudoConstant
::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Open Case');
217 $shortCuts = array_merge($shortCuts, [
219 'path' => 'civicrm/case/add',
220 'query' => "reset=1&action=add&atype={$activityType}&context=standalone",
222 'title' => ts('Case'),
231 * Respond to changes in the "enable_components" setting
233 * If CiviCase is being enabled, load the case related sample data
235 * @param array $oldValue
236 * List of component names.
237 * @param array $newValue
238 * List of component names.
239 * @param array $metadata
240 * Specification of the setting (per *.settings.php).
242 public static function onToggleComponents($oldValue, $newValue, $metadata) {
244 in_array('CiviCase', $newValue)
246 (!$oldValue ||
!in_array('CiviCase', $oldValue))
248 $pathToCaseSampleTpl = __DIR__
. '/xml/configuration.sample/';
249 CRM_Admin_Form_Setting_Component
::loadCaseSampleData($pathToCaseSampleTpl . 'case_sample.mysql.tpl');
250 if (!CRM_Case_BAO_Case
::createCaseViews()) {
251 $msg = ts("Could not create the MySQL views for CiviCase. Your mysql user needs to have the 'CREATE VIEW' permission");
252 CRM_Core_Error
::fatal($msg);
259 * Array(string $value => string $label).
261 public static function getRedactOptions() {
263 'default' => ts('Default'),
264 '0' => ts('Do not redact emails'),
265 '1' => ts('Redact emails'),
271 * Array(string $value => string $label).
273 public static function getMultiClientOptions() {
275 'default' => ts('Default'),
276 '0' => ts('Single client per case'),
277 '1' => ts('Multiple client per case'),
283 * Array(string $value => string $label).
285 public static function getSortOptions() {
287 'default' => ts('Default'),
288 '0' => ts('Definition order'),
289 '1' => ts('Alphabetical order'),