summaryrefslogtreecommitdiff
path: root/modules/digibug
diff options
context:
space:
mode:
Diffstat (limited to 'modules/digibug')
-rw-r--r--modules/digibug/controllers/admin_digibug.php26
-rw-r--r--modules/digibug/controllers/digibug.php96
-rw-r--r--modules/digibug/helpers/digibug_installer.php52
-rw-r--r--modules/digibug/helpers/digibug_menu.php51
-rw-r--r--modules/digibug/helpers/digibug_theme.php24
-rw-r--r--modules/digibug/images/digibug_logo.pngbin0 -> 17296 bytes
-rw-r--r--modules/digibug/js/digibug.js36
-rw-r--r--modules/digibug/models/digibug_proxy.php21
-rw-r--r--modules/digibug/module.info3
-rw-r--r--modules/digibug/views/admin_digibug.html.php22
-rw-r--r--modules/digibug/views/digibug_form.html.php11
11 files changed, 342 insertions, 0 deletions
diff --git a/modules/digibug/controllers/admin_digibug.php b/modules/digibug/controllers/admin_digibug.php
new file mode 100644
index 00000000..7124338f
--- /dev/null
+++ b/modules/digibug/controllers/admin_digibug.php
@@ -0,0 +1,26 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 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_Digibug_Controller extends Admin_Controller {
+ public function index() {
+ $v = new Admin_View("admin.html");
+ $v->content = new View("admin_digibug.html");
+ print $v;
+ }
+} \ No newline at end of file
diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php
new file mode 100644
index 00000000..c1852009
--- /dev/null
+++ b/modules/digibug/controllers/digibug.php
@@ -0,0 +1,96 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 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 Digibug_Controller extends Controller {
+ public function print_photo($id) {
+ access::verify_csrf();
+ $item = ORM::factory("item", $id);
+ access::required("view_full", $item);
+
+ if (access::group_can(group::everybody(), "view_full", $item)) {
+ $full_url = $item->file_url(true);
+ $thumb_url = $item->thumb_url(true);
+ } else {
+ $proxy = ORM::factory("digibug_proxy");
+ $proxy->uuid = md5(rand());
+ $proxy->item_id = $item->id;
+ $proxy->save();
+ $full_url = url::abs_site("digibug/print_proxy/full/$proxy->uuid");
+ $thumb_url = url::abs_site("digibug/print_proxy/thumb/$proxy->uuid");
+ }
+
+ $v = new View("digibug_form.html");
+ $v->order_parms = array(
+ "digibug_api_version" => "100",
+ "company_id" => module::get_var("digibug", "company_id"),
+ "event_id" => module::get_var("digibug", "event_id"),
+ "cmd" => "addimg",
+ "return_url" => url::abs_site("digibug/close_window"),
+ "num_images" => "1",
+ "image_1" => $full_url,
+ "thumb_1" => $thumb_url,
+ "image_height_1" => $item->height,
+ "image_width_1" => $item->width,
+ "thumb_height_1" => $item->thumb_height,
+ "thumb_width_1" => $item->thumb_width,
+ "title_1" => p::clean($item->title));
+
+ print $v;
+ }
+
+ public function print_proxy($type, $id) {
+ $proxy = ORM::factory("digibug_proxy", array("uuid", $id));
+ if (!$proxy->loaded || !$proxy->item->loaded) {
+ Kohana::show_404();
+ }
+
+ $file = $type == "full" ? $proxy->item->file_path() : $proxy->item->thumb_path();
+ if (!file_exists($file)) {
+ kohana::show_404();
+ }
+
+ // We don't need to save the session for this request
+ Session::abort_save();
+
+ // Dump out the image
+ header("Content-Type: $proxy->item->mime_type");
+ Kohana::close_buffers(false);
+ $fd = fopen($file, "rb");
+ fpassthru($fd);
+ fclose($fd);
+
+ // If the request was for the image and not the thumb, then delete the proxy.
+ if ($type == "full") {
+ $proxy->delete();
+ }
+
+ $this->_clean_expired();
+ }
+
+ public function close_window() {
+ print "<script type=\"text/javascript\">window.close();</script>";
+ }
+
+ private function _clean_expired() {
+ Database::instance()>query(
+ "DELETE FROM {digibug_proxy} " .
+ "WHERE request_date <= (CURDATE() - INTERVAL 10 DAY) " .
+ "LIMIT 20");
+ }
+} \ No newline at end of file
diff --git a/modules/digibug/helpers/digibug_installer.php b/modules/digibug/helpers/digibug_installer.php
new file mode 100644
index 00000000..1cd78b44
--- /dev/null
+++ b/modules/digibug/helpers/digibug_installer.php
@@ -0,0 +1,52 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 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 digibug_installer {
+ static function install() {
+ Database::instance()
+ ->query("CREATE TABLE {digibug_proxies} (
+ `id` int(9) NOT NULL AUTO_INCREMENT,
+ `uuid` char(32) NOT NULL,
+ `request_date` TIMESTAMP NOT NULL DEFAULT current_timestamp,
+ `item_id` int(9) NOT NULL,
+ PRIMARY KEY (`id`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+
+ module::set_var("digibug", "company_id", "3153");
+ module::set_var("digibug", "event_id", "8491");
+ module::set_version("digibug", 2);
+ }
+
+ static function upgrade($version) {
+ if ($version == 1) {
+ module::clear_var("digibug", "default_company_id");
+ module::clear_var("digibug", "default_event_id");
+ module::clear_var("digibug", "basic_default_company_id");
+ module::clear_var("digibug", "basic_event_id");
+ module::set_var("digibug", "company_id", "3153");
+ module::set_var("digibug", "event_id", "8491");
+ module::set_version("digibug", $version = 2);
+ }
+ }
+
+ static function uninstall() {
+ Database::instance()->query("DROP TABLE IF EXISTS {digibug_proxies}");
+ module::delete("digibug");
+ }
+}
diff --git a/modules/digibug/helpers/digibug_menu.php b/modules/digibug/helpers/digibug_menu.php
new file mode 100644
index 00000000..4b8db5a2
--- /dev/null
+++ b/modules/digibug/helpers/digibug_menu.php
@@ -0,0 +1,51 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 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 digibug_menu {
+ static function admin($menu, $theme) {
+ $menu->get("settings_menu")
+ ->append(Menu::factory("link")
+ ->id("digibug_menu")
+ ->label(t("Digibug"))
+ ->url(url::site("admin/digibug")));
+ }
+
+ static function photo($menu, $theme) {
+ $item = $theme->item();
+ $menu->append(
+ Menu::factory("link")
+ ->id("digibug")
+ ->label(t("Print with Digibug"))
+ ->url("javascript:digibug_popup('" .
+ url::site("digibug/print_photo/$item->id?csrf=$theme->csrf") . "')")
+ ->css_id("gDigibugLink"));
+ }
+
+ static function thumb($menu, $theme, $item) {
+ if ($item->type == "photo" && access::can("view_full", $item)) {
+ $menu->append(
+ Menu::factory("link")
+ ->id("digibug")
+ ->label(t("Print with Digibug"))
+ ->url("javascript:digibug_popup('" .
+ url::site("digibug/print_photo/$item->id?csrf=$theme->csrf") . "')")
+ ->css_id("gDigibugLink"));
+ }
+ }
+}
diff --git a/modules/digibug/helpers/digibug_theme.php b/modules/digibug/helpers/digibug_theme.php
new file mode 100644
index 00000000..f94d07c6
--- /dev/null
+++ b/modules/digibug/helpers/digibug_theme.php
@@ -0,0 +1,24 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 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 digibug_theme_Core {
+ static function head($theme) {
+ $theme->script("modules/digibug/js/digibug.js");
+ }
+}
diff --git a/modules/digibug/images/digibug_logo.png b/modules/digibug/images/digibug_logo.png
new file mode 100644
index 00000000..5eac2c7d
--- /dev/null
+++ b/modules/digibug/images/digibug_logo.png
Binary files differ
diff --git a/modules/digibug/js/digibug.js b/modules/digibug/js/digibug.js
new file mode 100644
index 00000000..78ca8cf3
--- /dev/null
+++ b/modules/digibug/js/digibug.js
@@ -0,0 +1,36 @@
+function digibug_popup(url, options) {
+ options = $.extend({
+ /* default options */
+ width: '800',
+ height: '600',
+ target: 'dbPopWin',
+ scrollbars: 'yes',
+ resizable: 'no',
+ menuBar: 'no',
+ addressBar: 'yes'
+ }, options);
+
+ // center the window by default.
+ if (!options.winY) {
+ options.winY = screen.height / 2 - options.height / 2;
+ };
+ if (!options.winX) {
+ options.winX = screen.width / 2 - options.width / 2;
+ };
+
+ open(
+ url,
+ options['target'],
+ 'width= ' + options.width +
+ ',height=' + options.height +
+ ',top=' + options.winY +
+ ',left=' + options.winX +
+ ',scrollbars=' + options.scrollbars +
+ ',resizable=' + options.resizable +
+ ',menubar=' + options.menuBar +
+ ',location=' + options.addressBar
+ );
+
+ return false;
+
+}
diff --git a/modules/digibug/models/digibug_proxy.php b/modules/digibug/models/digibug_proxy.php
new file mode 100644
index 00000000..036af9c7
--- /dev/null
+++ b/modules/digibug/models/digibug_proxy.php
@@ -0,0 +1,21 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 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 Digibug_Proxy_Model extends ORM {
+}
diff --git a/modules/digibug/module.info b/modules/digibug/module.info
new file mode 100644
index 00000000..c25a2454
--- /dev/null
+++ b/modules/digibug/module.info
@@ -0,0 +1,3 @@
+name = Digibug
+description = Digibug Photo Printing Module
+version = 2
diff --git a/modules/digibug/views/admin_digibug.html.php b/modules/digibug/views/admin_digibug.html.php
new file mode 100644
index 00000000..7e4436ff
--- /dev/null
+++ b/modules/digibug/views/admin_digibug.html.php
@@ -0,0 +1,22 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<div id="gAdminDigibug">
+ <div class="gAdminDigibugIntro">
+ <img id="DigibugLogo" src="<?= url::file("modules/digibug/images/digibug_logo.png") ?>">
+ <h2> <?= t("Digibug Photo Printing") ?> </h2>
+ <p>
+ <?= t("Turn your photos into a wide variety of prints, gifts and games!") ?>
+ </p>
+
+ <ul id="gMessage">
+ <li class="gSuccess">
+ <?= t("You're ready to print photos!") ?>
+ </li>
+ </ul>
+
+ <p>
+ <?= t("You don't need an account with Digibug, but if you <a href=\"%signup_url\">register with Digibug</a> and enter your Digibug id in the <a href=\"%advanced_settings_url\">Advanced Settings</a> page you can make money off of your photos!",
+ array("signup_url" => "http://www.digibug.com/signup.php",
+ "advanced_settings_url" => url::site("admin/advanced_settings"))) ?>
+ </p>
+ </div>
+</div>
diff --git a/modules/digibug/views/digibug_form.html.php b/modules/digibug/views/digibug_form.html.php
new file mode 100644
index 00000000..c6994cbe
--- /dev/null
+++ b/modules/digibug/views/digibug_form.html.php
@@ -0,0 +1,11 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<html>
+ <body>
+ <?= form::open("http://www.digibug.com/dapi/order.php") ?>
+ <?= form::hidden($order_parms) ?>
+ <?= form::close() ?>
+ <script type="text/javascript">
+ document.forms[0].submit();
+ </script>
+ </body>
+</html>