Added option to send a copy to yourself.
This commit is contained in:
parent
b1afdedaf5
commit
e906a747c2
@ -46,6 +46,9 @@ class Ecard_Controller extends Controller {
|
|||||||
$to_name = $form->send_ecard->to_name->value;
|
$to_name = $form->send_ecard->to_name->value;
|
||||||
$from_name = $form->send_ecard->from_name->value;
|
$from_name = $form->send_ecard->from_name->value;
|
||||||
$bcc = module::get_var("ecard", "bcc");
|
$bcc = module::get_var("ecard", "bcc");
|
||||||
|
if($form->send_ecard->send_to_self->checked == true) {
|
||||||
|
$cc = $form->send_ecard->inputs["from_email"]->value;
|
||||||
|
}
|
||||||
$v->message = t(module::get_var("ecard", "message"), array("toname" => $to_name, "fromname" => $from_name));
|
$v->message = t(module::get_var("ecard", "message"), array("toname" => $to_name, "fromname" => $from_name));
|
||||||
$v->custom_message = $form->send_ecard->text->value;
|
$v->custom_message = $form->send_ecard->text->value;
|
||||||
$v->image = $item->name;
|
$v->image = $item->name;
|
||||||
@ -57,7 +60,7 @@ class Ecard_Controller extends Controller {
|
|||||||
$mime->setHTMLBody($v->render());
|
$mime->setHTMLBody($v->render());
|
||||||
$mime->addHTMLImage($item->resize_path(),$item->mime_type,$item->name);
|
$mime->addHTMLImage($item->resize_path(),$item->mime_type,$item->name);
|
||||||
$body = $mime->get(array('html_charset' => 'UTF-8', 'text_charset' => 'UTF-8','text_encoding' => '8bit','head_charset' => 'UTF-8'));
|
$body = $mime->get(array('html_charset' => 'UTF-8', 'text_charset' => 'UTF-8','text_encoding' => '8bit','head_charset' => 'UTF-8'));
|
||||||
self::_notify($headers['to'], $headers['from'], $headers['subject'], $item, $body, $mime->headers(), $bcc);
|
self::_notify($headers['to'], $headers['from'], $headers['subject'], $item, $body, $mime->headers(), $bcc, $cc);
|
||||||
message::success("eCard successfully sent");
|
message::success("eCard successfully sent");
|
||||||
json::reply(array("result" => "success"));
|
json::reply(array("result" => "success"));
|
||||||
} else {
|
} else {
|
||||||
@ -75,7 +78,7 @@ class Ecard_Controller extends Controller {
|
|||||||
}
|
}
|
||||||
print ecard::prefill_send_form(ecard::get_send_form($item));
|
print ecard::prefill_send_form(ecard::get_send_form($item));
|
||||||
}
|
}
|
||||||
private static function _notify($to, $from, $subject, $item, $text, $headers, $bcc) {
|
private static function _notify($to, $from, $subject, $item, $text, $headers, $bcc, $cc) {
|
||||||
$sendmail = Sendmail::factory();
|
$sendmail = Sendmail::factory();
|
||||||
$sendmail
|
$sendmail
|
||||||
->to($to)
|
->to($to)
|
||||||
@ -84,6 +87,9 @@ class Ecard_Controller extends Controller {
|
|||||||
if(isset($bcc)) {
|
if(isset($bcc)) {
|
||||||
$sendmail->header("bcc",$bcc);
|
$sendmail->header("bcc",$bcc);
|
||||||
}
|
}
|
||||||
|
if(isset($cc)) {
|
||||||
|
$sendmail->header("cc",$cc);
|
||||||
|
}
|
||||||
foreach($headers as $key => $value) {
|
foreach($headers as $key => $value) {
|
||||||
$sendmail->header($key,$value);
|
$sendmail->header($key,$value);
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,10 @@ class ecard_Core {
|
|||||||
->id("g-text")
|
->id("g-text")
|
||||||
->rules("required")
|
->rules("required")
|
||||||
->error_messages("required", t("You must enter a message"));
|
->error_messages("required", t("You must enter a message"));
|
||||||
|
$group->checkbox("send_to_self")
|
||||||
|
->label(t("Send yourself a copy"))
|
||||||
|
->value(true)
|
||||||
|
->checked(false);
|
||||||
$group->hidden("item_id")->value($item->id);
|
$group->hidden("item_id")->value($item->id);
|
||||||
module::event("ecard_send_form", $form);
|
module::event("ecard_send_form", $form);
|
||||||
module::event("captcha_protect_form", $form);
|
module::event("captcha_protect_form", $form);
|
||||||
|
@ -25,6 +25,6 @@ class ecard_installer {
|
|||||||
"Click the image to be taken to the gallery.");
|
"Click the image to be taken to the gallery.");
|
||||||
module::set_var("ecard", "bcc", "");
|
module::set_var("ecard", "bcc", "");
|
||||||
module::set_var("ecard", "access_permissions", "everybody");
|
module::set_var("ecard", "access_permissions", "everybody");
|
||||||
module::set_version("ecard", 5);
|
module::set_version("ecard", 6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
name = "E-Card"
|
name = "E-Card"
|
||||||
description = "Send a photo as a postcard"
|
description = "Send a photo as a postcard"
|
||||||
version = 5
|
version = 6
|
||||||
|
|
||||||
|
@ -46,6 +46,9 @@ class Ecard_Controller extends Controller {
|
|||||||
$to_name = $form->send_ecard->to_name->value;
|
$to_name = $form->send_ecard->to_name->value;
|
||||||
$from_name = $form->send_ecard->from_name->value;
|
$from_name = $form->send_ecard->from_name->value;
|
||||||
$bcc = module::get_var("ecard", "bcc");
|
$bcc = module::get_var("ecard", "bcc");
|
||||||
|
if($form->send_ecard->send_to_self->checked == true) {
|
||||||
|
$cc = $form->send_ecard->inputs["from_email"]->value;
|
||||||
|
}
|
||||||
$v->message = t(module::get_var("ecard", "message"), array("toname" => $to_name, "fromname" => $from_name));
|
$v->message = t(module::get_var("ecard", "message"), array("toname" => $to_name, "fromname" => $from_name));
|
||||||
$v->custom_message = $form->send_ecard->text->value;
|
$v->custom_message = $form->send_ecard->text->value;
|
||||||
$v->image = $item->name;
|
$v->image = $item->name;
|
||||||
@ -57,7 +60,7 @@ class Ecard_Controller extends Controller {
|
|||||||
$mime->setHTMLBody($v->render());
|
$mime->setHTMLBody($v->render());
|
||||||
$mime->addHTMLImage($item->resize_path(),$item->mime_type,$item->name);
|
$mime->addHTMLImage($item->resize_path(),$item->mime_type,$item->name);
|
||||||
$body = $mime->get(array('html_charset' => 'UTF-8', 'text_charset' => 'UTF-8','text_encoding' => '8bit','head_charset' => 'UTF-8'));
|
$body = $mime->get(array('html_charset' => 'UTF-8', 'text_charset' => 'UTF-8','text_encoding' => '8bit','head_charset' => 'UTF-8'));
|
||||||
self::_notify($headers['to'], $headers['from'], $headers['subject'], $item, $body, $mime->headers(), $bcc);
|
self::_notify($headers['to'], $headers['from'], $headers['subject'], $item, $body, $mime->headers(), $bcc, $cc);
|
||||||
message::success("eCard successfully sent");
|
message::success("eCard successfully sent");
|
||||||
json::reply(array("result" => "success"));
|
json::reply(array("result" => "success"));
|
||||||
} else {
|
} else {
|
||||||
@ -75,7 +78,7 @@ class Ecard_Controller extends Controller {
|
|||||||
}
|
}
|
||||||
print ecard::prefill_send_form(ecard::get_send_form($item));
|
print ecard::prefill_send_form(ecard::get_send_form($item));
|
||||||
}
|
}
|
||||||
private static function _notify($to, $from, $subject, $item, $text, $headers, $bcc) {
|
private static function _notify($to, $from, $subject, $item, $text, $headers, $bcc, $cc) {
|
||||||
$sendmail = Sendmail::factory();
|
$sendmail = Sendmail::factory();
|
||||||
$sendmail
|
$sendmail
|
||||||
->to($to)
|
->to($to)
|
||||||
@ -84,6 +87,9 @@ class Ecard_Controller extends Controller {
|
|||||||
if(isset($bcc)) {
|
if(isset($bcc)) {
|
||||||
$sendmail->header("bcc",$bcc);
|
$sendmail->header("bcc",$bcc);
|
||||||
}
|
}
|
||||||
|
if(isset($cc)) {
|
||||||
|
$sendmail->header("cc",$cc);
|
||||||
|
}
|
||||||
foreach($headers as $key => $value) {
|
foreach($headers as $key => $value) {
|
||||||
$sendmail->header($key,$value);
|
$sendmail->header($key,$value);
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,10 @@ class ecard_Core {
|
|||||||
->id("g-text")
|
->id("g-text")
|
||||||
->rules("required")
|
->rules("required")
|
||||||
->error_messages("required", t("You must enter a message"));
|
->error_messages("required", t("You must enter a message"));
|
||||||
|
$group->checkbox("send_to_self")
|
||||||
|
->label(t("Send yourself a copy"))
|
||||||
|
->value(true)
|
||||||
|
->checked(false);
|
||||||
$group->hidden("item_id")->value($item->id);
|
$group->hidden("item_id")->value($item->id);
|
||||||
module::event("ecard_send_form", $form);
|
module::event("ecard_send_form", $form);
|
||||||
module::event("captcha_protect_form", $form);
|
module::event("captcha_protect_form", $form);
|
||||||
|
@ -25,6 +25,6 @@ class ecard_installer {
|
|||||||
"Click the image to be taken to the gallery.");
|
"Click the image to be taken to the gallery.");
|
||||||
module::set_var("ecard", "bcc", "");
|
module::set_var("ecard", "bcc", "");
|
||||||
module::set_var("ecard", "access_permissions", "everybody");
|
module::set_var("ecard", "access_permissions", "everybody");
|
||||||
module::set_version("ecard", 5);
|
module::set_version("ecard", 6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
name = "E-Card"
|
name = "E-Card"
|
||||||
description = "Send a photo as a postcard"
|
description = "Send a photo as a postcard"
|
||||||
version = 5
|
version = 6
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user