crm_core.module in CRM Core 7
Same filename and directory in other branches
Provides basic functionality for a CRM Core.
File
crm_core.moduleView source
<?php
/**
* @file
* Provides basic functionality for a CRM Core.
*/
/**
* Implements hook_help().
*/
function crm_core_help($path, $arg) {
switch ($path) {
case 'admin/help#crm_core':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('CRM Core is a set of modules for managing contacts, activities and relationships within your Drupal website. It is designed to provide a basic framework for managing these items and interacting with other components of Drupal. For more information, see the online handbook entry for <a href="@crm_core">CRM Core module</a>.', array(
'@crm_core' => 'https://www.drupal.org/docs/7/modules/crm-core',
)) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<p>' . t('CRM Core is a tool for developing your own systems for managing contact relationships. It was built in a way that makes it easy to expand basic features in meaningful ways by creating small, useful applications that extend what it can do. In this sense, CRM Core can be considered a platform within Drupal for creating your own CRM systems, which are portable, reliable and can be implemented over and over again.') . '</p>';
$output .= '<dt>' . t('General') . '</dt>';
$output .= '<dd>' . t('CRM Core is used to track contacts, relationships and activities. It creates these things as fieldable entities, meaning you can add as many custom fields as you want. It includes a variety of bulk operations for merging contacts, putting people into households, sending messages via email, and the like.') . '</dd>';
$output .= '<dt>' . t('Design') . '</dt>';
$output .= '<dd>' . t('CRM Core is designed to be easily managed by anyone who knows how to work with Drupal. This ensures that a specialized knowledge is not required in order to work with the system. The majority of components can be managed through drag-and-drop interfaces, and everything can be easily themed using skills you probably already have.') . '</dd>';
$output .= '<dt>' . t('Features') . '</dt>';
$output .= '<dd>' . t('CRM Core was built so that users can create small, useful applications that extend the operations of the core platform in meaningful ways. Its modular design allows administrators to easily select features that are useful in their specific use case, and ignore the ones that are not. The user interface for CRM Core itself can be turned off and replaced with something different. The default matching engine provided by CRM Core can be replaced with other custom matching engines simply by turning off a module.') . '</dd>';
$output .= '</dl>';
return $output;
}
}
/**
* Implements hook_hook_info().
*/
function crm_core_hook_info() {
$hooks = array(
'crm_core_entity_access' => array(
'group' => 'crm_core',
),
);
}
/**
* Return permission names for a given entity type.
*/
function crm_core_entity_access_permissions($entity_type) {
$entity_info = entity_get_info($entity_type);
$labels = $entity_info['permission labels'];
$permissions = array();
// General 'administer' permission.
$permissions['administer ' . $entity_type . ' entities'] = array(
'title' => t('Administer @entity_type', array(
'@entity_type' => $labels['plural'],
)),
'description' => t('Allows users to perform any action on @entity_type.', array(
'@entity_type' => $labels['plural'],
)),
'restrict access' => TRUE,
);
// Generic create and edit permissions.
$permissions['create ' . $entity_type . ' entities'] = array(
'title' => t('Create @entity_type of any type', array(
'@entity_type' => $labels['plural'],
)),
);
if (!empty($entity_info['access arguments']['user key'])) {
$permissions['edit own ' . $entity_type . ' entities'] = array(
'title' => t('Edit own @entity_type of any type', array(
'@entity_type' => $labels['plural'],
)),
);
}
$permissions['edit any ' . $entity_type . ' entity'] = array(
'title' => t('Edit any @entity_type of any type', array(
'@entity_type' => $labels['singular'],
)),
'restrict access' => TRUE,
);
if (!empty($entity_info['access arguments']['user key'])) {
$permissions['view own ' . $entity_type . ' entities'] = array(
'title' => t('View own @entity_type of any type', array(
'@entity_type' => $labels['plural'],
)),
);
}
$permissions['view any ' . $entity_type . ' entity'] = array(
'title' => t('View any @entity_type of any type', array(
'@entity_type' => $labels['singular'],
)),
'restrict access' => TRUE,
);
// Per-bundle create and edit permissions.
if (!empty($entity_info['entity keys']['bundle'])) {
foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
$permissions += crm_core_bundle_access_permissions($bundle_name, $bundle_info, $entity_type, $entity_info);
}
}
return $permissions;
}
/**
* Define per-bundle permissions.
*/
function crm_core_bundle_access_permissions($bundle_name, $bundle_info, $entity_type, $entity_info = array()) {
$labels = $entity_info['permission labels'];
$permissions['create ' . $entity_type . ' entities of bundle ' . $bundle_name] = array(
'title' => t('Create %bundle @entity_type', array(
'@entity_type' => $labels['plural'],
'%bundle' => $bundle_info['label'],
)),
);
if (!empty($entity_info['access arguments']['user key'])) {
$permissions['edit own ' . $entity_type . ' entities of bundle ' . $bundle_name] = array(
'title' => t('Edit own %bundle @entity_type', array(
'@entity_type' => $labels['plural'],
'%bundle' => $bundle_info['label'],
)),
);
}
$permissions['edit any ' . $entity_type . ' entity of bundle ' . $bundle_name] = array(
'title' => t('Edit any %bundle @entity_type', array(
'@entity_type' => $labels['singular'],
'%bundle' => $bundle_info['label'],
)),
'restrict access' => TRUE,
);
if (!empty($entity_info['access arguments']['user key'])) {
$permissions['delete own ' . $entity_type . ' entities of bundle ' . $bundle_name] = array(
'title' => t('Delete own %bundle @entity_type', array(
'@entity_type' => $labels['plural'],
'%bundle' => $bundle_info['label'],
)),
);
}
$permissions['delete any ' . $entity_type . ' entity of bundle ' . $bundle_name] = array(
'title' => t('Delete any %bundle @entity_type', array(
'@entity_type' => $labels['singular'],
'%bundle' => $bundle_info['label'],
)),
'restrict access' => TRUE,
);
if (!empty($entity_info['access arguments']['user key'])) {
$permissions['view own ' . $entity_type . ' entities of bundle ' . $bundle_name] = array(
'title' => t('View own %bundle @entity_type', array(
'@entity_type' => $labels['plural'],
'%bundle' => $bundle_info['label'],
)),
);
}
$permissions['view any ' . $entity_type . ' entity of bundle ' . $bundle_name] = array(
'title' => t('View any %bundle @entity_type', array(
'@entity_type' => $labels['singular'],
'%bundle' => $bundle_info['label'],
)),
'restrict access' => TRUE,
);
return $permissions;
}
Functions
Name | Description |
---|---|
crm_core_bundle_access_permissions | Define per-bundle permissions. |
crm_core_entity_access_permissions | Return permission names for a given entity type. |
crm_core_help | Implements hook_help(). |
crm_core_hook_info | Implements hook_hook_info(). |