<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
class CRM_Case_Info extends CRM_Core_Component_Info {
- // docs inherited from interface
+ /**
+ * @inheritDoc
+ */
protected $keyword = 'case';
- // docs inherited from interface
+ /**
+ * @inheritDoc
+ * @return array
+ */
public function getInfo() {
return array(
'name' => 'CiviCase',
}
/**
- * {@inheritDoc}
+ * @inheritDoc
*/
public function getAngularModules() {
$result = array();
'js' => array('js/angular-crmCaseType.js'),
'css' => array('css/angular-crmCaseType.css'),
);
- // Need full OptionValue records
- $actStatuses = civicrm_api3('OptionValue', 'get', array('option_group_id' => 'activity_status'));
- $actTypes = civicrm_api3('OptionValue', 'get', array('option_group_id' => 'activity_type'));
+
CRM_Core_Resources::singleton()->addSetting(array(
'crmCaseType' => array(
- 'actStatuses' => array_values($actStatuses['values']),
- 'actTypes' => array_values($actTypes['values']),
- //CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name'),
+ 'REL_TYPE_CNAME' => CRM_Case_XMLProcessor::REL_TYPE_CNAME,
),
));
return $result;
}
- // docs inherited from interface
+ /**
+ * @inheritDoc
+ * @return array
+ * @throws CRM_Core_Exception
+ */
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();
- foreach ($caseTypes as $name => $caseType) {
- $xml = $proc->retrieve($name);
- if (!$xml) {
- throw new CRM_Core_Exception("Failed to load XML for case type (" . $name . ")");
- }
-
- if (isset($caseType['module'], $caseType['name'], $caseType['file'])) {
- $entities[] = array(
- 'module' => $caseType['module'],
- 'name' => $caseType['name'],
- 'entity' => 'CaseType',
- 'params' => array(
- 'version' => 3,
- 'name' => $caseType['name'],
- 'title' => (string) $xml->name,
- 'description' => (string) $xml->description,
- 'is_reserved' => 1,
- 'is_active' => 1,
- 'weight' => $xml->weight ? $xml->weight : 1,
- ),
- );
- }
- else {
- throw new CRM_Core_Exception("Invalid case type");
- }
- }
-
+ $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',
}
/**
- * {@inheritdoc}
+ * @inheritDoc
*/
public function getReferenceCounts($dao) {
$result = array();
return $result;
}
- // docs inherited from interface
+ /**
+ * @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')
);
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'),
+ ),
+ ));
}
}
}
*
* 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 (
&&
(!$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, $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);
}
}
}
-