summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/access.php40
-rw-r--r--modules/gallery/helpers/gallery_installer.php16
2 files changed, 31 insertions, 25 deletions
diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php
index c84527f4..949aea84 100644
--- a/modules/gallery/helpers/access.php
+++ b/modules/gallery/helpers/access.php
@@ -166,8 +166,8 @@ class access_Core {
// For view permissions, if any parent is self::DENY, then those parents lock this one.
// Return
$lock = ORM::factory("item")
- ->where("`left` <= $item->left")
- ->where("`right` >= $item->right")
+ ->where("`left_ptr` <= $item->left_ptr")
+ ->where("`right_ptr` >= $item->right_ptr")
->where("items.id <> $item->id")
->join("access_intents", "items.id", "access_intents.item_id")
->where("access_intents.view_$group->id", self::DENY)
@@ -490,11 +490,11 @@ class access_Core {
// item, then its safe to propagate from here.
if ($access->$field !== self::DENY) {
$tmp_item = ORM::factory("item")
- ->where("left <", $item->left)
- ->where("right >", $item->right)
+ ->where("left_ptr <", $item->left_ptr)
+ ->where("right_ptr >", $item->right_ptr)
->join("access_intents", "access_intents.item_id", "items.id")
->where("access_intents.$field", self::DENY)
- ->orderby("left", "DESC")
+ ->orderby("left_ptr", "DESC")
->limit(1)
->find();
if ($tmp_item->loaded) {
@@ -507,13 +507,13 @@ class access_Core {
// them according the rule above. So mark every permission below this level as UNKNOWN so
// that we can tell which permissions have been changed, and which ones need to be updated.
$db->update("items", array($field => self::UNKNOWN),
- array("left >=" => $item->left, "right <=" => $item->right));
+ array("left_ptr >=" => $item->left_ptr, "right_ptr <=" => $item->right_ptr));
$query = ORM::factory("access_intent")
- ->select(array("access_intents.$field", "items.left", "items.right", "items.id"))
+ ->select(array("access_intents.$field", "items.left_ptr", "items.right_ptr", "items.id"))
->join("items", "items.id", "access_intents.item_id")
- ->where("left >=", $item->left)
- ->where("right <=", $item->right)
+ ->where("left_ptr >=", $item->left_ptr)
+ ->where("right_ptr <=", $item->right_ptr)
->where("type", "album")
->where("access_intents.$field IS NOT", self::INHERIT)
->orderby("level", "DESC")
@@ -522,11 +522,11 @@ class access_Core {
if ($row->$field == self::ALLOW) {
// Propagate ALLOW for any row that is still UNKNOWN.
$db->update("items", array($field => $row->$field),
- array($field => self::UNKNOWN, "left >=" => $row->left, "right <=" => $row->right));
+ array($field => self::UNKNOWN, "left_ptr >=" => $row->left_ptr, "right_ptr <=" => $row->right_ptr));
} else if ($row->$field == self::DENY) {
// DENY overwrites everything below it
$db->update("items", array($field => $row->$field),
- array("left >=" => $row->left, "right <=" => $row->right));
+ array("left_ptr >=" => $row->left_ptr, "right_ptr <=" => $row->right_ptr));
}
}
@@ -534,7 +534,7 @@ class access_Core {
// DENY parent in the hierarchy to propagate from. So we'll still have a UNKNOWN values in
// the hierarchy, and all of those are safe to change to ALLOW.
$db->update("items", array($field => self::ALLOW),
- array($field => self::UNKNOWN, "left >=" => $item->left, "right <=" => $item->right));
+ array($field => self::UNKNOWN, "left_ptr >=" => $item->left_ptr, "right_ptr <=" => $item->right_ptr));
}
/**
@@ -562,10 +562,10 @@ class access_Core {
if ($access->$field === self::INHERIT) {
$tmp_item = ORM::factory("item")
->join("access_intents", "items.id", "access_intents.item_id")
- ->where("left <", $item->left)
- ->where("right >", $item->right)
+ ->where("left_ptr <", $item->left_ptr)
+ ->where("right_ptr >", $item->right_ptr)
->where("$field IS NOT", self::UNKNOWN)
- ->orderby("left", "DESC")
+ ->orderby("left_ptr", "DESC")
->limit(1)
->find();
if ($tmp_item->loaded) {
@@ -576,10 +576,10 @@ class access_Core {
// With non-view permissions, each level can override any permissions that came above it
// so start at the top and work downwards, overlaying permissions as we go.
$query = ORM::factory("access_intent")
- ->select(array("access_intents.$field", "items.left", "items.right"))
+ ->select(array("access_intents.$field", "items.left_ptr", "items.right_ptr"))
->join("items", "items.id", "access_intents.item_id")
- ->where("left >=", $item->left)
- ->where("right <=", $item->right)
+ ->where("left_ptr >=", $item->left_ptr)
+ ->where("right_ptr <=", $item->right_ptr)
->where("$field IS NOT", self::INHERIT)
->orderby("level", "ASC")
->find_all();
@@ -589,8 +589,8 @@ class access_Core {
"UPDATE {access_caches} SET `$field` = $value " .
"WHERE `item_id` IN " .
" (SELECT `id` FROM {items} " .
- " WHERE `left` >= $row->left " .
- " AND `right` <= $row->right)");
+ " WHERE `left_ptr` >= $row->left_ptr " .
+ " AND `right_ptr` <= $row->right_ptr)");
}
}
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index db13307f..760bec31 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -72,7 +72,7 @@ class gallery_installer {
`created` int(9) default NULL,
`description` varchar(2048) default NULL,
`height` int(9) default NULL,
- `left` int(9) NOT NULL,
+ `left_ptr` int(9) NOT NULL,
`level` int(9) NOT NULL,
`mime_type` varchar(64) default NULL,
`name` varchar(255) default NULL,
@@ -83,7 +83,7 @@ class gallery_installer {
`resize_dirty` boolean default 1,
`resize_height` int(9) default NULL,
`resize_width` int(9) default NULL,
- `right` int(9) NOT NULL,
+ `right_ptr` int(9) NOT NULL,
`sort_column` varchar(64) default NULL,
`sort_order` char(4) default 'ASC',
`thumb_dirty` boolean default 1,
@@ -204,8 +204,8 @@ class gallery_installer {
$root->type = "album";
$root->title = "Gallery";
$root->description = "";
- $root->left = 1;
- $root->right = 2;
+ $root->left_ptr = 1;
+ $root->right_ptr = 2;
$root->parent_id = 0;
$root->level = 1;
$root->thumb_dirty = 1;
@@ -258,7 +258,7 @@ class gallery_installer {
module::set_var("gallery", "show_credits", 1);
// @todo this string needs to be picked up by l10n_scanner
module::set_var("gallery", "credits", "Powered by <a href=\"%url\">Gallery %version</a>");
- module::set_version("gallery", 7);
+ module::set_version("gallery", 9);
}
static function upgrade($version) {
@@ -323,6 +323,12 @@ class gallery_installer {
}
module::set_version("gallery", $version = 8);
}
+
+ if ($version == 8) {
+ $db->query("ALTER TABLE {items} CHANGE COLUMN `left` `left_ptr` INT(9) NOT NULL;");
+ $db->query("ALTER TABLE {items} CHANGE COLUMN `right` `right_ptr` INT(9) NOT NULL;");
+ module::set_version("gallery", $version = 9);
+ }
}
static function uninstall() {