1
0

Minor clean up.

* Change $_POST to Input::instance()->post
* Explain what access::verify_csrf() does
* Avoid breakages on tag album pages (which don't have an item)
* Minor style fixes.

There's more that could be done here, but this is sufficient.
This commit is contained in:
Bharat Mediratta 2009-06-20 16:29:01 -07:00
parent 57e4d745be
commit bcf7aee864
6 changed files with 19 additions and 21 deletions

View File

@ -28,14 +28,14 @@ class Admin_DownloadFullsize_Controller extends Admin_Controller {
} }
public function saveprefs() { public function saveprefs() {
// This probably does something important. // Prevent Cross Site Request Forgery
access::verify_csrf(); access::verify_csrf();
// Figure out which boxes where checked // Figure out which boxes where checked
$dlLinks_array = $_POST['DownloadLinkOptions']; $dlLinks_array = Input::instance()->post("DownloadLinkOptions");
$tButton = false; $tButton = false;
$fButton = false; $fButton = false;
for ($i=0; $i<count($dlLinks_array); $i++) { for ($i = 0; $i < count($dlLinks_array); $i++) {
if ($dlLinks_array[$i] == "tButton") { if ($dlLinks_array[$i] == "tButton") {
$tButton = true; $tButton = true;
} }

View File

@ -18,11 +18,10 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
class downloadfullsize_Controller extends Controller { class downloadfullsize_Controller extends Controller {
public function send($id) { public function send($id) {
$item = ORM::factory("item", $id); $item = ORM::factory("item", $id);
access::required("view_full", $item); access::required("view_full", $item);
download::force($item->file_path()); download::force($item->file_path());
return ;
} }
} }

View File

@ -20,13 +20,11 @@ class downloadfullsize_installer {
static function install() { static function install() {
$version = module::get_version("downloadfullsize"); $version = module::get_version("downloadfullsize");
if ($version == 0) { if ($version == 0) {
/* @todo Put database creation here */
module::set_version("downloadfullsize", 1); module::set_version("downloadfullsize", 1);
} }
} }
static function uninstall() { static function uninstall() {
/* @todo Put database table drops here */
module::delete("downloadfullsize"); module::delete("downloadfullsize");
} }
} }

View File

@ -31,6 +31,7 @@ class downloadfullsize_menu_Core {
} }
} }
} }
static function admin($menu, $theme) { static function admin($menu, $theme) {
$menu->get("settings_menu") $menu->get("settings_menu")
->append(Menu::factory("link") ->append(Menu::factory("link")

View File

@ -1,4 +1,5 @@
<?php defined("SYSPATH") or die("No direct script access.");/** <?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor * Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta * Copyright (C) 2000-2009 Bharat Mediratta
* *
@ -18,19 +19,18 @@
*/ */
class downloadfullsize_theme { class downloadfullsize_theme {
static function sidebar_blocks($theme) { static function sidebar_blocks($theme) {
if ($theme->item()->is_photo()) { $item = $theme->item();
if (access::can("view_full", $theme->item)) { if ($item && $item->is_photo() && access::can("view_full", $item)) {
if (module::get_var("downloadfullsize", "tButton")) { if (module::get_var("downloadfullsize", "tButton")) {
$block = new Block(); $block = new Block();
$block->css_id = "gDownloadFullsize"; $block->css_id = "gDownloadFullsize";
$block->title = t("Download"); $block->title = t("Download");
$block->content = new View("downloadfullsize_block.html"); $block->content = new View("downloadfullsize_block.html");
$block->content->item = ORM::factory("item", 1); $block->content->item = ORM::factory("item", 1);
return $block; return $block;
}
} }
} }
} }
} }

View File

@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.") ?> <?php defined("SYSPATH") or die("No direct script access.") ?>
<div class="gDownloadFullsizeBlock"> <div class="gDownloadFullsizeBlock">
<a href="<?= url::site("downloadfullsize/send/$theme->item") <a href="<?= url::site("downloadfullsize/send/$theme->item") ?>"
?>" title="<?= t("Download Photo") ?>" title="<?= t("Download Photo") ?>"
class="gButtonLink ui-icon-left ui-state-default ui-corner-all"><?= t("Download Fullsize Image") ?></a> class="gButtonLink ui-icon-left ui-state-default ui-corner-all"><?= t("Download Fullsize Image") ?></a>
</div> </div>