200 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			200 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
require_once 'entitytemplates.civix.php';
 | 
						|
use CRM_Entitytemplates_ExtensionUtil as E;
 | 
						|
 | 
						|
/**
 | 
						|
 * Implements hook_civicrm_config().
 | 
						|
 *
 | 
						|
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_config
 | 
						|
 */
 | 
						|
function entitytemplates_civicrm_config(&$config) {
 | 
						|
  _entitytemplates_civix_civicrm_config($config);
 | 
						|
}
 | 
						|
 | 
						|
/**
 | 
						|
 * Implements hook_civicrm_xmlMenu().
 | 
						|
 *
 | 
						|
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_xmlMenu
 | 
						|
 */
 | 
						|
function entitytemplates_civicrm_xmlMenu(&$files) {
 | 
						|
  _entitytemplates_civix_civicrm_xmlMenu($files);
 | 
						|
}
 | 
						|
 | 
						|
/**
 | 
						|
 * Implements hook_civicrm_install().
 | 
						|
 *
 | 
						|
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install
 | 
						|
 */
 | 
						|
function entitytemplates_civicrm_install() {
 | 
						|
  _entitytemplates_civix_civicrm_install();
 | 
						|
}
 | 
						|
 | 
						|
/**
 | 
						|
 * Implements hook_civicrm_postInstall().
 | 
						|
 *
 | 
						|
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_postInstall
 | 
						|
 */
 | 
						|
function entitytemplates_civicrm_postInstall() {
 | 
						|
  _entitytemplates_civix_civicrm_postInstall();
 | 
						|
}
 | 
						|
 | 
						|
/**
 | 
						|
 * Implements hook_civicrm_uninstall().
 | 
						|
 *
 | 
						|
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall
 | 
						|
 */
 | 
						|
function entitytemplates_civicrm_uninstall() {
 | 
						|
  _entitytemplates_civix_civicrm_uninstall();
 | 
						|
  CRM_Core_DAO::executeQuery('
 | 
						|
    DROP TABLE IF EXISTS civicrm_entity_templates;
 | 
						|
  ');
 | 
						|
}
 | 
						|
 | 
						|
/**
 | 
						|
 * Implements hook_civicrm_enable().
 | 
						|
 *
 | 
						|
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_enable
 | 
						|
 */
 | 
						|
function entitytemplates_civicrm_enable() {
 | 
						|
  _entitytemplates_civix_civicrm_enable();
 | 
						|
}
 | 
						|
 | 
						|
/**
 | 
						|
 * Implements hook_civicrm_disable().
 | 
						|
 *
 | 
						|
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_disable
 | 
						|
 */
 | 
						|
function entitytemplates_civicrm_disable() {
 | 
						|
  _entitytemplates_civix_civicrm_disable();
 | 
						|
}
 | 
						|
 | 
						|
/**
 | 
						|
 * Implements hook_civicrm_upgrade().
 | 
						|
 *
 | 
						|
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_upgrade
 | 
						|
 */
 | 
						|
function entitytemplates_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) {
 | 
						|
  return _entitytemplates_civix_civicrm_upgrade($op, $queue);
 | 
						|
}
 | 
						|
 | 
						|
/**
 | 
						|
 * Implements hook_civicrm_managed().
 | 
						|
 *
 | 
						|
 * Generate a list of entities to create/deactivate/delete when this module
 | 
						|
 * is installed, disabled, uninstalled.
 | 
						|
 *
 | 
						|
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_managed
 | 
						|
 */
 | 
						|
function entitytemplates_civicrm_managed(&$entities) {
 | 
						|
  _entitytemplates_civix_civicrm_managed($entities);
 | 
						|
  $entities[] = [
 | 
						|
    'module' => 'com.megaphonetech.entitytemplates',
 | 
						|
    'name' => 'entity_template_for',
 | 
						|
    'entity' => 'OptionGroup',
 | 
						|
    'params' => [
 | 
						|
      'name' => 'entity_template_for',
 | 
						|
      'title' => ts('Entity Template for'),
 | 
						|
      'data_type' => 'String',
 | 
						|
      'is_reserved' => 1,
 | 
						|
      'is_active' => 1,
 | 
						|
      'is_locked' => 0,
 | 
						|
      'version' => 3,
 | 
						|
    ],
 | 
						|
  ];
 | 
						|
  foreach ([
 | 
						|
    'Individual' => ['CRM_Contact_Form_Contact', 'civicrm/contact/add?reset=1&ct=Individual'],
 | 
						|
    'Organization' => ['CRM_Contact_Form_Contact', 'civicrm/contact/add?reset=1&ct=Organization'],
 | 
						|
    'Contribution' => ['CRM_Contribute_Form_Contribution', 'civicrm/contribute/add?reset=1&action=add&context=standalone'],
 | 
						|
  ] as $entityType => $formClassName) {
 | 
						|
    $entities[] = [
 | 
						|
      'module' => 'com.megaphonetech.entitytemplates',
 | 
						|
      'name' => $entityType,
 | 
						|
      'entity' => 'OptionValue',
 | 
						|
      'params' => [
 | 
						|
        'version' => 3,
 | 
						|
        'option_group_id' => 'entity_template_for',
 | 
						|
        'label' => ts("{$entityType}"),
 | 
						|
        'value' => $entityType,
 | 
						|
        'name' => $formClassName[1],
 | 
						|
        'description' => $formClassName[0],
 | 
						|
        'is_default' => '0',
 | 
						|
        'weight' => '1',
 | 
						|
        'is_optgroup' => '0',
 | 
						|
        'is_reserved' => '0',
 | 
						|
        'is_active' => '1'
 | 
						|
      ],
 | 
						|
    ];
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
/**
 | 
						|
 * Implements hook_civicrm_caseTypes().
 | 
						|
 *
 | 
						|
 * Generate a list of case-types.
 | 
						|
 *
 | 
						|
 * Note: This hook only runs in CiviCRM 4.4+.
 | 
						|
 *
 | 
						|
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_caseTypes
 | 
						|
 */
 | 
						|
function entitytemplates_civicrm_caseTypes(&$caseTypes) {
 | 
						|
  _entitytemplates_civix_civicrm_caseTypes($caseTypes);
 | 
						|
}
 | 
						|
 | 
						|
/**
 | 
						|
 * Implements hook_civicrm_angularModules().
 | 
						|
 *
 | 
						|
 * Generate a list of Angular modules.
 | 
						|
 *
 | 
						|
 * Note: This hook only runs in CiviCRM 4.5+. It may
 | 
						|
 * use features only available in v4.6+.
 | 
						|
 *
 | 
						|
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules
 | 
						|
 */
 | 
						|
function entitytemplates_civicrm_angularModules(&$angularModules) {
 | 
						|
  _entitytemplates_civix_civicrm_angularModules($angularModules);
 | 
						|
}
 | 
						|
 | 
						|
/**
 | 
						|
 * Implements hook_civicrm_alterSettingsFolders().
 | 
						|
 *
 | 
						|
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_alterSettingsFolders
 | 
						|
 */
 | 
						|
function entitytemplates_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
 | 
						|
  _entitytemplates_civix_civicrm_alterSettingsFolders($metaDataFolders);
 | 
						|
}
 | 
						|
 | 
						|
/**
 | 
						|
 * Implements hook_civicrm_entityTypes().
 | 
						|
 *
 | 
						|
 * Declare entity types provided by this module.
 | 
						|
 *
 | 
						|
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_entityTypes
 | 
						|
 */
 | 
						|
function entitytemplates_civicrm_entityTypes(&$entityTypes) {
 | 
						|
  _entitytemplates_civix_civicrm_entityTypes($entityTypes);
 | 
						|
  $entityTypes[] = [
 | 
						|
    'name'  => 'EntityTemplates',
 | 
						|
    'class' => 'CRM_Core_DAO_EntityTemplates',
 | 
						|
    'table' => 'civicrm_entity_templates',
 | 
						|
  ];
 | 
						|
}
 | 
						|
 | 
						|
/**
 | 
						|
 * Implements hook_civicrm_navigationMenu().
 | 
						|
 *
 | 
						|
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_navigationMenu
 | 
						|
 *
 | 
						|
 */
 | 
						|
function entitytemplates_civicrm_navigationMenu(&$menu) {
 | 
						|
  _entitytemplates_civix_insert_navigation_menu($menu, 'Administer/Customize Data and Screens', [
 | 
						|
    'label' => ts('Entity Templates', ['domain' => 'com.megaphonetech.entitytemplates']),
 | 
						|
    'name' => 'entity_templates',
 | 
						|
    'url' => CRM_Utils_System::url('civicrm/entity/templates', 'reset=1&action=browse', TRUE),
 | 
						|
    'active' => 1,
 | 
						|
    'permission_operator' => 'AND',
 | 
						|
    'permission' => 'administer CiviCRM',
 | 
						|
  ]);
 | 
						|
  _entitytemplates_civix_navigationMenu($menu);
 | 
						|
}
 |