123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386 |
- <?php
- use Drupal\Core\Field\BaseFieldDefinition;
- use Drupal\user\RoleInterface;
- function heartbeat_requirements($phase) {
- $requirements = array();
- if ($phase === 'runtime') {
-
-
-
- $grant_count = \Drupal::entityManager()->getAccessControlHandler('node')->countGrants();
- if ($grant_count != 1 || count(\Drupal::moduleHandler()->getImplementations('node_grants')) > 0) {
- $value = \Drupal::translation()->formatPlural($grant_count, 'One permission in use', '@count permissions in use', array('@count' => $grant_count));
- }
- else {
- $value = t('Disabled');
- }
- $requirements['node_access'] = array(
- 'title' => t('Node Access Permissions'),
- 'value' => $value,
- 'description' => t('If the site is experiencing problems with permissions to content, you may have to rebuild the permissions cache. Rebuilding will remove all privileges to content and replace them with permissions based on the current modules and settings. Rebuilding may take some time if there is a lot of content or complex permission settings. After rebuilding has completed, content will automatically use the new permissions. <a href=":rebuild">Rebuild permissions</a>', array(
- ':rebuild' => \Drupal::url('node.configure_rebuild_confirm'),
- )),
- );
- }
- return $requirements;
- }
- function heartbeat_schema() {
- $schema['heartbeat_messages'] = array(
- 'description' => 'Table that contains predefined messages that can be used in heartbeat views.',
- 'fields' => array(
- 'hid' => array(
- 'description' => 'Primary Key: Unique heartbeat_messages event ID.',
- 'type' => 'serial',
- 'not null' => TRUE,
- ),
- 'message_id' => array(
- 'description' => 'The message id which is unique to identify activity.',
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'default' => '',
- ),
- 'description' => array(
- 'description' => 'Description and help text',
- 'type' => 'text',
- 'not null' => FALSE,
- 'size' => 'big'
- ),
- 'message' => array(
- 'type' => 'text',
- 'not null' => TRUE,
- 'size' => 'big',
- 'description' => 'Text of log message to be passed into the ) function.',
-
- ),
- 'message_concat' => array(
- 'type' => 'text',
- 'not null' => TRUE,
- 'size' => 'big',
- 'description' => 'Text of translatable log message for in concatenated form.',
-
- ),
- 'perms' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => FALSE,
- 'default' => 4,
- 'description' => 'Permissions for this message.',
- ),
- 'group_type' => array(
- 'type' => 'varchar',
- 'length' => 20,
- 'not null' => TRUE,
- 'default' => 'single',
- 'description' => 'The group type of the template',
- ),
- 'concatargs' => array(
- 'description' => 'Arguments for concatenation message.',
- 'type' => 'blob',
- 'serialize' => TRUE,
- 'not null' => FALSE,
- ),
- 'variables' => array(
- 'description' => 'Variables to parse into the message (used in message).',
- 'type' => 'blob',
- 'serialize' => TRUE,
- 'not null' => FALSE,
- ),
- 'attachments' => array(
- 'description' => 'Attachments on messages.',
- 'type' => 'blob',
- 'serialize' => TRUE,
- 'not null' => FALSE,
- ),
- ),
- 'primary key' => array('hid'),
- 'indexes' => array(
- 'message_id' => array('message_id'),
- ),
- );
- $schema['heartbeat_activity']['fields']['in_group'] = array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'size' => 'big',
- 'description' => 'Indicates whether the activity is related to a group.',
- 'default' => 0,
- );
- $schema['heartbeat_activity']['indexes']['in_group'] = array('in_group');
- $schema['heartbeat_user_templates'] = heartbeat_install_table_user_templates();
-
- return $schema;
- }
- function heartbeat_install_table_user_templates() {
- return array(
- 'description' => 'Table that connects translations of the same activity.',
- 'fields' => array(
- 'uid' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'description' => 'The referenced user ID.',
- ),
- 'message_id' => array(
- 'type' => 'varchar',
- 'length' => 250,
- 'not null' => FALSE,
- 'default' => '',
- 'description' => 'The template message ID.',
- ),
- 'status' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'description' => 'The status of the template.',
- ),
- ),
- );
- }
- function heartbeat_uninstall() {
- $entities = \Drupal::service("entity.query")->get("heartbeat")->execute();
- foreach($entities as $entity) {
- $heartbeat = \Drupal::service("entity_type.manager")->getStorage("heartbeat")->load($entity);
- $heartbeat->delete();
- }
- $entities = \Drupal::service("entity.query")->get("heartbeat_stream")->execute();
- foreach($entities as $entity) {
- $heartbeat = \Drupal::service("entity_type.manager")->getStorage("heartbeat")->load($entity);
- $heartbeat->delete();
- }
- }
|