Author: david
Date: Mon May 7 14:54:40 2012
New Revision: 11653
Log:
Use slugs for acl_permission conditionals, like r10996. Fixes issue 2263
Modified:
trunk/lib/task/migrate/arUpgrader120.class.php
Modified: trunk/lib/task/migrate/arUpgrader120.class.php
==============================================================================
--- trunk/lib/task/migrate/arUpgrader120.class.php Mon May 7 13:05:47
2012 (r11652)
+++ trunk/lib/task/migrate/arUpgrader120.class.php Mon May 7 14:54:40
2012 (r11653)
@@ -108,14 +108,62 @@
// Add 'active' column to user table
case 80:
- // NOTE: this ALTER statement automatically sets `active`=1 for
existing users
+ // NOTE: ALTER automatically sets `active`=1 (the DEFAULT) for
existing rows
$sql = sprintf('ALTER TABLE %s ADD COLUMN active TINYINT DEFAULT 1;',
QubitUser::TABLE_NAME);
QubitPdo::modify($sql);
break;
- // TODO Add refId column to terms table???
+ // Use repository slug instead of id in acl_permission conditionals,
+ // (r10996)
case 81:
+ $sql = sprintf('SELECT
+ id,
+ conditional,
+ constants
+ FROM %s
+ WHERE constants IS NOT NULL', QubitAclPermission::TABLE_NAME);
+
+ foreach (QubitPdo::fetchAll($sql) as $item)
+ {
+ if ('%p[repositoryId] == %k[repositoryId]' == $item->conditional)
+ {
+ $name = 'repository';
+ }
+ else if ('%p[taxonomyId] == %k[taxonomyId]' == $item->conditional)
+ {
+ $name = 'taxonomy';
+ }
+ else
+ {
+ continue;
+ }
+
+ $arr = unserialize($item->constants);
+
+ // Get slug
+ $sql = 'SELECT slug FROM slug WHERE object_id=?';
+ $slug = QubitPdo::fetchOne($sql, array($arr[$name.'Id']));
+
+ // Update acl_permission values
+ if ($slug)
+ {
+ $sql = sprintf("UPDATE %s SET
+ conditional = ?,
+ constants = ?
+ WHERE id = ?;", QubitAclPermission::TABLE_NAME);
+
+ QubitPdo::modify($sql, array(
+ "%p[$name] == %k[$name]",
+ serialize(array($name => $slug->slug)),
+ $item->id));
+ }
+ }
+
+ break;
+
+ // TODO Add refId column to terms table???
+ case 82:
// $sql = sprintf('ALTER TABLE %s ADD COLUMN ref_id varchar(255);',
QubitTaxonomy::TABLE_NAME);
// $sql = sprintf('ALTER TABLE %s ADD COLUMN ref_id varchar(255);',
QubitTerm::TABLE_NAME);
return false;
@@ -127,6 +175,4 @@
return true;
}
-
-
}
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.