Skip to content

Commit

Permalink
Merge remote branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
colings committed Jan 9, 2011
2 parents c2a1ea6 + de5b06a commit 02a349f
Show file tree
Hide file tree
Showing 72 changed files with 11,053 additions and 383 deletions.
5 changes: 5 additions & 0 deletions index.php
Expand Up @@ -35,6 +35,11 @@
// and logging. You can turn off Kohana errors in application/config/config.php
ini_set("display_errors", false);

// Turn off session.use_trans_sid -- that feature attempts to inject session ids
// into generated URLs and forms, but it doesn't interoperate will with Gallery's
// Ajax code.
ini_set("session.use_trans_sid", false);

define("EXT", ".php");
define("DOCROOT", getcwd() . "/");
define("KOHANA", "index.php");
Expand Down
5 changes: 5 additions & 0 deletions installer/index.php
Expand Up @@ -26,6 +26,11 @@
exit;
}

// Turn off session.use_trans_sid -- that feature attempts to inject session ids
// into generated URLs and forms, but it doesn't interoperate will with Gallery's
// Ajax code.
ini_set("session.use_trans_sid", false);

require(DOCROOT . "installer/installer.php");
if (PHP_SAPI == "cli") {
include("cli.php");
Expand Down
41 changes: 16 additions & 25 deletions installer/install.sql
Expand Up @@ -43,7 +43,7 @@ CREATE TABLE {caches} (
`expiration` int(9) NOT NULL,
`cache` longblob,
PRIMARY KEY (`id`),
KEY `key` (`key`),
UNIQUE KEY `key` (`key`),
KEY `tags` (`tags`)
) DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
Expand Down Expand Up @@ -152,7 +152,7 @@ CREATE TABLE {items} (
`album_cover_item_id` int(9) DEFAULT NULL,
`captured` int(9) DEFAULT NULL,
`created` int(9) DEFAULT NULL,
`description` varchar(2048) DEFAULT NULL,
`description` text,
`height` int(9) DEFAULT NULL,
`left_ptr` int(9) NOT NULL,
`level` int(9) NOT NULL,
Expand Down Expand Up @@ -242,18 +242,17 @@ CREATE TABLE {modules} (
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
KEY `weight` (`weight`)
) AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
) AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO {modules} VALUES (1,1,'gallery',42,1);
INSERT INTO {modules} VALUES (1,1,'gallery',43,1);
INSERT INTO {modules} VALUES (2,1,'user',3,2);
INSERT INTO {modules} VALUES (3,1,'comment',3,3);
INSERT INTO {modules} VALUES (4,1,'organize',2,4);
INSERT INTO {modules} VALUES (5,1,'info',1,5);
INSERT INTO {modules} VALUES (6,1,'rest',3,6);
INSERT INTO {modules} VALUES (7,1,'rss',1,7);
INSERT INTO {modules} VALUES (8,1,'search',1,8);
INSERT INTO {modules} VALUES (9,1,'slideshow',2,9);
INSERT INTO {modules} VALUES (10,1,'tag',2,10);
INSERT INTO {modules} VALUES (4,1,'organize',3,4);
INSERT INTO {modules} VALUES (5,1,'info',2,5);
INSERT INTO {modules} VALUES (6,1,'rss',1,6);
INSERT INTO {modules} VALUES (7,1,'search',1,7);
INSERT INTO {modules} VALUES (8,1,'slideshow',2,8);
INSERT INTO {modules} VALUES (9,1,'tag',2,9);
DROP TABLE IF EXISTS {outgoing_translations};
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
Expand Down Expand Up @@ -350,18 +349,6 @@ CREATE TABLE {themes} (
/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO {themes} VALUES (1,'wind',1);
INSERT INTO {themes} VALUES (2,'admin_wind',1);
DROP TABLE IF EXISTS {user_access_keys};
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE {user_access_keys} (
`id` int(9) NOT NULL AUTO_INCREMENT,
`user_id` int(9) NOT NULL,
`access_key` char(32) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `access_key` (`access_key`),
UNIQUE KEY `user_id` (`user_id`)
) DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS {users};
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
Expand Down Expand Up @@ -395,7 +382,7 @@ CREATE TABLE {vars} (
`value` text,
PRIMARY KEY (`id`),
UNIQUE KEY `module_name` (`module_name`,`name`)
) AUTO_INCREMENT=35 DEFAULT CHARSET=utf8;
) AUTO_INCREMENT=39 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO {vars} VALUES (NULL,'gallery','active_site_theme','wind');
INSERT INTO {vars} VALUES (NULL,'gallery','active_admin_theme','admin_wind');
Expand Down Expand Up @@ -429,5 +416,9 @@ INSERT INTO {vars} VALUES (NULL,'gallery','identity_provider','user');
INSERT INTO {vars} VALUES (NULL,'user','mininum_password_length','5');
INSERT INTO {vars} VALUES (NULL,'comment','spam_caught','0');
INSERT INTO {vars} VALUES (NULL,'comment','access_permissions','everybody');
INSERT INTO {vars} VALUES (NULL,'rest','allow_guest_access','0');
INSERT INTO {vars} VALUES (NULL,'info','show_title','1');
INSERT INTO {vars} VALUES (NULL,'info','show_description','1');
INSERT INTO {vars} VALUES (NULL,'info','show_owner','1');
INSERT INTO {vars} VALUES (NULL,'info','show_name','1');
INSERT INTO {vars} VALUES (NULL,'info','show_captured','1');
INSERT INTO {vars} VALUES (NULL,'slideshow','max_scale','0');
51 changes: 49 additions & 2 deletions modules/g2_import/helpers/g2_import.php
Expand Up @@ -499,6 +499,9 @@ static function import_album(&$queue) {
static function set_album_highlight(&$queue) {
// Dequeue the current album and enqueue its children
list($g2_album_id, $children) = each($queue);
if (empty($children)) {
return;
}
unset($queue[$g2_album_id]);
foreach ($children as $key => $value) {
$queue[$key] = $value;
Expand Down Expand Up @@ -1152,7 +1155,8 @@ static function get_comment_ids($min_id) {
"SELECT [GalleryComment::id] " .
"FROM [GalleryComment] " .
"WHERE [GalleryComment::publishStatus] = 0 " . // 0 == COMMENT_PUBLISH_STATUS_PUBLISHED
"AND [GalleryComment::id] > ?",
"AND [GalleryComment::id] > ? " .
"ORDER BY [GalleryComment::id] ASC",
array($min_id),
array("limit" => array("count" => 100))));
while ($result = $results->nextResult()) {
Expand All @@ -1171,7 +1175,50 @@ static function get_tag_item_ids($min_id) {
$ids = array();
$results = g2($gallery->search(
"SELECT DISTINCT([TagItemMap::itemId]) FROM [TagItemMap] " .
"WHERE [TagItemMap::itemId] > ?",
"WHERE [TagItemMap::itemId] > ? " .
"ORDER BY [TagItemMap::itemId] ASC",
array($min_id),
array("limit" => array("count" => 100))));
while ($result = $results->nextResult()) {
$ids[] = $result[0];
}
return $ids;
}

/**
* Get a set of user ids from Gallery 2 greater than $min_id. We use this to get the
* next chunk of users to import.
*/
static function get_user_ids($min_id) {
global $gallery;

$ids = array();
$results = g2($gallery->search(
"SELECT [GalleryUser::id] " .
"FROM [GalleryUser] " .
"WHERE [GalleryUser::id] > ? " .
"ORDER BY [GalleryUser::id] ASC",
array($min_id),
array("limit" => array("count" => 100))));
while ($result = $results->nextResult()) {
$ids[] = $result[0];
}
return $ids;
}

/**
* Get a set of group ids from Gallery 2 greater than $min_id. We use this to get the
* next chunk of groups to import.
*/
static function get_group_ids($min_id) {
global $gallery;

$ids = array();
$results = g2($gallery->search(
"SELECT [GalleryGroup::id] " .
"FROM [GalleryGroup] " .
"WHERE [GalleryGroup::id] > ? " .
"ORDER BY [GalleryGroup::id] ASC",
array($min_id),
array("limit" => array("count" => 100))));
while ($result = $results->nextResult()) {
Expand Down
8 changes: 4 additions & 4 deletions modules/g2_import/helpers/g2_import_task.php
Expand Up @@ -96,7 +96,8 @@ static function import($task) {
switch($modes[$mode]) {
case "groups":
if (empty($queue)) {
$task->set("queue", $queue = array_keys(g2(GalleryCoreApi::fetchGroupNames())));
$task->set("queue", $queue = g2_import::get_group_ids($task->get("last_id", 0)));
$task->set("last_id", end($queue));
}
$log_message = g2_import::import_group($queue);
if ($log_message) {
Expand All @@ -109,8 +110,8 @@ static function import($task) {

case "users":
if (empty($queue)) {
$task->set(
"queue", $queue = array_keys(g2(GalleryCoreApi::fetchUsersForGroup(GROUP_EVERYBODY))));
$task->set("queue", $queue = g2_import::get_user_ids($task->get("last_id", 0)));
$task->set("last_id", end($queue));
}
$log_message = g2_import::import_user($queue);
if ($log_message) {
Expand Down Expand Up @@ -141,7 +142,6 @@ static function import($task) {
$task->set("queue", $queue = g2_import::get_item_ids($task->get("last_id", 0)));
$task->set("last_id", end($queue));
}

$log_message = g2_import::import_item($queue);
if ($log_message) {
$task->log($log_message);
Expand Down
22 changes: 10 additions & 12 deletions modules/gallery/controllers/albums.php
Expand Up @@ -61,20 +61,18 @@ public function show($album) {
}

$template = new Theme_View("page.html", "collection", "album");
$template->set_global("page", $page);
$template->set_global("page_title", null);
$template->set_global("max_pages", $max_pages);
$template->set_global("page_size", $page_size);
$template->set_global("item", $album);
$template->set_global("children", $album->viewable()->children($page_size, $offset));
$template->set_global("children_count", $children_count);
$template->set_global("parents", $album->parents()->as_array()); // view calls empty() on this
$template->set_global(
array("page" => $page,
"page_title" => null,
"max_pages" => $max_pages,
"page_size" => $page_size,
"item" => $album,
"children" => $album->viewable()->children($page_size, $offset),
"parents" => $album->parents()->as_array(), // view calls empty() on this
"children_count" => $children_count));
$template->content = new View("album.html");

// We can't use math in ORM or the query builder, so do this by hand. It's important
// that we do this with math, otherwise concurrent accesses will damage accuracy.
db::query("UPDATE {items} SET `view_count` = `view_count` + 1 WHERE `id` = $album->id")
->execute();
$album->increment_view_count();

print $template;
}
Expand Down
20 changes: 10 additions & 10 deletions modules/gallery/controllers/movies.php
Expand Up @@ -38,19 +38,19 @@ public function show($movie) {
}

$template = new Theme_View("page.html", "item", "movie");
$template->set_global("item", $movie);
$template->set_global("children", array());
$template->set_global("children_count", 0);
$template->set_global("parents", $movie->parents()->as_array());
$template->set_global("next_item", $next_item);
$template->set_global("previous_item", $previous_item);
$template->set_global("sibling_count", $movie->parent()->viewable()->children_count($where));
$template->set_global("position", $position);
$template->set_global(
array("item" => $movie,
"children" => array(),
"children_count" => 0,
"parents" => $movie->parents()->as_array(),
"next_item" => $next_item,
"previous_item" => $previous_item,
"sibling_count" => $movie->parent()->viewable()->children_count($where),
"position" => $position));

$template->content = new View("movie.html");

$movie->view_count++;
$movie->save();
$movie->increment_view_count();

print $template;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/gallery/controllers/packager.php
Expand Up @@ -59,7 +59,7 @@ private function _reset() {
// numbers, keeping our install.sql file more stable.
srand(0);

foreach (array("gallery", "user", "comment", "organize", "info", "rest",
foreach (array("gallery", "user", "comment", "organize", "info",
"rss", "search", "slideshow", "tag") as $module_name) {
module::install($module_name);
module::activate($module_name);
Expand Down
20 changes: 10 additions & 10 deletions modules/gallery/controllers/photos.php
Expand Up @@ -38,19 +38,19 @@ public function show($photo) {
}

$template = new Theme_View("page.html", "item", "photo");
$template->set_global("item", $photo);
$template->set_global("children", array());
$template->set_global("children_count", 0);
$template->set_global("parents", $photo->parents()->as_array());
$template->set_global("next_item", $next_item);
$template->set_global("previous_item", $previous_item);
$template->set_global("sibling_count", $photo->parent()->viewable()->children_count($where));
$template->set_global("position", $position);
$template->set_global(
array("item" => $photo,
"children" => array(),
"children_count" => 0,
"parents" => $photo->parents()->as_array(),
"next_item" => $next_item,
"previous_item" => $previous_item,
"sibling_count" => $photo->parent()->viewable()->children_count($where),
"position" => $position));

$template->content = new View("photo.html");

$photo->view_count++;
$photo->save();
$photo->increment_view_count();

print $template;
}
Expand Down
9 changes: 8 additions & 1 deletion modules/gallery/helpers/gallery.php
Expand Up @@ -153,8 +153,15 @@ static function find_file($directory, $file, $required=false) {
if (is_string($file_name)) {
// make relative to DOCROOT
$parts = explode("/", $file_name);
$count = count($parts);
foreach ($parts as $idx => $part) {
if (in_array($part, array("application", "modules", "themes", "lib"))) {
// If this part is "modules" or "themes" make sure that the part 2 after this
// is the target directory, and if it is then we're done. This check makes
// sure that if Gallery is installed in a directory called "modules" or "themes"
// We don't parse the directory structure incorrectly.
if (in_array($part, array("modules", "themes")) &&
$idx + 2 < $count &&
$parts[$idx + 2] == $directory) {
break;
}
unset($parts[$idx]);
Expand Down
4 changes: 0 additions & 4 deletions modules/gallery/helpers/gallery_event.php
Expand Up @@ -178,10 +178,6 @@ static function user_login($user) {
}
Session::instance()->set("active_auth_timestamp", time());
auth::clear_failed_attempts($user);

if ($user->admin && ini_get("session.use_trans_sid")) {
message::info(t("PHP is configured with <a href=\"url\">session.use_trans_sid</a> enabled which will cause random logouts. Please disable this setting.", array("url" => "http://www.php.net/manual/en/session.configuration.php#ini.session.use-trans-sid")));
}
}

static function user_auth_failed($name) {
Expand Down
11 changes: 8 additions & 3 deletions modules/gallery/helpers/gallery_installer.php
Expand Up @@ -44,7 +44,7 @@ static function install() {
`expiration` int(9) NOT NULL,
`cache` longblob,
PRIMARY KEY (`id`),
KEY (`key`),
UNIQUE KEY (`key`),
KEY (`tags`))
DEFAULT CHARSET=utf8;");

Expand Down Expand Up @@ -84,7 +84,7 @@ static function install() {
`album_cover_item_id` int(9) default NULL,
`captured` int(9) default NULL,
`created` int(9) default NULL,
`description` varchar(2048) default NULL,
`description` text default NULL,
`height` int(9) default NULL,
`left_ptr` int(9) NOT NULL,
`level` int(9) NOT NULL,
Expand Down Expand Up @@ -309,7 +309,7 @@ static function install() {
module::set_var("gallery", "show_user_profiles_to", "registered_users");
module::set_var("gallery", "extra_binary_paths", "/usr/local/bin:/opt/local/bin:/opt/bin");

module::set_version("gallery", 42);
module::set_version("gallery", 43);
}

static function upgrade($version) {
Expand Down Expand Up @@ -648,6 +648,11 @@ static function upgrade($version) {
$db->query("ALTER TABLE {caches} DROP INDEX `key`, ADD UNIQUE `key` (`key`)");
module::set_version("gallery", $version = 42);
}

if ($version == 42) {
$db->query("ALTER TABLE {items} CHANGE `description` `description` text DEFAULT NULL");
module::set_version("gallery", $version = 43);
}
}

static function uninstall() {
Expand Down
2 changes: 1 addition & 1 deletion modules/gallery/helpers/module.php
Expand Up @@ -168,7 +168,7 @@ static function install($module_name) {
if (method_exists($installer_class, "install")) {
call_user_func_array(array($installer_class, "install"), array());
} else {
module::set_version($module_name, 1);
module::set_version($module_name, module::available()->$module_name->code_version);
}

// Set the weight of the new module, which controls the order in which the modules are
Expand Down

0 comments on commit 02a349f

Please sign in to comment.