summaryrefslogtreecommitdiff
path: root/modules/g2_import
diff options
context:
space:
mode:
Diffstat (limited to 'modules/g2_import')
-rw-r--r--modules/g2_import/controllers/admin_g2_import.php2
-rw-r--r--modules/g2_import/controllers/g2.php2
-rw-r--r--modules/g2_import/helpers/g2_import.php53
-rw-r--r--modules/g2_import/helpers/g2_import_event.php2
-rw-r--r--modules/g2_import/helpers/g2_import_installer.php2
-rw-r--r--modules/g2_import/helpers/g2_import_task.php10
-rw-r--r--modules/g2_import/libraries/G2_Import_Exception.php2
-rw-r--r--modules/g2_import/models/g2_map.php2
8 files changed, 61 insertions, 14 deletions
diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php
index b9427f79..33186fb5 100644
--- a/modules/g2_import/controllers/admin_g2_import.php
+++ b/modules/g2_import/controllers/admin_g2_import.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 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
diff --git a/modules/g2_import/controllers/g2.php b/modules/g2_import/controllers/g2.php
index 0f51173a..6e60bed0 100644
--- a/modules/g2_import/controllers/g2.php
+++ b/modules/g2_import/controllers/g2.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 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
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php
index 8de5ce44..5fd92972 100644
--- a/modules/g2_import/helpers/g2_import.php
+++ b/modules/g2_import/helpers/g2_import.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 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
@@ -499,6 +499,9 @@ class g2_import_Core {
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;
@@ -1152,7 +1155,8 @@ class g2_import_Core {
"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()) {
@@ -1171,7 +1175,50 @@ class g2_import_Core {
$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()) {
diff --git a/modules/g2_import/helpers/g2_import_event.php b/modules/g2_import/helpers/g2_import_event.php
index d3eb001a..0e078d08 100644
--- a/modules/g2_import/helpers/g2_import_event.php
+++ b/modules/g2_import/helpers/g2_import_event.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 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
diff --git a/modules/g2_import/helpers/g2_import_installer.php b/modules/g2_import/helpers/g2_import_installer.php
index 8ada4fcb..a422ed30 100644
--- a/modules/g2_import/helpers/g2_import_installer.php
+++ b/modules/g2_import/helpers/g2_import_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 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
diff --git a/modules/g2_import/helpers/g2_import_task.php b/modules/g2_import/helpers/g2_import_task.php
index f2a13291..6bda8f17 100644
--- a/modules/g2_import/helpers/g2_import_task.php
+++ b/modules/g2_import/helpers/g2_import_task.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 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
@@ -96,7 +96,8 @@ class g2_import_task_Core {
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) {
@@ -109,8 +110,8 @@ class g2_import_task_Core {
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) {
@@ -141,7 +142,6 @@ class g2_import_task_Core {
$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);
diff --git a/modules/g2_import/libraries/G2_Import_Exception.php b/modules/g2_import/libraries/G2_Import_Exception.php
index 591f51cd..f5814ccb 100644
--- a/modules/g2_import/libraries/G2_Import_Exception.php
+++ b/modules/g2_import/libraries/G2_Import_Exception.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 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
diff --git a/modules/g2_import/models/g2_map.php b/modules/g2_import/models/g2_map.php
index 8b96050d..7795ba6a 100644
--- a/modules/g2_import/models/g2_map.php
+++ b/modules/g2_import/models/g2_map.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 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