Skip to content

Commit c6da490

Browse files
committed
initial commit
0 parents  commit c6da490

File tree

5 files changed

+241
-0
lines changed

5 files changed

+241
-0
lines changed

css/os2web_print_send_to_friend.css

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
html body{
2+
min-width: 0px !important;
3+
}
4+
5+
#region-page-top, #section-header, #breadcrumb, #region-sidebar-first, #region-sidebar-second, #zone-user-wrapper, #zone-menu-wrapper, #section-footer{
6+
display: none;
7+
}
8+
9+
.container-12{
10+
background: #FFF !important;
11+
width: 300px !important;
12+
margin-left: 0px !important;
13+
}
14+
15+
#cccwr {
16+
display: none !important;
17+
}
18+
19+
textarea {
20+
width: 400px !important;
21+
height: 100px !important;
22+
}
23+
24+
input[type="submit"] {
25+
float: right;
26+
}
27+
28+
input[type="text"] {
29+
width: 250px;
30+
}
31+
32+
.vegas-overlay {
33+
background: #FFF !important;
34+
opacity: 1 !important;
35+
}

js/os2web_print_send_to_friend.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
jQuery(document).ready(function($) {
2+
$(".throbber").hide();
3+
$("#send_to_friend_form").submit(function(e){
4+
e.preventDefault;
5+
var $form = $("#send_to_friend_form");
6+
serializedData = $form.serialize();
7+
8+
var email = $("#field_send_to_friend_email").val();
9+
var id = $("#field_bullet_point_id").val();
10+
var base_url = $("#field_base_url").val();
11+
12+
if (!checkEmail(email)){
13+
$("#field_send_to_friend_email").focus();
14+
$("#field_send_to_friend_email").addClass("error");
15+
return false;
16+
} else {
17+
$(".throbber").show();
18+
$("#field_send_to_friend_email").removeClass("error");
19+
20+
$.post(base_url + "/dagsorden_punkt/"+ id +"/send_to_friend_service", serializedData, function(response){
21+
$(".throbber").hide();
22+
parent.Lightbox.end();
23+
});
24+
return false;
25+
}
26+
});
27+
28+
function checkEmail(email) {
29+
var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
30+
return regex.test(email);
31+
}
32+
33+
});

os2web_print_send_to_friend.info

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name = OS2Web Print or Send to Friend
2+
description = A module allowing print bullet point ot send it to friend via email.
3+
core = 7.x
4+
package = OS2Web
5+

os2web_print_send_to_friend.module

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
<?php
2+
3+
/**
4+
* OS2Web_Print_Send_to_Friend
5+
*
6+
* PHP version 5
7+
*
8+
* @category OS2Web
9+
* @package OS2Web_Print_Send_to_Friend
10+
* @author Stanislav Kutasevits <[email protected]>
11+
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
12+
* @link http://bellcom.dk
13+
*/
14+
15+
/**
16+
* Implementation of hook_menu().
17+
*
18+
* @return array of links.
19+
*/
20+
function os2web_print_send_to_friend_menu() {
21+
$items = array();
22+
23+
$items['dagsorden_punkt/%/print'] = array(
24+
'title' => 'Print Dagsorden Punkt',
25+
'type' => MENU_CALLBACK,
26+
'page callback' => 'os2web_print_send_to_friend_print_bullet_point',
27+
'page arguments' => array(1),
28+
'access arguments' => array(1),
29+
'access callback' => 'os2web_print_send_to_friend_bullet_point_access',
30+
);
31+
32+
$items['dagsorden_punkt/%/send_to_friend_form'] = array(
33+
'title' => 'Send dagsorden punkt til venner',
34+
'type' => MENU_CALLBACK,
35+
'page callback' => 'os2web_print_send_to_friend_send_to_friend_form',
36+
'page arguments' => array(1),
37+
'access arguments' => array(1),
38+
'access callback' => 'os2web_print_send_to_friend_bullet_point_access',
39+
);
40+
41+
$items['dagsorden_punkt/%/send_to_friend_service'] = array(
42+
'title' => 'Dagsorden Punkt Send til venner',
43+
'type' => MENU_CALLBACK,
44+
'page callback' => 'os2web_print_send_to_friend_send_to_friend',
45+
'page arguments' => array(1),
46+
'access arguments' => array(1),
47+
'access callback' => 'os2web_print_send_to_friend_bullet_point_access',
48+
);
49+
50+
return $items;
51+
}
52+
53+
/**
54+
* Creates a light version of the bullet point for printing
55+
*
56+
* @param int $bullet_point_id bullet point id
57+
*
58+
*/
59+
function os2web_print_send_to_friend_print_bullet_point($bullet_point_id) {
60+
$bullet_point = node_load($bullet_point_id);
61+
if (strcmp($bullet_point->type, 'bullet_point') == 0) {
62+
$html = '<h1>' . $bullet_point->title . '</h1>';
63+
64+
foreach ($bullet_point->field_ref_attachment['und'] as $attachment_id) {
65+
$attachment = node_load($attachment_id['target_id']);
66+
$html .= '<h3>' . $attachment->title . '</h3>';
67+
$html .= $attachment->field_bpa_body['und'][0]['value'];
68+
}
69+
}
70+
return ('<div class="node" id="content">' . $html . '</div>');
71+
}
72+
73+
/**
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
77+
*
78+
*/
79+
function os2web_print_send_to_friend_send_to_friend_form($bullet_point_id) {
80+
//adding css that tweaks the elements for the modal window
81+
drupal_add_css(drupal_get_path('module', 'os2web_print_send_to_friend') . '/css/os2web_print_send_to_friend.css');
82+
83+
drupal_add_js(drupal_get_path('module', 'os2web_print_send_to_friend') . '/js/os2web_print_send_to_friend.js');
84+
85+
$html = t('Fill out the fields below and press "Send", when you want to send the e-mail');
86+
$html .= '<form id="send_to_friend_form">';
87+
$html .= '<label>' . t('Your name') . ':</label><input type="text" name="name" />';
88+
$html .= '<label>' . t('Message') . ':</label><textarea name="message"> </textarea>';
89+
$html .= '<label>' . t('Recipients email') . ':</label><input type="text" name="email" id="field_send_to_friend_email" />';
90+
$html .= '<input type="hidden" name="base_url" value="' . $GLOBALS['base_url'] . '" />';
91+
$html .= '<input type="hidden" name="bullet_point_id" id="field_bullet_point_id" value="' . $bullet_point_id . '" />';
92+
$html .= '<button type="submit" id="btn_send_to_friend">Send</button>';
93+
$html .= '<div class="throbber"></div>';
94+
$html .= '</form>';
95+
96+
return '<div class="bullet-point-send-to-friend-form ajax-progress">' . $html . '</div>';
97+
}
98+
99+
function os2web_print_send_to_friend_bullet_point_access($bullet_point_id) {
100+
$bullet_point = node_load($bullet_point_id);
101+
102+
if (strcmp($bullet_point->type, 'bullet_point') == 0) {
103+
if ($bullet_point->field_bul_point_closed['und'][0]['value'])
104+
return TRUE;
105+
else
106+
return FALSE;
107+
}
108+
return FALSE;
109+
}
110+
111+
/**
112+
* Does the actual sending to the provided email
113+
*
114+
* @param int $bullet_point_id bullet point id
115+
* @patam string $email email
116+
*
117+
*/
118+
function os2web_print_send_to_friend_send_to_friend($bullet_point_id) {
119+
$query = new EntityFieldQuery();
120+
$result = array_pop($query->entityCondition('entity_type', 'node')
121+
->propertyCondition('type', 'meeting')
122+
->fieldCondition('field_ref_bullet_points', 'target_id', $bullet_point_id, '=')
123+
->execute());
124+
$meeting_id = (int) is_array($result) ? array_pop($result)->nid : null;
125+
126+
$bullet_point = node_load($bullet_point_id);
127+
$subject = 'Dagsorden Punkt: ' . $bullet_point->title;
128+
129+
$body = "Hej \n\n" . $_POST['name'] . " har sendt dig et dagsordenspunkt. \n\n";
130+
131+
if (is_numeric($meeting_id)) {
132+
$url = url('node/' . $meeting_id, array('absolute' => TRUE));
133+
$body .= 'Mødet hvor punktet indgår, kan ses på ' . $url . "\n\n";
134+
}
135+
136+
$body .= "Med beskeden:\n" . trim($_POST['message']) . "\n\n";
137+
138+
$body .= os2web_print_send_to_friend_print_bullet_point($bullet_point_id);
139+
140+
$from = variable_get('system_mail');
141+
$message = array(
142+
'id' => 'send_to_friend_',
143+
'to' => '[email protected]',
144+
'subject' => $subject,
145+
'body' => array($body),
146+
'headers' => array(
147+
'From' => $from,
148+
'Sender' => $from,
149+
'Return-Path' => $from,
150+
'Content-Type' => 'text/plain; charset=UTF-8;',
151+
'Content-Transfer-Encoding' => '8Bit',
152+
),
153+
);
154+
$system = drupal_mail_system("os2web_print_send_to_friend", "");
155+
156+
// The format function must be called before calling the mail function.
157+
$message = $system->format($message);
158+
159+
$system->mail($message);
160+
}

translations/da.po

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
msgid ""
2+
"Fill out the fields below and press \"Send\", when you want to send "
3+
"the e-mail"
4+
msgstr "Udfyld felterne herunder og tryk \"Send\", når du vil sende beskeden."
5+
6+
msgid "Recipients email"
7+
msgstr "Modtagers email"
8+

0 commit comments

Comments
 (0)