Skip to content

Commit

Permalink
Minor clean up.
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
bharat committed Jun 20, 2009
1 parent 57e4d74 commit bcf7aee
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 21 deletions.
Expand Up @@ -28,14 +28,14 @@ public function index() {
}

public function saveprefs() {
// This probably does something important.
// Prevent Cross Site Request Forgery
access::verify_csrf();

// Figure out which boxes where checked
$dlLinks_array = $_POST['DownloadLinkOptions'];
$dlLinks_array = Input::instance()->post("DownloadLinkOptions");
$tButton = false;
$fButton = false;
for ($i=0; $i<count($dlLinks_array); $i++) {
for ($i = 0; $i < count($dlLinks_array); $i++) {
if ($dlLinks_array[$i] == "tButton") {
$tButton = true;
}
Expand Down
3 changes: 1 addition & 2 deletions modules/downloadfullsize/controllers/downloadfullsize.php
Expand Up @@ -18,11 +18,10 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class downloadfullsize_Controller extends Controller {

public function send($id) {
$item = ORM::factory("item", $id);
access::required("view_full", $item);
download::force($item->file_path());
return ;
}
}
Expand Up @@ -20,13 +20,11 @@ class downloadfullsize_installer {
static function install() {
$version = module::get_version("downloadfullsize");
if ($version == 0) {
/* @todo Put database creation here */
module::set_version("downloadfullsize", 1);
}
}

static function uninstall() {
/* @todo Put database table drops here */
module::delete("downloadfullsize");
}
}
1 change: 1 addition & 0 deletions modules/downloadfullsize/helpers/downloadfullsize_menu.php
Expand Up @@ -31,6 +31,7 @@ static function photo($menu, $theme) {
}
}
}

static function admin($menu, $theme) {
$menu->get("settings_menu")
->append(Menu::factory("link")
Expand Down
24 changes: 12 additions & 12 deletions modules/downloadfullsize/helpers/downloadfullsize_theme.php
@@ -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
* Copyright (C) 2000-2009 Bharat Mediratta
*
Expand All @@ -18,19 +19,18 @@
*/
class downloadfullsize_theme {
static function sidebar_blocks($theme) {
if ($theme->item()->is_photo()) {
if (access::can("view_full", $theme->item)) {
if (module::get_var("downloadfullsize", "tButton")) {
$block = new Block();
$block->css_id = "gDownloadFullsize";
$block->title = t("Download");
$block->content = new View("downloadfullsize_block.html");
$item = $theme->item();
if ($item && $item->is_photo() && access::can("view_full", $item)) {
if (module::get_var("downloadfullsize", "tButton")) {
$block = new Block();
$block->css_id = "gDownloadFullsize";
$block->title = t("Download");
$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;
}
}
}
}
}
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>

<div class="gDownloadFullsizeBlock">
<a href="<?= url::site("downloadfullsize/send/$theme->item")
?>" title="<?= t("Download Photo") ?>"
<a href="<?= url::site("downloadfullsize/send/$theme->item") ?>"
title="<?= t("Download Photo") ?>"
class="gButtonLink ui-icon-left ui-state-default ui-corner-all"><?= t("Download Fullsize Image") ?></a>
</div>

0 comments on commit bcf7aee

Please sign in to comment.