Since several people are having permission issues when setting forum permissions or setting/maintaining admin permissions with the 'Can be administrator in Gallery 2' option, I'll post the fixes here until a new release is made available.
A HUGE thanks to IngerK for helping me pursue and test the G2 admin issues! And, thanks to BigTom for pointing out the issue with forum permissions!
To apply these fixes you will have to remove the original 0.0.4 mods to these two files:
includes/functions_user.php
includes/acp/auth.php
And apply these mods instead:Code: › #
#-----[ OPEN ]------------------------------------------
#
includes/functions_user.php
#
#-----[ FIND ]------------------------------------------
#
foreach ($table_ary as $table)
{
$sql = "DELETE FROM $table
WHERE user_id = $user_id";
$db->sql_query($sql);
}
#
#-----[ AFTER, ADD ]------------------------------------------
#
// Delete user in Gallery
require($phpbb_root_path . 'g2helper.inc');
$g2h = new g2helper($db);
$g2h->deleteUser($user_id);
#
#-----[ FIND ]------------------------------------------
#
if (isset($sql_ary['group_rank']) && !$sql_ary['group_rank'])
{
remove_default_rank($group_id, $user_ary);
}
#
#-----[ AFTER, ADD ]------------------------------------------
#
// Update group in Gallery
require($phpbb_root_path . 'g2helper.inc');
$g2h = new g2helper($db);
$g2h->updateGroup($group_id, $sql_ary['group_name']);
#
#-----[ FIND ]------------------------------------------
#
$sql = 'INSERT INTO ' . GROUPS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// Create group in Gallery
require($phpbb_root_path . 'g2helper.inc');
$g2h = new g2helper($db);
$g2h->createGroup($sql_ary['group_name']);
#
#-----[ FIND ]------------------------------------------
#
// Delete group
$sql = 'DELETE FROM ' . GROUPS_TABLE . "
WHERE group_id = $group_id";
$db->sql_query($sql);
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// Delete group in Gallery
require_once($phpbb_root_path . 'g2helper.inc');
$g2h = new g2helper($db);
$g2h->deleteGroup($group_id);
#
#-----[ FIND ]------------------------------------------
#
function group_user_add($group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $default = false, $leader = 0, $pending = 0, $group_attributes = false)
{
global $db, $auth;
#
#-----[ REPLACE WITH ]------------------------------------------
#
function group_user_add($group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $default = false, $leader = 0, $pending = 0, $group_attributes = false)
{
global $db, $auth, $phpbb_root_path;
#
#-----[ FIND ]------------------------------------------
#
foreach ($add_id_ary as $user_id)
{
$sql_ary[] = array(
'user_id' => (int) $user_id,
'group_id' => (int) $group_id,
'group_leader' => (int) $leader,
'user_pending' => (int) $pending,
);
}
$db->sql_multi_insert(USER_GROUP_TABLE, $sql_ary);
#
#-----[ AFTER, ADD ]------------------------------------------
#
// Add users to group in Gallery
require($phpbb_root_path . 'g2helper.inc');
$g2h = new g2helper($db);
$g2h->addUserToGroup($add_id_ary, $group_id);
#
#-----[ FIND ]------------------------------------------
#
$db->sql_transaction('commit');
// Clear permissions cache of relevant users
$auth->acl_clear_prefetch($user_id_ary);
#
#-----[ AFTER, ADD ]------------------------------------------
#
$g2h->updateAdminPermissions($user_id_ary, 'user');
#
#-----[ FIND ]------------------------------------------
#
function group_user_del($group_id, $user_id_ary = false, $username_ary = false, $group_name = false)
{
global $db, $auth;
#
#-----[ REPLACE WITH ]------------------------------------------
#
function group_user_del($group_id, $user_id_ary = false, $username_ary = false, $group_name = false)
{
global $db, $auth, $phpbb_root_path;
#
#-----[ FIND ]------------------------------------------
#
$sql = 'DELETE FROM ' . USER_GROUP_TABLE . "
WHERE group_id = $group_id
AND " . $db->sql_in_set('user_id', $user_id_ary);
$db->sql_query($sql);
// Clear permissions cache of relevant users
$auth->acl_clear_prefetch($user_id_ary);
#
#-----[ REPLACE WITH ]------------------------------------------
#
$sql = 'DELETE FROM ' . USER_GROUP_TABLE . "
WHERE group_id = $group_id
AND " . $db->sql_in_set('user_id', $user_id_ary);
$db->sql_query($sql);
// Delete users from group in Gallery
require($phpbb_root_path . 'g2helper.inc');
$g2h = new g2helper($db);
$g2h->removeUserFromGroup($user_id_ary, $group_id);
// Clear permissions cache of relevant users
$auth->acl_clear_prefetch($user_id_ary);
$g2h->updateAdminPermissions($user_id_ary, 'user');
#
#-----[ OPEN ]------------------------------------------
#
includes/acp/auth.php
#
#-----[ FIND ]------------------------------------------
#
function acl_set($ug_type, $forum_id, $ug_id, $auth, $role_id = 0, $clear_prefetch = true)
{
global $db;
#
#-----[ REPLACE WITH ]------------------------------------------
#
function acl_set($ug_type, $forum_id, $ug_id, $auth, $role_id = 0, $clear_prefetch = true)
{
global $db, $phpbb_root_path;
#
#-----[ FIND ]------------------------------------------
#
$db->sql_multi_insert($table, $sql_ary);
if ($clear_prefetch)
{
$this->acl_clear_prefetch();
}
#
#-----[ AFTER, ADD ]------------------------------------------
#
if (empty($forum_id[0]))
{
// Update admin permissions in Gallery
require($phpbb_root_path . 'g2helper.inc');
$g2h = new g2helper($db);
$g2h->updateAdminPermissions($ug_id, $ug_type);
}
#
#-----[ FIND ]------------------------------------------
#
function acl_set_role($role_id, $auth)
{
global $db;
#
#-----[ REPLACE WITH ]------------------------------------------
#
function acl_set_role($role_id, $auth)
{
global $db, $phpbb_root_path;
#
#-----[ FIND ]------------------------------------------
#
// Now insert the new values
$db->sql_multi_insert(ACL_ROLES_DATA_TABLE, $sql_ary);
$this->acl_clear_prefetch();
#
#-----[ AFTER, ADD ]------------------------------------------
#
// Update admin permissions in Gallery
require($phpbb_root_path . 'g2helper.inc');
$g2h = new g2helper($db);
$g2h->updateAdminPermissions(array($role_id), 'role');
#
#-----[ FIND ]------------------------------------------
#
function acl_delete($mode, $ug_id = false, $forum_id = false, $permission_type = false)
{
global $db;
#
#-----[ REPLACE WITH ]------------------------------------------
#
function acl_delete($mode, $ug_id = false, $forum_id = false, $permission_type = false)
{
global $db, $phpbb_root_path;
#
#-----[ FIND ]------------------------------------------
#
$sql = "DELETE FROM $table
WHERE " . implode(' AND ', $where_sql);
$db->sql_query($sql);
$this->acl_clear_prefetch();
#
#-----[ AFTER, ADD ]------------------------------------------
#
if ($permission_type !== false && empty($forum_id))
{
// Update admin permissions in Gallery
require($phpbb_root_path . 'g2helper.inc');
$g2h = new g2helper($db);
$g2h->updateAdminPermissions($ug_id, $mode);
}
Then replace these two files:
g2helper.inc
langauge/en/acp/gallery2.php
With these new ones:
g2helper.zip [jettyfishing.com]