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
48 public function getInfo() {
51 'translatedName' => ts('CiviCase'),
52 'title' => ts('CiviCase Engine'),
54 'showActivitiesInCore' => 0,
61 public function getAngularModules() {
63 $result['crmCaseType'] = array(
65 'js' => array('js/angular-crmCaseType.js'),
66 'css' => array('css/angular-crmCaseType.css'),
69 CRM_Core_Resources
::singleton()->addSetting(array(
70 'crmCaseType' => array(
71 'REL_TYPE_CNAME' => CRM_Case_XMLProcessor
::REL_TYPE_CNAME
,
77 // docs inherited from interface
80 * @throws CRM_Core_Exception
82 public function getManagedEntities() {
83 $entities = array_merge(
84 CRM_Case_ManagedEntities
::createManagedCaseTypes(),
85 CRM_Case_ManagedEntities
::createManagedActivityTypes(CRM_Case_XMLRepository
::singleton(), CRM_Core_ManagedEntities
::singleton()),
86 CRM_Case_ManagedEntities
::createManagedRelationshipTypes(CRM_Case_XMLRepository
::singleton(), CRM_Core_ManagedEntities
::singleton())
91 // docs inherited from interface
93 * @param bool $getAllUnconditionally
97 public function getPermissions($getAllUnconditionally = FALSE) {
100 'administer CiviCase',
101 'access my cases and activities',
102 'access all cases and activities',
110 public function getReferenceCounts($dao) {
112 if ($dao instanceof CRM_Core_DAO_OptionValue
) {
113 /** @var $dao CRM_Core_DAO_OptionValue */
114 $activity_type_gid = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', 'activity_type', 'id', 'name');
115 if ($activity_type_gid == $dao->option_group_id
) {
116 $count = CRM_Case_XMLRepository
::singleton()
117 ->getActivityReferenceCount($dao->name
);
120 'name' => 'casetypexml:activities',
121 'type' => 'casetypexml',
127 elseif ($dao instanceof CRM_Contact_DAO_RelationshipType
) {
128 /** @var $dao CRM_Contact_DAO_RelationshipType */
129 $count = CRM_Case_XMLRepository
::singleton()
130 ->getRelationshipReferenceCount($dao->{CRM_Case_XMLProcessor
::REL_TYPE_CNAME
});
133 'name' => 'casetypexml:relationships',
134 'type' => 'casetypexml',
142 // docs inherited from interface
146 public function getUserDashboardElement() {
150 // docs inherited from interface
154 public function registerTab() {
155 return array('title' => ts('Cases'),
161 // docs inherited from interface
165 public function registerAdvancedSearchPane() {
166 return array('title' => ts('Cases'),
171 // docs inherited from interface
175 public function getActivityTypes() {
179 // add shortcut to Create New
183 public function creatNewShortcut(&$shortCuts) {
184 if (CRM_Core_Permission
::check('access all cases and activities') ||
185 CRM_Core_Permission
::check('add cases')
187 $atype = CRM_Core_OptionGroup
::getValue('activity_type',
192 $shortCuts = array_merge($shortCuts, array(
193 array('path' => 'civicrm/case/add',
194 'query' => "reset=1&action=add&atype=$atype&context=standalone",
196 'title' => ts('Case'),
204 * Respond to changes in the "enable_components" setting
206 * If CiviCase is being enabled, load the case related sample data
208 * @param array $oldValue List of component names
209 * @param array $newValue List of component names
210 * @param array $metadata Specification of the setting (per *.settings.php)
212 public static function onToggleComponents($oldValue, $newValue, $metadata) {
214 in_array('CiviCase', $newValue)
216 (!$oldValue ||
!in_array('CiviCase', $oldValue))
218 $config = CRM_Core_Config
::singleton();
219 CRM_Admin_Form_Setting_Component
::loadCaseSampleData($config->dsn
, $config->sqlDir
. 'case_sample.mysql');
220 if (!CRM_Case_BAO_Case
::createCaseViews()) {
221 $msg = ts("Could not create the MySQL views for CiviCase. Your mysql user needs to have the 'CREATE VIEW' permission");
222 CRM_Core_Error
::fatal($msg);