1
0

trying to recommit the deletion of old files.

This commit is contained in:
dmolavi 2010-08-08 15:33:21 -04:00
parent 435b677141
commit e94df5cdd0

View File

@ -1,98 +1,95 @@
<?php defined("SYSPATH") or die("No direct script access."); <?php defined("SYSPATH") or die("No direct script access.");
/** /**
* Gallery - a web based photo album viewer and editor * Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2010 Bharat Mediratta * Copyright (C) 2000-2010 Bharat Mediratta
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at * the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
class Ecard_Controller extends Controller {
/** class Ecard_Controller extends Controller {
* Send the ecard. /**
*/ * Send the ecard.
public function send($id) { */
$item = ORM::factory("item", $id); public function send($id) {
access::required("view", $item); $item = ORM::factory("item", $id);
if (!ecard::can_send_ecard()) { access::required("view", $item);
access::forbidden(); if (!ecard::can_send_ecard()) {
} access::forbidden();
}
$form = ecard::get_send_form($item); $form = ecard::get_send_form($item);
try { try {
$valid = $form->validate(); $valid = $form->validate();
} catch (ORM_Validation_Exception $e) { } catch (ORM_Validation_Exception $e) {
// Translate ORM validation errors into form error messages // Translate ORM validation errors into form error messages
foreach ($e->validation->errors() as $key => $error) { foreach ($e->validation->errors() as $key => $error) {
$form->edit_item->inputs[$key]->add_error($error, 1); $form->edit_item->inputs[$key]->add_error($error, 1);
} }
$valid = false; $valid = false;
} }
if ($valid) { if ($valid) {
$v = new View("ecard_email.html"); $v = new View("ecard_email.html");
$v->item = $item; $v->item = $item;
$v->subject = module::get_var("ecard", "subject"); $v->subject = module::get_var("ecard", "subject");
$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");
$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;
$to = $form->send_ecard->inputs["to_email"]->value; $to = $form->send_ecard->inputs["to_email"]->value;
$from = $form->send_ecard->inputs["from_email"]->value; $from = $form->send_ecard->inputs["from_email"]->value;
$headers = array("from" => $from_name."<".$from.">", "to" => $to, "subject" => module::get_var("ecard", "subject")); $headers = array("from" => $from_name."<".$from.">", "to" => $to, "subject" => module::get_var("ecard", "subject"));
require_once(MODPATH. "ecard/lib/mime.php"); require_once(MODPATH. "ecard/lib/mime.php");
$mime = new Mail_mime("\n"); $mime = new Mail_mime("\n");
$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);
message::success("eCard successfully sent"); message::success("eCard successfully sent");
json::reply(array("result" => "success")); json::reply(array("result" => "success"));
} else { } else {
json::reply(array("result" => "error", "html" => (string) $form)); json::reply(array("result" => "error", "html" => (string) $form));
} }
} }
/**
/** * Present a form for sending a new ecard.
* Present a form for sending a new ecard. */
*/ public function form_send($item_id) {
public function form_send($item_id) { $item = ORM::factory("item", $item_id);
$item = ORM::factory("item", $item_id); access::required("view", $item);
access::required("view", $item); if (!ecard::can_send_ecard()) {
if (!ecard::can_send_ecard()) { access::forbidden();
access::forbidden(); }
} 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) {
} $sendmail = Sendmail::factory();
$sendmail
private static function _notify($to, $from, $subject, $item, $text, $headers, $bcc) { ->to($to)
$sendmail = Sendmail::factory(); ->from($from)
$sendmail ->subject($subject);
->to($to) if(isset($bcc)) {
->from($from) $sendmail->header("bcc",$bcc);
->subject($subject); }
if(isset($bcc)) { foreach($headers as $key => $value) {
$sendmail->header("bcc",$bcc); $sendmail->header($key,$value);
} }
foreach($headers as $key => $value) { $sendmail
$sendmail->header($key,$value); ->message($text)
} ->send();
$sendmail return;
->message($text) }
->send(); }
return;
}
}