News:

Please note these forums are mostly a testing ground for my SMF work and I don't really use them otherwise.

Main Menu

Paste-1183348656:v:use_geshi-1:v:type-php

Started by SleePy, Jul 02, 2007, 03:57 AM

Previous topic - Next topic

0 Members and 4 Guests are viewing this topic.

SleePy

function CanDo($smf_groups, $todo_groups, $permission)
{
   global $user_info, $tSettings;

   if(is_array($smf_groups))
      $TheSMFunc = 'array_intersect';
   else
      $TheSMFunc = 'in_array';

   if(!is_array($todo_groups))
      $todo_groups = array($todo_groups);

   if($TheSMFunc($smf_groups, $user_info['groups']))
   {
      if($TheSMFunc == 'array_intersect')
      {
         foreach($smf_groups as $smf_group)
         {
            $tgroup = $tSettings['permissions'][$smf_group];

            foreach($todo_groups as $thegroup)
            {
               if($thegroup == $tgroup)
               {
                  foreach($tSettings['moderation'][$permission] as $tperm)
                  {
                     if($tperm == $tgroup)
                        return true;
                  }
               }
            }
         }
      }
      else
      {
         $tgroup = $tSettings['permissions'][$smf_groups];

         foreach($todo_groups as $thegroup)
         {
            if($thegroup == $tgroup)
            {
               foreach($tSettings['moderation'][$permission] as $tperm)
               {
                  if($tperm == $tgroup)
                     return true;
               }
            }
         }
      }
   }

   return false;
}
No siggy! :D

SleePy

function CanDo($smf_groups, $todo_groups, $permission)
{
   global $user_info, $tSettings;

   if(!is_array($smf_groups))
      $smf_groups = array($smf_groups);

   if(!is_array($todo_groups))
      $todo_groups = array($todo_groups);

   if(array_intersect($smf_groups, $user_info['groups']))
   {
      foreach($smf_groups as $smf_group)
      {
         $tgroup = $tSettings['permissions'][$smf_group];
         foreach($todo_groups as $thegroup)
         {
            if($thegroup == $tgroup)
            {
               foreach($tSettings['moderation'][$permission] as $tperm)
               {
                  if($tperm == $tgroup)
                     return true;
               }
            }
         }
      }
   }

   return false;
}
No siggy! :D

SleePy

function CanDo($permission, $creater = false)
{
   global $user_info, $tSettings;

   if($creater && $creater == $user_info['id'])
   {
      if($tSettings['moderate_own'][0] == 'all' || in_array($permission, $tSettings['moderate_own']))
         return true;
   }

   $todo_groups = $tSettings['moderation'][$permission];

   $smf_groups = array();
   foreach($todo_groups as $grp)
   {
      if(isset($tSettings['groups'][$grp]))
         $smf_groups[] = $tSettings['groups'][$grp];
   }

   if(array_intersect($smf_groups, $user_info['groups']))
   {
      foreach($smf_groups as $smf_group)
      {
         $tgroup = $tSettings['groups'][$smf_group];
         foreach($todo_groups as $thegroup)
         {
            if($thegroup == $tgroup)
            {
               foreach($tSettings['moderation'][$permission] as $tperm)
               {
                  if($tperm == $tgroup)
                     return true;
               }
            }
         }
      }
   }

   return false;
}
No siggy! :D