4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: IcEcReaM on February 16, 2006, 08:10:25 AM
-
[ Introduction ]
With this mod you can now set the user rights per Category.
For example:
If you set categorie_view in an categorie to private,
you have to set the user rights (which user are allowed to view this category) for each user,
by searching the user, what takes some time and also is uncomfortable.
With this mod now you can set the user, which are allowed to view this category,
directly in the category editing page.
German:
Mit diesem Mod könnt ihr die User Rechte direkt per Kategorie setzen.
Bisher musste man, wenn man z.B. category view auf private gesetzt hat,
die User einzeln raussuchen, und dann bei jedem User einzeln die Erlaubnis setzen.
Mit diesem Mod könnt ihr direkt in der Kategorie Bearbeitungsseite die Rechte für die User setzen.
[ Changed Files ]
admin/categories.php
lang/<your language>/admin.php
[ Installation ]
First Backup your Files
Step 1
Open admin/categories.php
search for
AUTH_ADMIN => $lang['userlevel_admin']
);
insert below
####################### 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 #######################
Search for
$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);
insert below
####################### 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 #######################
Search for
foreach ($access_field_array as $key => $val) {
show_access_select($lang[$key], $key, $result[$key]);
}
and replace with
foreach ($access_field_array as $key => $val) {
show_access_select2($lang[$key], $key, $result[$key]);
}
Search for
show_form_footer($lang['save_changes'], $lang['reset'], 2, $lang['back']);
and insert above
show_radio_row($lang['save_user_rights'], "do_user_rights", 0); // pre setting 1-yes / 0-no
Step 2
Open lang/<your language>/admin.php
Search for
//-----------------------------------------------------
//--- Images ------------------------------------------
//-----------------------------------------------------
and insert above
(choose your preferred language)
German:
$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.)";
English:
$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\" )";
Finished!
I've tested the mod on a fresh & clean 4images installation.
Note:
This options only appears if a category permission is set to private.
17.02 Fixed multlanguage support
-
wow! fantastic! thank you very much! :D
-
Great! Fantastic MOD, i try it after a cup of hours :)
-
Very nice and good idea!
I have a question though, ones you saved the category settings, it will NOT show which members were previously added...so, I guess, its not a big deal, but you can not use this form to remove specific users access permission, correct?
-
I have a question myself for this interesting MOD. Doesn't it also require additional modifications to the check_permission module ? Since it is for grouping with the add / edit users page rather than simply the cat page ? ;)
-
I don't know what you exactly mean.
This mod shows, when a category is set to private,
and already some users have the rights to view the category,
in the form as "preselected" users.
So with this one is also possible to kick out just one user,
by deselecting him, and let the others selected.
I hope that was what you asked for. :roll:
Edit:
No it doesn't need any other modfications,
cause mainly it does the same thing as you would all users step by step and setting their rights,
just a little bit comfortabler.
-
This mod shows, when a category is set to private,
and already some users have the rights to view the category,
in the form as "preselected" users.
Thanks for the info.
-
Never mind my question...the mod works great.
One little thing though, since this mod supports multi language, I guess you forgot to add multi-lang support in last item of Step 1:[qcode]show_radio_row("Save changes of User Rights", "do_user_rights", 0); // pre setting 1-yes / 0-no[/qcode]
-
In fact, this line :
show_radio_row("Save changes of User Rights", "do_user_rights", 0); // pre setting 1-yes / 0-no
could be done like this :
show_radio_row($lang['save_user_rights'], "do_user_rights", 0); // pre setting 1-yes / 0-no
Then, in your lang/english/admin.php file,
add above the '?>' tag :
$lang['save_user_rights'] = "Save changes of User Rights";
-
One little thing though, since this mod supports multi language, I guess you forgot to add multi-lang support in last item of Step
thx for the hint.
Fixed it in the first post.
Man this multilanuage support drives me crazy :mrgreen:
-
Hi, I just started to install this mod of yours but at the third replacement I found out that
foreach ($access_field_array as $key => $val) {
show_access_select($lang[$key], $key, $result[$key]);
}
cannot be found in the categories.php of admin of version 1.74 What should I do to go on. Am I stuck then? Is this compatible?
Thanks for your help :D
Frank
-
@ koolred
... search instead for ...
foreach ($access_field_array as $key => $val) {
show_access_select2($lang[$key], $key, $cat_row[$key]);
}
-
Thanks a lot Mawenzi :D I'll do that..
Frank
-
Would I be able to use this MOD to create adult related categories (for a public gallery, which requires registration), and then only allow users who has specified thei're older than 18, to view the adult related categories?
-
@SoftDux
... yes ...
... but ...
... you can also create usergroups, and give them the permission for certain categories ...
... then only you need to add the new user to the appropriate usergroup ...
... and this function is already in the standard version of 4images ...
-
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?
-
... try this ...
... [MOD] Terms and Conditions for images v1.2.1 ...
... http://www.4homepages.de/forum/index.php?topic=7113.0 ...
-
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.
-
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
AUTH_ADMIN => $lang['userlevel_admin']
);
:flag-de: füge darunter ein :flag-en: insert below
####################### 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
$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
####################### 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
foreach ($access_field_array as $key => $val) {
show_access_select($lang[$key], $key, $cat_row[$key]);
}
:flag-de: ersetze mit :flag-en: replace with
foreach ($access_field_array as $key => $val) {
show_access_select2($lang[$key], $key, $cat_row[$key]);
}
:flag-de: suche nach :flag-en: search for
show_form_footer($lang['save_changes'], $lang['reset'], 2, $lang['back']);
:flag-de: füge da drüber ein :flag-en: insert above
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
//-----------------------------------------------------
//--- Images ------------------------------------------
//-----------------------------------------------------
:flag-de: füge da drüber ein :flag-en: insert above
:flag-de:
$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:
$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 dir!!
Kann nützlich sein das Teil!
LG
Phisker
Ps.: Habs in der Liste mit aufgenommen!
-
Lässt sich das auch für Usergruppen modifizieren? Sonst ist es ein super MOD.
-
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
$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
$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
####################### 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
####################### 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
####################### 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
####################### 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
-
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