X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCase%2FInfo.php;h=7ee506fe4a161bcffd79d2073a1185a21abe98a3;hb=266a559f66f8242321969f8181b9c0f8c1ef5799;hp=b77352ef8f51e21166817b72c583b5cf7c627e22;hpb=5c10c3bed0db55e2d4fccc7bfbde5df87b9ec35c;p=civicrm-core.git diff --git a/CRM/Case/Info.php b/CRM/Case/Info.php index b77352ef8f..7ee506fe4a 100644 --- a/CRM/Case/Info.php +++ b/CRM/Case/Info.php @@ -1,7 +1,7 @@ 'CiviCase', @@ -52,54 +57,45 @@ class CRM_Case_Info extends CRM_Core_Component_Info { ); } - // docs inherited from interface - public function getManagedEntities() { - // Use hook_civicrm_caseTypes to build a list of OptionValues - // In the long run, we may want more specialized logic for this, but - // this design is fairly convenient and will allow us to replace it - // without changing the hook_civicrm_caseTypes interface. - $entities = array(); - - $caseTypes = array(); - CRM_Utils_Hook::caseTypes($caseTypes); - - $proc = new CRM_Case_XMLProcessor(); - $caseTypesGroupId = civicrm_api3('OptionGroup', 'getvalue', array('name' => 'case_type', 'return' => 'id')); - if (!is_numeric($caseTypesGroupId)) { - throw new CRM_Core_Exception("Found invalid ID for OptionGroup (case_type)"); - } - foreach ($caseTypes as $name => $caseType) { - $xml = $proc->retrieve($name); - if (!$xml) { - throw new CRM_Core_Exception("Failed to load XML for case type (" . $name . ")"); - } + /** + * @inheritDoc + */ + public function getAngularModules() { + $result = array(); + $result['crmCaseType'] = array( + 'ext' => 'civicrm', + 'js' => array('js/angular-crmCaseType.js'), + 'css' => array('css/angular-crmCaseType.css'), + ); - if (isset($caseType['module'], $caseType['name'], $caseType['file'])) { - $entities[] = array( - 'module' => $caseType['module'], - 'name' => $caseType['name'], - 'entity' => 'OptionValue', - 'params' => array( - 'version' => 3, - 'name' => $caseType['name'], - 'label' => (string) $xml->name, - 'description' => (string) $xml->description, // CRM_Utils_Array::value('description', $caseType, ''), - 'option_group_id' => $caseTypesGroupId, - 'filter' => empty($xml->filter) ? 0 : 1, - 'grouping' => $xml->grouping, - 'is_reserved' => 1, - ), - ); - } - else { - throw new CRM_Core_Exception("Invalid case type"); - } - } + CRM_Core_Resources::singleton()->addSetting(array( + 'crmCaseType' => array( + 'REL_TYPE_CNAME' => CRM_Case_XMLProcessor::REL_TYPE_CNAME, + ), + )); + return $result; + } + /** + * @inheritDoc + * @return array + * @throws CRM_Core_Exception + */ + public function getManagedEntities() { + $entities = array_merge( + CRM_Case_ManagedEntities::createManagedCaseTypes(), + CRM_Case_ManagedEntities::createManagedActivityTypes(CRM_Case_XMLRepository::singleton(), CRM_Core_ManagedEntities::singleton()), + CRM_Case_ManagedEntities::createManagedRelationshipTypes(CRM_Case_XMLRepository::singleton(), CRM_Core_ManagedEntities::singleton()) + ); return $entities; } - // docs inherited from interface + /** + * @inheritDoc + * @param bool $getAllUnconditionally + * + * @return array + */ public function getPermissions($getAllUnconditionally = FALSE) { return array( 'delete in CiviCase', @@ -110,32 +106,84 @@ class CRM_Case_Info extends CRM_Core_Component_Info { ); } - // docs inherited from interface + /** + * @inheritDoc + */ + public function getReferenceCounts($dao) { + $result = array(); + if ($dao instanceof CRM_Core_DAO_OptionValue) { + /** @var $dao CRM_Core_DAO_OptionValue */ + $activity_type_gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'activity_type', 'id', 'name'); + if ($activity_type_gid == $dao->option_group_id) { + $count = CRM_Case_XMLRepository::singleton() + ->getActivityReferenceCount($dao->name); + if ($count > 0) { + $result[] = array( + 'name' => 'casetypexml:activities', + 'type' => 'casetypexml', + 'count' => $count, + ); + } + } + } + elseif ($dao instanceof CRM_Contact_DAO_RelationshipType) { + /** @var $dao CRM_Contact_DAO_RelationshipType */ + $count = CRM_Case_XMLRepository::singleton() + ->getRelationshipReferenceCount($dao->{CRM_Case_XMLProcessor::REL_TYPE_CNAME}); + if ($count > 0) { + $result[] = array( + 'name' => 'casetypexml:relationships', + 'type' => 'casetypexml', + 'count' => $count, + ); + } + } + return $result; + } + + /** + * @inheritDoc + * @return array + */ public function getUserDashboardElement() { return array(); } - // docs inherited from interface + /** + * @inheritDoc + * @return array + */ public function registerTab() { - return array('title' => ts('Cases'), + return array( + 'title' => ts('Cases'), 'url' => 'case', 'weight' => 50, ); } - // docs inherited from interface + /** + * @inheritDoc + * @return array + */ public function registerAdvancedSearchPane() { - return array('title' => ts('Cases'), + return array( + 'title' => ts('Cases'), 'weight' => 50, ); } - // docs inherited from interface + /** + * @inheritDoc + * @return null + */ public function getActivityTypes() { return NULL; } - // add shortcut to Create New + /** + * add shortcut to Create New + * @param $shortCuts + */ public function creatNewShortcut(&$shortCuts) { if (CRM_Core_Permission::check('access all cases and activities') || CRM_Core_Permission::check('add cases') @@ -146,11 +194,13 @@ class CRM_Case_Info extends CRM_Core_Component_Info { ); if ($atype) { $shortCuts = array_merge($shortCuts, array( - array('path' => 'civicrm/case/add', - 'query' => "reset=1&action=add&atype=$atype&context=standalone", - 'ref' => 'new-case', - 'title' => ts('Case'), - ))); + array( + 'path' => 'civicrm/case/add', + 'query' => "reset=1&action=add&atype=$atype&context=standalone", + 'ref' => 'new-case', + 'title' => ts('Case'), + ), + )); } } } @@ -161,9 +211,12 @@ class CRM_Case_Info extends CRM_Core_Component_Info { * * If CiviCase is being enabled, load the case related sample data * - * @param array $oldValue List of component names - * @param array $newValue List of component names - * @param array $metadata Specification of the setting (per *.settings.php) + * @param array $oldValue + * List of component names. + * @param array $newValue + * List of component names. + * @param array $metadata + * Specification of the setting (per *.settings.php). */ public static function onToggleComponents($oldValue, $newValue, $metadata) { if ( @@ -171,9 +224,9 @@ class CRM_Case_Info extends CRM_Core_Component_Info { && (!$oldValue || !in_array('CiviCase', $oldValue)) ) { + $pathToCaseSampleTpl = __DIR__ . '/xml/configuration.sample/'; $config = CRM_Core_Config::singleton(); - CRM_Admin_Form_Setting_Component::loadCaseSampleData($config->dsn, $config->sqlDir . 'case_sample.mysql'); - CRM_Admin_Form_Setting_Component::loadCaseSampleData($config->dsn, $config->sqlDir . 'case_sample1.mysql'); + CRM_Admin_Form_Setting_Component::loadCaseSampleData($config->dsn, $pathToCaseSampleTpl . 'case_sample.mysql.tpl'); if (!CRM_Case_BAO_Case::createCaseViews()) { $msg = ts("Could not create the MySQL views for CiviCase. Your mysql user needs to have the 'CREATE VIEW' permission"); CRM_Core_Error::fatal($msg); @@ -181,4 +234,3 @@ class CRM_Case_Info extends CRM_Core_Component_Info { } } } -