Added code changes
This commit is contained in:
@ -175,7 +175,7 @@ function entitytemplates_civicrm_entityTypes(&$entityTypes) {
|
||||
_entitytemplates_civix_civicrm_entityTypes($entityTypes);
|
||||
$entityTypes[] = [
|
||||
'name' => 'EntityTemplates',
|
||||
'class' => 'CRM_Core_DAO_EntityTemplates',
|
||||
'class' => 'CRM_EntityTemplates_BAO_EntityTemplates',
|
||||
'table' => 'civicrm_entity_templates',
|
||||
];
|
||||
}
|
||||
@ -197,3 +197,67 @@ function entitytemplates_civicrm_navigationMenu(&$menu) {
|
||||
]);
|
||||
_entitytemplates_civix_navigationMenu($menu);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_civicrm_preProcess().
|
||||
*
|
||||
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_preProcess
|
||||
*
|
||||
*/
|
||||
function entitytemplates_civicrm_preProcess($formName, &$form) {
|
||||
CRM_EntityTemplates_Utils::preProcess($formName, $form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_civicrm_buildForm().
|
||||
*
|
||||
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_buildForm
|
||||
*
|
||||
*/
|
||||
function entitytemplates_civicrm_buildForm($formName, &$form) {
|
||||
if ($formName == 'CRM_Admin_Form_Options' && $form->getVar('_gName') == 'entity_template_for') {
|
||||
$form->add(
|
||||
'text',
|
||||
'name',
|
||||
ts('Url'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'name')
|
||||
);
|
||||
}
|
||||
CRM_EntityTemplates_Utils::buildForm($formName, $form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_civicrm_pre().
|
||||
*
|
||||
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_pre
|
||||
*
|
||||
*/
|
||||
function entitytemplates_civicrm_pre($op, $objectName, $id, &$params) {
|
||||
if ($op == 'create') {
|
||||
CRM_EntityTemplates_Utils::addTemplate($objectName, $params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_civicrm_validateForm().
|
||||
*
|
||||
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_validateForm
|
||||
*
|
||||
*/
|
||||
function entitytemplates_civicrm_validateForm($formName, &$fields, &$files, &$form, &$errors) {
|
||||
if ($form->_entityTemplate) {
|
||||
if (!empty($fields['entity_template_title'])) {
|
||||
$params = [
|
||||
'title' => $fields['entity_template_title'],
|
||||
'entity_table' => $form->_entityTemplate,
|
||||
];
|
||||
if ($form->_entityTemplateId) {
|
||||
$params['id'] = ['NOT IN' => [$form->_entityTemplateId]];
|
||||
}
|
||||
$count = civicrm_api3('EntityTemplates', 'getcount', $params);
|
||||
if ($count) {
|
||||
$errors['entity_template_title'] = ts('Title already exists.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user