1
1
<?php
2
-
3
2
/**
4
- * OS2Web_Print_Send_to_Friend
3
+ * @file
4
+ * os2web_print_send_to_friend
5
5
*
6
6
* PHP version 5
7
7
*
13
13
*/
14
14
15
15
/**
16
- * Implementation of hook_menu().
17
- *
18
- * @return array of links.
16
+ * Implements hook_menu().
19
17
*/
20
18
function os2web_print_send_to_friend_menu() {
21
19
$items = array();
@@ -51,10 +49,10 @@ function os2web_print_send_to_friend_menu() {
51
49
}
52
50
53
51
/**
54
- * Creates a light version of the bullet point for printing
55
- *
56
- * @param int $bullet_point_id bullet point id
52
+ * Creates a light version of the bullet point for printing.
57
53
*
54
+ * @param int $bullet_point_id
55
+ * bullet point id
58
56
*/
59
57
function os2web_print_send_to_friend_print_bullet_point($bullet_point_id) {
60
58
$bullet_point = node_load($bullet_point_id);
@@ -66,18 +64,19 @@ function os2web_print_send_to_friend_print_bullet_point($bullet_point_id) {
66
64
$html .= '<h3>' . $attachment->title . '</h3>';
67
65
$html .= $attachment->field_bpa_body['und'][0]['value'];
68
66
}
67
+
69
68
}
70
69
return ('<div class="node" id="content">' . $html . '</div>');
71
70
}
72
71
73
72
/**
74
- * Creates a form that allows to send the content of the bullet point to an email addess.
75
- *
76
- * @param int $bullet_point_id bullet point id
73
+ * Form callback for send_to_friend_form.
77
74
*
75
+ * Creates a form that allows to send the content of the
76
+ * bullet point to an email addess.
78
77
*/
79
78
function os2web_print_send_to_friend_send_to_friend_form($bullet_point_id) {
80
- //adding css that tweaks the elements for the modal window
79
+ // Adding css that tweaks the elements for the modal window.
81
80
drupal_add_css(drupal_get_path('module', 'os2web_print_send_to_friend') . '/css/os2web_print_send_to_friend.css');
82
81
83
82
drupal_add_js(drupal_get_path('module', 'os2web_print_send_to_friend') . '/js/os2web_print_send_to_friend.js');
@@ -96,57 +95,58 @@ function os2web_print_send_to_friend_send_to_friend_form($bullet_point_id) {
96
95
return '<div class="bullet-point-send-to-friend-form ajax-progress">' . $html . '</div>';
97
96
}
98
97
98
+ /**
99
+ * Form access callback.
100
+ */
99
101
function os2web_print_send_to_friend_bullet_point_access($bullet_point_id) {
100
102
$bullet_point = node_load($bullet_point_id);
101
-
102
103
if (strcmp($bullet_point->type, 'bullet_point') == 0) {
103
- if ($bullet_point->field_bul_point_closed['und'][0]['value'])
104
+ if ($bullet_point->field_bul_point_closed['und'][0]['value']) {
104
105
return TRUE;
105
- else
106
+ }
107
+ else {
106
108
return FALSE;
109
+ }
107
110
}
108
111
return FALSE;
109
112
}
110
113
111
114
/**
112
- * Does the actual sending to the provided email
115
+ * Form callback for os2web_print_send_to_friend_send_to_friend.
113
116
*
114
- * @param int $bullet_point_id bullet point id
115
- * @patam string $email email
117
+ * Does the actual sending to the provided email
116
118
*
119
+ * @param int $bullet_point_id
120
+ * bullet point id
117
121
*/
118
- function os2web_print_send_to_friend_send_to_friend($bullet_point_id){
119
- $bullet_point = node_load($bullet_point_id);
120
- $subject = 'Dagsorden Punkt: ' . $bullet_point->title;
121
-
122
- $name = check_plain(trim($_POST['name']));
123
- $message = check_plain(trim($_POST['message']));
124
- $to_email = check_plain($_POST['email']);
125
-
126
- $body = "Hej \n\n" . $name ." har sendt dig et dagsordenspunkt. \n\n";
127
- $body .= "Med beskeden:\n". $message ."\n\n";
128
-
129
- $body .= os2web_print_send_to_friend_print_bullet_point($bullet_point_id);
130
-
131
- $from = variable_get('system_mail');
132
- $message = array(
133
- 'id' => 'send_to_friend_',
134
- 'to' => $to_email,
135
- 'subject' => $subject,
136
- 'body' => array($body),
137
- 'headers' => array(
138
- 'From' => $from,
139
- 'Sender' => $from,
140
- 'Return-Path' => $from,
141
- 'Content-Type' => 'text/plain; charset=UTF-8;',
142
- 'Content-Transfer-Encoding' => '8Bit',
143
- ),
144
- );
145
- $system = drupal_mail_system("os2web_print_send_to_friend", "");
146
-
147
- // The format function must be called before calling the mail function.
148
- $message = $system->format($message);
149
-
150
-
151
- $system->mail($message);
122
+ function os2web_print_send_to_friend_send_to_friend($bullet_point_id) {
123
+ $bullet_point = node_load($bullet_point_id);
124
+ $subject = 'Dagsorden Punkt: ' . $bullet_point->title;
125
+
126
+ $body = "Hej \n\n" . $_POST['name'] . " har sendt dig et dagsordenspunkt. \n\n";
127
+ $body .= "Med beskeden:\n" . trim($_POST['message']) . "\n\n";
128
+
129
+ $body .= os2web_print_send_to_friend_print_bullet_point($bullet_point_id);
130
+
131
+ $from = variable_get('system_mail');
132
+ $message = array(
133
+ 'id' => 'send_to_friend_',
134
+ 'to' => $_POST['email'],
135
+ 'subject' => $subject,
136
+ 'body' => array($body),
137
+ 'headers' => array(
138
+ 'From' => $from,
139
+ 'Sender' => $from,
140
+ 'Return-Path' => $from,
141
+ 'Content-Type' => 'text/plain; charset=UTF-8;',
142
+ 'Content-Transfer-Encoding' => '8Bit',
143
+ ),
144
+ );
145
+ $system = drupal_mail_system("os2web_print_send_to_friend", "");
146
+
147
+ // The format function must be called before calling the mail function.
148
+ $message = $system->format($message);
149
+
150
+
151
+ $system->mail($message);
152
152
}
0 commit comments