3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
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
36 class CRM_Case_Info
extends CRM_Core_Component_Info
{
42 protected $keyword = 'case';
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('ang/crmCaseType.js'),
66 'css' => array('ang/crmCaseType.css'),
67 'partials' => array('ang/crmCaseType'),
70 CRM_Core_Resources
::singleton()->addSetting(array(
71 'crmCaseType' => array(
72 'REL_TYPE_CNAME' => CRM_Case_XMLProcessor
::REL_TYPE_CNAME
,
81 * @throws CRM_Core_Exception
83 public function getManagedEntities() {
84 $entities = array_merge(
85 CRM_Case_ManagedEntities
::createManagedCaseTypes(),
86 CRM_Case_ManagedEntities
::createManagedActivityTypes(CRM_Case_XMLRepository
::singleton(), CRM_Core_ManagedEntities
::singleton()),
87 CRM_Case_ManagedEntities
::createManagedRelationshipTypes(CRM_Case_XMLRepository
::singleton(), CRM_Core_ManagedEntities
::singleton())
94 * @param bool $getAllUnconditionally
95 * @param bool $descriptions
96 * Whether to return permission descriptions
100 public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) {
101 $permissions = array(
102 'delete in CiviCase' => array(
103 ts('delete in CiviCase'),
106 'administer CiviCase' => array(
107 ts('administer CiviCase'),
109 'access my cases and activities' => array(
110 ts('access my cases and activities'),
112 'access all cases and activities' => array(
113 ts('access all cases and activities'),
115 'add cases' => array(
120 if (!$descriptions) {
121 foreach ($permissions as $name => $attr) {
122 $permissions[$name] = array_shift($attr);
132 public function getReferenceCounts($dao) {
134 if ($dao instanceof CRM_Core_DAO_OptionValue
) {
135 /** @var $dao CRM_Core_DAO_OptionValue */
136 $activity_type_gid = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', 'activity_type', 'id', 'name');
137 if ($activity_type_gid == $dao->option_group_id
) {
138 $count = CRM_Case_XMLRepository
::singleton()
139 ->getActivityReferenceCount($dao->name
);
142 'name' => 'casetypexml:activities',
143 'type' => 'casetypexml',
149 elseif ($dao instanceof CRM_Contact_DAO_RelationshipType
) {
150 /** @var $dao CRM_Contact_DAO_RelationshipType */
151 $count = CRM_Case_XMLRepository
::singleton()
152 ->getRelationshipReferenceCount($dao->{CRM_Case_XMLProcessor
::REL_TYPE_CNAME
});
155 'name' => 'casetypexml:relationships',
156 'type' => 'casetypexml',
168 public function getUserDashboardElement() {
176 public function registerTab() {
178 'title' => ts('Cases'),
188 public function registerAdvancedSearchPane() {
190 'title' => ts('Cases'),
199 public function getActivityTypes() {
204 * add shortcut to Create New.
207 public function creatNewShortcut(&$shortCuts) {
208 if (CRM_Core_Permission
::check('access all cases and activities') ||
209 CRM_Core_Permission
::check('add cases')
211 $atype = CRM_Core_OptionGroup
::getValue('activity_type',
216 $shortCuts = array_merge($shortCuts, array(
218 'path' => 'civicrm/case/add',
219 'query' => "reset=1&action=add&atype=$atype&context=standalone",
221 'title' => ts('Case'),
230 * Respond to changes in the "enable_components" setting
232 * If CiviCase is being enabled, load the case related sample data
234 * @param array $oldValue
235 * List of component names.
236 * @param array $newValue
237 * List of component names.
238 * @param array $metadata
239 * Specification of the setting (per *.settings.php).
241 public static function onToggleComponents($oldValue, $newValue, $metadata) {
243 in_array('CiviCase', $newValue)
245 (!$oldValue ||
!in_array('CiviCase', $oldValue))
247 $pathToCaseSampleTpl = __DIR__
. '/xml/configuration.sample/';
248 $config = CRM_Core_Config
::singleton();
249 CRM_Admin_Form_Setting_Component
::loadCaseSampleData($config->dsn
, $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);