Support Forums | Demo Gallery [1.x] [2.x] | Downloads | News | Site Map ]
Nuked Gallery
  Create a FREE account or Login   As a guest, you don't have access to our FULL navigation system.
 Forum FAQForum FAQ   StatisticsStatistics   SearchSearch   UsergroupsUsergroups   FavoritesFavorites  

Permissions fix

 
Post new topic   Reply to topic    NukedGallery.net Forum Index » phpBB Integration » phpBB3 / Gallery 2 Integration View previous topicPrinter friendly versionView next topic
Author Message
jettyrat

Moderator
Moderator


Joined: Nov 28, 2005
Posts: 1139

PostPosted: Fri Dec 21, 2007 11:33 am    Post subject: Permissions fix Reply with quote

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]
Back to top
Offline View user's profile Send private message
AdBot
   Post subject: Permissions fix  

Back to top
jettyrat

Moderator
Moderator


Joined: Nov 28, 2005
Posts: 1139

PostPosted: Fri Dec 21, 2007 11:39 am    Post subject: Re: Permissions fix Reply with quote

Oh yeah, this also will fix a couple of group issues reported here [nukedgallery.net] and here [nukedgallery.net].
Back to top
Offline View user's profile Send private message
BigTom

Beginner
Beginner


Joined: Aug 27, 2007
Posts: 11

PostPosted: Fri Dec 21, 2007 3:51 pm    Post subject: Re: Permissions fix Reply with quote

Great work! Thanks a lot again, Merry Christmas and a great 2008!!

Tom
Back to top
Offline View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    NukedGallery.net Forum Index » phpBB Integration » phpBB3 / Gallery 2 Integration View previous topicPrinter friendly versionView next topic

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours

Powered by phpBB © phpBB Group



Sponsors: Web HostingDedicated ServersDomain NamesDomain Name RegistrationDedicated Web HostingSEO Search Engine OptimisationSEOWeb Design New YorkSEO Web DesignWeb hosting AustraliaCheap Web Design

6th year online! 2003-2009
Legal • Use of this site consitutes agreement to the Acceptable Use Policy
Hosted by Implosion WorksSourceForge.net Logo • Theme by TonicMedia