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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132 | <?php
function simpletest_example_node_info() {
return array(
'simpletest_example' => array(
'name' => t('Simpletest Example Node Type'),
'module' => 'simpletest_example',
'base' => 'simpletest_example',
'description' => t('simpletest_example page node type.'),
)
);
}
function simpletest_example_permission() {
$perms = array();
$perms['extra special edit any simpletest_example'] = array('title' => t('Extra special edit any Simpletest Example'), 'description' => t('Extra special edit any Simpletest Example'));
return $perms;
}
function simpletest_example_node_access($node, $op, $account) {
$type = is_string($node) ? $node : $node->type;
if ($type != 'simpletest_example' || ($op != 'update' && $op != 'delete')) {
return NODE_ACCESS_IGNORE;
}
if ( ($op == 'delete') && (user_access('extra special edit any simpletest_example', $account) && ($account->uid == $node->uid))) {
return NODE_ACCESS_ALLOW;
}
return NODE_ACCESS_DENY;
}
function simpletest_example_form($node, $form_state) {
$type = node_type_get_type($node);
$form = array();
if ($type->has_title) {
$form['title'] = array(
'#type' => 'textfield',
'#title' => check_plain($type->title_label),
'#required' => TRUE,
'#default_value' => $node->title,
'#maxlength' => 255,
'#weight' => -5,
);
}
return $form;
}
function simpletest_example_menu() {
$items['examples/simpletest_example'] = array(
'title' => 'Simpletest Example',
'description' => 'Explain the simpletest example and allow the error logic to be executed.',
'page callback' => '_simpletest_example_explanation',
'access callback' => TRUE,
);
return $items;
}
function _simpletest_example_explanation() {
$explanation = t("This Simpletest Example is designed to give an introductory tutorial to writing
a simpletest test. Please see the <a href='http://drupal.org/node/890654'>associated tutorial</a>.");
return $explanation;
}
function simpletest_example_empty_mysql_date($date_string) {
if (empty($date_string) || $date_string == '0000-00-00' || $date_string == '0000-00-00 00:00:00') {
return true;
}
return false;
}
|