forked from socketwench/flag-drupal8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flag.install
101 lines (94 loc) · 3.4 KB
/
flag.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/**
* @file
* Flag module install/schema/update hooks.
*/
/**
* Implements hook_schema().
*/
function flag_schema() {
$schema = [];
$schema['flag_counts'] = [
'description' => 'The number of times an item has been flagged.',
'fields' => [
'fid' => [
'type' => 'varchar',
'length' => '32',
],
'entity_type' => [
'description' => 'The flag type, usually one of "node", "comment", "user".',
'type' => 'varchar',
'length' => '128',
],
'entity_id' => [
'description' => 'The unique ID of the content, usually either the {cid}, {uid}, or {nid}.',
'type' => 'int',
'unsigned' => TRUE,
'disp-width' => '10',
],
'count' => [
'description' => 'The number of times this object has been flagged for this flag.',
'type' => 'int',
'unsigned' => TRUE,
'disp-width' => '10',
],
'last_updated' => [
'description' => 'The UNIX time stamp representing when the flag was last updated.',
'type' => 'int',
'unsigned' => TRUE,
'disp-size' => 11,
],
],
'primary key' => ['fid', 'entity_id'],
'indexes' => [
'fid_entity_type' => ['fid', 'entity_type'],
'entity_type_entity_id' => ['entity_type', 'entity_id'],
'fid_count' => ['fid', 'count'],
'fid_last_updated' => ['fid', 'last_updated'],
],
];
return $schema;
}
/**
* Implements hook_uninstall().
*/
function flag_uninstall() {
drupal_set_message(t('Flag has been uninstalled.'));
}
/**
* Implements hook_requirements().
*/
function flag_requirements($phase) {
$requirements = array();
/*
if ($phase == 'runtime') {
if (\Drupal::moduleHandler()->moduleExists('translation') && !\Drupal::moduleHandler()->moduleExists('translation_helpers')) {
$requirements['flag_translation'] = array(
'title' => t('Flag'),
'severity' => REQUIREMENT_ERROR,
'description' => t('To have the flag module work with translations, you need to install and enable the <a href="http://drupal.org/project/translation_helpers">Translation helpers</a> module.'),
'value' => t('Translation helpers module not found.'),
);
}
if (\Drupal::moduleHandler()->moduleExists('session_api')) {
if (file_exists('./robots.txt')) {
$flag_path = url('flag') . '/';
// We don't use url() because this may return an absolute URL when
// language negotiation is set to 'domain'.
$flag_path = parse_url($flag_path, PHP_URL_PATH);
$robots_string = 'Disallow: ' . $flag_path;
$contents = file_get_contents('./robots.txt');
if (strpos($contents, $robots_string) === FALSE) {
$requirements['flag_robots'] = array(
'title' => t('Flag robots.txt problem'),
'severity' => REQUIREMENT_WARNING,
'description' => t('Flag module may currently be used with anonymous users, however the robots.txt file does not exclude the "@flag-path" path, which may cause search engines to randomly flag and unflag content when they index the site. It is highly recommended to add "@robots-string" to your robots.txt file (located in the root of your Drupal installation).', array('@flag-path' => $flag_path, '@robots-string' => $robots_string)),
'value' => t('Search engines flagging content'),
);
}
}
}
}
*/
return $requirements;
}