Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update to the installer based on initial feedback. Ticket #1273.

  • Loading branch information...
commit 75b639c9983caed77d6fc190d779da5ab908b9ad 1 parent aaa1fd3
@talmdal talmdal authored
View
30 modules/gallery/helpers/access.php
@@ -346,36 +346,6 @@ static function delete_permission($name) {
}
/**
- * Copy permission values (used for core version 50 upgrade).
- * It is a public method, but it is really internal hence the leading underscore in the name.
- * Not part of the API.
- *
- * @param string $from_perm_name
- * @param array $array of permission names to copy
- * @return void
- */
- static function _copy_permissions($from_perm_name, $to_perm_names) {
- self::_copy_permission_columns($from_perm_name, $to_perm_names, ORM::factory("access_intent")->find_all());
-
- self::_copy_permission_columns($from_perm_name, $to_perm_names, ORM::factory("access_cache")->find_all());
- }
-
- private static function _copy_permission_columns($from_perm_name, $to_perm_names, $query) {
- $groups = self::_get_all_groups();
- foreach ($query as $row) {
- foreach ($groups as $group) {
- $from_column = "{$from_perm_name}_{$group->id}";
-
- foreach ($to_perm_names as $to_perm_name) {
- $to_column = "{$to_perm_name}_{$group->id}";
- $row->$to_column = $row->$from_column;
- }
- $row->save();
- }
- }
- }
-
- /**
* Add the appropriate columns for a new group
*
* @param Group_Model $group
View
53 modules/gallery/helpers/gallery_installer.php
@@ -221,21 +221,21 @@ static function install() {
access::register_permission("view", "View");
access::register_permission("view_full", "View full size");
access::register_permission("edit", "Edit");
- access::register_permission("edit_all_photos", "Edit All Photos");
- access::register_permission("edit_my_photos", "Edit My Photos");
+ access::register_permission("edit_all_photos", "Edit all photos");
+ access::register_permission("edit_my_photos", "Edit my photos");
- access::register_permission("add_album", "Add Album");
- access::register_permission("add_photo", "Add Photo");
+ access::register_permission("add_album", "Add album");
+ access::register_permission("add_photo", "Add photo");
// Mark for translation (must be the same strings as used above)
t("View full size");
t("View");
t("Edit");
- t("Edit All Photos");
- t("Edit My Photos");
+ t("Edit all photos");
+ t("Edit my photos");
- t("Add Album");
- t("Add Photo");
+ t("Add album");
+ t("Add photo");
// Hardcode the first item to sidestep ORM validation rules
$now = time();
@@ -702,18 +702,45 @@ static function upgrade($version) {
}
if ($version == 49) {
- access::register_permission("edit_all", "Edit All Photos");
- access::register_permission("edit_my_photos", "Edit My Photos");
+ access::register_permission("edit_all", "Edit all photos");
+ access::register_permission("edit_my_photos", "Edit my photos");
- access::register_permission("add_album", "Add Album");
- access::register_permission("add_photo", "Add Photo");
+ access::register_permission("add_album", "Add album");
+ access::register_permission("add_photo", "Add photo");
- access::_copy_permissions("add", array("add_album", "add_photo"));
+ self::_copy_permissions("add", array("add_album", "add_photo"), "access_intent");
+ self::_copy_permissions("add", array("add_album", "add_photo"), "access_cache");
access::delete_permission("add");
module::set_version("gallery", $version = 50);
}
}
+ private static function _copy_permissions($from_perm_name, $to_perm_names, $table) {
+ $query = ORM::factory($table)->find_all();
+ $groups = self::_get_all_groups();
+ foreach ($query as $row) {
+ foreach ($groups as $group) {
+ $from_column = "{$from_perm_name}_{$group->id}";
+
+ foreach ($to_perm_names as $to_perm_name) {
+ $to_column = "{$to_perm_name}_{$group->id}";
+ $row->$to_column = $row->$from_column;
+ }
+ $row->save();
+ }
+ }
+ }
+
+ private static function _get_all_groups() {
+ // When we build the gallery package, it's possible that there is no identity provider
+ // installed yet. This is ok at packaging time, so work around it.
+ if (module::is_active(module::get_var("gallery", "identity_provider", "user"))) {
+ return identity::groups();
+ } else {
+ return array();
+ }
+ }
+
static function uninstall() {
$db = Database::instance();
$db->query("DROP TABLE IF EXISTS {access_caches}");
Please sign in to comment.
Something went wrong with that request. Please try again.