Initial version of eCard from dmolavi, with carriage returns removed.
This commit is contained in:
parent
1c1e9ad920
commit
6e38f07e9c
65
modules/ecard/controllers/admin_ecards.php
Normal file
65
modules/ecard/controllers/admin_ecards.php
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2010 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class Admin_ecards_Controller extends Admin_Controller {
|
||||||
|
public function index() {
|
||||||
|
$view = new Admin_View("admin.html");
|
||||||
|
$view->page_title = t("eCard settings");
|
||||||
|
$view->content = new View("admin_ecards.html");
|
||||||
|
$view->content->form = $this->_get_admin_form();
|
||||||
|
print $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save() {
|
||||||
|
access::verify_csrf();
|
||||||
|
$form = $this->_get_admin_form();
|
||||||
|
$form->validate();
|
||||||
|
module::set_var(
|
||||||
|
"ecard", "sender", $form->ecard->sender->value);
|
||||||
|
module::set_var(
|
||||||
|
"ecard", "subject", $form->ecard->subject->value);
|
||||||
|
module::set_var(
|
||||||
|
"ecard", "message", $form->ecard->message->value);
|
||||||
|
module::set_var(
|
||||||
|
"ecard", "access_permissions",
|
||||||
|
$form->ecard->access_permissions->value);
|
||||||
|
message::success(t("eCard settings updated"));
|
||||||
|
url::redirect("admin/ecards");
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _get_admin_form() {
|
||||||
|
$form = new Forge("admin/ecards/save", "", "post",
|
||||||
|
array("id" => "g-ecards-admin-form"));
|
||||||
|
$ecard_settings = $form->group("ecard")->label(t("eCard settings"));
|
||||||
|
$ecard_settings->input("sender")->label(t('E-mail Sender (leave blank for a user-defined address)'))
|
||||||
|
->value(module::get_var("ecard", "sender", ""));
|
||||||
|
$ecard_settings->input("subject")->label(t('E-mail Subject'))
|
||||||
|
->value(module::get_var("ecard", "subject", "You have been sent an eCard"));
|
||||||
|
$ecard_settings->textarea("message")->label(t('E-mail Message'))
|
||||||
|
->value(module::get_var("ecard", "message", "Hello %toname%, \r\n%fromname% has sent you an eCard. Click the image to be taken to the gallery."));
|
||||||
|
$ecard_settings->dropdown("access_permissions")
|
||||||
|
->label(t("Who can send eCards?"))
|
||||||
|
->options(array("everybody" => t("Everybody"),
|
||||||
|
"registered_users" => t("Only registered users")))
|
||||||
|
->selected(module::get_var("ecard", "access_permissions"));
|
||||||
|
$ecard_settings->submit("save")->value(t("Save"));
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
77
modules/ecard/controllers/ecards.php
Normal file
77
modules/ecard/controllers/ecards.php
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2010 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class ecards_Controller extends Controller {
|
||||||
|
/**
|
||||||
|
* Add a new ecard to the collection.
|
||||||
|
*/
|
||||||
|
public function create($id) {
|
||||||
|
$item = ORM::factory("item", $id);
|
||||||
|
access::required("view", $item);
|
||||||
|
if (!ecard::can_ecard()) {
|
||||||
|
access::forbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
$form = ecard::get_add_form($item);
|
||||||
|
try {
|
||||||
|
$valid = $form->validate();
|
||||||
|
$form->item_id = $id;
|
||||||
|
$form->author_id = identity::active_user()->id;
|
||||||
|
$form->text = $form->add_ecard->text->value;
|
||||||
|
$form->to_name = $form->add_ecard->inputs["to_name"]->value;
|
||||||
|
$form->to_email = $form->add_ecard->to_email->value;
|
||||||
|
$form->validate();
|
||||||
|
} catch (ORM_Validation_Exception $e) {
|
||||||
|
// Translate ORM validation errors into form error messages
|
||||||
|
foreach ($e->validation->errors() as $key => $error) {
|
||||||
|
switch ($key) {
|
||||||
|
case "to_name": $key = "name"; break;
|
||||||
|
case "to_email": $key = "email"; break;
|
||||||
|
}
|
||||||
|
$form->add_ecard->inputs[$key]->add_error($error, 1);
|
||||||
|
}
|
||||||
|
$valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($valid) {
|
||||||
|
ecard::save();
|
||||||
|
|
||||||
|
print json_encode(
|
||||||
|
array("result" => "success",
|
||||||
|
"view" => (string) $view,
|
||||||
|
"form" => (string) ecard::get_add_form($item)));
|
||||||
|
} else {
|
||||||
|
$form = ecard::prefill_add_form($form);
|
||||||
|
print json_encode(array("result" => "error", "form" => (string) $form));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Present a form for adding a new ecard to this item or editing an existing ecard.
|
||||||
|
*/
|
||||||
|
public function form_add($item_id) {
|
||||||
|
$item = ORM::factory("item", $item_id);
|
||||||
|
access::required("view", $item);
|
||||||
|
if (!ecard::can_ecard()) {
|
||||||
|
access::forbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
print ecard::prefill_add_form(ecard::get_add_form($item));
|
||||||
|
}
|
||||||
|
}
|
45
modules/ecard/css/ecard.css
Normal file
45
modules/ecard/css/ecard.css
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#g-content #g-ecard-form {
|
||||||
|
margin-top: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#g-content #g-ecards {
|
||||||
|
margin-top: 2em;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
#g-content #g-ecards ul li {
|
||||||
|
margin: 1em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#g-content #g-ecards .g-author {
|
||||||
|
border-bottom: 1px solid #ccc;
|
||||||
|
color: #999;
|
||||||
|
height: 32px;
|
||||||
|
line-height: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#g-content #g-ecards ul li div {
|
||||||
|
padding: 0 8px 8px 43px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#g-content #g-ecards .g-avatar {
|
||||||
|
height: 32px;
|
||||||
|
margin-right: .4em;
|
||||||
|
width: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#g-add-ecard {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#g-admin-ecards-menu {
|
||||||
|
margin: 1em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#g-admin-ecards-menu a {
|
||||||
|
margin: 0;
|
||||||
|
padding: .2em .6em;
|
||||||
|
}
|
||||||
|
|
74
modules/ecard/helpers/ecard.php
Normal file
74
modules/ecard/helpers/ecard.php
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2010 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the API for handling ecards.
|
||||||
|
*
|
||||||
|
* Note: by design, this class does not do any permission checking.
|
||||||
|
*/
|
||||||
|
class ecard_Core {
|
||||||
|
static function get_add_form($item) {
|
||||||
|
$form = new Forge("ecards/create/{$item->id}", "", "post", array("id" => "g-ecard-form"));
|
||||||
|
$group = $form->group("add_ecard")->label(t("Send eCard"));
|
||||||
|
$group->input("from_name")
|
||||||
|
->label(t("Your Name"))
|
||||||
|
->id("g-author")
|
||||||
|
->error_messages("required", t("You must enter a name for yourself"));
|
||||||
|
$group->input("from_email")
|
||||||
|
->label(t("Your e-mail"))
|
||||||
|
->id("g-email")
|
||||||
|
->error_messages("required", t("You must enter a valid email address"))
|
||||||
|
->error_messages("invalid", t("You must enter a valid email address"));
|
||||||
|
$group->input("to_name")
|
||||||
|
->label(t("Recipient's Name"))
|
||||||
|
->id("g-recipient")
|
||||||
|
->error_messages("required", t("You must enter a recipient's name"));
|
||||||
|
$group->input("to_email")
|
||||||
|
->label(t("Recipient's e-mail"))
|
||||||
|
->id("g-recip-email")
|
||||||
|
->error_messages("required", t("You must enter a valid email address"))
|
||||||
|
->error_messages("invalid", t("You must enter a valid email address"));
|
||||||
|
$group->textarea("text")
|
||||||
|
->label(t("Message"))
|
||||||
|
->id("g-text")
|
||||||
|
->error_messages("required", t("You must enter a message"));
|
||||||
|
$group->hidden("item_id")->value($item->id);
|
||||||
|
module::event("ecard_add_form", $form);
|
||||||
|
$group->submit("")->value(t("Send"))->class("ui-state-default ui-corner-all");
|
||||||
|
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function prefill_add_form($form) {
|
||||||
|
$active = identity::active_user();
|
||||||
|
if (!$active->guest) {
|
||||||
|
$group = $form->add_ecard;
|
||||||
|
$group->inputs["from_name"]->value($active->full_name)->disabled("disabled");
|
||||||
|
$group->from_email->value($active->email)->disabled("disabled");
|
||||||
|
}
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function can_ecard() {
|
||||||
|
return !identity::active_user()->guest ||
|
||||||
|
module::get_var("ecard", "access_permissions") == "everybody";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
28
modules/ecard/helpers/ecard_event.php
Normal file
28
modules/ecard/helpers/ecard_event.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2010 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class ecard_event_Core {
|
||||||
|
static function admin_menu($menu, $theme) {
|
||||||
|
$menu->get("settings_menu")
|
||||||
|
->append(Menu::factory("link")
|
||||||
|
->id("ecard")
|
||||||
|
->label(t("eCard Settings"))
|
||||||
|
->url(url::site("admin/ecards")));
|
||||||
|
}
|
||||||
|
}
|
43
modules/ecard/helpers/ecard_theme.php
Normal file
43
modules/ecard/helpers/ecard_theme.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2010 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class ecard_theme_Core {
|
||||||
|
static function head($theme) {
|
||||||
|
$theme->css("ecard.css");
|
||||||
|
$theme->script("ecard.js");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
static function admin_head($theme) {
|
||||||
|
$theme->css("ecard.css");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
static function photo_bottom($theme) {
|
||||||
|
$block = new Block;
|
||||||
|
$block->css_id = "g-ecards";
|
||||||
|
$block->title = t("ecards");
|
||||||
|
$block->anchor = "ecards";
|
||||||
|
|
||||||
|
$view = new View("ecards.html");
|
||||||
|
|
||||||
|
$block->content = $view;
|
||||||
|
return $block;
|
||||||
|
}
|
||||||
|
}
|
45
modules/ecard/js/ecard.js
Normal file
45
modules/ecard/js/ecard.js
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
$("document").ready(function() {
|
||||||
|
$("#g-add-ecard").click(function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
if (!$("#g-ecard-form").length) {
|
||||||
|
$.get($(this).attr("href"),
|
||||||
|
{},
|
||||||
|
function(data) {
|
||||||
|
$("#g-ecard-detail").append(data);
|
||||||
|
ajaxify_ecard_form();
|
||||||
|
$.scrollTo("#g-ecard-form-anchor", 800);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$(".g-no-ecards a").click(function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
if (!$("#g-ecard-form").length) {
|
||||||
|
$.get($(this).attr("href"),
|
||||||
|
{},
|
||||||
|
function(data) {
|
||||||
|
$("#g-ecard-detail").append(data);
|
||||||
|
ajaxify_ecard_form();
|
||||||
|
});
|
||||||
|
$(".g-no-ecards").remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function ajaxify_ecard_form() {
|
||||||
|
$("#g-ecards form").ajaxForm({
|
||||||
|
dataType: "json",
|
||||||
|
success: function(data) {
|
||||||
|
if (data.result == "success") {
|
||||||
|
$("#g-ecards #g-ecard-detail ul").append(data.view);
|
||||||
|
$("#g-ecards #g-ecard-detail ul li:last").effect("highlight", {color: "#cfc"}, 8000);
|
||||||
|
$("#g-ecard-form").hide(2000).remove();
|
||||||
|
$("#g-no-ecards").hide(2000);
|
||||||
|
} else {
|
||||||
|
if (data.form) {
|
||||||
|
$("#g-ecards form").replaceWith(data.form);
|
||||||
|
ajaxify_ecard_form();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
125
modules/ecard/models/ecard.php
Normal file
125
modules/ecard/models/ecard.php
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2010 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class ecard_Model extends ORM {
|
||||||
|
function item() {
|
||||||
|
return ORM::factory("item", $this->item_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function author() {
|
||||||
|
return identity::lookup_user($this->author_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function author_name() {
|
||||||
|
$author = $this->author();
|
||||||
|
if ($author->guest) {
|
||||||
|
return $this->from_name;
|
||||||
|
} else {
|
||||||
|
return $author->display_name();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function author_email() {
|
||||||
|
$author = $this->author();
|
||||||
|
if ($author->guest) {
|
||||||
|
return $this->from_email;
|
||||||
|
} else {
|
||||||
|
return $author->email;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add some custom per-instance rules.
|
||||||
|
*/
|
||||||
|
public function validate(Validation $array=null) {
|
||||||
|
// validate() is recursive, only modify the rules on the outermost call.
|
||||||
|
if (!$array) {
|
||||||
|
$this->rules = array(
|
||||||
|
"from_name" => array("callbacks" => array(array($this, "valid_author"))),
|
||||||
|
"from_email" => array("callbacks" => array(array($this, "valid_email"))),
|
||||||
|
"to_name" => array("rules" => array("required")),
|
||||||
|
"item_id" => array("callbacks" => array(array($this, "valid_item"))),
|
||||||
|
"to_email" => array("rules" => array("required")),
|
||||||
|
"message" => array("rules" => array("required")),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::validate($array);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ORM::save()
|
||||||
|
*/
|
||||||
|
public function save() {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a set of restrictions to any following queries to restrict access only to items
|
||||||
|
* viewable by the active user.
|
||||||
|
* @chainable
|
||||||
|
*/
|
||||||
|
public function viewable() {
|
||||||
|
$this->join("items", "items.id", "ecards.item_id");
|
||||||
|
return item::viewable($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make sure we have an appropriate author id set, or a guest name.
|
||||||
|
*/
|
||||||
|
public function valid_author(Validation $v, $field) {
|
||||||
|
if (empty($this->author_id)) {
|
||||||
|
$v->add_error("author_id", "required");
|
||||||
|
} else if ($this->author_id == identity::guest()->id && empty($this->from_name)) {
|
||||||
|
$v->add_error("from_name", "required");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make sure that the email address is legal.
|
||||||
|
*/
|
||||||
|
public function valid_email(Validation $v, $field) {
|
||||||
|
if ($this->author_id == identity::guest()->id) {
|
||||||
|
if (empty($v->from_email)) {
|
||||||
|
$v->add_error("from_email", "required");
|
||||||
|
} else if (!valid::email($v->from_email)) {
|
||||||
|
$v->add_error("from_email", "invalid");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make sure we have a valid associated item id.
|
||||||
|
*/
|
||||||
|
public function valid_item(Validation $v, $field) {
|
||||||
|
if (db::build()
|
||||||
|
->from("items")
|
||||||
|
->where("id", "=", $this->item_id)
|
||||||
|
->count_records() != 1) {
|
||||||
|
$v->add_error("item_id", "invalid");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make sure that the state is legal.
|
||||||
|
*/
|
||||||
|
static function valid_state($value) {
|
||||||
|
return in_array($value, array("published", "unpublished", "spam", "deleted"));
|
||||||
|
}
|
||||||
|
}
|
3
modules/ecard/module.info
Normal file
3
modules/ecard/module.info
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name = "E-Card"
|
||||||
|
description = "Send a photo as a postcard"
|
||||||
|
version = 1
|
7
modules/ecard/views/admin_ecards.html.php
Normal file
7
modules/ecard/views/admin_ecards.html.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
|
<div class="g-block">
|
||||||
|
<h1> <?= t("ecard settings") ?> </h1>
|
||||||
|
<div class="g-block-content">
|
||||||
|
<?= $form ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
12
modules/ecard/views/ecards.html.php
Normal file
12
modules/ecard/views/ecards.html.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
|
<? if (ecard::can_ecard()): ?>
|
||||||
|
<a href="<?= url::site("form/add/ecards/{$item->id}") ?>#ecard-form" id="g-add-ecard"
|
||||||
|
class="g-button ui-corner-all ui-icon-left ui-state-default">
|
||||||
|
<span class="ui-icon ui-icon-ecard"></span>
|
||||||
|
<?= t("Send an eCard") ?>
|
||||||
|
</a>
|
||||||
|
<? endif ?>
|
||||||
|
|
||||||
|
<div id="g-ecard-detail">
|
||||||
|
<a name="ecard-form" id="g-ecard-form-anchor"></a>
|
||||||
|
</div>
|
Reference in New Issue
Block a user