-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwot.module
More file actions
109 lines (97 loc) · 3.14 KB
/
wot.module
File metadata and controls
109 lines (97 loc) · 3.14 KB
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
102
103
104
105
106
107
108
<?php
// $Id$
/**
* @file
* Functions for the WOT module.
*/
/**
* Implements hook_init().
*/
function wot_init() {
if ($wot = variable_get('wot', NULL) && drupal_is_front_page()) {
$element = array(
'#tag' => 'meta',
'#attributes' => array(
'name' => 'wot-verification',
'content' => $wot,
),
);
drupal_add_html_head($element, 'wot');
}
}
/**
* Implements hook_requirements().
*/
function wot_requirements($phase) {
if ($phase == 'runtime' && empty(variable_get('wot', NULL))) {
$requirements = array();
$requirements['wot'] = array(
'title' => t('Web of Trust'),
'description' => t('WOT module has not been configured yet. Please configure its settings from the <a href="@url">WOT settings page</a>.', array('@url' => url('admin/config/search/wot'))),
'severity' => REQUIREMENT_ERROR,
'value' => t('Not configured'),
);
return $requirements;
}
}
/**
* Implements hook_help().
*/
function wot_help($path, $arg) {
$message = NULL;
switch ($path) {
case 'admin/help#wot':
$message .= '<p>' . t('Register at <a href="@url">WOT website</a> to get your verification code.', array('@url' => url('http://www.mywot.com/', array('absolute' => TRUE, 'attributes' => array('target' => '_blank'))))) . '</p>';
$message .= '<p>' . t('<a href="@url">Extensions and plugins</a> are available for Firefox, Chrome, Internet Explorer and Safari.', array('@url' => url('http://www.mywot.com/download', array('absolute' => TRUE, 'attributes' => array('target' => '_blank'))))) . '</p>';
break;
case 'admin/config/search/wot':
$message .= '<p>' . t('Please set your Web of Trust verification code.') . '</p>';
break;
}
return $message;
}
/**
* Implements hook_menu().
*/
function wot_menu() {
$items = array();
$items['admin/config/search/wot'] = array(
'title' => 'WOT',
'description' => 'Manage Web of Trust settings.',
'page callback' => 'drupal_get_form',
'page arguments' => array('wot_admin_settings'),
'access callback' => 'user_access',
'access arguments' => array('administer website'),
'type' => MENU_NORMAL_ITEM,
'file' => 'wot.admin.inc',
);
return $items;
}
/**
* Validate wot_admin_settings form.
*/
function wot_admin_settings_validate($form, &$form_state) {
variable_del('wot');
$wot = drupal_strtolower(trim($form_state['values']['wot']));
$form_state['values']['wot'] = $wot;
if (empty($wot)) {
drupal_set_message(t('WOT verification code is empty.'), 'warning');
}
elseif (ctype_xdigit($wot) == FALSE) {
form_set_error('wot', t('Unvalid WOT verification code : only digits and hexadecimal characters are allowed'));
}
}
/**
* Submit wot_admin_settings form.
*/
function wot_admin_settings_submit($form, &$form_state) {
variable_set('wot', $form_state['values']['wot']);
drupal_set_message(t('The configuration options have been saved.'));
}
/**
* Submit Reset button from wot_admin_settings form.
*/
function wot_admin_settings_reset_submit($form, &$form_state) {
variable_del('wot');
drupal_set_message(t('The configuration options have been reset to their default values.'));
}