From 39cf3c2b046b03691937e112268403130508da63 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 21 Jun 2009 08:52:26 -0700 Subject: The start of the digibug printing module. The first cut at the administration panels. This is still a work in progress. --- modules/digibug/controllers/admin_digibug.php | 73 +++++++++++++++++++++ modules/digibug/controllers/digibug.php | 51 +++++++++++++++ modules/digibug/css/digibug.css | 88 ++++++++++++++++++++++++++ modules/digibug/css/logo.png | Bin 0 -> 17296 bytes modules/digibug/helpers/digibug_installer.php | 43 +++++++++++++ modules/digibug/helpers/digibug_menu.php | 42 ++++++++++++ modules/digibug/helpers/digibug_theme.php | 25 ++++++++ modules/digibug/module.info | 3 + modules/digibug/views/admin_digibug.html.php | 70 ++++++++++++++++++++ 9 files changed, 395 insertions(+) create mode 100644 modules/digibug/controllers/admin_digibug.php create mode 100644 modules/digibug/controllers/digibug.php create mode 100644 modules/digibug/css/digibug.css create mode 100644 modules/digibug/css/logo.png create mode 100644 modules/digibug/helpers/digibug_installer.php create mode 100644 modules/digibug/helpers/digibug_menu.php create mode 100644 modules/digibug/helpers/digibug_theme.php create mode 100644 modules/digibug/module.info create mode 100644 modules/digibug/views/admin_digibug.html.php (limited to 'modules') diff --git a/modules/digibug/controllers/admin_digibug.php b/modules/digibug/controllers/admin_digibug.php new file mode 100644 index 00000000..86338f6b --- /dev/null +++ b/modules/digibug/controllers/admin_digibug.php @@ -0,0 +1,73 @@ +_get_view(); + } + + public function basic() { + access::verify_csrf(); + + module::set_var("digibug", "mode", "basic"); + message::success(t("Successfully set Digibug mode to basic")); + + url::redirect("admin/digibug"); + } + + public function advanced() { + access::verify_csrf(); + + $form = $this->_get_form(); + if ($form->validate()) { + module::set_var("digibug", "company_id", $form->group->company_id->value); + module::set_var("digibug", "event_id", $form->group->event_id->value); + module::set_var("digibug", "mode", "advanced"); + message::success(t("Successfully set Digibug mode to advanced")); + + url::redirect("admin/digibug"); + } + + print $this->_get_view($form); + } + + private function _get_view($form=null) { + $v = new Admin_View("admin.html"); + $v->content = new View("admin_digibug.html"); + $v->content->mode = module::get_var("digibug", "mode", "basic"); + $v->content->form = empty($form) ? $this->_get_form() : $form; + return $v; + } + + private function _get_form() { + $form = new Forge("admin/digibug/advanced", "", "post", + array("id" => "gAdminForm")); + $group = $form->group("group"); + $group->input("company_id") + ->label(t("Company Id")) + ->rules("required") + ->value(module::get_var("digibug", "company_id", "")); + $group->input("event_id") + ->label(t("Event Id")) + ->rules("required") + ->value(module::get_var("digibug", "event_id", "")); + $group->submit("submit")->value(t("Submit")); + + return $form; + } +} \ 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..1e968d74 --- /dev/null +++ b/modules/digibug/controllers/digibug.php @@ -0,0 +1,51 @@ +_get_form(); + } + + public function handler() { + access::verify_csrf(); + + $form = $this->_get_form(); + if ($form->validate()) { + // @todo process the admin form + + message::success(t("Digibug Processing Successfully")); + + print json_encode( + array("result" => "success")); + } else { + print json_encode( + array("result" => "error", + "form" => $form->__toString())); + } + } + + private function _get_form() { + $form = new Forge("digibug/handler", "", "post", + array("id" => "gDigibugForm")); + $group = $form->group("group")->label(t("Digibug Handler")); + $group->input("text")->label(t("Text"))->rules("required"); + $group->submit("submit")->value(t("Submit")); + + return $form; + } +} \ No newline at end of file diff --git a/modules/digibug/css/digibug.css b/modules/digibug/css/digibug.css new file mode 100644 index 00000000..f5cd6717 --- /dev/null +++ b/modules/digibug/css/digibug.css @@ -0,0 +1,88 @@ +.gAdminDigibugIntro { + background-image: url(logo.png); + background-repeat: no-repeat; + padding-bottom: 20px; + width: 820px; +} + +.gAdminDigibugIntro p { + font-family: Trebuchet MS,Arial,Verdana,Helvetica,sans-serif; + font-size: 1.3em; + font-weight: bold; + padding-left: 110px; + padding-top: 15px; +} + +.gDigibugTab { + width: 820px; + height: 420px; +} + +.gDigibugTab .gDigibugTitle { + font-family: Georgia; + font-size: 20px; + font-weight: bold; + padding-bottom: 10px; +} + +.gDigibugTab .gDigibugText { + font-size: 12px; + font-weight: bold; + line-height: 17px; + padding-bottom: 15px; +} + +.gDigibugListItems ul { + list-style-type: disc; + padding-left: 20px; + font-size: 12px; + font-weight: bold; + line-height: 15px; +} + +.gDigibugListItems ul li{ + padding-top: 10px; +} + +.gDigibugRounded { + background-color:#5C9CCC; + color: white; + width: 308px; + height: 45px; + text-align: center; + line-height: 15px; + margin-top: 10px; + font-weight: bold; + font-size: 12px; + margin-left: 60px; + margin-right: -50px; + margin-left: 20px; + margin-right: 0px; +} + +.gDigibugRounded a { + color: white !important; + font-weight: bold; + text-decoration: underline; +} + +.gDigibugSignIn { + width: 115px; + float: left; +} + +.gDigibugSignIn a { + color: black; + font-size: 16px; + font-weight: bold; + text-decoration: underline; +} + +.gDigibugAdvancedForm { + float: left; + padding-left: 30px; + width: 180px; +} + + + diff --git a/modules/digibug/css/logo.png b/modules/digibug/css/logo.png new file mode 100644 index 00000000..5eac2c7d Binary files /dev/null and b/modules/digibug/css/logo.png differ diff --git a/modules/digibug/helpers/digibug_installer.php b/modules/digibug/helpers/digibug_installer.php new file mode 100644 index 00000000..90dab990 --- /dev/null +++ b/modules/digibug/helpers/digibug_installer.php @@ -0,0 +1,43 @@ +query("CREATE TABLE {print_proxy} ( + `id` int(9) NOT NULL auto_increment, + `proxy_id` char(55) NOT NULL, + `item_id` int(9), + PRIMARY KEY (`id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + + module::set_var("digibug", "basic_company_id", "3153"); + module::set_var("digibug", "basic_event_id", "8491"); + module::set_var("digibug", "mode", "basic"); + + module::set_version("digibug", 1); + } + } + + static function uninstall() { + Database::instance()->query("DROP TABLE IF EXISTS {print_proxy}"); + 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..3f41bb16 --- /dev/null +++ b/modules/digibug/helpers/digibug_menu.php @@ -0,0 +1,42 @@ +get("settings_menu") + ->append(Menu::factory("link") + ->id("digibug_menu") + ->label(t("Digibug Administration")) + ->url(url::site("admin/digibug"))); + } + + static function photo($menu, $theme) { + } + + static function site($menu, $theme) { + $item = $theme->item(); + + if ($item && access::can("edit", $item)) { + $options_menu = $menu->get("options_menu") + ->append(Menu::factory("dialog") + ->id("digibug") + ->label(t("Peform Digibug Processing")) + ->url(url::site("digibug/index/$item->id"))); + } + } +} diff --git a/modules/digibug/helpers/digibug_theme.php b/modules/digibug/helpers/digibug_theme.php new file mode 100644 index 00000000..06d656c8 --- /dev/null +++ b/modules/digibug/helpers/digibug_theme.php @@ -0,0 +1,25 @@ +"; + } +} diff --git a/modules/digibug/module.info b/modules/digibug/module.info new file mode 100644 index 00000000..58602c0d --- /dev/null +++ b/modules/digibug/module.info @@ -0,0 +1,3 @@ +name = Digibug +description = Digibug Photo Printing Module +version = 1 diff --git a/modules/digibug/views/admin_digibug.html.php b/modules/digibug/views/admin_digibug.html.php new file mode 100644 index 00000000..33ce5f83 --- /dev/null +++ b/modules/digibug/views/admin_digibug.html.php @@ -0,0 +1,70 @@ + + +
+

+
+

+ +

+
+
+
    +
  • +
  • +
+
+
+ +
+ +
+
+ +
+
+
    +
  • +
  • +
  • +
+
+
+
+ + + + + + +
+
+
+
+ +
+ +
+
+ +
+
+ +
+
+ +

+ +
+
+
+ +
+
+
+
-- cgit v1.2.3 From ee8887045e8f6702b13565173ba80330fcdb4572 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 22 Jun 2009 05:46:40 -0700 Subject: Change the quick pan from static to dynamic. This allows modules to add buttons to the quick pane. The quick pane is now divided into 4 sections: left, center, right and additional. Additional items appear in the drop down box. Buttons are not sorted within the groupings. In addition, the quick pane will overflow onto the "additional" dropdown if there is not enough room to display all the buttons. The use case is the digibug printing module needed to add a button to the quick pane, and I don't like putting code into core that says if module is active... That's another one of those code smells :-) --- modules/gallery/controllers/quick.php | 2 + modules/gallery/helpers/gallery_quick.php | 146 ++++++++++++++++++++++++++++++ modules/gallery/views/quick_pane.html.php | 103 +++------------------ 3 files changed, 160 insertions(+), 91 deletions(-) create mode 100644 modules/gallery/helpers/gallery_quick.php (limited to 'modules') diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index cff6686b..6203728c 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -25,6 +25,8 @@ class Quick_Controller extends Controller { } $view = new View("quick_pane.html"); + $view->button_list = + gallery_quick::get_quick_buttons($item, Input::instance()->get("page_type")); $view->item = $item; $view->page_type = Input::instance()->get("page_type"); print $view; diff --git a/modules/gallery/helpers/gallery_quick.php b/modules/gallery/helpers/gallery_quick.php new file mode 100644 index 00000000..19ed23dc --- /dev/null +++ b/modules/gallery/helpers/gallery_quick.php @@ -0,0 +1,146 @@ +name == "gallery") { + continue; + } + $class_name = "{$module->name}_quick"; + if (method_exists($class_name, "buttons")) { + $module_buttons = call_user_func(array($class_name, "buttons"), $item, $page_type); + foreach (array("left", "center", "right", "additional") as $position) { + if (!empty($module_buttons[$position])) { + $buttons[$position] = array_merge($buttons[$position], $module_buttons[$position]); + } + } + } + } + + $sorted_buttons->main = array(); + foreach (array("left", "center", "right") as $position) { + $sorted_buttons->main = array_merge($sorted_buttons->main, $buttons[$position]); + } + + $sorted_buttons->additional = $buttons["additional"]; + $max_display = empty($sorted_buttons->additional) ? 6 : 5; + if (count($sorted_buttons->main) >= $max_display) { + $to_move = array_slice($sorted_buttons->main, 5); + $sorted_buttons->additional = array_merge($to_move, $sorted_buttons->additional); + for ($i = count($sorted_buttons->main); $i >= 5; $i--) { + unset($sorted_buttons->main[$i]); + } + } + + Kohana::log("error", ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + Kohana::log("error", Kohana::debug($sorted_buttons)); + Kohana::log("error", "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); + return $sorted_buttons; + } + + static function buttons($item, $page_type) { + $elements = array("left" => array(), "center" => array(), "right" => array(), + "additional" => array()); + switch ($item->type) { + case "movie": + $edit_title = t("Edit this movie"); + $move_title = t("Move this movie to another album"); + $cover_title = t("Choose this movie as the album cover"); + $delete_title = t("Delete this movie"); + break; + case "album": + $edit_title = t("Edit this album"); + $move_title = t("Move this album to another album"); + $cover_title = t("Choose this album as the album cover"); + $delete_title = t("Delete this album"); + break; + default: + $edit_title = t("Edit this photo"); + $move_title = t("Move this photo to another album"); + $cover_title = t("Choose this photo as the album cover"); + $delete_title = t("Delete this photo"); + break; + } + + $csrf = access::csrf_token(); + $elements["left"][] = (object)array( + "title" => $edit_title, + "class" => "gDialogLink gButtonLink", + "icon" => "ui-icon-pencil", + "href" => url::site("quick/form_edit/$item->id?page_type=$page_type")); + if ($item->is_photo() && graphics::can("rotate")) { + $elements["left"][] = + (object)array( + "title" => t("Rotate 90 degrees counter clockwise"), + "class" => "gButtonLink", + "icon" => "ui-icon-rotate-ccw", + "href" => url::site("quick/form_edit/$item->id/ccw?csrf=$csrf&?page_type=$page_type")); + $elements["left"][] = + (object)array( + "title" => t("Rotate 90 degrees clockwise"), + "class" => "gButtonLink", + "icon" => "ui-icon-rotate-cw", + "href" => url::site("quick/form_edit/$item->id/cw?csrf=$csrf&page_type=$page_type")); + } + + // Don't move photos from the photo page; we don't yet have a good way of redirecting after move + if ($page_type == "album") { + $elements["left"][] = (object)array( + "title" => $move_title, + "class" => "gDialogLink gButtonLink", + "icon" => "ui-icon-folder-open", + "href" => url::site("move/browse/$item->id")); + } + + if (access::can("edit", $item->parent())) { + $disabledState = + $item->type == "album" && empty($item->album_cover_item_id) ? " ui-state-disabled" : ""; + $elements["right"][] = (object)array( + "title" => $cover_title, + "class" => "gButtonLink{$disabledState}", + "icon" => "ui-icon-star", + "href" => url::site("quick/make_album_cover/$item->id?csrf=$csrf&page_type=$page_type")); + + $elements["right"][] = (object)array( + "title" => $delete_title, + "class" => "gButtonLink", + "icon" => "ui-icon-trash", + "id" => "gQuickDelete", + "href" => url::site("quick/form_delete/$item->id?csrf=$csrf&page_type=$page_type")); + } + + if ($item->is_album()) { + $elements["additional"][] = (object)array( + "title" => t("Add a photo"), + "class" => "add_item gDialogLink", + "href" => url::site("simple_uploader/app/$item->id")); + $elements["additional"][] = (object)array( + "title" => t("Add an album"), + "class" => "add_album gDialogLink", + "href" => url::site("form/add/albums/$item->id?type=album")); + $elements["additional"][] = (object)array( + "title" => t("Edit permissions"), + "class" => "permissions gDialogLink", + "href" => url::site("permissions/browse/$item->id")); + } + return $elements; + } +} diff --git a/modules/gallery/views/quick_pane.html.php b/modules/gallery/views/quick_pane.html.php index f50e1abe..eabf4a67 100644 --- a/modules/gallery/views/quick_pane.html.php +++ b/modules/gallery/views/quick_pane.html.php @@ -1,85 +1,14 @@ -type == "photo"): ?> - -type == "movie"): ?> - -type == "album"): ?> - - -id?page_type=$page_type") ?>" - title=""> - - - - - -is_photo() && graphics::can("rotate")): ?> -id/ccw?csrf=$csrf&page_type=$page_type") ?>" - title=""> - - - - - -id/cw?csrf=$csrf&page_type=$page_type") ?>" - title=""> - - +main as $button): ?> + + + title ?> - + - - -type == "photo"): ?> - -type == "movie"): ?> - -type == "album"): ?> - - -id") ?>" - title=""> - - - - - - - -parent())): ?> -type == "photo"): ?> - -type == "movie"): ?> - -type == "album"): ?> -album_cover_item_id)): ?> -album_cover_item_id) ? " ui-state-disabled" : "" ?> - - - -id?csrf=$csrf&page_type=$page_type") ?>" - title=""> - - - - - -type == "photo"): ?> - -type == "movie"): ?> - -type == "album"): ?> - - -id?page_type=$page_type") ?>" id="gQuickDelete" title=""> - - - - - - -is_album()): ?> +additional)): ?> "> @@ -87,19 +16,11 @@ -- cgit v1.2.3 From f981484a8051c0d5d05dae55882aefdb7094403a Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 22 Jun 2009 05:52:47 -0700 Subject: Add a digibug printing button to the quick pane --- modules/digibug/helpers/digibug_quick.php | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 modules/digibug/helpers/digibug_quick.php (limited to 'modules') diff --git a/modules/digibug/helpers/digibug_quick.php b/modules/digibug/helpers/digibug_quick.php new file mode 100644 index 00000000..dce0c519 --- /dev/null +++ b/modules/digibug/helpers/digibug_quick.php @@ -0,0 +1,34 @@ +type == "photo") { + $csrf = access::csrf_token(); + $elements["center"][] = (object)array( + "title" => t("Print photo with Digibug"), + "class" => "gButtonLink", + "icon" => "ui-icon-print", + "href" => url::site("digibug/print/$item->id?csrf=$csrf")); + } + + return $elements; + } +} -- cgit v1.2.3 From 05f8659a7ffa35cb1458c69e4db1196aa384fff0 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 22 Jun 2009 06:03:55 -0700 Subject: Fix preamble so tests pass --- modules/digibug/controllers/admin_digibug.php | 3 ++- modules/digibug/controllers/digibug.php | 5 +++-- modules/digibug/helpers/digibug_installer.php | 3 ++- modules/digibug/helpers/digibug_menu.php | 7 ++++--- 4 files changed, 11 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/digibug/controllers/admin_digibug.php b/modules/digibug/controllers/admin_digibug.php index 86338f6b..8263fc83 100644 --- a/modules/digibug/controllers/admin_digibug.php +++ b/modules/digibug/controllers/admin_digibug.php @@ -1,4 +1,5 @@ - $form->__toString())); } } - + private function _get_form() { $form = new Forge("digibug/handler", "", "post", array("id" => "gDigibugForm")); diff --git a/modules/digibug/helpers/digibug_installer.php b/modules/digibug/helpers/digibug_installer.php index 90dab990..33b5107b 100644 --- a/modules/digibug/helpers/digibug_installer.php +++ b/modules/digibug/helpers/digibug_installer.php @@ -1,4 +1,5 @@ -label(t("Digibug Administration")) ->url(url::site("admin/digibug"))); } - + static function photo($menu, $theme) { } - + static function site($menu, $theme) { $item = $theme->item(); -- cgit v1.2.3 From 6b552fb07c8a162c9755895c132c6985c9dd1ddc Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 22 Jun 2009 06:27:31 -0700 Subject: Remove debugging output that was overlooked --- modules/gallery/helpers/gallery_quick.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_quick.php b/modules/gallery/helpers/gallery_quick.php index 19ed23dc..bb791c33 100644 --- a/modules/gallery/helpers/gallery_quick.php +++ b/modules/gallery/helpers/gallery_quick.php @@ -50,9 +50,6 @@ class gallery_quick_Core { } } - Kohana::log("error", ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); - Kohana::log("error", Kohana::debug($sorted_buttons)); - Kohana::log("error", "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); return $sorted_buttons; } -- cgit v1.2.3 From 58d5624e401f1c369cbbf913008775bc5a165570 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 22 Jun 2009 21:51:22 -0700 Subject: This commit moves a little further along the path: 1) moves the print button from the quick pane to thumb_bottom 2) Creates an entry into the proxy table --- modules/digibug/controllers/digibug.php | 64 ++++++++++++++++++--------- modules/digibug/css/digibug.css | 3 ++ modules/digibug/helpers/digibug.php | 57 ++++++++++++++++++++++++ modules/digibug/helpers/digibug_installer.php | 6 +-- modules/digibug/helpers/digibug_quick.php | 34 -------------- modules/digibug/helpers/digibug_theme.php | 23 ++++++++++ modules/digibug/js/digibug.js | 24 ++++++++++ modules/digibug/models/proxy.php | 22 +++++++++ 8 files changed, 175 insertions(+), 58 deletions(-) create mode 100644 modules/digibug/helpers/digibug.php delete mode 100644 modules/digibug/helpers/digibug_quick.php create mode 100644 modules/digibug/js/digibug.js create mode 100644 modules/digibug/models/proxy.php (limited to 'modules') diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php index f2f3d6cd..f90b88e2 100644 --- a/modules/digibug/controllers/digibug.php +++ b/modules/digibug/controllers/digibug.php @@ -18,35 +18,57 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Digibug_Controller extends Controller { - public function index() { - print $this->_get_form(); - } - - public function handler() { + public function print_photo($id) { access::verify_csrf(); - $form = $this->_get_form(); - if ($form->validate()) { - // @todo process the admin form + $item = ORM::factory("item", $id); - message::success(t("Digibug Processing Successfully")); + $proxy = ORM::factory("proxy"); + $proxy->uuid = digibug::uuid(); + $proxy->item_id = $item->id; + $proxy->save(); - print json_encode( - array("result" => "success")); + $url = url::abs_site("digibug/print_proxy/{$proxy->uuid}"); + if (module::get_var("digibug", "mode", "basic")) { + $company_id = module::get_var("digibug", "basic_company_id"); + $event_id = module::get_var("digibug", "basic_event_id"); } else { - print json_encode( - array("result" => "error", - "form" => $form->__toString())); + $company_id = module::get_var("digibug", "company_id"); + $event_id = module::get_var("digibug", "event_id"); } + $digibug_parms = array( + "digibug_api_version" => "100", + "company_id" => $company_id, + "event_id" => $event_id, + "cmd" => "adding", + "return_url" => url::abs_site($this->input->get("return")), + "num_images" => "1", + "image_1" => $url, + "thumb_1" => "$url/thumb", + "image_height_1" => $item->height, + "image_width_1" => $item->width, + "thumb_height_1" => $item->thumb_height, + "thumb_width_1" => $item->thumb_width, + "title" => $item->title); + + Kohana::log("error", Kohana::debug($digibug_parms)); + + message::success( + t("Photo '%title' was submitted for printing.", array("title" => $item->title))); + print json_encode(array("result" => "success", "reload" => 1)); } - private function _get_form() { - $form = new Forge("digibug/handler", "", "post", - array("id" => "gDigibugForm")); - $group = $form->group("group")->label(t("Digibug Handler")); - $group->input("text")->label(t("Text"))->rules("required"); - $group->submit("submit")->value(t("Submit")); + public function print_proxy($id, $thumb=null) { + + // We don't need to save the session for this request + Session::abort_save(); - return $form; + // Dump out the image + header("Content-Type: $item->mime_type"); + Kohana::close_buffers(false); + $fd = fopen($file, "rb"); + fpassthru($fd); + fclose($fd); } + } \ No newline at end of file diff --git a/modules/digibug/css/digibug.css b/modules/digibug/css/digibug.css index f5cd6717..a09e4551 100644 --- a/modules/digibug/css/digibug.css +++ b/modules/digibug/css/digibug.css @@ -84,5 +84,8 @@ width: 180px; } +.gDigibugPrintButton { + float: left; +} diff --git a/modules/digibug/helpers/digibug.php b/modules/digibug/helpers/digibug.php new file mode 100644 index 00000000..46c9d945 --- /dev/null +++ b/modules/digibug/helpers/digibug.php @@ -0,0 +1,57 @@ +> 4; + $time_hi_and_version = $time_hi_and_version | 0x4000; + + /** + * Set the two most significant bits (bits 6 and 7) of the + * clock_seq_hi_and_reserved to zero and one, respectively. + */ + $clock_seq_hi_and_reserved = hexdec ( $clock_seq_hi_and_reserved ); + $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved >> 2; + $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved | 0x8000; + + return sprintf ('%08s-%04s-%04x-%04x-%012s', + $time_low, $time_mid, $time_hi_and_version, $clock_seq_hi_and_reserved, $node); + } +} diff --git a/modules/digibug/helpers/digibug_installer.php b/modules/digibug/helpers/digibug_installer.php index 33b5107b..73645eb7 100644 --- a/modules/digibug/helpers/digibug_installer.php +++ b/modules/digibug/helpers/digibug_installer.php @@ -22,9 +22,9 @@ class digibug_installer { $version = module::get_version("digibug"); if ($version == 0) { Database::instance() - ->query("CREATE TABLE {print_proxy} ( + ->query("CREATE TABLE {proxies} ( `id` int(9) NOT NULL auto_increment, - `proxy_id` char(55) NOT NULL, + `uuid` char(32) NOT NULL, `item_id` int(9), PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); @@ -38,7 +38,7 @@ class digibug_installer { } static function uninstall() { - Database::instance()->query("DROP TABLE IF EXISTS {print_proxy}"); + Database::instance()->query("DROP TABLE IF EXISTS {proxys}"); module::delete("digibug"); } } diff --git a/modules/digibug/helpers/digibug_quick.php b/modules/digibug/helpers/digibug_quick.php deleted file mode 100644 index dce0c519..00000000 --- a/modules/digibug/helpers/digibug_quick.php +++ /dev/null @@ -1,34 +0,0 @@ -type == "photo") { - $csrf = access::csrf_token(); - $elements["center"][] = (object)array( - "title" => t("Print photo with Digibug"), - "class" => "gButtonLink", - "icon" => "ui-icon-print", - "href" => url::site("digibug/print/$item->id?csrf=$csrf")); - } - - return $elements; - } -} diff --git a/modules/digibug/helpers/digibug_theme.php b/modules/digibug/helpers/digibug_theme.php index 06d656c8..2e44b115 100644 --- a/modules/digibug/helpers/digibug_theme.php +++ b/modules/digibug/helpers/digibug_theme.php @@ -18,8 +18,31 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class digibug_theme_Core { + static function head($theme) { + $head[] = ""; + $head[] = html::script("modules/digibug/js/digibug.js");; + return implode("\n", $head); + } + static function admin_head($theme) { return ""; } + + static function thumb_bottom($theme, $child) { + if ($theme->page_type() == "album" && $child->type == "photo") { + $csrf = access::csrf_token(); + $return = "album/{$child->parent()->id}"; + $href = url::site("digibug/print_photo/$child->id?csrf={$csrf}&return=$return"); + $title = t("Print photo with Digibug"); + return ""; + } + return ""; + } } diff --git a/modules/digibug/js/digibug.js b/modules/digibug/js/digibug.js new file mode 100644 index 00000000..f30678c0 --- /dev/null +++ b/modules/digibug/js/digibug.js @@ -0,0 +1,24 @@ +$(document).ready(function() { + $(".gDigibugPrintButton a").click(function(e) { + e.preventDefault(); + queue_print(e); + }); +}); + +function queue_print(e) { + var parent = e.currentTarget.parentNode; + $(parent).addClass("gLoadingLarge"); + $.ajax({ + type: "GET", + url: e.currentTarget.href, + dataType: "json", + success: function(data) { + $(parent).removeClass("gLoadingLarge"); + if (data.location) { + window.location = data.location; + } else if (data.reload) { + window.location.reload(); + } + } + }); +}; diff --git a/modules/digibug/models/proxy.php b/modules/digibug/models/proxy.php new file mode 100644 index 00000000..ce10c592 --- /dev/null +++ b/modules/digibug/models/proxy.php @@ -0,0 +1,22 @@ + Date: Tue, 23 Jun 2009 05:26:44 -0700 Subject: Extract the html for the Print button on the album page into a seperate view --- modules/digibug/views/digibug_album.html.php | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 modules/digibug/views/digibug_album.html.php (limited to 'modules') diff --git a/modules/digibug/views/digibug_album.html.php b/modules/digibug/views/digibug_album.html.php new file mode 100644 index 00000000..0f1537e9 --- /dev/null +++ b/modules/digibug/views/digibug_album.html.php @@ -0,0 +1,8 @@ + + \ No newline at end of file -- cgit v1.2.3 From 8f443cef3e304c12f9e3555332880395051e7e3d Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 23 Jun 2009 06:06:33 -0700 Subject: This change implements the print_proxy method. This method allows a 1 time security bypass for the remote print processor to retrieve the fullsize image. --- modules/digibug/controllers/digibug.php | 25 ++++++++++++++++++++++--- modules/digibug/helpers/digibug_theme.php | 15 +++++---------- 2 files changed, 27 insertions(+), 13 deletions(-) (limited to 'modules') diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php index f90b88e2..b0807aa5 100644 --- a/modules/digibug/controllers/digibug.php +++ b/modules/digibug/controllers/digibug.php @@ -51,24 +51,43 @@ class Digibug_Controller extends Controller { "thumb_width_1" => $item->thumb_width, "title" => $item->title); - Kohana::log("error", Kohana::debug($digibug_parms)); - message::success( t("Photo '%title' was submitted for printing.", array("title" => $item->title))); print json_encode(array("result" => "success", "reload" => 1)); } public function print_proxy($id, $thumb=null) { + $proxy = ORM::factory("proxy") + ->where("uuid", $id) + ->find(); + + if (!$proxy->loaded) { + Kohana::show_404(); + } + + if (!$proxy->item->loaded) { + Kohana::show_404(); + } + + $file = empty($thumb) ? $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: $item->mime_type"); + 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 (empty($thumb)) { + $proxy->delete(); + } } } \ No newline at end of file diff --git a/modules/digibug/helpers/digibug_theme.php b/modules/digibug/helpers/digibug_theme.php index 2e44b115..0fe2ce2e 100644 --- a/modules/digibug/helpers/digibug_theme.php +++ b/modules/digibug/helpers/digibug_theme.php @@ -32,16 +32,11 @@ class digibug_theme_Core { static function thumb_bottom($theme, $child) { if ($theme->page_type() == "album" && $child->type == "photo") { - $csrf = access::csrf_token(); - $return = "album/{$child->parent()->id}"; - $href = url::site("digibug/print_photo/$child->id?csrf={$csrf}&return=$return"); - $title = t("Print photo with Digibug"); - return ""; + $v = new View("digibug_album.html"); + $v->id = $child->id; + $v->return = "album/{$child->parent()->id}"; + $v->title = t("Print photo with Digibug"); + return $v->render(); } return ""; } -- cgit v1.2.3 From 342d5e118664274fb1d8329734815640f5169887 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Jun 2009 11:53:38 -0700 Subject: Order log entries by id as well so that multiple events in the same second are still shown in descending order. --- modules/gallery/helpers/gallery_block.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php index c3837f54..a10f2bbf 100644 --- a/modules/gallery/helpers/gallery_block.php +++ b/modules/gallery/helpers/gallery_block.php @@ -49,8 +49,9 @@ class gallery_block_Core { $block->css_id = "gLogEntries"; $block->title = t("Log Entries"); $block->content = new View("admin_block_log_entries.html"); - $block->content->entries = ORM::factory("log")->orderby("timestamp", "DESC")->find_all(5); - break; + $block->content->entries = ORM::factory("log") + ->orderby(array("timestamp" => "DESC", "id" => "DESC"))->find_all(5); + break; case "stats": $block->css_id = "gStats"; -- cgit v1.2.3 From bfca0c79030d5b8a18e41e8b80f5560ebaf6f202 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Jun 2009 12:00:49 -0700 Subject: Refactor the install/upgrade code to be more flexible. Add xxx_installer::upgrade($version) method so that upgrade stanzas are separate from install stanzas. In the old code, to do an upgrade meant that you had to re-evolve everything from the initial install because we'd step through each version's changes. But what we really want is for the initial install to start off in the perfect initial state, and the upgrades to do the work behind the scenes. So now the install() function gets things set up properly the first time, and the upgrade() function does any work to catch you up to the latest code. See gallery_installer.php for a good example. --- installer/install.sql | 2 +- modules/akismet/helpers/akismet_installer.php | 5 +- modules/comment/helpers/comment_installer.php | 60 ++- modules/exif/helpers/exif_installer.php | 26 +- modules/g2_import/helpers/g2_import_installer.php | 21 +- modules/gallery/controllers/admin_modules.php | 6 +- modules/gallery/controllers/upgrader.php | 6 +- modules/gallery/helpers/gallery_installer.php | 426 ++++++++++----------- modules/gallery/helpers/module.php | 34 +- .../image_block/helpers/image_block_installer.php | 4 +- modules/info/helpers/info_installer.php | 5 +- .../helpers/notification_installer.php | 36 +- modules/organize/helpers/organize_installer.php | 5 +- modules/recaptcha/helpers/recaptcha_installer.php | 5 +- modules/rss/helpers/rss_installer.php | 5 +- modules/search/helpers/search_installer.php | 23 +- .../server_add/helpers/server_add_installer.php | 6 +- modules/slideshow/helpers/slideshow_installer.php | 5 +- modules/tag/helpers/tag_installer.php | 35 +- modules/user/helpers/user_installer.php | 106 +++-- modules/watermark/helpers/watermark_installer.php | 29 +- 21 files changed, 415 insertions(+), 435 deletions(-) (limited to 'modules') diff --git a/installer/install.sql b/installer/install.sql index 432aee64..91108460 100755 --- a/installer/install.sql +++ b/installer/install.sql @@ -335,4 +335,4 @@ CREATE TABLE {vars} ( UNIQUE KEY `module_name` (`module_name`,`name`) ) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -INSERT INTO {vars} VALUES (1,'gallery','active_site_theme','default'),(2,'gallery','active_admin_theme','admin_default'),(3,'gallery','page_size','9'),(4,'gallery','thumb_size','200'),(5,'gallery','resize_size','640'),(6,'gallery','default_locale','en_US'),(7,'gallery','image_quality','75'),(9,'gallery','blocks_dashboard_sidebar','a:4:{i:2;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"block_adder\";}i:3;a:2:{i:0;s:7:\"gallery\";i:1;s:5:\"stats\";}i:4;a:2:{i:0;s:7:\"gallery\";i:1;s:13:\"platform_info\";}i:5;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"project_news\";}}'),(14,'gallery','blocks_dashboard_center','a:4:{i:6;a:2:{i:0;s:7:\"gallery\";i:1;s:7:\"welcome\";}i:7;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"photo_stream\";}i:8;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"log_entries\";}i:9;a:2:{i:0;s:7:\"comment\";i:1;s:15:\"recent_comments\";}}'),(17,'gallery','version','3.0 pre beta 2 (git)'),(18,'gallery','choose_default_tookit','1'),(19,'gallery','credits','Powered by Gallery %version'),(20,'gallery','date_format','Y-M-d'),(21,'gallery','date_time_format','Y-M-d H:i:s'),(22,'gallery','time_format','H:i:s'),(24,'comment','spam_caught','0'); +INSERT INTO {vars} VALUES (1,'gallery','active_site_theme','default'),(2,'gallery','active_admin_theme','admin_default'),(3,'gallery','page_size','9'),(4,'gallery','thumb_size','200'),(5,'gallery','resize_size','640'),(6,'gallery','default_locale','en_US'),(7,'gallery','image_quality','75'),(9,'gallery','blocks_dashboard_sidebar','a:4:{i:2;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"block_adder\";}i:3;a:2:{i:0;s:7:\"gallery\";i:1;s:5:\"stats\";}i:4;a:2:{i:0;s:7:\"gallery\";i:1;s:13:\"platform_info\";}i:5;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"project_news\";}}'),(14,'gallery','blocks_dashboard_center','a:4:{i:6;a:2:{i:0;s:7:\"gallery\";i:1;s:7:\"welcome\";}i:7;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"photo_stream\";}i:8;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"log_entries\";}i:9;a:2:{i:0;s:7:\"comment\";i:1;s:15:\"recent_comments\";}}'),(17,'gallery','version','3.0 pre beta 2 (git)'),(18,'gallery','choose_default_tookit','1'),(19,'gallery','date_format','Y-M-d'),(20,'gallery','date_time_format','Y-M-d H:i:s'),(21,'gallery','time_format','H:i:s'),(22,'gallery','credits','Powered by Gallery %version'),(24,'comment','spam_caught','0'); diff --git a/modules/akismet/helpers/akismet_installer.php b/modules/akismet/helpers/akismet_installer.php index 920c58b7..5d8c0e07 100644 --- a/modules/akismet/helpers/akismet_installer.php +++ b/modules/akismet/helpers/akismet_installer.php @@ -19,10 +19,7 @@ */ class akismet_installer { static function install() { - $version = module::get_version("akismet"); - if ($version == 0) { - module::set_version("akismet", 1); - } + module::set_version("akismet", 1); } static function activate() { diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php index b1cfcdc0..2bfb7330 100644 --- a/modules/comment/helpers/comment_installer.php +++ b/modules/comment/helpers/comment_installer.php @@ -20,39 +20,35 @@ class comment_installer { static function install() { $db = Database::instance(); - $version = module::get_version("comment"); + $db->query("CREATE TABLE IF NOT EXISTS {comments} ( + `author_id` int(9) default NULL, + `created` int(9) NOT NULL, + `guest_email` varchar(128) default NULL, + `guest_name` varchar(128) default NULL, + `guest_url` varchar(255) default NULL, + `id` int(9) NOT NULL auto_increment, + `item_id` int(9) NOT NULL, + `server_http_accept_charset` varchar(64) default NULL, + `server_http_accept_encoding` varchar(64) default NULL, + `server_http_accept_language` varchar(64) default NULL, + `server_http_accept` varchar(128) default NULL, + `server_http_connection` varchar(64) default NULL, + `server_http_host` varchar(64) default NULL, + `server_http_referer` varchar(255) default NULL, + `server_http_user_agent` varchar(128) default NULL, + `server_query_string` varchar(64) default NULL, + `server_remote_addr` varchar(32) default NULL, + `server_remote_host` varchar(64) default NULL, + `server_remote_port` varchar(16) default NULL, + `state` char(15) default 'unpublished', + `text` text, + `updated` int(9) NOT NULL, + PRIMARY KEY (`id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - if ($version == 0) { - $db->query("CREATE TABLE IF NOT EXISTS {comments} ( - `author_id` int(9) default NULL, - `created` int(9) NOT NULL, - `guest_email` varchar(128) default NULL, - `guest_name` varchar(128) default NULL, - `guest_url` varchar(255) default NULL, - `id` int(9) NOT NULL auto_increment, - `item_id` int(9) NOT NULL, - `server_http_accept_charset` varchar(64) default NULL, - `server_http_accept_encoding` varchar(64) default NULL, - `server_http_accept_language` varchar(64) default NULL, - `server_http_accept` varchar(128) default NULL, - `server_http_connection` varchar(64) default NULL, - `server_http_host` varchar(64) default NULL, - `server_http_referer` varchar(255) default NULL, - `server_http_user_agent` varchar(128) default NULL, - `server_query_string` varchar(64) default NULL, - `server_remote_addr` varchar(32) default NULL, - `server_remote_host` varchar(64) default NULL, - `server_remote_port` varchar(16) default NULL, - `state` char(15) default 'unpublished', - `text` text, - `updated` int(9) NOT NULL, - PRIMARY KEY (`id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - - block_manager::add("dashboard_center", "comment", "recent_comments"); - module::set_var("comment", "spam_caught", 0); - module::set_version("comment", 1); - } + block_manager::add("dashboard_center", "comment", "recent_comments"); + module::set_var("comment", "spam_caught", 0); + module::set_version("comment", 1); } static function uninstall() { diff --git a/modules/exif/helpers/exif_installer.php b/modules/exif/helpers/exif_installer.php index da49f649..0233f2bb 100644 --- a/modules/exif/helpers/exif_installer.php +++ b/modules/exif/helpers/exif_installer.php @@ -19,21 +19,17 @@ */ class exif_installer { static function install() { - $version = module::get_version("exif"); - - if ($version == 0) { - $db = Database::instance(); - $db->query("CREATE TABLE IF NOT EXISTS {exif_records} ( - `id` int(9) NOT NULL auto_increment, - `item_id` INTEGER(9) NOT NULL, - `key_count` INTEGER(9) default 0, - `data` TEXT, - `dirty` BOOLEAN default 1, - PRIMARY KEY (`id`), - KEY(`item_id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - module::set_version("exif", 1); - } + $db = Database::instance(); + $db->query("CREATE TABLE IF NOT EXISTS {exif_records} ( + `id` int(9) NOT NULL auto_increment, + `item_id` INTEGER(9) NOT NULL, + `key_count` INTEGER(9) default 0, + `data` TEXT, + `dirty` BOOLEAN default 1, + PRIMARY KEY (`id`), + KEY(`item_id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + module::set_version("exif", 1); } static function activate() { diff --git a/modules/g2_import/helpers/g2_import_installer.php b/modules/g2_import/helpers/g2_import_installer.php index 5f414d42..0f87da6c 100644 --- a/modules/g2_import/helpers/g2_import_installer.php +++ b/modules/g2_import/helpers/g2_import_installer.php @@ -20,19 +20,16 @@ class g2_import_installer { static function install() { $db = Database::instance(); - $version = module::get_version("g2_import"); - if ($version == 0) { - $db->query("CREATE TABLE IF NOT EXISTS {g2_maps} ( - `id` int(9) NOT NULL auto_increment, - `g2_id` int(9) NOT NULL, - `g3_id` int(9) NOT NULL, - PRIMARY KEY (`id`), - KEY (`g2_id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE IF NOT EXISTS {g2_maps} ( + `id` int(9) NOT NULL auto_increment, + `g2_id` int(9) NOT NULL, + `g3_id` int(9) NOT NULL, + PRIMARY KEY (`id`), + KEY (`g2_id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - module::set_version("g2_import", 1); - mkdir(VARPATH . "modules/g2_import"); - } + module::set_version("g2_import", 1); + mkdir(VARPATH . "modules/g2_import"); } static function uninstall() { diff --git a/modules/gallery/controllers/admin_modules.php b/modules/gallery/controllers/admin_modules.php index f7dd909d..ed1f7665 100644 --- a/modules/gallery/controllers/admin_modules.php +++ b/modules/gallery/controllers/admin_modules.php @@ -45,7 +45,11 @@ class Admin_Modules_Controller extends Admin_Controller { } else if (!$info->active && $desired && !module::is_active($module_name)) { $changes->activate[] = $module_name; $activated_names[] = $info->name; - module::install($module_name); + if (module::is_installed($module_name)) { + module::upgrade($module_name); + } else { + module::install($module_name); + } module::activate($module_name); } } diff --git a/modules/gallery/controllers/upgrader.php b/modules/gallery/controllers/upgrader.php index 5eb96fdd..91952fa9 100644 --- a/modules/gallery/controllers/upgrader.php +++ b/modules/gallery/controllers/upgrader.php @@ -50,8 +50,8 @@ class Upgrader_Controller extends Controller { } // Upgrade gallery and user first - module::install("gallery"); - module::install("user"); + module::upgrade("gallery"); + module::upgrade("user"); // Then upgrade the rest foreach (module::available() as $id => $module) { @@ -60,7 +60,7 @@ class Upgrader_Controller extends Controller { } if ($module->active && $module->code_version != $module->version) { - module::install($id); + module::upgrade($id); } } diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index cd871c17..4f6342b4 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -18,244 +18,240 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class gallery_installer { - static function install($initial_install=false) { + static function install() { $db = Database::instance(); - if ($initial_install) { - $version = 0; - } else { - $version = module::get_version("gallery"); - } - - if ($version == 0) { - $db->query("CREATE TABLE {access_caches} ( - `id` int(9) NOT NULL auto_increment, - `item_id` int(9), - PRIMARY KEY (`id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {access_caches} ( + `id` int(9) NOT NULL auto_increment, + `item_id` int(9), + PRIMARY KEY (`id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {access_intents} ( - `id` int(9) NOT NULL auto_increment, - `item_id` int(9), - PRIMARY KEY (`id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {access_intents} ( + `id` int(9) NOT NULL auto_increment, + `item_id` int(9), + PRIMARY KEY (`id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {graphics_rules} ( - `id` int(9) NOT NULL auto_increment, - `active` BOOLEAN default 0, - `args` varchar(255) default NULL, - `module_name` varchar(64) NOT NULL, - `operation` varchar(64) NOT NULL, - `priority` int(9) NOT NULL, - `target` varchar(32) NOT NULL, - PRIMARY KEY (`id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {graphics_rules} ( + `id` int(9) NOT NULL auto_increment, + `active` BOOLEAN default 0, + `args` varchar(255) default NULL, + `module_name` varchar(64) NOT NULL, + `operation` varchar(64) NOT NULL, + `priority` int(9) NOT NULL, + `target` varchar(32) NOT NULL, + PRIMARY KEY (`id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {incoming_translations} ( - `id` int(9) NOT NULL auto_increment, - `key` char(32) NOT NULL, - `locale` char(10) NOT NULL, - `message` text NOT NULL, - `revision` int(9) DEFAULT NULL, - `translation` text, - PRIMARY KEY (`id`), - UNIQUE KEY(`key`, `locale`), - KEY `locale_key` (`locale`, `key`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {incoming_translations} ( + `id` int(9) NOT NULL auto_increment, + `key` char(32) NOT NULL, + `locale` char(10) NOT NULL, + `message` text NOT NULL, + `revision` int(9) DEFAULT NULL, + `translation` text, + PRIMARY KEY (`id`), + UNIQUE KEY(`key`, `locale`), + KEY `locale_key` (`locale`, `key`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {items} ( - `id` int(9) NOT NULL auto_increment, - `album_cover_item_id` int(9) default NULL, - `captured` int(9) default NULL, - `created` int(9) default NULL, - `description` varchar(2048) default NULL, - `height` int(9) default NULL, - `left` int(9) NOT NULL, - `level` int(9) NOT NULL, - `mime_type` varchar(64) default NULL, - `name` varchar(255) default NULL, - `owner_id` int(9) default NULL, - `parent_id` int(9) NOT NULL, - `rand_key` float default NULL, - `relative_path_cache` varchar(255) default NULL, - `resize_dirty` boolean default 1, - `resize_height` int(9) default NULL, - `resize_width` int(9) default NULL, - `right` int(9) NOT NULL, - `sort_column` varchar(64) default NULL, - `sort_order` char(4) default 'ASC', - `thumb_dirty` boolean default 1, - `thumb_height` int(9) default NULL, - `thumb_width` int(9) default NULL, - `title` varchar(255) default NULL, - `type` varchar(32) NOT NULL, - `updated` int(9) default NULL, - `view_count` int(9) default 0, - `weight` int(9) NOT NULL default 0, - `width` int(9) default NULL, - PRIMARY KEY (`id`), - KEY `parent_id` (`parent_id`), - KEY `type` (`type`), - KEY `random` (`rand_key`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {items} ( + `id` int(9) NOT NULL auto_increment, + `album_cover_item_id` int(9) default NULL, + `captured` int(9) default NULL, + `created` int(9) default NULL, + `description` varchar(2048) default NULL, + `height` int(9) default NULL, + `left` int(9) NOT NULL, + `level` int(9) NOT NULL, + `mime_type` varchar(64) default NULL, + `name` varchar(255) default NULL, + `owner_id` int(9) default NULL, + `parent_id` int(9) NOT NULL, + `rand_key` float default NULL, + `relative_path_cache` varchar(255) default NULL, + `resize_dirty` boolean default 1, + `resize_height` int(9) default NULL, + `resize_width` int(9) default NULL, + `right` int(9) NOT NULL, + `sort_column` varchar(64) default NULL, + `sort_order` char(4) default 'ASC', + `thumb_dirty` boolean default 1, + `thumb_height` int(9) default NULL, + `thumb_width` int(9) default NULL, + `title` varchar(255) default NULL, + `type` varchar(32) NOT NULL, + `updated` int(9) default NULL, + `view_count` int(9) default 0, + `weight` int(9) NOT NULL default 0, + `width` int(9) default NULL, + PRIMARY KEY (`id`), + KEY `parent_id` (`parent_id`), + KEY `type` (`type`), + KEY `random` (`rand_key`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {logs} ( - `id` int(9) NOT NULL auto_increment, - `category` varchar(64) default NULL, - `html` varchar(255) default NULL, - `message` text default NULL, - `referer` varchar(255) default NULL, - `severity` int(9) default 0, - `timestamp` int(9) default 0, - `url` varchar(255) default NULL, - `user_id` int(9) default 0, - PRIMARY KEY (`id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {logs} ( + `id` int(9) NOT NULL auto_increment, + `category` varchar(64) default NULL, + `html` varchar(255) default NULL, + `message` text default NULL, + `referer` varchar(255) default NULL, + `severity` int(9) default 0, + `timestamp` int(9) default 0, + `url` varchar(255) default NULL, + `user_id` int(9) default 0, + PRIMARY KEY (`id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {messages} ( - `id` int(9) NOT NULL auto_increment, - `key` varchar(255) default NULL, - `severity` varchar(32) default NULL, - `value` varchar(255) default NULL, - PRIMARY KEY (`id`), - UNIQUE KEY(`key`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {messages} ( + `id` int(9) NOT NULL auto_increment, + `key` varchar(255) default NULL, + `severity` varchar(32) default NULL, + `value` varchar(255) default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY(`key`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {modules} ( - `id` int(9) NOT NULL auto_increment, - `active` BOOLEAN default 0, - `name` varchar(64) default NULL, - `version` int(9) default NULL, - PRIMARY KEY (`id`), - UNIQUE KEY(`name`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {modules} ( + `id` int(9) NOT NULL auto_increment, + `active` BOOLEAN default 0, + `name` varchar(64) default NULL, + `version` int(9) default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY(`name`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {outgoing_translations} ( - `id` int(9) NOT NULL auto_increment, - `base_revision` int(9) DEFAULT NULL, - `key` char(32) NOT NULL, - `locale` char(10) NOT NULL, - `message` text NOT NULL, - `translation` text, - PRIMARY KEY (`id`), - UNIQUE KEY(`key`, `locale`), - KEY `locale_key` (`locale`, `key`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {outgoing_translations} ( + `id` int(9) NOT NULL auto_increment, + `base_revision` int(9) DEFAULT NULL, + `key` char(32) NOT NULL, + `locale` char(10) NOT NULL, + `message` text NOT NULL, + `translation` text, + PRIMARY KEY (`id`), + UNIQUE KEY(`key`, `locale`), + KEY `locale_key` (`locale`, `key`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {permissions} ( - `id` int(9) NOT NULL auto_increment, - `display_name` varchar(64) default NULL, - `name` varchar(64) default NULL, - PRIMARY KEY (`id`), - UNIQUE KEY(`name`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {permissions} ( + `id` int(9) NOT NULL auto_increment, + `display_name` varchar(64) default NULL, + `name` varchar(64) default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY(`name`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {sessions} ( - `session_id` varchar(127) NOT NULL, - `data` text NOT NULL, - `last_activity` int(10) UNSIGNED NOT NULL, - PRIMARY KEY (`session_id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {sessions} ( + `session_id` varchar(127) NOT NULL, + `data` text NOT NULL, + `last_activity` int(10) UNSIGNED NOT NULL, + PRIMARY KEY (`session_id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {tasks} ( - `id` int(9) NOT NULL auto_increment, - `callback` varchar(128) default NULL, - `context` text NOT NULL, - `done` boolean default 0, - `name` varchar(128) default NULL, - `owner_id` int(9) default NULL, - `percent_complete` int(9) default 0, - `state` varchar(32) default NULL, - `status` varchar(255) default NULL, - `updated` int(9) default NULL, - PRIMARY KEY (`id`), - KEY (`owner_id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {tasks} ( + `id` int(9) NOT NULL auto_increment, + `callback` varchar(128) default NULL, + `context` text NOT NULL, + `done` boolean default 0, + `name` varchar(128) default NULL, + `owner_id` int(9) default NULL, + `percent_complete` int(9) default 0, + `state` varchar(32) default NULL, + `status` varchar(255) default NULL, + `updated` int(9) default NULL, + PRIMARY KEY (`id`), + KEY (`owner_id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {themes} ( - `id` int(9) NOT NULL auto_increment, - `name` varchar(64) default NULL, - `version` int(9) default NULL, - PRIMARY KEY (`id`), - UNIQUE KEY(`name`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {themes} ( + `id` int(9) NOT NULL auto_increment, + `name` varchar(64) default NULL, + `version` int(9) default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY(`name`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {vars} ( - `id` int(9) NOT NULL auto_increment, - `module_name` varchar(64) NOT NULL, - `name` varchar(64) NOT NULL, - `value` text, - PRIMARY KEY (`id`), - UNIQUE KEY(`module_name`, `name`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {vars} ( + `id` int(9) NOT NULL auto_increment, + `module_name` varchar(64) NOT NULL, + `name` varchar(64) NOT NULL, + `value` text, + PRIMARY KEY (`id`), + UNIQUE KEY(`module_name`, `name`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - foreach (array("albums", "logs", "modules", "resizes", "thumbs", "tmp", "uploads") as $dir) { - @mkdir(VARPATH . $dir); - } - - access::register_permission("view", "View"); - access::register_permission("view_full", "View Full Size"); - access::register_permission("edit", "Edit"); - access::register_permission("add", "Add"); + foreach (array("albums", "logs", "modules", "resizes", "thumbs", "tmp", "uploads") as $dir) { + @mkdir(VARPATH . $dir); + } - $root = ORM::factory("item"); - $root->type = "album"; - $root->title = "Gallery"; - $root->description = ""; - $root->left = 1; - $root->right = 2; - $root->parent_id = 0; - $root->level = 1; - $root->thumb_dirty = 1; - $root->resize_dirty = 1; - $root->sort_column = "weight"; - $root->sort_order = "ASC"; - $root->save(); - access::add_item($root); + access::register_permission("view", "View"); + access::register_permission("view_full", "View Full Size"); + access::register_permission("edit", "Edit"); + access::register_permission("add", "Add"); - module::set_var("gallery", "active_site_theme", "default"); - module::set_var("gallery", "active_admin_theme", "admin_default"); - module::set_var("gallery", "page_size", 9); - module::set_var("gallery", "thumb_size", 200); - module::set_var("gallery", "resize_size", 640); - module::set_var("gallery", "default_locale", "en_US"); - module::set_var("gallery", "image_quality", 75); + $root = ORM::factory("item"); + $root->type = "album"; + $root->title = "Gallery"; + $root->description = ""; + $root->left = 1; + $root->right = 2; + $root->parent_id = 0; + $root->level = 1; + $root->thumb_dirty = 1; + $root->resize_dirty = 1; + $root->sort_column = "weight"; + $root->sort_order = "ASC"; + $root->save(); + access::add_item($root); - // Add rules for generating our thumbnails and resizes - graphics::add_rule( - "gallery", "thumb", "resize", - array("width" => 200, "height" => 200, "master" => Image::AUTO), - 100); - graphics::add_rule( - "gallery", "resize", "resize", - array("width" => 640, "height" => 480, "master" => Image::AUTO), - 100); + module::set_var("gallery", "active_site_theme", "default"); + module::set_var("gallery", "active_admin_theme", "admin_default"); + module::set_var("gallery", "page_size", 9); + module::set_var("gallery", "thumb_size", 200); + module::set_var("gallery", "resize_size", 640); + module::set_var("gallery", "default_locale", "en_US"); + module::set_var("gallery", "image_quality", 75); - // Instantiate default themes (site and admin) - foreach (array("default", "admin_default") as $theme_name) { - $theme_info = new ArrayObject(parse_ini_file(THEMEPATH . $theme_name . "/theme.info"), - ArrayObject::ARRAY_AS_PROPS); - $theme = ORM::factory("theme"); - $theme->name = $theme_name; - $theme->version = $theme_info->version; - $theme->save(); - } + // Add rules for generating our thumbnails and resizes + graphics::add_rule( + "gallery", "thumb", "resize", + array("width" => 200, "height" => 200, "master" => Image::AUTO), + 100); + graphics::add_rule( + "gallery", "resize", "resize", + array("width" => 640, "height" => 480, "master" => Image::AUTO), + 100); - block_manager::add("dashboard_sidebar", "gallery", "block_adder"); - block_manager::add("dashboard_sidebar", "gallery", "stats"); - block_manager::add("dashboard_sidebar", "gallery", "platform_info"); - block_manager::add("dashboard_sidebar", "gallery", "project_news"); - block_manager::add("dashboard_center", "gallery", "welcome"); - block_manager::add("dashboard_center", "gallery", "photo_stream"); - block_manager::add("dashboard_center", "gallery", "log_entries"); + // Instantiate default themes (site and admin) + foreach (array("default", "admin_default") as $theme_name) { + $theme_info = new ArrayObject(parse_ini_file(THEMEPATH . $theme_name . "/theme.info"), + ArrayObject::ARRAY_AS_PROPS); + $theme = ORM::factory("theme"); + $theme->name = $theme_name; + $theme->version = $theme_info->version; + $theme->save(); + } - module::set_version("gallery", $version = 1); - module::set_var("gallery", "version", "3.0 beta 1"); - module::set_var("gallery", "choose_default_tookit", 1); + block_manager::add("dashboard_sidebar", "gallery", "block_adder"); + block_manager::add("dashboard_sidebar", "gallery", "stats"); + block_manager::add("dashboard_sidebar", "gallery", "platform_info"); + block_manager::add("dashboard_sidebar", "gallery", "project_news"); + block_manager::add("dashboard_center", "gallery", "welcome"); + block_manager::add("dashboard_center", "gallery", "photo_stream"); + block_manager::add("dashboard_center", "gallery", "log_entries"); - // @todo this string needs to be picked up by l10n_scanner - module::set_var("gallery", "credits", "Powered by Gallery %version"); - } + module::set_var("gallery", "version", "3.0 pre beta 2 (git)"); + module::set_var("gallery", "choose_default_tookit", 1); + module::set_var("gallery", "date_format", "Y-M-d"); + module::set_var("gallery", "date_time_format", "Y-M-d H:i:s"); + module::set_var("gallery", "time_format", "H:i:s"); + // @todo this string needs to be picked up by l10n_scanner + module::set_var("gallery", "credits", "Powered by Gallery %version"); + module::set_version("gallery", 2); + } + static function upgrade($version) { if ($version == 1) { module::set_var("gallery", "date_format", "Y-M-d"); module::set_var("gallery", "date_time_format", "Y-M-d H:i:s"); diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index dea8e22c..0d483206 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -107,7 +107,7 @@ class module_Core { /** * Install a module. This will call _installer::install(), which is responsible for - * creating database tables, setting module variables and and calling module::set_version(). + * creating database tables, setting module variables and calling module::set_version(). * Note that after installing, the module must be activated before it is available for use. * @param string $module_name */ @@ -130,6 +130,38 @@ class module_Core { "module", t("Installed module %module_name", array("module_name" => $module_name))); } + /** + * Upgrade a module. This will call _installer::upgrade(), which is responsible for + * modifying database tables, changing module variables and calling module::set_version(). + * Note that after upgrading, the module must be activated before it is available for use. + * @param string $module_name + */ + static function upgrade($module_name) { + $kohana_modules = Kohana::config("core.modules"); + array_unshift($kohana_modules, MODPATH . $module_name); + Kohana::config_set("core.modules", $kohana_modules); + + $version_before = module::get_version($module_name); + $installer_class = "{$module_name}_installer"; + if (method_exists($installer_class, "upgrade")) { + call_user_func_array(array($installer_class, "upgrade"), array($version_before)); + } + module::load_modules(); + + // Now the module is upgraded but inactive, so don't leave it in the active path + array_shift($kohana_modules); + Kohana::config_set("core.modules", $kohana_modules); + + $version_after = module::get_version($module_name); + if ($version_before != $version_after) { + log::success( + "module", t("Upgraded module %module_name from %version_before to %version_after", + array("module_name" => $module_name, + "version_before" => $version_before, + "version_after" => $version_after))); + } + } + /** * Activate an installed module. This will call _installer::activate() which should take * any steps to make sure that the module is ready for use. This will also activate any diff --git a/modules/image_block/helpers/image_block_installer.php b/modules/image_block/helpers/image_block_installer.php index 57279d05..7ea6a229 100644 --- a/modules/image_block/helpers/image_block_installer.php +++ b/modules/image_block/helpers/image_block_installer.php @@ -19,8 +19,6 @@ */ class image_block_installer { static function install() { - if (module::get_version("image_block") == 0) { - module::set_version("image_block", 1); - } + module::set_version("image_block", 1); } } diff --git a/modules/info/helpers/info_installer.php b/modules/info/helpers/info_installer.php index 94fc22d0..e3e78b90 100644 --- a/modules/info/helpers/info_installer.php +++ b/modules/info/helpers/info_installer.php @@ -19,9 +19,6 @@ */ class info_installer { static function install() { - $version = module::get_version("info"); - if ($version == 0) { - module::set_version("info", 1); - } + module::set_version("info", 1); } } diff --git a/modules/notification/helpers/notification_installer.php b/modules/notification/helpers/notification_installer.php index ad10184b..3d450258 100644 --- a/modules/notification/helpers/notification_installer.php +++ b/modules/notification/helpers/notification_installer.php @@ -20,27 +20,23 @@ class notification_installer { static function install() { $db = Database::instance(); - $version = module::get_version("notification"); + $db->query("CREATE TABLE IF NOT EXISTS {subscriptions} ( + `id` int(9) NOT NULL auto_increment, + `item_id` int(9) NOT NULL, + `user_id` int(9) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY (`item_id`, `user_id`), + UNIQUE KEY (`user_id`, `item_id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE IF NOT EXISTS {pending_notifications} ( + `id` int(9) NOT NULL auto_increment, + `email` varchar(128) NOT NULL, + `subject` varchar(255) NOT NULL, + `text` text, + PRIMARY KEY (`id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - if ($version == 0) { - $db->query("CREATE TABLE IF NOT EXISTS {subscriptions} ( - `id` int(9) NOT NULL auto_increment, - `item_id` int(9) NOT NULL, - `user_id` int(9) NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY (`item_id`, `user_id`), - UNIQUE KEY (`user_id`, `item_id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE IF NOT EXISTS {pending_notifications} ( - `id` int(9) NOT NULL auto_increment, - `email` varchar(128) NOT NULL, - `subject` varchar(255) NOT NULL, - `text` text, - PRIMARY KEY (`id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - - module::set_version("notification", 1); - } + module::set_version("notification", 1); } static function uninstall() { diff --git a/modules/organize/helpers/organize_installer.php b/modules/organize/helpers/organize_installer.php index ea0f4e3d..22ca1793 100644 --- a/modules/organize/helpers/organize_installer.php +++ b/modules/organize/helpers/organize_installer.php @@ -19,9 +19,6 @@ */ class organize_installer { static function install() { - $version = module::get_version("organize"); - if ($version == 0) { - module::set_version("organize", 1); - } + module::set_version("organize", 1); } } diff --git a/modules/recaptcha/helpers/recaptcha_installer.php b/modules/recaptcha/helpers/recaptcha_installer.php index f74bf558..12044a1b 100644 --- a/modules/recaptcha/helpers/recaptcha_installer.php +++ b/modules/recaptcha/helpers/recaptcha_installer.php @@ -19,10 +19,7 @@ */ class recaptcha_installer { static function install() { - $version = module::get_version("recaptcha"); - if ($version == 0) { - module::set_version("recaptcha", 1); - } + module::set_version("recaptcha", 1); } static function activate() { diff --git a/modules/rss/helpers/rss_installer.php b/modules/rss/helpers/rss_installer.php index 2beafb33..7766fdfa 100644 --- a/modules/rss/helpers/rss_installer.php +++ b/modules/rss/helpers/rss_installer.php @@ -19,9 +19,6 @@ */ class rss_installer { static function install() { - $version = module::get_version("rss"); - if ($version == 0) { - module::set_version("rss", 1); - } + module::set_version("rss", 1); } } diff --git a/modules/search/helpers/search_installer.php b/modules/search/helpers/search_installer.php index ed4a3a90..cd253be4 100644 --- a/modules/search/helpers/search_installer.php +++ b/modules/search/helpers/search_installer.php @@ -19,20 +19,17 @@ */ class search_installer { static function install() { - $version = module::get_version("search"); $db = Database::instance(); - if ($version == 0) { - $db->query("CREATE TABLE {search_records} ( - `id` int(9) NOT NULL auto_increment, - `item_id` int(9), - `dirty` boolean default 1, - `data` LONGTEXT default NULL, - PRIMARY KEY (`id`), - KEY(`item_id`), - FULLTEXT INDEX (`data`)) - ENGINE=MyISAM DEFAULT CHARSET=utf8;"); - module::set_version("search", 1); - } + $db->query("CREATE TABLE {search_records} ( + `id` int(9) NOT NULL auto_increment, + `item_id` int(9), + `dirty` boolean default 1, + `data` LONGTEXT default NULL, + PRIMARY KEY (`id`), + KEY(`item_id`), + FULLTEXT INDEX (`data`)) + ENGINE=MyISAM DEFAULT CHARSET=utf8;"); + module::set_version("search", 1); } static function activate() { diff --git a/modules/server_add/helpers/server_add_installer.php b/modules/server_add/helpers/server_add_installer.php index f8773a2e..c9d92e69 100644 --- a/modules/server_add/helpers/server_add_installer.php +++ b/modules/server_add/helpers/server_add_installer.php @@ -19,11 +19,7 @@ */ class server_add_installer { static function install() { - $db = Database::instance(); - $version = module::get_version("server_add"); - if ($version == 0) { - module::set_version("server_add", 1); - } + module::set_version("server_add", 1); server_add::check_config(); } diff --git a/modules/slideshow/helpers/slideshow_installer.php b/modules/slideshow/helpers/slideshow_installer.php index b46f5471..cd1c6e05 100644 --- a/modules/slideshow/helpers/slideshow_installer.php +++ b/modules/slideshow/helpers/slideshow_installer.php @@ -19,10 +19,7 @@ */ class slideshow_installer { static function install() { - $version = module::get_version("slideshow"); - if ($version == 0) { - module::set_version("slideshow", 1); - } + module::set_version("slideshow", 1); } static function deactivate() { diff --git a/modules/tag/helpers/tag_installer.php b/modules/tag/helpers/tag_installer.php index 07544c54..3c16e3f3 100644 --- a/modules/tag/helpers/tag_installer.php +++ b/modules/tag/helpers/tag_installer.php @@ -20,26 +20,23 @@ class tag_installer { static function install() { $db = Database::instance(); - $version = module::get_version("tag"); - if ($version == 0) { - $db->query("CREATE TABLE IF NOT EXISTS {tags} ( - `id` int(9) NOT NULL auto_increment, - `name` varchar(64) NOT NULL, - `count` int(10) unsigned NOT NULL DEFAULT 0, - PRIMARY KEY (`id`), - UNIQUE KEY(`name`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE IF NOT EXISTS {tags} ( + `id` int(9) NOT NULL auto_increment, + `name` varchar(64) NOT NULL, + `count` int(10) unsigned NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + UNIQUE KEY(`name`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE IF NOT EXISTS {items_tags} ( - `id` int(9) NOT NULL auto_increment, - `item_id` int(9) NOT NULL, - `tag_id` int(9) NOT NULL, - PRIMARY KEY (`id`), - KEY(`tag_id`, `id`), - KEY(`item_id`, `id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - module::set_version("tag", 1); - } + $db->query("CREATE TABLE IF NOT EXISTS {items_tags} ( + `id` int(9) NOT NULL auto_increment, + `item_id` int(9) NOT NULL, + `tag_id` int(9) NOT NULL, + PRIMARY KEY (`id`), + KEY(`tag_id`, `id`), + KEY(`item_id`, `id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + module::set_version("tag", 1); } static function uninstall() { diff --git a/modules/user/helpers/user_installer.php b/modules/user/helpers/user_installer.php index 68868fc1..1959d038 100644 --- a/modules/user/helpers/user_installer.php +++ b/modules/user/helpers/user_installer.php @@ -20,70 +20,66 @@ class user_installer { static function install() { $db = Database::instance(); - $version = module::get_version("user"); + $db->query("CREATE TABLE IF NOT EXISTS {users} ( + `id` int(9) NOT NULL auto_increment, + `name` varchar(32) NOT NULL, + `full_name` varchar(255) NOT NULL, + `password` varchar(64) NOT NULL, + `login_count` int(10) unsigned NOT NULL DEFAULT 0, + `last_login` int(10) unsigned NOT NULL DEFAULT 0, + `email` varchar(64) default NULL, + `admin` BOOLEAN default 0, + `guest` BOOLEAN default 0, + `hash` char(32) default NULL, + `url` varchar(255) default NULL, + `locale` char(10) default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY(`hash`), + UNIQUE KEY(`name`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - if ($version == 0) { - $db->query("CREATE TABLE IF NOT EXISTS {users} ( - `id` int(9) NOT NULL auto_increment, - `name` varchar(32) NOT NULL, - `full_name` varchar(255) NOT NULL, - `password` varchar(64) NOT NULL, - `login_count` int(10) unsigned NOT NULL DEFAULT 0, - `last_login` int(10) unsigned NOT NULL DEFAULT 0, - `email` varchar(64) default NULL, - `admin` BOOLEAN default 0, - `guest` BOOLEAN default 0, - `hash` char(32) default NULL, - `url` varchar(255) default NULL, - `locale` char(10) default NULL, - PRIMARY KEY (`id`), - UNIQUE KEY(`hash`), - UNIQUE KEY(`name`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE IF NOT EXISTS {groups} ( + `id` int(9) NOT NULL auto_increment, + `name` char(64) default NULL, + `special` BOOLEAN default 0, + PRIMARY KEY (`id`), + UNIQUE KEY(`name`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE IF NOT EXISTS {groups} ( - `id` int(9) NOT NULL auto_increment, - `name` char(64) default NULL, - `special` BOOLEAN default 0, - PRIMARY KEY (`id`), - UNIQUE KEY(`name`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE IF NOT EXISTS {groups_users} ( + `group_id` int(9) NOT NULL, + `user_id` int(9) NOT NULL, + PRIMARY KEY (`group_id`, `user_id`), + UNIQUE KEY(`user_id`, `group_id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE IF NOT EXISTS {groups_users} ( - `group_id` int(9) NOT NULL, - `user_id` int(9) NOT NULL, - PRIMARY KEY (`group_id`, `user_id`), - UNIQUE KEY(`user_id`, `group_id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $everybody = group::create("Everybody"); + $everybody->special = true; + $everybody->save(); - $everybody = group::create("Everybody"); - $everybody->special = true; - $everybody->save(); + $registered = group::create("Registered Users"); + $registered->special = true; + $registered->save(); - $registered = group::create("Registered Users"); - $registered->special = true; - $registered->save(); + $guest = user::create("guest", "Guest User", ""); + $guest->guest = true; + $guest->remove($registered); + $guest->save(); - $guest = user::create("guest", "Guest User", ""); - $guest->guest = true; - $guest->remove($registered); - $guest->save(); + $admin = user::create("admin", "Gallery Administrator", "admin"); + $admin->admin = true; + $admin->save(); - $admin = user::create("admin", "Gallery Administrator", "admin"); - $admin->admin = true; - $admin->save(); + // Let the admin own everything + $db->update("items", array("owner_id" => $admin->id), array("owner_id" => "IS NULL")); + module::set_version("user", 1); - // Let the admin own everything - $db->update("items", array("owner_id" => $admin->id), array("owner_id" => "IS NULL")); - module::set_version("user", 1); + $root = ORM::factory("item", 1); + access::allow($everybody, "view", $root); + access::allow($everybody, "view_full", $root); - $root = ORM::factory("item", 1); - access::allow($everybody, "view", $root); - access::allow($everybody, "view_full", $root); - - access::allow($registered, "view", $root); - access::allow($registered, "view_full", $root); - } + access::allow($registered, "view", $root); + access::allow($registered, "view_full", $root); } static function uninstall() { diff --git a/modules/watermark/helpers/watermark_installer.php b/modules/watermark/helpers/watermark_installer.php index ed4265ec..705b89d4 100644 --- a/modules/watermark/helpers/watermark_installer.php +++ b/modules/watermark/helpers/watermark_installer.php @@ -20,23 +20,20 @@ class watermark_installer { static function install() { $db = Database::instance(); - $version = module::get_version("watermark"); - if ($version == 0) { - $db->query("CREATE TABLE IF NOT EXISTS {watermarks} ( - `id` int(9) NOT NULL auto_increment, - `name` varchar(32) NOT NULL, - `width` int(9) NOT NULL, - `height` int(9) NOT NULL, - `active` boolean default 0, - `position` boolean default 0, - `mime_type` varchar(64) default NULL, - PRIMARY KEY (`id`), - UNIQUE KEY(`name`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE IF NOT EXISTS {watermarks} ( + `id` int(9) NOT NULL auto_increment, + `name` varchar(32) NOT NULL, + `width` int(9) NOT NULL, + `height` int(9) NOT NULL, + `active` boolean default 0, + `position` boolean default 0, + `mime_type` varchar(64) default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY(`name`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - @mkdir(VARPATH . "modules/watermark"); - module::set_version("watermark", 1); - } + @mkdir(VARPATH . "modules/watermark"); + module::set_version("watermark", 1); } static function uninstall() { -- cgit v1.2.3 From e49c4a2459fd94d7df167b68432920ca95420767 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Jun 2009 13:25:14 -0700 Subject: Upgrade to version 2 and change the state column to a varchar for Postgres compatibility. --- modules/comment/helpers/comment_installer.php | 8 ++++++++ modules/comment/module.info | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php index 2bfb7330..f5a7542b 100644 --- a/modules/comment/helpers/comment_installer.php +++ b/modules/comment/helpers/comment_installer.php @@ -51,6 +51,14 @@ class comment_installer { module::set_version("comment", 1); } + static function upgrade($version) { + if ($version == 1) { + $db = Database::instance(); + $db->query("ALTER TABLE {comments} CHANGE `state` `state` varchar(15) default 'unpublished'"); + module::set_version("comment", 2); + } + } + static function uninstall() { $db = Database::instance(); $sql = "SELECT `item_id` FROM {comments}"; diff --git a/modules/comment/module.info b/modules/comment/module.info index 08a800a6..946f1d39 100644 --- a/modules/comment/module.info +++ b/modules/comment/module.info @@ -1,3 +1,3 @@ name = Comments description = Allows users and guests to leave comments on photos and albums. -version = 1 +version = 2 -- cgit v1.2.3 From 3b0baa827150e457c630052d6ef87853aaad8bdc Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Jun 2009 13:45:16 -0700 Subject: Replay change from Romain DE LISEZ to change the state column to be a varchar --- modules/comment/helpers/comment_installer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php index f5a7542b..f54913c3 100644 --- a/modules/comment/helpers/comment_installer.php +++ b/modules/comment/helpers/comment_installer.php @@ -40,7 +40,7 @@ class comment_installer { `server_remote_addr` varchar(32) default NULL, `server_remote_host` varchar(64) default NULL, `server_remote_port` varchar(16) default NULL, - `state` char(15) default 'unpublished', + `state` varchar(15) default 'unpublished', `text` text, `updated` int(9) NOT NULL, PRIMARY KEY (`id`)) @@ -48,7 +48,7 @@ class comment_installer { block_manager::add("dashboard_center", "comment", "recent_comments"); module::set_var("comment", "spam_caught", 0); - module::set_version("comment", 1); + module::set_version("comment", 2); } static function upgrade($version) { -- cgit v1.2.3 From d5ee5741f2afa0e4a2d6406828cdad01bc8c3f2e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Jun 2009 14:08:07 -0700 Subject: Don't allow renaming of the root album. --- modules/gallery/controllers/albums.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index 17fdec6b..22f50fb8 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -167,7 +167,8 @@ class Albums_Controller extends Items_Controller { $form = album::get_edit_form($album); if ($valid = $form->validate()) { // Make sure that there's not a conflict - if (Database::instance() + if ($album->id != 1 && + Database::instance() ->from("items") ->where("parent_id", $album->parent_id) ->where("id <>", $album->id) @@ -188,7 +189,9 @@ class Albums_Controller extends Items_Controller { $album->description = $form->edit_album->description->value; $album->sort_column = $form->edit_album->sort_order->column->value; $album->sort_order = $form->edit_album->sort_order->direction->value; - $album->rename($form->edit_album->dirname->value); + if ($album->id != 1) { + $album->rename($form->edit_album->dirname->value); + } $album->save(); module::event("item_updated", $orig, $album); -- cgit v1.2.3 From 4e3b84eb391de177d94fd1c4189d456280fd7fdd Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Jun 2009 14:23:11 -0700 Subject: Escape {$this->sort_column} in get_position() --- modules/gallery/models/item.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 7dce9e51..07c305d8 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -381,9 +381,9 @@ class Item_Model extends ORM_MPTT { $result = Database::instance()->query(" SELECT COUNT(*) AS position FROM {items} WHERE parent_id = {$this->id} - AND {$this->sort_column} <= (SELECT {$this->sort_column} + AND `{$this->sort_column}` <= (SELECT `{$this->sort_column}` FROM {items} WHERE id = $child_id) - ORDER BY {$this->sort_column} {$this->sort_order}"); + ORDER BY `{$this->sort_column}` {$this->sort_order}"); return $result->current()->position; } -- cgit v1.2.3 From ba7163bd30939f87aa3786dd8583a361bc638baf Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Jun 2009 14:50:41 -0700 Subject: Fix get_position() to properly deal with duplicate values in the sort column. Fixes #389 --- modules/gallery/models/item.php | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 07c305d8..430119b5 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -378,14 +378,41 @@ class Item_Model extends ORM_MPTT { * the first child in the album is at position 1. */ public function get_position($child_id) { - $result = Database::instance()->query(" + if ($this->sort_order == "DESC") { + $comp = ">"; + } else { + $comp = "<"; + } + + $db = Database::instance(); + $position = $db->query(" SELECT COUNT(*) AS position FROM {items} - WHERE parent_id = {$this->id} - AND `{$this->sort_column}` <= (SELECT `{$this->sort_column}` - FROM {items} WHERE id = $child_id) - ORDER BY `{$this->sort_column}` {$this->sort_order}"); + WHERE parent_id = {$this->id} + AND `{$this->sort_column}` $comp (SELECT `{$this->sort_column}` + FROM {items} WHERE id = $child_id) + ORDER BY `{$this->sort_column}` {$this->sort_order}")->current()->position; + + // We stopped short of our target value in the sort (notice that we're using a < comparator + // above) because it's possible that we have duplicate values in the sort column. An + // equality check would just arbitrarily pick one of those multiple possible equivalent + // columns, which would mean that if you choose a sort order that has duplicates, it'd pick + // any one of them as the child's "position". + // + // Fix this by doing a 2nd query where we iterate over the equivalent columns and add them to + // our base value. + $result = $db->query(" + SELECT id FROM {items} + WHERE parent_id = {$this->id} + AND `{$this->sort_column}` = (SELECT `{$this->sort_column}` + FROM {items} WHERE id = $child_id)"); + foreach ($result as $row) { + $position++; + if ($row->id == $child_id) { + break; + } + } - return $result->current()->position; + return $position; } /** -- cgit v1.2.3 From 297ac6ebd15bc53ce6c7d96b659b22fb3b220d74 Mon Sep 17 00:00:00 2001 From: Romain LE DISEZ Date: Tue, 23 Jun 2009 16:05:15 +0800 Subject: Improve compatibility with other RDBMS Signed-off-by: Bharat Mediratta --- modules/search/helpers/search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php index 15efa3b2..9046ad2d 100644 --- a/modules/search/helpers/search.php +++ b/modules/search/helpers/search.php @@ -45,7 +45,7 @@ class search_Core { "WHERE MATCH({search_records}.`data`) AGAINST ('$q' IN BOOLEAN MODE) " . $access_sql . "ORDER BY `score` DESC " . - "LIMIT $offset, $limit"; + "LIMIT $limit OFFSET $offset"; return array($count, new ORM_Iterator(ORM::factory("item"), $db->query($query))); } -- cgit v1.2.3 From da09185a4baa739dd011804eb1301cdf2d126c11 Mon Sep 17 00:00:00 2001 From: Romain LE DISEZ Date: Tue, 23 Jun 2009 16:08:55 +0800 Subject: SQL is case insensitive Signed-off-by: Bharat Mediratta --- modules/search/helpers/search.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php index 9046ad2d..ea8dad81 100644 --- a/modules/search/helpers/search.php +++ b/modules/search/helpers/search.php @@ -34,11 +34,11 @@ class search_Core { // Count the total number of rows. We can't do this with our regular query because of the // limit statement. It's possible that if we get rid of the limit (but keep the offset) on // the 2nd query and combine the two, it might be faster than making 2 separate queries. - $count_query = "SELECT COUNT(*) AS C " . + $count_query = "SELECT COUNT(*) AS c " . "FROM {items} JOIN {search_records} ON ({items}.`id` = {search_records}.`item_id`) " . "WHERE MATCH({search_records}.`data`) AGAINST ('$q' IN BOOLEAN MODE) " . $access_sql; - $count = $db->query($count_query)->current()->C; + $count = $db->query($count_query)->current()->c; $query = "SELECT {items}.*, MATCH({search_records}.`data`) AGAINST ('$q') AS `score` " . "FROM {items} JOIN {search_records} ON ({items}.`id` = {search_records}.`item_id`) " . -- cgit v1.2.3 From b9b68e09527f2680252bcba054019c45db07829a Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Jun 2009 16:05:32 -0700 Subject: Add a new "show credits" check box in the theme options so that you can disable any module credits if you want. Update the theme to obey it. --- modules/gallery/controllers/admin_theme_options.php | 1 + modules/gallery/helpers/gallery_installer.php | 8 +++++++- modules/gallery/helpers/theme.php | 2 ++ modules/gallery/module.info | 2 +- themes/default/views/footer.html.php | 4 +++- 5 files changed, 14 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/admin_theme_options.php b/modules/gallery/controllers/admin_theme_options.php index 2716ed93..8970c3c9 100644 --- a/modules/gallery/controllers/admin_theme_options.php +++ b/modules/gallery/controllers/admin_theme_options.php @@ -56,6 +56,7 @@ class Admin_Theme_Options_Controller extends Admin_Controller { module::set_var("gallery", "header_text", $form->edit_theme->header_text->value); module::set_var("gallery", "footer_text", $form->edit_theme->footer_text->value); + module::set_var("gallery", "show_credits", $form->edit_theme->show_credits->value); message::success(t("Updated theme details")); url::redirect("admin/theme_options"); diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 4f6342b4..df555d52 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -246,9 +246,10 @@ class gallery_installer { module::set_var("gallery", "date_format", "Y-M-d"); module::set_var("gallery", "date_time_format", "Y-M-d H:i:s"); module::set_var("gallery", "time_format", "H:i:s"); + module::set_var("gallery", "show_credits", 1); // @todo this string needs to be picked up by l10n_scanner module::set_var("gallery", "credits", "Powered by Gallery %version"); - module::set_version("gallery", 2); + module::set_version("gallery", 3); } static function upgrade($version) { @@ -259,6 +260,11 @@ class gallery_installer { module::set_var("gallery", "version", "3.0 pre beta 2 (git)"); module::set_version("gallery", $version = 2); } + + if ($version == 2) { + module::set_var("gallery", "show_credits", 1); + module::set_version("gallery", $version = 3); + } } static function uninstall() { diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index 0a43f25c..b46a2c14 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -55,6 +55,8 @@ class theme_Core { ->value(module::get_var("gallery", "header_text")); $group->textarea("footer_text")->label(t("Footer text"))->id("gFooterText") ->value(module::get_var("gallery", "footer_text")); + $group->checkbox("show_credits")->label(t("Show site credits"))->id("gFooterText") + ->checked(module::get_var("gallery", "show_credits")); $group->submit("")->value(t("Save")); return $form; } diff --git a/modules/gallery/module.info b/modules/gallery/module.info index 3a5dd593..e5b1f809 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ name = Gallery 3 description = Gallery core application -version = 2 +version = 3 diff --git a/themes/default/views/footer.html.php b/themes/default/views/footer.html.php index d7111922..040a4062 100644 --- a/themes/default/views/footer.html.php +++ b/themes/default/views/footer.html.php @@ -2,7 +2,9 @@ footer() ?> - + + +
    credits() ?>
-- cgit v1.2.3 From 2a190660baeff8cd708926cea79f94f1630418b7 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Jun 2009 17:09:37 -0700 Subject: Gracefully handle the case when the gallery2 instances moves somewhere else (or gets deleted). Fixes ticket #458 --- modules/g2_import/controllers/admin_g2_import.php | 3 +++ modules/g2_import/helpers/g2_import_task.php | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php index f2969f49..18d09363 100644 --- a/modules/g2_import/controllers/admin_g2_import.php +++ b/modules/g2_import/controllers/admin_g2_import.php @@ -21,6 +21,9 @@ class Admin_g2_import_Controller extends Admin_Controller { public function index() { if (g2_import::is_configured()) { g2_import::init(); + } + + if (class_exists("GalleryCoreApi")) { $g2_stats = g2_import::stats(); $g2_sizes = g2_import::common_sizes(); } diff --git a/modules/g2_import/helpers/g2_import_task.php b/modules/g2_import/helpers/g2_import_task.php index 4cd95581..3961097d 100644 --- a/modules/g2_import/helpers/g2_import_task.php +++ b/modules/g2_import/helpers/g2_import_task.php @@ -21,15 +21,19 @@ class g2_import_task_Core { static function available_tasks() { if (g2_import::is_configured()) { g2_import::init(); + } + + + if (class_exists("GalleryCoreApi")) { return array(Task_Definition::factory() ->callback("g2_import_task::import") ->name(t("Import from Gallery 2")) ->description( t("Gallery %version detected", array("version" => g2_import::version()))) ->severity(log::SUCCESS)); - } else { - return array(); } + + return array(); } static function import($task) { -- cgit v1.2.3 From 9a0448e5d6f83d93f906e6fe1aec4bbb8d78912f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Jun 2009 17:25:59 -0700 Subject: Add gDialogLink to the delete button, since its got a jQuery confirmation dialog now. This was a regression in fa4bb5b7ac89bbbd0325e5c336c2e9b31f59d12b. Fixes ticket #459. --- modules/gallery/helpers/gallery_quick.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_quick.php b/modules/gallery/helpers/gallery_quick.php index bb791c33..302a3144 100644 --- a/modules/gallery/helpers/gallery_quick.php +++ b/modules/gallery/helpers/gallery_quick.php @@ -118,7 +118,7 @@ class gallery_quick_Core { $elements["right"][] = (object)array( "title" => $delete_title, - "class" => "gButtonLink", + "class" => "gDialogLink gButtonLink", "icon" => "ui-icon-trash", "id" => "gQuickDelete", "href" => url::site("quick/form_delete/$item->id?csrf=$csrf&page_type=$page_type")); -- cgit v1.2.3 From 53284ec5b892915c5905ea4f1e3fe76b18d3b576 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Jun 2009 18:39:00 -0700 Subject: Add support for Gallery 2.2.2 style bootstrap syntax. --- modules/g2_import/helpers/g2_import.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'modules') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 2eee564a..91ca1e63 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -113,11 +113,13 @@ class g2_import_Core { "require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');", "define('GALLERY_CONFIG_DIR', dirname(__FILE__));", "\$gallery =& new Gallery();", + "\$GLOBALS['gallery'] =& new Gallery();", "\$gallery = new Gallery();"), array("require_once(dirname(__FILE__) . '/Gallery.class');", "require_once('$base_dir/modules/core/classes/GalleryDataCache.class');", "define('GALLERY_CONFIG_DIR', '$config_dir');", "\$gallery =& new G2_Gallery();", + "\$GLOBALS['gallery'] =& new G2_Gallery();", "\$gallery = new G2_Gallery();"), array_merge(array("\n"), file("$base_dir/bootstrap.inc")))); -- cgit v1.2.3 From d01c3d2373cc98a0d6abb1eb5a1f71491e1001e2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Jun 2009 21:27:17 -0700 Subject: Remove stray ? that was breaking ccw rotation. --- modules/gallery/helpers/gallery_quick.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_quick.php b/modules/gallery/helpers/gallery_quick.php index 302a3144..9da0e082 100644 --- a/modules/gallery/helpers/gallery_quick.php +++ b/modules/gallery/helpers/gallery_quick.php @@ -89,7 +89,7 @@ class gallery_quick_Core { "title" => t("Rotate 90 degrees counter clockwise"), "class" => "gButtonLink", "icon" => "ui-icon-rotate-ccw", - "href" => url::site("quick/form_edit/$item->id/ccw?csrf=$csrf&?page_type=$page_type")); + "href" => url::site("quick/form_edit/$item->id/ccw?csrf=$csrf&page_type=$page_type")); $elements["left"][] = (object)array( "title" => t("Rotate 90 degrees clockwise"), -- cgit v1.2.3 From f9dbd4eb2feede5381d481f473bf7f0a77b49e4a Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Jun 2009 21:31:58 -0700 Subject: Fix broken rotate urls. --- modules/gallery/helpers/gallery_quick.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_quick.php b/modules/gallery/helpers/gallery_quick.php index 9da0e082..d0ffc584 100644 --- a/modules/gallery/helpers/gallery_quick.php +++ b/modules/gallery/helpers/gallery_quick.php @@ -83,19 +83,20 @@ class gallery_quick_Core { "class" => "gDialogLink gButtonLink", "icon" => "ui-icon-pencil", "href" => url::site("quick/form_edit/$item->id?page_type=$page_type")); + if ($item->is_photo() && graphics::can("rotate")) { $elements["left"][] = (object)array( "title" => t("Rotate 90 degrees counter clockwise"), "class" => "gButtonLink", "icon" => "ui-icon-rotate-ccw", - "href" => url::site("quick/form_edit/$item->id/ccw?csrf=$csrf&page_type=$page_type")); + "href" => url::site("quick/rotate/$item->id/ccw?csrf=$csrf&page_type=$page_type")); $elements["left"][] = (object)array( "title" => t("Rotate 90 degrees clockwise"), "class" => "gButtonLink", "icon" => "ui-icon-rotate-cw", - "href" => url::site("quick/form_edit/$item->id/cw?csrf=$csrf&page_type=$page_type")); + "href" => url::site("quick/rotate/$item->id/cw?csrf=$csrf&page_type=$page_type")); } // Don't move photos from the photo page; we don't yet have a good way of redirecting after move -- cgit v1.2.3 From e44053f692109069977c097ecd24c45ab8e2f228 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Jun 2009 21:42:25 -0700 Subject: Cache the page_type in pane() instead of looking it up twice. --- modules/gallery/controllers/quick.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index 6203728c..e89d9701 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -25,10 +25,10 @@ class Quick_Controller extends Controller { } $view = new View("quick_pane.html"); - $view->button_list = - gallery_quick::get_quick_buttons($item, Input::instance()->get("page_type")); + $page_type = Input::instance()->get("page_type"); + $view->button_list = gallery_quick::get_quick_buttons($item, $page_type); $view->item = $item; - $view->page_type = Input::instance()->get("page_type"); + $view->page_type = $page_type; print $view; } -- cgit v1.2.3 From 231ad4f32950f42c76c16ab453246bedea8abf2c Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 23 Jun 2009 22:13:28 -0700 Subject: This implements the Digibug printing. When a a print request is made the digibug shopping cart is opened in a new window. When the cart is emptied, the window is closed. Users can close the window by pressing the continue shopping button --- modules/digibug/controllers/digibug.php | 12 ++++--- modules/digibug/helpers/digibug_installer.php | 2 +- modules/digibug/helpers/digibug_theme.php | 1 - modules/digibug/js/digibug.js | 52 +++++++++++++++++++-------- modules/digibug/views/digibug_album.html.php | 2 +- modules/digibug/views/digibug_form.html.php | 16 +++++++++ 6 files changed, 62 insertions(+), 23 deletions(-) create mode 100644 modules/digibug/views/digibug_form.html.php (limited to 'modules') diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php index b0807aa5..609da875 100644 --- a/modules/digibug/controllers/digibug.php +++ b/modules/digibug/controllers/digibug.php @@ -36,12 +36,13 @@ class Digibug_Controller extends Controller { $company_id = module::get_var("digibug", "company_id"); $event_id = module::get_var("digibug", "event_id"); } - $digibug_parms = array( + $v = new View("digibug_form.html"); + $v->order_parms = array( "digibug_api_version" => "100", "company_id" => $company_id, "event_id" => $event_id, "cmd" => "adding", - "return_url" => url::abs_site($this->input->get("return")), + "return_url" => url::abs_site("digibug/close_window"), "num_images" => "1", "image_1" => $url, "thumb_1" => "$url/thumb", @@ -51,9 +52,7 @@ class Digibug_Controller extends Controller { "thumb_width_1" => $item->thumb_width, "title" => $item->title); - message::success( - t("Photo '%title' was submitted for printing.", array("title" => $item->title))); - print json_encode(array("result" => "success", "reload" => 1)); + print $v; } public function print_proxy($id, $thumb=null) { @@ -90,4 +89,7 @@ class Digibug_Controller extends Controller { } } + public function close_window() { + print ""; + } } \ No newline at end of file diff --git a/modules/digibug/helpers/digibug_installer.php b/modules/digibug/helpers/digibug_installer.php index 73645eb7..0476e2cc 100644 --- a/modules/digibug/helpers/digibug_installer.php +++ b/modules/digibug/helpers/digibug_installer.php @@ -24,7 +24,7 @@ class digibug_installer { Database::instance() ->query("CREATE TABLE {proxies} ( `id` int(9) NOT NULL auto_increment, - `uuid` char(32) NOT NULL, + `uuid` char(36) NOT NULL, `item_id` int(9), PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); diff --git a/modules/digibug/helpers/digibug_theme.php b/modules/digibug/helpers/digibug_theme.php index 0fe2ce2e..e52fcc7f 100644 --- a/modules/digibug/helpers/digibug_theme.php +++ b/modules/digibug/helpers/digibug_theme.php @@ -34,7 +34,6 @@ class digibug_theme_Core { if ($theme->page_type() == "album" && $child->type == "photo") { $v = new View("digibug_album.html"); $v->id = $child->id; - $v->return = "album/{$child->parent()->id}"; $v->title = t("Print photo with Digibug"); return $v->render(); } diff --git a/modules/digibug/js/digibug.js b/modules/digibug/js/digibug.js index f30678c0..e9e8933e 100644 --- a/modules/digibug/js/digibug.js +++ b/modules/digibug/js/digibug.js @@ -5,20 +5,42 @@ $(document).ready(function() { }); }); +function popUp(url, options) { + options = $.extend({ + /* default options */ + width: 400, + height: 400, + 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; + +} + function queue_print(e) { - var parent = e.currentTarget.parentNode; - $(parent).addClass("gLoadingLarge"); - $.ajax({ - type: "GET", - url: e.currentTarget.href, - dataType: "json", - success: function(data) { - $(parent).removeClass("gLoadingLarge"); - if (data.location) { - window.location = data.location; - } else if (data.reload) { - window.location.reload(); - } - } - }); + return popUp(e.currentTarget.href, { width: 800, height: 600 } ); }; diff --git a/modules/digibug/views/digibug_album.html.php b/modules/digibug/views/digibug_album.html.php index 0f1537e9..c3337324 100644 --- a/modules/digibug/views/digibug_album.html.php +++ b/modules/digibug/views/digibug_album.html.php @@ -1,7 +1,7 @@
" + href="" title=""> diff --git a/modules/digibug/views/digibug_form.html.php b/modules/digibug/views/digibug_form.html.php new file mode 100644 index 00000000..c2cd889e --- /dev/null +++ b/modules/digibug/views/digibug_form.html.php @@ -0,0 +1,16 @@ + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3 From 0062f8a24a62fe8f5abdffcea8c35382afa32244 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 24 Jun 2009 05:47:58 -0700 Subject: Add a timestamp column to the proxies table. --- modules/digibug/helpers/digibug_installer.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/digibug/helpers/digibug_installer.php b/modules/digibug/helpers/digibug_installer.php index 0476e2cc..baff2075 100644 --- a/modules/digibug/helpers/digibug_installer.php +++ b/modules/digibug/helpers/digibug_installer.php @@ -23,9 +23,10 @@ class digibug_installer { if ($version == 0) { Database::instance() ->query("CREATE TABLE {proxies} ( - `id` int(9) NOT NULL auto_increment, + `id` int(9) NOT NULL AUTO_INCREMENT, `uuid` char(36) NOT NULL, - `item_id` int(9), + `request_date` TIMESTAMP NOT NULL DEFAULT current_timestamp, + `item_id` int(9) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); @@ -38,7 +39,7 @@ class digibug_installer { } static function uninstall() { - Database::instance()->query("DROP TABLE IF EXISTS {proxys}"); + Database::instance()->query("DROP TABLE IF EXISTS {proxies}"); module::delete("digibug"); } } -- cgit v1.2.3 From 40e27e128e34601380079a02dca9346aed54c3bf Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 24 Jun 2009 13:11:53 -0700 Subject: Create a maintenance task that allows the administrator to remove any proxy requests that are still active after 10 days. Digibug requires that the image be available for 5 days, so we'll give them an extra 5 days. Also correct a few issues with the protocol. --- modules/digibug/controllers/digibug.php | 4 +- modules/digibug/helpers/digibug_task.php | 68 ++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 modules/digibug/helpers/digibug_task.php (limited to 'modules') diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php index 609da875..3a427149 100644 --- a/modules/digibug/controllers/digibug.php +++ b/modules/digibug/controllers/digibug.php @@ -41,7 +41,7 @@ class Digibug_Controller extends Controller { "digibug_api_version" => "100", "company_id" => $company_id, "event_id" => $event_id, - "cmd" => "adding", + "cmd" => "addimg", "return_url" => url::abs_site("digibug/close_window"), "num_images" => "1", "image_1" => $url, @@ -50,7 +50,7 @@ class Digibug_Controller extends Controller { "image_width_1" => $item->width, "thumb_height_1" => $item->thumb_height, "thumb_width_1" => $item->thumb_width, - "title" => $item->title); + "title_1" => $item->title); print $v; } diff --git a/modules/digibug/helpers/digibug_task.php b/modules/digibug/helpers/digibug_task.php new file mode 100644 index 00000000..98f79731 --- /dev/null +++ b/modules/digibug/helpers/digibug_task.php @@ -0,0 +1,68 @@ +query( + "SELECT count(*) as print_requests + FROM {proxies} + WHERE `request_date` <= (CURDATE() - INTERVAL 10 DAY)")->current()->print_requests; + + return array(Task_Definition::factory() + ->callback("digibug_task::remove_expired") + ->name(t("Remove Digibug print requests")) + ->description($expired_request_count + ? t2("1 Digibug print request has expired", + "%count Digibug print requests have expired", + $expired_request_count) + : t("All print requests are current")) + ->severity($expired_request_count ? log::WARNING : log::SUCCESS)); + } + + static function remove_expired($task) { + $completed = $task->get("completed", 0); + $expired = ORM::factory("proxy") + ->where("request_date <= (CURDATE() - INTERVAL 10 DAY)") + ->find_all(); + $remaining = $expired->count(); + + $start = microtime(true); + foreach ($expired as $proxy) { + if (microtime(true) - $start > 1.5) { + break; + } + $proxy->delete(); + $completed++; + $remaining--; + } + + if ($completed + $remaining > 0) { + $task->percent_complete = (int)(100 * $completed / ($completed + $remaining)); + } else { + $task->percent_complete = 100; + } + + $task->set("completed", $completed); + if ($remaining == 0) { + $task->done = true; + $task->state = "success"; + } + } +} -- cgit v1.2.3