3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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-2015
38 class CRM_Case_Info
extends CRM_Core_Component_Info
{
44 protected $keyword = 'case';
50 public function getInfo() {
53 'translatedName' => ts('CiviCase'),
54 'title' => ts('CiviCase Engine'),
56 'showActivitiesInCore' => 0,
63 public function getAngularModules() {
65 $result['crmCaseType'] = array(
67 'js' => array('ang/crmCaseType.js'),
68 'css' => array('ang/crmCaseType.css'),
69 'partials' => array('ang/crmCaseType'),
72 CRM_Core_Resources
::singleton()->addSetting(array(
73 'crmCaseType' => array(
74 'REL_TYPE_CNAME' => CRM_Case_XMLProcessor
::REL_TYPE_CNAME
,
83 * @throws CRM_Core_Exception
85 public function getManagedEntities() {
86 $entities = array_merge(
87 CRM_Case_ManagedEntities
::createManagedCaseTypes(),
88 CRM_Case_ManagedEntities
::createManagedActivityTypes(CRM_Case_XMLRepository
::singleton(), CRM_Core_ManagedEntities
::singleton()),
89 CRM_Case_ManagedEntities
::createManagedRelationshipTypes(CRM_Case_XMLRepository
::singleton(), CRM_Core_ManagedEntities
::singleton())
96 * @param bool $getAllUnconditionally
97 * @param bool $descriptions
98 * Whether to return permission descriptions
102 public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) {
103 $permissions = array(
104 'delete in CiviCase' => array(
105 ts('delete in CiviCase'),
108 'administer CiviCase' => array(
109 ts('administer CiviCase'),
111 'access my cases and activities' => array(
112 ts('access my cases and activities'),
114 'access all cases and activities' => array(
115 ts('access all cases and activities'),
117 'add cases' => array(
122 if (!$descriptions) {
123 foreach ($permissions as $name => $attr) {
124 $permissions[$name] = array_shift($attr);
134 public function getReferenceCounts($dao) {
136 if ($dao instanceof CRM_Core_DAO_OptionValue
) {
137 /** @var $dao CRM_Core_DAO_OptionValue */
138 $activity_type_gid = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', 'activity_type', 'id', 'name');
139 if ($activity_type_gid == $dao->option_group_id
) {
140 $count = CRM_Case_XMLRepository
::singleton()
141 ->getActivityReferenceCount($dao->name
);
144 'name' => 'casetypexml:activities',
145 'type' => 'casetypexml',
151 elseif ($dao instanceof CRM_Contact_DAO_RelationshipType
) {
152 /** @var $dao CRM_Contact_DAO_RelationshipType */
153 $count = CRM_Case_XMLRepository
::singleton()
154 ->getRelationshipReferenceCount($dao->{CRM_Case_XMLProcessor
::REL_TYPE_CNAME
});
157 'name' => 'casetypexml:relationships',
158 'type' => 'casetypexml',
170 public function getUserDashboardElement() {
178 public function registerTab() {
180 'title' => ts('Cases'),
190 public function registerAdvancedSearchPane() {
192 'title' => ts('Cases'),
201 public function getActivityTypes() {
206 * add shortcut to Create New.
209 public function creatNewShortcut(&$shortCuts) {
210 if (CRM_Core_Permission
::check('access all cases and activities') ||
211 CRM_Core_Permission
::check('add cases')
213 $atype = CRM_Core_OptionGroup
::getValue('activity_type',
218 $shortCuts = array_merge($shortCuts, array(
220 'path' => 'civicrm/case/add',
221 'query' => "reset=1&action=add&atype=$atype&context=standalone",
223 'title' => ts('Case'),
232 * Respond to changes in the "enable_components" setting
234 * If CiviCase is being enabled, load the case related sample data
236 * @param array $oldValue
237 * List of component names.
238 * @param array $newValue
239 * List of component names.
240 * @param array $metadata
241 * Specification of the setting (per *.settings.php).
243 public static function onToggleComponents($oldValue, $newValue, $metadata) {
245 in_array('CiviCase', $newValue)
247 (!$oldValue ||
!in_array('CiviCase', $oldValue))
249 $pathToCaseSampleTpl = __DIR__
. '/xml/configuration.sample/';
250 $config = CRM_Core_Config
::singleton();
251 CRM_Admin_Form_Setting_Component
::loadCaseSampleData($config->dsn
, $pathToCaseSampleTpl . 'case_sample.mysql.tpl');
252 if (!CRM_Case_BAO_Case
::createCaseViews()) {
253 $msg = ts("Could not create the MySQL views for CiviCase. Your mysql user needs to have the 'CREATE VIEW' permission");
254 CRM_Core_Error
::fatal($msg);