Skip to content

Commit

Permalink
Merge branch 'master' into talmdal_dev
Browse files Browse the repository at this point in the history
Conflicts:
	modules/gallery/controllers/albums.php
	modules/gallery/controllers/movies.php
	modules/gallery/controllers/photos.php
  • Loading branch information
Tim Almdal committed Dec 26, 2009
2 parents 1cd6a61 + 32d25da commit 3060a6f
Show file tree
Hide file tree
Showing 307 changed files with 10,916 additions and 12,265 deletions.
67 changes: 67 additions & 0 deletions application/Bootstrap.php
@@ -0,0 +1,67 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/

// Kohana benchmarks are prefixed to prevent collisions
define('SYSTEM_BENCHMARK', 'system_benchmark');

// Load benchmarking support
require SYSPATH.'core/Benchmark'.EXT;

// Start total_execution
Benchmark::start(SYSTEM_BENCHMARK.'_total_execution');

// Start kohana_loading
Benchmark::start(SYSTEM_BENCHMARK.'_kohana_loading');

// Load core files
require SYSPATH.'core/Event'.EXT;
final class Event extends Event_Core {}

require SYSPATH.'core/Kohana'.EXT;
final class Kohana extends Kohana_Core {}

require SYSPATH.'core/Kohana_Exception'.EXT;
require MODPATH.'gallery/libraries/MY_Kohana_Exception'.EXT;

require SYSPATH.'core/Kohana_Config'.EXT;
require SYSPATH.'libraries/drivers/Config'.EXT;
require SYSPATH.'libraries/drivers/Config/Array'.EXT;
final class Kohana_Config extends Kohana_Config_Core {}

// Prepare the environment
Kohana::setup();

// End kohana_loading
Benchmark::stop(SYSTEM_BENCHMARK.'_kohana_loading');

// Start system_initialization
Benchmark::start(SYSTEM_BENCHMARK.'_system_initialization');

// Prepare the system
Event::run('system.ready');

// Determine routing
Event::run('system.routing');

// End system_initialization
Benchmark::stop(SYSTEM_BENCHMARK.'_system_initialization');

// Make the magic happen!
Event::run('system.execute');
7 changes: 7 additions & 0 deletions application/config/config.php
Expand Up @@ -129,13 +129,20 @@
*/
$config["extension_prefix"] = "MY_";

/**
* An optional list of Config Drivers to use, they "fallback" to the one below them if they
* dont work so the first driver is tried then so on until it hits the built in "array" driver and fails
*/
$config['config_drivers'] = array();

/**
* Additional resource paths, or "modules". Each path can either be absolute
* or relative to the docroot. Modules can include any resource that can exist
* in your application directory, configuration files, controllers, views, etc.
*/
$config["modules"] = array(
MODPATH . "forge",
MODPATH . "kohana23_compat",
MODPATH . "gallery", // gallery must be *last* in the order
);

Expand Down
2 changes: 1 addition & 1 deletion index.php
Expand Up @@ -87,4 +87,4 @@
}

// Initialize.
require SYSPATH . "core/Bootstrap" . EXT;
require APPPATH . "Bootstrap" . EXT;
3 changes: 2 additions & 1 deletion installer/database_config.php
Expand Up @@ -35,7 +35,8 @@
'host' => '<?php print $host ?>',
'port' => <?php if (!empty($port)): ?>'<?php print $port ?>' <?php else: ?>false<?php endif ?>,
'socket' => false,
'database' => '<?php print $dbname ?>'
'database' => '<?php print $dbname ?>',
'params' => null,
),
'character_set' => 'utf8',
'table_prefix' => '<?php print $prefix ?>',
Expand Down
4 changes: 2 additions & 2 deletions modules/akismet/helpers/akismet.php
Expand Up @@ -166,7 +166,7 @@ private static function _http_post($http_request, $host=null) {
}
$response = "";

Kohana::log("debug", "Send request\n" . print_r($http_request, 1));
Kohana_Log::add("debug", "Send request\n" . print_r($http_request, 1));
if (false !== ($fs = @fsockopen($host, 80, $errno, $errstr, 5))) {
fwrite($fs, $http_request);
while ( !feof($fs) ) {
Expand All @@ -181,7 +181,7 @@ private static function _http_post($http_request, $host=null) {
} else {
throw new Exception("@todo CONNECTION TO SPAM SERVICE FAILED");
}
Kohana::log("debug", "Received response\n" . print_r($response, 1));
Kohana_Log::add("debug", "Received response\n" . print_r($response, 1));

return $response;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/akismet/tests/Akismet_Helper_Test.php
Expand Up @@ -22,7 +22,7 @@ class Akismet_Helper_Test extends Unit_Test_Case {

public function setup() {
Input::instance()->ip_address = "1.1.1.1";
Kohana::$user_agent = "Akismet_Helper_Test";
request::set_user_agent("Akismet_Helper_Test");

$root = ORM::factory("item", 1);
$this->_comment = comment::create(
Expand Down
26 changes: 14 additions & 12 deletions modules/comment/controllers/admin_comments.php
Expand Up @@ -22,10 +22,11 @@ class Admin_Comments_Controller extends Admin_Controller {

public function index() {
// Get rid of old deleted/spam comments once in a while
Database::instance()->query(
"DELETE FROM {comments} " .
"WHERE state IN ('deleted', 'spam') " .
"AND unix_timestamp(now()) - updated > 86400 * 7");
db::build()
->delete("comments")
->where("state", "IN", array("deleted", "spam"))
->where("updated", "<", "UNIX_TIMESTAMP() - 86400 * 7")
->execute();

// Redirect to the appropriate queue
url::redirect("admin/comments/queue/unpublished");
Expand All @@ -48,8 +49,8 @@ public function queue($state) {
$view->content->menu = $this->_menu($view->content->counts);
$view->content->state = $state;
$view->content->comments = ORM::factory("comment")
->orderby("created", "DESC")
->where("state", $state)
->order_by("created", "DESC")
->where("state", "=", $state)
->limit(self::$items_per_page, ($page - 1) * self::$items_per_page)
->find_all();
$view->content->pager = new Pagination();
Expand Down Expand Up @@ -95,11 +96,12 @@ private function _counts() {
$counts->published = 0;
$counts->spam = 0;
$counts->deleted = 0;
foreach (Database::instance()
->select("state", "count(*) as c")
foreach (db::build()
->select("state")
->select(array("c" => 'COUNT("*")'))
->from("comments")
->groupby("state")
->get() as $row) {
->group_by("state")
->execute() as $row) {
$counts->{$row->state} = $row->c;
}
return $counts;
Expand All @@ -110,7 +112,7 @@ public function set_state($id, $state) {

$comment = ORM::factory("comment", $id);
$orig = clone $comment;
if ($comment->loaded) {
if ($comment->loaded()) {
$comment->state = $state;
$comment->save();
}
Expand All @@ -120,7 +122,7 @@ public function delete_all_spam() {
access::verify_csrf();

ORM::factory("comment")
->where("state", "spam")
->where("state", "=", "spam")
->delete_all();
url::redirect("admin/comments/queue/spam");
}
Expand Down
2 changes: 1 addition & 1 deletion modules/comment/helpers/comment_block.php
Expand Up @@ -30,7 +30,7 @@ static function get($block_id) {
$block->title = t("Recent comments");
$block->content = new View("admin_block_recent_comments.html");
$block->content->comments =
ORM::factory("comment")->orderby("created", "DESC")->limit(5)->find_all();
ORM::factory("comment")->order_by("created", "DESC")->limit(5)->find_all();
break;
}

Expand Down
41 changes: 22 additions & 19 deletions modules/comment/helpers/comment_event.php
Expand Up @@ -19,29 +19,33 @@
*/
class comment_event_Core {
static function item_deleted($item) {
Database::instance()->delete("comments", array("item_id" => $item->id));
db::build()
->delete("comments")
->where("item_id", "=", $item->id)
->execute();
}

static function user_deleted($user) {
$guest = identity::guest();
Database::instance()->from("comments")
->set(array("author_id" => $guest->id,
"guest_email" => null,
"guest_name" => "guest",
"guest_url" => null))
->where(array("author_id" => $user->id))
->update();
db::build()
->update("comments")
->set("author_id", $guest->id)
->set("guest_email", null)
->set("guest_name", "guest")
->set("guest_url", null)
->where("author_id", "=", $user->id)
->execute();
}

static function identity_provider_changed($old_provider, $new_provider) {
$guest = identity::guest();
Database::instance()->from("comments")
->set(array("author_id" => $guest->id,
"guest_email" => null,
"guest_name" => "guest",
"guest_url" => null))
->where("1 = 1")
->update();
db::build()
->update("comments")
->set("author_id", $guest->id)
->set("guest_email", null)
->set("guest_name", "guest")
->set("guest_url", null)
->execute();
}

static function admin_menu($menu, $theme) {
Expand All @@ -62,12 +66,11 @@ static function photo_menu($menu, $theme) {
}

static function item_index_data($item, $data) {
foreach (Database::instance()
foreach (db::build()
->select("text")
->from("comments")
->where("item_id", $item->id)
->get()
->as_array() as $row) {
->where("item_id", "=", $item->id)
->execute() as $row) {
$data[] = $row->text;
}
}
Expand Down
6 changes: 3 additions & 3 deletions modules/comment/helpers/comment_rss.php
Expand Up @@ -35,11 +35,11 @@ static function feed($feed_id, $offset, $limit, $id) {

$comments = ORM::factory("comment")
->viewable()
->where("state", "published")
->orderby("created", "DESC");
->where("state", "=", "published")
->order_by("created", "DESC");

if ($feed_id == "item") {
$comments->where("item_id", $id);
$comments->where("item_id", "=", $id);
}

$feed->view = "comment.mrss";
Expand Down
6 changes: 3 additions & 3 deletions modules/comment/helpers/comment_theme.php
Expand Up @@ -37,9 +37,9 @@ static function photo_bottom($theme) {

$view = new View("comments.html");
$view->comments = ORM::factory("comment")
->where("item_id", $theme->item()->id)
->where("state", "published")
->orderby("created", "ASC")
->where("item_id", "=", $theme->item()->id)
->where("state", "=", "published")
->order_by("created", "ASC")
->find_all();

$block->content = $view;
Expand Down
2 changes: 1 addition & 1 deletion modules/comment/models/comment.php
Expand Up @@ -59,7 +59,7 @@ function author_url() {
public function save() {
if (!empty($this->changed)) {
$this->updated = time();
if (!$this->loaded && empty($this->created)) {
if (!$this->loaded() && empty($this->created)) {
$this->created = $this->updated;
$created = true;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/comment/tests/Comment_Event_Test.php
Expand Up @@ -27,6 +27,6 @@ public function deleting_an_item_deletes_its_comments_too_test() {
$album->delete();

$deleted_comment = ORM::factory("comment", $comment->id);
$this->assert_false($deleted_comment->loaded);
$this->assert_false($deleted_comment->loaded());
}
}
7 changes: 4 additions & 3 deletions modules/comment/tests/Comment_Helper_Test.php
Expand Up @@ -23,7 +23,7 @@ class Comment_Helper_Test extends Unit_Test_Case {

public function setup() {
$this->_ip_address = Input::instance()->ip_address;
$this->_user_agent = Kohana::$user_agent;
$this->_user_agent = request::user_agent();
$this->_save = $_SERVER;

$_SERVER["HTTP_ACCEPT"] = "HTTP_ACCEPT";
Expand All @@ -33,16 +33,17 @@ public function setup() {
$_SERVER["HTTP_CONNECTION"] = "HTTP_CONNECTION";
$_SERVER["HTTP_HOST"] = "HTTP_HOST";
$_SERVER["HTTP_REFERER"] = "HTTP_REFERER";
$_SERVER["HTTP_USER_AGENT"] = "HTTP_USER_AGENT";
$_SERVER["QUERY_STRING"] = "QUERY_STRING";
$_SERVER["REMOTE_ADDR"] = "REMOTE_ADDR";
$_SERVER["REMOTE_HOST"] = "REMOTE_HOST";
$_SERVER["REMOTE_PORT"] = "REMOTE_PORT";

request::set_user_agent("HTTP_USER_AGENT");
}

public function teardown() {
Input::instance()->ip_address = $this->_ip_address;
Kohana::$user_agent = $this->_user_agent;
request::set_user_agent($this->_user_agent);
$_SERVER = $this->_save;
}

Expand Down
4 changes: 2 additions & 2 deletions modules/comment/tests/Comment_Model_Test.php
Expand Up @@ -29,12 +29,12 @@ public function cant_view_comments_for_unviewable_items_test() {
access::allow(identity::everybody(), "view", $album);
$this->assert_equal(
1,
ORM::factory("comment")->viewable()->where("comments.id", $comment->id)->count_all());
ORM::factory("comment")->viewable()->where("comments.id", "=", $comment->id)->count_all());

// We can't see the comment when permissions are denied on the album
access::deny(identity::everybody(), "view", $album);
$this->assert_equal(
0,
ORM::factory("comment")->viewable()->where("comments.id", $comment->id)->count_all());
ORM::factory("comment")->viewable()->where("comments.id", "=", $comment->id)->count_all());
}
}

0 comments on commit 3060a6f

Please sign in to comment.