Author Topic: [MOD] Set User Rights per Category in ACP / User Rights Mod  (Read 36685 times)

0 Members and 1 Guest are viewing this topic.

Offline SoftDux

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • SoftDux - The Leaders in Software & Networking
Re: [MOD] Set User Rights per Category in ACP / User Rights Mod
« Reply #15 on: May 05, 2007, 06:03:25 PM »
ok, cool. Sorry for the dumb question, I'm looking for a gallery script for a specific project, so instead of downloading each gallery on the net + install + learn + use + run into a deadend, I'd rather look around on the forums, and see which one will work for me :)

How would I be able to tell, if a user is older than 18 years old, that he / she has access to a certain group?
Visit these Website:  SA WebHosting Talk || SoftDux

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [MOD] Set User Rights per Category in ACP / User Rights Mod
« Reply #16 on: May 05, 2007, 07:31:43 PM »
... try this ...
... [MOD] Terms and Conditions for images v1.2.1 ...
... http://www.4homepages.de/forum/index.php?topic=7113.0 ...
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline sigma.

  • Full Member
  • ***
  • Posts: 148
  • cydonian.com/potd
    • View Profile
    • sigma's gallery
Re: [MOD] Set User Rights per Category in ACP / User Rights Mod
« Reply #17 on: May 13, 2007, 12:18:32 AM »
Would it be possible to insted apply this per Image in the ACP?

Im looking for a way to add user rights per Image. Possibly with usergroups.

Offline Jan-Lukas

  • Addicted member
  • ******
  • Posts: 1.289
    • View Profile
    • Discover the New World of Kindersurprise
Re: [MOD] Set User Rights per Category in ACP / User Rights Mod
« Reply #18 on: June 28, 2008, 09:21:44 PM »
Hier der Einbau für Version 1.7.6

Step 1

 :flag-de:  öffne admin/categories.php
 :flag-en: Open admin/categories.php

 :flag-de: suche nach  :flag-en: search for

 
Code: [Select]
AUTH_ADMIN => $lang['userlevel_admin']
);

 :flag-de: füge darunter ein  :flag-en: insert below

Code: [Select]
####################### User Rights per Cat MOD Start #######################

function update_single_usergroup($user_id, $user_name) {
    global $site_db, $user_table_fields;

    $group_name = $user_name;

    $sql = "SELECT group_id
            FROM ".GROUPS_TABLE."
            WHERE group_name = '".addslashes($group_name)."' AND group_type = ".GROUPTYPE_SINGLE;
    $row2 = $site_db->query_firstrow($sql);
    if (!$row2) {
        $sql = "INSERT INTO ".GROUPS_TABLE."
                (group_name, group_type)
                VALUES
                ('".addslashes($group_name)."', ".GROUPTYPE_SINGLE.")";
        $site_db->query($sql);
        $group_id = $site_db->get_insert_id();
  }
  else {
        $group_id = $row2['group_id'];
  }
  $sql = "SELECT group_id
          FROM ".GROUP_MATCH_TABLE."
          WHERE group_id = $group_id AND user_id = $user_id";
  if ($site_db->is_empty($sql)) {
    $sql = "INSERT INTO ".GROUP_MATCH_TABLE."
            (group_id, user_id, groupmatch_startdate, groupmatch_enddate)
            VALUES
            ($group_id, $user_id, 0, 0)";
    $site_db->query($sql);
  }
  return $group_id;
}

function show_access_select2($title = "", $type, $status) {
  global $access_array, $HTTP_POST_VARS, $site_db, $cat_id, $user_table_fields, $lang;
  if (isset($HTTP_POST_VARS[$type])) {
    $status = $HTTP_POST_VARS[$type];
  }
  echo "<tr class=\"".get_row_bg()."\" valign=\"top\">\n<td><p class=\"rowtitle\">".$title."</p></td>\n";
  echo "<td>\n<select name=\"".$type."\">\n";
  foreach ($access_array as $key => $val) {
    echo "<option value=\"".$key."\"";         //$key Nummer 0-9  Einstelloptionsmöglichkeiten
    if ($status == $key) {             // $status eingestellte Option
      echo " selected=\"selected\"";
    }
    echo ">".$val."</option>\n";      // $val = Einstelloptionsmöglichkeiten
  }
  echo "</select>";

  if ($status == AUTH_ACL)  {
     echo "<tr class=\"".get_row_bg()."\" valign=\"top\">\n<td> <div class=\"rowtitle\">".$lang['cat_user_rights']."</div> \n";
     echo $lang['cat_user_rights_users'].$title."</b></font> </td>\n";
     echo "<td>\n";
     echo "<select name=\"".$type."_rights[]\" size=5 multiple>\n";

      $sql = "SELECT ".get_user_table_field("u.", "user_id").", ".get_user_table_field("u.", "user_name").", a.cat_id, a.".$type."
              FROM ".USERS_TABLE." u
              LEFT JOIN ".GROUP_MATCH_TABLE." m ON (m.user_id = ".get_user_table_field("u.", "user_id").") AND groupmatch_startdate = '0'
              LEFT JOIN ".GROUP_ACCESS_TABLE." a ON (a.group_id = m.group_id) AND a.cat_id = ".$cat_id."
              WHERE ".get_user_table_field("u.", "user_id")." != ".GUEST."
              ORDER BY a.".$type." DESC , ".get_user_table_field("u.", "user_name")." ASC";
             
      $foo = $site_db->query($sql);
      while ($row = $site_db->fetch_array($foo)) {
            if ($row[$type] == 1) {
               //$categorie_useraccess .= ", ".$row[$user_table_fields['user_name']]." (".$row['userid'].")";   // Check Usernames
               echo "<option value=\"".$row[$user_table_fields['user_id']]."\" selected>".$row[$user_table_fields['user_name']]."</option>\n";
            }
            else echo "<option value=\"".$row[$user_table_fields['user_id']]."\">".$row[$user_table_fields['user_name']]."</option>\n";
       }
     echo "</select>";
     //echo "User: ".$categorie_useraccess;
     echo "<br>".$lang['cat_user_rights_select_tip']."</td></tr>";
   }
  echo "\n</td>\n</tr>\n";
}

####################### User Rights per Cat MOD End #######################


:flag-de: suche nach  :flag-en: search for

Code: [Select]
$sql = "UPDATE ".CATEGORIES_TABLE."
            SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment
            WHERE cat_id = $cat_id";
    $result = $site_db->query($sql);

 :flag-de: füge darunter ein  :flag-en: insert below

Code: [Select]
####################### User Rights per Cat MOD Start #######################

  $do_user_rights = (isset($HTTP_POST_VARS['do_user_rights']) && $HTTP_POST_VARS['do_user_rights']) ? 1 : 0;
  $do_user_rights_ok = 0;
  $array_merge_list = array();

  $access_field_arrays = array(1 =>'auth_viewcat','auth_viewimage','auth_download','auth_upload','auth_directupload','auth_vote','auth_sendpostcard','auth_readcomment','auth_postcomment');
    foreach ($access_field_arrays as $key => $val) {
         if (isset ($HTTP_POST_VARS[$val."_rights"])) {
             ${$val."_rights"} = $HTTP_POST_VARS[$val."_rights"];
             $array_merge_list = array_merge ($array_merge_list,${$val."_rights"});
             $do_user_rights_ok = 1;
         }
         else {
            ${$val."_rights"} = "";
         }
    }
  $array_merge_list = array_unique ($array_merge_list);
  $array_merge_user_sql = implode (",",$array_merge_list);

  if ($do_user_rights)  {

      $sql = "DELETE FROM ".GROUP_ACCESS_TABLE."
              WHERE cat_id = $cat_id";
      $site_db->query($sql);              // Delete old entries

      if ($array_merge_user_sql) {
      $sql = "SELECT ".get_user_table_field("u.",user_id).", ".get_user_table_field("u.",user_name).", g.group_id
              FROM ".USERS_TABLE." u
              LEFT JOIN ".GROUP_MATCH_TABLE." gm ON (gm.user_id = ".get_user_table_field("u.",user_id).") AND gm.groupmatch_startdate = 0
              LEFT JOIN ".GROUPS_TABLE." g ON (g.group_id = gm.group_id)
              WHERE ".get_user_table_field("u.",user_id)." IN (".$array_merge_user_sql.")
              ORDER BY ".get_user_table_field("u.",user_id)." ASC";

      $foo = $site_db->query($sql);
      while ($row = $site_db->fetch_array($foo)) {
         $user_id = $row[$user_table_fields['user_id']];
         
          if (!$row['group_id']) {
               $row['group_id'] = update_single_usergroup($user_id, $row[$user_table_fields['user_name']]);
           }
           
         $group_id = $row['group_id'];
   
         foreach ($access_field_arrays as $key => $val) {
              ${$val."_sql"} = ((${$val."_rights"})) && (in_array ("$user_id", ${$val."_rights"}) && $$val == AUTH_ACL) ? 1 : 0;
          }
         
         if (($auth_viewcat_sql || $auth_viewimage_sql || $auth_download_sql || $auth_upload_sql || $auth_directupload_sql || $auth_vote_sql || $auth_sendpostcard_sql || $auth_readcomment_sql || $auth_postcomment_sql) && $group_id) {
                 $sql = "INSERT INTO ".GROUP_ACCESS_TABLE."
                 (group_id, cat_id, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment)
                 VALUES
                 ($group_id, $cat_id, $auth_viewcat_sql, $auth_viewimage_sql, $auth_download_sql, $auth_upload_sql, $auth_directupload_sql, $auth_vote_sql, $auth_sendpostcard_sql, $auth_readcomment_sql, $auth_postcomment_sql)";
                 $site_db->query($sql);
         }
      }  // While
     }   
    }

####################### User Rights per Cat MOD End #######################

:flag-de: suche nach  :flag-en: search for

Code: [Select]
foreach ($access_field_array as $key => $val) {
    show_access_select($lang[$key], $key, $cat_row[$key]);
  }

:flag-de: ersetze mit  :flag-en: replace with

Code: [Select]
foreach ($access_field_array as $key => $val) {
    show_access_select2($lang[$key], $key, $cat_row[$key]);
  }

:flag-de: suche nach  :flag-en: search for

Code: [Select]
show_form_footer($lang['save_changes'], $lang['reset'], 2, $lang['back']);
:flag-de: füge da drüber ein  :flag-en: insert above

Code: [Select]
show_radio_row($lang['save_user_rights'],  "do_user_rights", 0);   // pre setting 1-yes / 0-no

Step 2

 :flag-de:  öffne lang/<your language>/admin.php
 :flag-en: Open lang/<your language>/admin.php

 :flag-de: suche nach  :flag-en: search for

Code: [Select]
//-----------------------------------------------------
//--- Images ------------------------------------------
//-----------------------------------------------------

:flag-de: füge da drüber ein  :flag-en: insert above

 :flag-de:
Code: [Select]
$lang['cat_user_rights'] = "Einzelrechte - User:";
$lang['save_user_rights'] = "Einstellungen speichern für Userrechte";
$lang['cat_user_rights_users'] = "Welche User dürfen: ";
$lang['cat_user_rights_select_tip'] = "(Mehrfache Markierungen sind bei vielen Browsern durch gleichzeitiges Drücken von \"Ctrl/Strg\" möglich.)";

 :flag-en:
Code: [Select]
$lang['save_user_rights'] = "Save changes of User Rights";
$lang['cat_user_rights'] = "User Rights:";
$lang['cat_user_rights_users'] = "Which Users are allowed to: ";
$lang['cat_user_rights_select_tip'] = "(To select multiple user by pushing  \"Ctrl/Strg\" )";



Danke Harald




Offline qBass17

  • Addicted member
  • ******
  • Posts: 1.800
  • I ♥ 4I
    • View Profile
Re: [MOD] Set User Rights per Category in ACP / User Rights Mod
« Reply #19 on: June 28, 2008, 11:05:37 PM »
Danke dir!!
Kann nützlich sein das Teil!

LG
Phisker

Ps.: Habs in der Liste mit aufgenommen!

Offline escbln

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: [MOD] Set User Rights per Category in ACP / User Rights Mod
« Reply #20 on: February 24, 2009, 06:14:12 PM »
Lässt sich das auch für Usergruppen modifizieren? Sonst ist es ein super MOD.

Offline escbln

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: [MOD] Set User Rights per Category in ACP / User Rights Mod
« Reply #21 on: February 27, 2009, 03:14:55 PM »
Ich habe den MOD für 1.7.6 so modifiziert, dass man Usergruppenweise die Rechte bei der Kategoriebearbeitung ändern kann.

Folgende Änderungen sind notwendig:

1. lang/deutsch/admin.php

Code: [Select]
$lang['cat_user_rights'] = "Einzelrechte - User:";
$lang['save_user_rights'] = "Einstellungen speichern für Userrechte";
$lang['cat_user_rights_users'] = "Welche User dürfen: ";
$lang['cat_user_rights_select_tip'] = "(Mehrfache Markierungen sind bei vielen Browsern durch gleichzeitiges Drücken von \"Ctrl/Strg\" möglich.)";

ersetzen durch

Code: [Select]
$lang['cat_user_rights'] = "Einzelrechte - Usergruppen:";
$lang['save_user_rights'] = "Usergruppen-Zugriffsrechte speichern";
$lang['cat_user_rights_users'] = "Welche Usergruppen dürfen: ";
$lang['cat_user_rights_select_tip'] = "(Mehrfache Markierungen sind bei vielen Browsern durch gleichzeitiges Drücken von \"Ctrl/Strg\" möglich.)";

2. admin/categories.php

Code: [Select]
####################### User Rights per Cat MOD Start #######################

function update_single_usergroup($user_id, $user_name) {
    global $site_db, $user_table_fields;

    $group_name = $user_name;

    $sql = "SELECT group_id
            FROM ".GROUPS_TABLE."
            WHERE group_name = '".addslashes($group_name)."' AND group_type = ".GROUPTYPE_SINGLE;
    $row2 = $site_db->query_firstrow($sql);
    if (!$row2) {
        $sql = "INSERT INTO ".GROUPS_TABLE."
                (group_name, group_type)
                VALUES
                ('".addslashes($group_name)."', ".GROUPTYPE_SINGLE.")";
        $site_db->query($sql);
        $group_id = $site_db->get_insert_id();
  }
  else {
        $group_id = $row2['group_id'];
  }
  $sql = "SELECT group_id
          FROM ".GROUP_MATCH_TABLE."
          WHERE group_id = $group_id AND user_id = $user_id";
  if ($site_db->is_empty($sql)) {
    $sql = "INSERT INTO ".GROUP_MATCH_TABLE."
            (group_id, user_id, groupmatch_startdate, groupmatch_enddate)
            VALUES
            ($group_id, $user_id, 0, 0)";
    $site_db->query($sql);
  }
  return $group_id;
}

function show_access_select2($title = "", $type, $status) {
  global $access_array, $HTTP_POST_VARS, $site_db, $cat_id, $user_table_fields, $lang;
  if (isset($HTTP_POST_VARS[$type])) {
    $status = $HTTP_POST_VARS[$type];
  }
  echo "<tr class=\"".get_row_bg()."\" valign=\"top\">\n<td><p class=\"rowtitle\">".$title."</p></td>\n";
  echo "<td>\n<select name=\"".$type."\">\n";
  foreach ($access_array as $key => $val) {
    echo "<option value=\"".$key."\"";         //$key Nummer 0-9  Einstelloptionsmöglichkeiten
    if ($status == $key) {             // $status eingestellte Option
      echo " selected=\"selected\"";
    }
    echo ">".$val."</option>\n";      // $val = Einstelloptionsmöglichkeiten
  }
  echo "</select>";

  if ($status == AUTH_ACL)  {
     echo "<tr class=\"".get_row_bg()."\" valign=\"top\">\n<td> <div class=\"rowtitle\">".$lang['cat_user_rights']."</div> \n";
     echo $lang['cat_user_rights_users'].$title."</b></font> </td>\n";
     echo "<td>\n";
     echo "<select name=\"".$type."_rights[]\" size=5 multiple>\n";

      $sql = "SELECT ".get_user_table_field("u.", "user_id").", ".get_user_table_field("u.", "user_name").", a.cat_id, a.".$type."
              FROM ".USERS_TABLE." u
              LEFT JOIN ".GROUP_MATCH_TABLE." m ON (m.user_id = ".get_user_table_field("u.", "user_id").") AND groupmatch_startdate = '0'
              LEFT JOIN ".GROUP_ACCESS_TABLE." a ON (a.group_id = m.group_id) AND a.cat_id = ".$cat_id."
              WHERE ".get_user_table_field("u.", "user_id")." != ".GUEST."
              ORDER BY a.".$type." DESC , ".get_user_table_field("u.", "user_name")." ASC";
             
      $foo = $site_db->query($sql);
      while ($row = $site_db->fetch_array($foo)) {
            if ($row[$type] == 1) {
               //$categorie_useraccess .= ", ".$row[$user_table_fields['user_name']]." (".$row['userid'].")";   // Check Usernames
               echo "<option value=\"".$row[$user_table_fields['user_id']]."\" selected>".$row[$user_table_fields['user_name']]."</option>\n";
            }
            else echo "<option value=\"".$row[$user_table_fields['user_id']]."\">".$row[$user_table_fields['user_name']]."</option>\n";
       }
     echo "</select>";
     //echo "User: ".$categorie_useraccess;
     echo "<br>".$lang['cat_user_rights_select_tip']."</td></tr>";
   }
  echo "\n</td>\n</tr>\n";
}

####################### User Rights per Cat MOD End #######################

ersetzen durch

Code: [Select]
####################### User Rights per Cat MOD Start #######################

function update_single_usergroup($user_id, $user_name) {
    global $site_db, $user_table_fields;

    $group_name = $user_name;

    $sql = "SELECT group_id
            FROM ".GROUPS_TABLE."
            WHERE group_name = '".addslashes($group_name)."' AND group_type = ".GROUPTYPE_SINGLE;
    $row2 = $site_db->query_firstrow($sql);
    if (!$row2) {
        $sql = "INSERT INTO ".GROUPS_TABLE."
                (group_name, group_type)
                VALUES
                ('".addslashes($group_name)."', ".GROUPTYPE_SINGLE.")";
        $site_db->query($sql);
        $group_id = $site_db->get_insert_id();
  }
  else {
        $group_id = $row2['group_id'];
  }
  $sql = "SELECT group_id
          FROM ".GROUP_MATCH_TABLE."
          WHERE group_id = $group_id AND user_id = $user_id";
  if ($site_db->is_empty($sql)) {
    $sql = "INSERT INTO ".GROUP_MATCH_TABLE."
            (group_id, user_id, groupmatch_startdate, groupmatch_enddate)
            VALUES
            ($group_id, $user_id, 0, 0)";
    $site_db->query($sql);
  }
  return $group_id;
}

function show_access_select2($title = "", $type, $status) {
  global $access_array, $HTTP_POST_VARS, $site_db, $cat_id, $user_table_fields, $lang;
  if (isset($HTTP_POST_VARS[$type])) {
    $status = $HTTP_POST_VARS[$type];
  }
  echo "<tr class=\"".get_row_bg()."\" valign=\"top\">\n<td><p class=\"rowtitle\">".$title."</p></td>\n";
  echo "<td>\n<select name=\"".$type."\">\n";
  foreach ($access_array as $key => $val) {
    echo "<option value=\"".$key."\"";         //$key Nummer 0-9  Einstelloptionsmöglichkeiten
    if ($status == $key) {             // $status eingestellte Option
      echo " selected=\"selected\"";
    }
    echo ">".$val."</option>\n";      // $val = Einstelloptionsmöglichkeiten
  }
  echo "</select>";

  if ($status == AUTH_ACL)  {
     echo "<tr class=\"".get_row_bg()."\" valign=\"top\">\n<td> <div class=\"rowtitle\">".$lang['cat_user_rights']."</div> \n";
     echo $lang['cat_user_rights_users'].$title."</b></font> </td>\n";
     echo "<td>\n";
     echo "<select name=\"".$type."_rights[]\" size=3 multiple>\n";

      $sql = "SELECT u.group_id, u.group_name, a.cat_id, a.".$type."
              FROM 4images_groups u
  LEFT JOIN 4images_groupaccess a ON (a.group_id = u.group_id) AND a.cat_id = ".$cat_id."
              WHERE u.group_type = '1'
              ORDER BY u.group_name ASC";

      $foo = $site_db->query($sql);

     while ($row = $site_db->fetch_array($foo)) {
echo $row['group_name'];
            if ($row[$type] == 1) {
               //$categorie_useraccess .= ", ".$row[$user_table_fields['user_name']]." (".$row['userid'].")";   // Check Usernames
               echo "<option value=\"".$row['group_id']."\" selected>".$row['group_name']."</option>\n";
            }
            else echo "<option value=\"".$row['group_id']."\">".$row['group_name']."</option>\n";
       }
 
     echo "</select>";
     //echo "User: ".$categorie_useraccess;
     echo "<br>".$lang['cat_user_rights_select_tip']."</td></tr>";
   }
  echo "\n</td>\n</tr>\n";
}

####################### User Rights per Cat MOD End #######################

und

Code: [Select]
####################### User Rights per Cat MOD Start #######################

  $do_user_rights = (isset($HTTP_POST_VARS['do_user_rights']) && $HTTP_POST_VARS['do_user_rights']) ? 1 : 0;
  $do_user_rights_ok = 0;
  $array_merge_list = array();

  $access_field_arrays = array(1 =>'auth_viewcat','auth_viewimage','auth_download','auth_upload','auth_directupload','auth_vote','auth_sendpostcard','auth_readcomment','auth_postcomment');
    foreach ($access_field_arrays as $key => $val) {
         if (isset ($HTTP_POST_VARS[$val."_rights"])) {
             ${$val."_rights"} = $HTTP_POST_VARS[$val."_rights"];
             $array_merge_list = array_merge ($array_merge_list,${$val."_rights"});
             $do_user_rights_ok = 1;
         }
         else {
            ${$val."_rights"} = "";
         }
    }
  $array_merge_list = array_unique ($array_merge_list);
  $array_merge_user_sql = implode (",",$array_merge_list);

  if ($do_user_rights)  {

      $sql = "DELETE FROM ".GROUP_ACCESS_TABLE."
              WHERE cat_id = $cat_id";
      $site_db->query($sql);              // Delete old entries

      if ($array_merge_user_sql) {
      $sql = "SELECT ".get_user_table_field("u.",user_id).", ".get_user_table_field("u.",user_name).", g.group_id
              FROM ".USERS_TABLE." u
              LEFT JOIN ".GROUP_MATCH_TABLE." gm ON (gm.user_id = ".get_user_table_field("u.",user_id).") AND gm.groupmatch_startdate = 0
              LEFT JOIN ".GROUPS_TABLE." g ON (g.group_id = gm.group_id)
              WHERE ".get_user_table_field("u.",user_id)." IN (".$array_merge_user_sql.")
              ORDER BY ".get_user_table_field("u.",user_id)." ASC";

      $foo = $site_db->query($sql);
      while ($row = $site_db->fetch_array($foo)) {
         $user_id = $row[$user_table_fields['user_id']];
         
          if (!$row['group_id']) {
               $row['group_id'] = update_single_usergroup($user_id, $row[$user_table_fields['user_name']]);
           }
           
         $group_id = $row['group_id'];
   
         foreach ($access_field_arrays as $key => $val) {
              ${$val."_sql"} = ((${$val."_rights"})) && (in_array ("$user_id", ${$val."_rights"}) && $$val == AUTH_ACL) ? 1 : 0;
          }
         
         if (($auth_viewcat_sql || $auth_viewimage_sql || $auth_download_sql || $auth_upload_sql || $auth_directupload_sql || $auth_vote_sql || $auth_sendpostcard_sql || $auth_readcomment_sql || $auth_postcomment_sql) && $group_id) {
                 $sql = "INSERT INTO ".GROUP_ACCESS_TABLE."
                 (group_id, cat_id, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment)
                 VALUES
                 ($group_id, $cat_id, $auth_viewcat_sql, $auth_viewimage_sql, $auth_download_sql, $auth_upload_sql, $auth_directupload_sql, $auth_vote_sql, $auth_sendpostcard_sql, $auth_readcomment_sql, $auth_postcomment_sql)";
                 $site_db->query($sql);
         }
      }  // While
     }   
    }

####################### User Rights per Cat MOD End #######################

ersetzen durch

Code: [Select]
####################### User Rights per Cat MOD Start #######################

  $do_user_rights = (isset($HTTP_POST_VARS['do_user_rights']) && $HTTP_POST_VARS['do_user_rights']) ? 1 : 0;
  $do_user_rights_ok = 0;
  $array_merge_list = array();

  $access_field_arrays = array(1 =>'auth_viewcat','auth_viewimage','auth_download','auth_upload','auth_directupload','auth_vote','auth_sendpostcard','auth_readcomment','auth_postcomment');
    foreach ($access_field_arrays as $key => $val) {
         if (isset ($HTTP_POST_VARS[$val."_rights"])) {
             ${$val."_rights"} = $HTTP_POST_VARS[$val."_rights"];
             $array_merge_list = array_merge ($array_merge_list,${$val."_rights"});
             $do_user_rights_ok = 1;
         }
         else {
            ${$val."_rights"} = "";
         }
    }
  $array_merge_list = array_unique ($array_merge_list);
  $array_merge_user_sql = implode (",",$array_merge_list);

  if ($do_user_rights)  {

      $sql = "DELETE FROM ".GROUP_ACCESS_TABLE."
              WHERE cat_id = $cat_id";
      $site_db->query($sql);              // Delete old entries

      if ($array_merge_user_sql) {

      $sql = "SELECT u.group_id, u.group_name, a.cat_id
              FROM 4images_groups u
  LEFT JOIN 4images_groupaccess a ON (a.group_id = u.group_id) AND a.cat_id = ".$cat_id."
              WHERE u.group_type = '1'
              ORDER BY u.group_name ASC";

      $foo = $site_db->query($sql);
      while ($row = $site_db->fetch_array($foo)) {

         $group_id = $row['group_id'];

//          if (!$row['group_id']) {
//               $row['group_id'] = update_single_usergroup($user_id, $row[$user_table_fields['user_name']]);
//           }
           
         foreach ($access_field_arrays as $key => $val) {
              ${$val."_sql"} = ((${$val."_rights"})) && (in_array ("$group_id", ${$val."_rights"}) && $$val == AUTH_ACL) ? 1 : 0;
          }
         
         if (($auth_viewcat_sql || $auth_viewimage_sql || $auth_download_sql || $auth_upload_sql || $auth_directupload_sql || $auth_vote_sql || $auth_sendpostcard_sql || $auth_readcomment_sql || $auth_postcomment_sql) && $group_id) {
                 $sql = "INSERT INTO ".GROUP_ACCESS_TABLE."
                 (group_id, cat_id, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment)
                 VALUES
                 ($group_id, $cat_id, $auth_viewcat_sql, $auth_viewimage_sql, $auth_download_sql, $auth_upload_sql, $auth_directupload_sql, $auth_vote_sql, $auth_sendpostcard_sql, $auth_readcomment_sql, $auth_postcomment_sql)";
                 $site_db->query($sql);
         }
      }  // While
     }   
    }

####################### User Rights per Cat MOD End #######################

Viel Spass damit,

Erik

Offline henary

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: [MOD] Set User Rights per Category in ACP / User Rights Mod
« Reply #22 on: December 14, 2010, 04:23:14 PM »
Hallo,

der ursprüngliche MOD wie auch die Änderung auf Usergruppen laufen beide unter 1.7.9 - danke für dieses feine MOD.

Bis später,
Henry

 

Post your comments here