Elgg
Version master
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
engine
schema
migrations
20171106100916_add_acl_subtype.php
Go to the documentation of this file.
1
<?php
2
3
use
Phinx\Db\Adapter\MysqlAdapter
;
4
use
Phinx\Migration\AbstractMigration
;
5
6
class
AddAclSubtype
extends
AbstractMigration {
28
public
function
change
() {
29
$table
= $this->table(
'access_collections'
);
30
$prefix = $this->getAdapter()->getOption(
'table_prefix'
);
31
32
if
(!
$table
->hasColumn(
'subtype'
)) {
33
$table
->addColumn(
'subtype'
,
'string'
, [
34
'null'
=>
true
,
35
'limit'
=> MysqlAdapter::TEXT_SMALL,
36
]);
37
38
$table
->save();
39
}
40
41
// add friends collection subtype to user owned acls
42
// this was the assumed usage of user owned acls
43
$this->query(
"
44
UPDATE {$prefix}{$table->getName()} acl
45
INNER JOIN {$prefix}entities e ON acl.owner_guid = e.guid
46
SET acl.subtype = 'friends_collection'
47
WHERE e.type = 'user'
48
"
);
49
50
// add group_acl subtype to group owned acls as tracked in group_acl metadata
51
$this->query(
"
52
UPDATE {$prefix}{$table->getName()} acl
53
INNER JOIN {$prefix}metadata md ON acl.owner_guid = md.entity_guid
54
INNER JOIN {$prefix}entities e ON md.entity_guid = e.guid
55
SET acl.subtype = 'group_acl'
56
WHERE md.name = 'group_acl'
57
AND md.value = acl.id
58
AND e.type = 'group'
59
"
);
60
61
// remove the migrated group_acl metadata
62
$this->query(
"
63
DELETE md FROM {$prefix}metadata md
64
INNER JOIN {$prefix}entities e ON md.entity_guid = e.guid
65
INNER JOIN {$prefix}{$table->getName()} acl ON md.value = acl.id
66
WHERE md.name = 'group_acl'
67
AND e.type = 'group'
68
"
);
69
}
70
}
MysqlAdapter
AddAclSubtype\change
change()
Change Method.
Definition:
20171106100916_add_acl_subtype.php:28
AddAclSubtype
Definition:
20171106100916_add_acl_subtype.php:6
$table
$table
Definition:
user.php:37
AbstractMigration
Generated on Sat Dec 21 2024 00:02:53 for Elgg by
1.8.11