THIS MOD NOT IS SUPPORTED BY THE AUTHOR ANYMORE, BECAUSE THE WAY ITS DONE, IT HAS NO POTENTIAL FUTURE TO EXPAND.
IF U HAVEN'T INSTALL THIS MOD, PLEASE DON'T. IF VERSION 2 EVER COMES OUT, AND U INSTALLED THIS VERSION, U'LL HAVE TO REMOVE THIS VERSION PRIOR INSTALLING NEXT VERSION.
SAVE YOURSELF FROM TROUBLE AND WAIT TILL NEXT VERSION.
SORRY.NOTE:
MPC =
Members
Personal
Category
--- Overview --------
With this MOD members will be able have their own one personal (private) category, with almost full admin control.
As usual, u can see it in action
here--- Features ---------
- Members can make their category for: public, only members or private.
When category set to private, the owner can chose wich members will have access to the category.
- Control from AdminControlPanel:
Anable/disable this mod
Anable/disable activating new categories. This means that for members who previously activated their MPC, it wont affect, but who hasnt - they wont be able have MPC. (this works same as "disable new account signup").
Chose "parent" category where new MPC will be created
Chose what permissions owners of MPC will be able to change.
Disable single member MPC (u can use this to panish abusing member)[/list:u]
--- Warning ------------
If u have to use this:
http://4homepages.de/forum/viewtopic.php?t=3383This MOD probably not for u, your members wont be very hapy
--- Changed Files -----
/member.php
/details.php
/admin/settings.php
/admin/users.php
/includes/db_field_definitions.php
/lang/<yourlanguage>/main.php
/lang/<yourlanguage>/admin.php
/templates/<yourtemplate>/member_editprofile.htmlNew templates:
member_cat_edit.html
member_cat_edit_bit.html
member_cat_terms.html--- Installation ---------
Step 1.Open
/member.phpFind
if ($action == "deletecomment") {
if (!$comment_id || ($config['user_delete_comments'] != 1 && $user_info['user_level'] != ADMIN)) {
show_error_page($lang['no_permission']);
exit;
}
$sql = "SELECT c.comment_id, c.user_id AS comment_user_id, i.image_id, i.cat_id, i.user_id, i.image_name
FROM ".COMMENTS_TABLE." c, ".IMAGES_TABLE." i
WHERE c.comment_id = $comment_id AND i.image_id = c.image_id";
$comment_row = $site_db->query_firstrow($sql);
if (!$comment_row || $comment_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $comment_row['user_id'] && $user_info['user_level'] != ADMIN)) {
Replace with:
if ($action == "deletecomment") {
if (!$comment_id) {
show_error_page($lang['no_permission']);
exit;
}
$sql = "SELECT c.comment_id, c.user_id AS comment_user_id, i.image_id, i.cat_id, i.user_id, i.image_name
FROM ".COMMENTS_TABLE." c, ".IMAGES_TABLE." i
WHERE c.comment_id = $comment_id AND i.image_id = c.image_id";
$comment_row = $site_db->query_firstrow($sql);
// if (!$comment_row || $comment_row['user_id'] <= USER_AWAITING || ($config['user_delete_comments'] != 1 && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $image_row['cat_id']) || ($user_info['user_id'] != $comment_row['user_id'] && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $comment_row['cat_id']&& $user_info['user_id'] != $comment_row['comment_user_id'])) {
if (!$comment_row || $comment_row['user_id'] <= USER_AWAITING || ($config['user_delete_comments'] != 1 && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $image_row['cat_id']) || ($user_info['user_id'] != $comment_row['user_id'] && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $comment_row['cat_id'])) {
Step 1.2.Find:
if ($action == "removecomment") {
if (!$comment_id || ($config['user_delete_comments'] != 1 && $user_info['user_level'] != ADMIN)) {
header("Location: ".$site_sess->url($url, "&"));
exit;
}
$sql = "SELECT c.comment_id, c.image_id, c.user_id AS comment_user_id, c.user_name AS comment_user_name, c.comment_headline, c.comment_text, i.image_name, i.cat_id, i.user_id".get_user_table_field(", u.", "user_name")."
FROM ".COMMENTS_TABLE." c, ".IMAGES_TABLE." i
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
WHERE c.comment_id = $comment_id AND i.image_id = c.image_id";
$comment_row = $site_db->query_firstrow($sql);
if (!$comment_row || $comment_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $comment_row['user_id'] && $user_info['user_level'] != ADMIN)) {
Replace with:
if ($action == "removecomment") {
if (!$comment_id) {
header("Location: ".$site_sess->url($url, "&"));
exit;
}
$sql = "SELECT c.comment_id, c.image_id, c.user_id AS comment_user_id, c.user_name AS comment_user_name, c.comment_headline, c.comment_text, i.image_name, i.cat_id, i.user_id".get_user_table_field(", u.", "user_name")."
FROM ".COMMENTS_TABLE." c, ".IMAGES_TABLE." i
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
WHERE c.comment_id = $comment_id AND i.image_id = c.image_id";
$comment_row = $site_db->query_firstrow($sql);
// if (!$comment_row || $comment_row['user_id'] <= USER_AWAITING || ($config['user_delete_comments'] != 1 && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $image_row['cat_id']) || ($user_info['user_id'] != $comment_row['user_id'] && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $comment_row['cat_id']&& $user_info['user_id'] != $comment_row['comment_user_id'])) {
if (!$comment_row || $comment_row['user_id'] <= USER_AWAITING || ($config['user_delete_comments'] != 1 && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $image_row['cat_id']) || ($user_info['user_id'] != $comment_row['user_id'] && $user_info['user_level'] != ADMIN && $user_info['user_id'] != $comment_row['comment_user_id'])) {
Step 1.3.Find:
if ($action == "updatecomment") {
if (!$comment_id || ($config['user_edit_comments'] != 1 && $user_info['user_level'] != ADMIN)) {
show_error_page($lang['no_permission']);
exit;
}
$sql = "SELECT c.comment_id, c.image_id, i.image_name, i.cat_id, i.user_id".get_user_table_field(", u.", "user_name")."
FROM ".COMMENTS_TABLE." c, ".IMAGES_TABLE." i
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
WHERE c.comment_id = $comment_id AND i.image_id = c.image_id";
$comment_row = $site_db->query_firstrow($sql);
if (!$comment_row || $comment_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $comment_row['user_id'] && $user_info['user_level'] != ADMIN)) {
Replace with:
if ($action == "updatecomment") {
if (!$comment_id) {
show_error_page($lang['no_permission']);
exit;
}
$sql = "SELECT c.comment_id, c.image_id, c.user_id AS comment_user_id, i.image_name, i.cat_id, i.user_id".get_user_table_field(", u.", "user_name")."
FROM ".COMMENTS_TABLE." c, ".IMAGES_TABLE." i
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
WHERE c.comment_id = $comment_id AND i.image_id = c.image_id";
$comment_row = $site_db->query_firstrow($sql);
// if (!$comment_row || $comment_row['user_id'] <= USER_AWAITING || ($config['user_edit_comments'] != 1 && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $image_row['cat_id']) || ($user_info['user_id'] != $comment_row['user_id'] && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $comment_row['cat_id']&& $user_info['user_id'] != $comment_row['comment_user_id'])) {
if (!$comment_row || $comment_row['user_id'] <= USER_AWAITING || ($config['user_edit_comments'] != 1 && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $image_row['cat_id']) || ($user_info['user_id'] != $comment_row['user_id'] && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $comment_row['cat_id'])) {
Step 1.4.Find:
if ($action == "editcomment") {
if (!$comment_id || ($config['user_edit_comments'] != 1 && $user_info['user_level'] != ADMIN)) {
header("Location: ".$site_sess->url($url, "&"));
exit;
}
$sql = "SELECT c.comment_id, c.image_id, c.user_id AS comment_user_id, c.user_name AS comment_user_name, c.comment_headline, c.comment_text, i.image_name, i.cat_id, i.user_id".get_user_table_field(", u.", "user_name")."
FROM ".COMMENTS_TABLE." c, ".IMAGES_TABLE." i
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
WHERE c.comment_id = $comment_id AND i.image_id = c.image_id";
$comment_row = $site_db->query_firstrow($sql);
if (!$comment_row || $comment_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $comment_row['user_id'] && $user_info['user_level'] != ADMIN)) {
Replace with:
if ($action == "editcomment") {
if (!$comment_id) {
header("Location: ".$site_sess->url($url, "&"));
exit;
}
$sql = "SELECT c.comment_id, c.image_id, c.user_id AS comment_user_id, c.user_name AS comment_user_name, c.comment_headline, c.comment_text, i.image_name, i.cat_id, i.user_id".get_user_table_field(", u.", "user_name")."
FROM ".COMMENTS_TABLE." c, ".IMAGES_TABLE." i
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
WHERE c.comment_id = $comment_id AND i.image_id = c.image_id";
$comment_row = $site_db->query_firstrow($sql);
// if (!$comment_row || $comment_row['user_id'] <= USER_AWAITING || ($config['user_edit_comments'] != 1 && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $image_row['cat_id']) || ($user_info['user_id'] != $comment_row['user_id'] && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $comment_row['cat_id']&& $user_info['user_id'] != $comment_row['comment_user_id'])) {
if (!$comment_row || $comment_row['user_id'] <= USER_AWAITING || ($config['user_edit_comments'] != 1 && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $image_row['cat_id']) || ($user_info['user_id'] != $comment_row['user_id'] && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $comment_row['cat_id'])) {
Step 1.5.Find:
if ($action == "deleteimage") {
if (!$image_id || ($config['user_delete_image'] != 1 && $user_info['user_level'] != ADMIN)) {
show_error_page($lang['no_permission']);
exit;
}
$sql = "SELECT image_id, cat_id, user_id, image_name, image_media_file, image_thumb_file
FROM ".IMAGES_TABLE."
WHERE image_id = $image_id";
$image_row = $site_db->query_firstrow($sql);
if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $image_row['user_id'] && $user_info['user_level'] != ADMIN)) {
Replace with:
if ($action == "deleteimage") {
if (!$image_id) {
show_error_page($lang['no_permission']);
exit;
}
$sql = "SELECT image_id, cat_id, user_id, image_name, image_media_file, image_thumb_file
FROM ".IMAGES_TABLE."
WHERE image_id = $image_id";
$image_row = $site_db->query_firstrow($sql);
if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($config['user_edit_image'] != 1 && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $image_row['cat_id']) || ($user_info['user_id'] != $image_row['user_id'] && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $image_row['cat_id'])) {
Step 1.6.Find:
if ($action == "removeimage") {
if (!$image_id || ($config['user_delete_image'] != 1 && $user_info['user_level'] != ADMIN)) {
header("Location: ".$site_sess->url($url, "&"));
exit;
}
$sql = "SELECT image_id, cat_id, user_id, image_name
FROM ".IMAGES_TABLE."
WHERE image_id = $image_id";
$image_row = $site_db->query_firstrow($sql);
if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $image_row['user_id'] && $user_info['user_level'] != ADMIN)) {
Replace with:
if ($action == "removeimage") {
if (!$image_id) {
header("Location: ".$site_sess->url($url, "&"));
exit;
}
$sql = "SELECT image_id, cat_id, user_id, image_name
FROM ".IMAGES_TABLE."
WHERE image_id = $image_id";
$image_row = $site_db->query_firstrow($sql);
if (!$image_id || ($config['user_delete_image'] != 1 && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $image_row['cat_id'])) {
header("Location: ".$site_sess->url($url, "&"));
exit;
}
if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $image_row['user_id'] && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $image_row['cat_id'])) {
Step 1.7.Find:
if ($action == "updateimage") {
if (!$image_id || ($config['user_edit_image'] != 1 && $user_info['user_level'] != ADMIN)) {
show_error_page($lang['no_permission']);
}
$sql = "SELECT image_id, cat_id, user_id, image_name
FROM ".IMAGES_TABLE."
WHERE image_id = $image_id";
$image_row = $site_db->query_firstrow($sql);
if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $image_row['user_id'] && $user_info['user_level'] != ADMIN)) {
Replace with:
if ($action == "updateimage") {
if (!$image_id) {
show_error_page($lang['no_permission']);
} $sql = "SELECT image_id, cat_id, user_id, image_name
FROM ".IMAGES_TABLE."
WHERE image_id = $image_id";
$image_row = $site_db->query_firstrow($sql);
if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($config['user_edit_image'] != 1 && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $image_row['cat_id']) || ($user_info['user_id'] != $image_row['user_id'] && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $image_row['cat_id'])) {
Step 1.8.Find:
if ($action == "editimage") {
if (!$image_id || ($config['user_edit_image'] != 1 && $user_info['user_level'] != ADMIN)) {
header("Location: ".$site_sess->url($url, "&"));
exit;
}
$additional_sql = "";
if (!empty($additional_image_fields)) {
foreach ($additional_image_fields as $key => $val) {
$additional_sql .= ", ".$key;
}
}
$sql = "SELECT image_id, cat_id, user_id, image_name, image_description, image_keywords, image_allow_comments".$additional_sql."
FROM ".IMAGES_TABLE."
WHERE image_id = $image_id";
$image_row = $site_db->query_firstrow($sql);
if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $image_row['user_id'] && $user_info['user_level'] != ADMIN)) {
Replace with:
if ($action == "editimage") {
if (!$image_id) {
header("Location: ".$site_sess->url($url, "&"));
exit;
}
$additional_sql = "";
if (!empty($additional_image_fields)) {
foreach ($additional_image_fields as $key => $val) {
$additional_sql .= ", ".$key;
}
}
$sql = "SELECT image_id, cat_id, user_id, image_name, image_description, image_keywords, image_allow_comments".$additional_sql."
FROM ".IMAGES_TABLE."
WHERE image_id = $image_id";
$image_row = $site_db->query_firstrow($sql);
if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($config['user_edit_image'] != 1 && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $image_row['cat_id']) || ($user_info['user_id'] != $image_row['user_id'] && $user_info['user_level'] != ADMIN && $user_info['user_cat'] != $image_row['cat_id'])) {
Step 1.9.Find:
if (!$error) {
$additional_sql = "";
if (!empty($additional_user_fields)) {
$table_fields = $site_db->get_table_fields(USERS_TABLE);
foreach ($additional_user_fields as $key => $val) {
if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
$additional_sql .= ", $key = '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
}
}
}
$sql = "UPDATE ".USERS_TABLE."
Replace with:
if (!$error) {
$additional_sql = "";
if (!empty($additional_user_fields)) {
$table_fields = $site_db->get_table_fields(USERS_TABLE);
foreach ($additional_user_fields as $key => $val) {
if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
$additional_sql .= ", $key = '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
}
}
if (isset($HTTP_POST_VARS['user_cat_active']) && isset($table_fields['user_cat_active'])) {
user_cat_create();
}else{
$additional_sql .= ", user_cat_active = 0";
}
}
$sql = "UPDATE ".USERS_TABLE."
Step 1.10.Find:
"user_name" => htmlspecialchars(stripslashes($user_name)),
Add before (obove it):
"lang_activate" => ($config['user_cat'] && $user_info['user_cat_active_admin'] && ($config['user_cat_new'] || $user_info['user_cat'])) ? $lang['user_cat_activate'] : "",
"user_cat_edit" => ($user_info['user_cat_active']) ? $site_sess->url(ROOT_PATH."member.php?action=usercatpermedit") : "",
"lang_edit" => $lang['edit'],
Step 1.11.Find:
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].$txt_clickstream."</span>";
Add before (above it):
//-------------------------
//---- User Create Cat ----
//-------------------------
function user_cat_create(){
global $user_info, $cat_cache, $config;
if ($user_info['user_cat'] == 0 || !$cat_cache[$user_info['user_cat']]) {
if (!$cat_id = create_user_cat($user_info['user_id'], $user_info['user_name'])) {
$msg .= "Error creating category";
}
}
}
//-----------------------------
//---- User Cat Permissions----
//-----------------------------
if ($action == "usercatpermedit") {
if ((!user_cat_check() || !$user_info['user_cat_active']) && $user_info['user_level'] != ADMIN) {
show_error_page($lang['no_permission']);
exit;
}
$error = 0;
$user_cat_terms = 0;
if ($user_info['user_level'] != ADMIN && !$user_info['user_cat_active_admin']) {
$msg = $lang['user_cat_deactive_admin'];
$error = 1;
}
if ($user_info['user_level'] != ADMIN && !$user_info['user_cat_terms']) {
if (isset($HTTP_POST_VARS['user_cat_accept']) && $HTTP_POST_VARS['user_cat_accept']) {
$sql = "UPDATE ".USERS_TABLE."
SET user_cat_terms = 1
WHERE user_id = ".$user_info['user_id'];
$site_db->query($sql);
}else{
$user_cat_terms = 1;
}
}
if (!$error) {
if ($user_cat_terms) {
$site_template->register_vars(array(
"lang_user_cat_terms" => $lang['user_cat_terms'],
"lang_agreement_terms" => $lang['user_cat_terms_text'],
"lang_agree" => $lang['agree'],
"lang_agree_not" => $lang['agree_not']
));
$content .= $site_template->parse_template("member_cat_terms");
}else{
$auth_show = "";
$user_list_added = "";
$user_list_rmvd = "";
$user_list_added_count = 0;
$user_list_rmvd_count = 0;
$auth_array = get_auth_array(($user_info['user_level'] == ADMIN) ? "1,1,1,1,1,1,1,1,1" : "");
if (isset($HTTP_POST_VARS['auth']) || isset($HTTP_GET_VARS['auth'])) {
$auth_check = ($HTTP_POST_VARS['auth'] ) ? $HTTP_POST_VARS['auth'] : $HTTP_GET_VARS['auth'];
if (in_array("auth_".$auth_check, $auth_array)){
$auth_show = "auth_".$auth_check;
if (isset($HTTP_POST_VARS[$auth_check.'_1']) || isset($HTTP_GET_VARS[$auth_check.'_1'])) {
$auth_list_no = ($HTTP_POST_VARS[$auth_check.'_1'] ) ? $HTTP_POST_VARS[$auth_check.'_1'] : $HTTP_GET_VARS[$auth_check.'_1'];
foreach ($auth_list_no as $key){
if ($key != 0) {
$user_list = get_user_info($key);
$user_list_added .= $user_list['user_name']."<br />";
$user_list_added_count++;
$user_perm = user_cat_perm_cur($key);
$user_perm_cur = array();
foreach ($auth_array as $val) {
$user_perm_cur[$val] = (($val == $auth_show) ? 1 : (($user_perm[$val]) ? $user_perm[$val] : 0));
}
update_user_group($key, $admin_cat_id, $user_perm_cur);
}
}
}
if (isset($HTTP_POST_VARS[$auth_check.'_2']) || isset($HTTP_GET_VARS[$auth_check.'_2'])) {
$auth_list_yes = ($HTTP_POST_VARS[$auth_check.'_2'] ) ? $HTTP_POST_VARS[$auth_check.'_2'] : $HTTP_GET_VARS[$auth_check.'_2'];
foreach ($auth_list_yes as $key){
if ($key != 0) {
$user_list = get_user_info($key);
$user_list_rmvd .= $user_list['user_name']."<br />";
$user_list_rmvd_count++;
$user_perm = user_cat_perm_cur($key);
$user_perm_cur = array();
foreach ($auth_array as $val) {
$user_perm_cur[$val] = (($val == $auth_show) ? 0 : (($user_perm[$val]) ? $user_perm[$val] : 0));
}
update_user_group($key, $admin_cat_id, $user_perm_cur);
}
}
}
if (isset($HTTP_POST_VARS['auth_type']) || isset($HTTP_GET_VARS['auth_type'])) {
$auth_type = ($HTTP_POST_VARS['auth_type'] ) ? $HTTP_POST_VARS['auth_type'] : $HTTP_GET_VARS['auth_type'];
$auth_type = ($auth_type) ? $auth_type : 0;
if ($cat_cache[$admin_cat_id][$auth_show] != $auth_type) {
$sql = "UPDATE ".CATEGORIES_TABLE."
SET ".$auth_show." = ".$auth_type."
WHERE cat_id = ".$admin_cat_id;
$site_db->query($sql);
$cat_cache[$admin_cat_id][$auth_show] = $auth_type;
}
}
}
}
$sql = "SELECT ".get_user_table_field("", "user_id").get_user_table_field(", ", "user_level").get_user_table_field(", ", "user_name").get_user_table_field(", ", "user_email")."
FROM ".USERS_TABLE."
WHERE ".get_user_table_field("", "user_level")." > ".USER_AWAITING." AND ".get_user_table_field("", "user_id")." <> ".$user_info['user_id']." AND ".get_user_table_field("", "user_level")." != ".ADMIN."
ORDER BY ".get_user_table_field("", "user_name")." ASC";
$result = $site_db->query($sql);
$user_list = "";
while ($user_cache = $site_db->fetch_array($result)) {
$user_list .= $user_cache['user_id'].",".addslashes($user_cache['user_name']).",";
}
$auth_list = "";
$auth_edit_js = "";
foreach ($auth_array as $auth_item) {
$auth_type = "";
$auth_edit = 0;
$auth_edit_prv = 0;
$user_cat_note_warning = "";
$user_cat_help = "";
if ($auth_show == $auth_item) {
if ($cat_cache[$admin_cat_id][$auth_item] == AUTH_ACL){
$users = user_cat_perm($auth_show);
foreach ($users as $key => $val) {
$auth_list .= $key.",";
}
$auth_edit_js = 1;
$auth_edit = 1;
$user_cat_help = $lang['user_cat_help'];
}
$auth_type = "<select name=\"auth_type\">\n";
foreach ($user_cat_auth_type as $key => $val) {
$auth_type .= "<option value=\"".$key."\"";
if ($cat_cache[$admin_cat_id][$auth_item] == $key){
$auth_type .= " style=\"color: #FF5353\" selected=\"selected\"";
$auth_cur = $key;
}
$auth_type .= ">".$val."</option>\n";
}
$auth_type .= "</select> **\n";
$auth_edit_prv = 1;
if ($auth_show != "auth_viewcat" && $cat_cache[$admin_cat_id]['auth_viewcat'] == AUTH_ACL) {
$user_cat_note_warning = "<br /><br />".$lang['auth_warning'];
}
}
$site_template->register_vars(array(
"user_list_added" => $user_list_added,
"user_list_rmvd" => $user_list_rmvd,
"lang_added" => $lang['added']." (".$user_list_added_count.")",
"lang_rmvd" => $lang['removed']." (".$user_list_rmvd_count.")",
"auth_type" => $auth_type,
"auth_cur" => $user_cat_auth_type[$cat_cache[$admin_cat_id][$auth_item]],
"admin_cat" => ($user_info['user_level'] == ADMIN) ? "<input type=\"hidden\" name=\"user_id\" value=\"".$admin_cat_owner['user_id']."\" />" : "",
"usercat_auth" => $auth_check,
"usercat_auth_show" => $lang[$auth_item],
"auth_edit" => $auth_edit,
"user_cat_note" => $lang['user_cat_note'].$user_cat_note_warning,
"auth_edit_prv" => $auth_edit_prv,
"auth_edit_link" => ($auth_edit_prv) ? "" : $site_sess->url(ROOT_PATH."member.php?action=usercatpermedit&auth=".str_replace("auth_", "", $auth_item).(($user_info['user_level'] == ADMIN) ? "&user_id=".$admin_cat_owner['user_id'] : "")),
"lang_save" => $lang['save'],
"lang_edit" => $lang['edit'],
"lang_cancel" => $lang['cancel'],
"lang_not_in_list" => $lang['not_in_list'],
"lang_in_list" => $lang['in_list'],
"user_cat_help" => $user_cat_help
));
$auth_bit .= $site_template->parse_template("member_cat_edit_bit");
}
$site_template->register_vars(array(
"auth_edit_js" => $auth_edit_js,
"admin_cat_owner" => $admin_cat_owner['user_id'],
"user_cat_owner" => $admin_cat_owner['user_name'],
"user_list" => trim($user_list, ","),
"usercat_auth" => $auth_check,
"auth_list" => trim($auth_list, ","),
"auth_bit" => $auth_bit,
"lang_auth" => $lang['user_cat_for']." <a href=\"".$site_sess->url(ROOT_PATH."categories.php?cat_id=".$admin_cat_id)."\">".$admin_cat_owner['user_name']."</a>"
));
$content .= $site_template->parse_template("member_cat_edit");
}
}
$txt_clickstream = $lang['user_cat'];
}
function user_cat_perm_cur($user_id){
global $site_db, $user_info, $admin_cat_id;
$auth_array = get_auth_array();
$sql = "SELECT g.group_id, g.group_name
FROM ".GROUPS_TABLE." g, ".GROUP_MATCH_TABLE." gm
WHERE gm.user_id = $user_id AND g.group_id = gm.group_id";
$row = $site_db->query_firstrow($sql);
if (!$row) {
$row = update_single_usergroup($user_id);
}
$group_id = $row['group_id'];
$group_name = $row['group_name'];
$sql = "SELECT *
FROM ".GROUP_ACCESS_TABLE."
WHERE group_id = $group_id AND cat_id = ".$admin_cat_id;
$result = $site_db->query_firstrow($sql);
return $result;
}
function user_cat_perm($field = ""){
global $site_db, $user_info, $admin_cat_id;
$sql = "SELECT group_id
FROM ".GROUP_ACCESS_TABLE."
WHERE cat_id = ".$admin_cat_id.(($field) ? " AND $field = 1" : "");
$result = $site_db->query($sql);
$group_ids = array();
while ($row = $site_db->fetch_array($result)) {
$group_ids[] = $row['group_id'];
}
if ($group_ids){
$sql = "SELECT u.*
FROM ".GROUP_MATCH_TABLE." gm, ".USERS_TABLE." u
WHERE u.user_id = gm.user_id AND gm.group_id IN (".implode(",", $group_ids).") AND u.user_id <> ".$user_info['user_id'];
$result = $site_db->query($sql);
$users = array();
while ($row = $site_db->fetch_array($result)) {
$users[$row['user_id']] = $row;
}
return $users;
}
return array();
}
function user_cat_check(){
global $config, $user_info, $cat_cache, $HTTP_POST_VARS, $HTTP_GET_VARS, $admin_cat_id, $site_db, $admin_cat_owner;
if (!$config['user_cat'] && $user_info['user_level'] != ADMIN && $user_info['user_level'] == GUEST) {
return false;
}
if ($user_info['user_level'] == ADMIN) {
if (isset($HTTP_POST_VARS['user_id']) || isset($HTTP_GET_VARS['user_id'])) {
$admin_user_id = (intval($HTTP_POST_VARS['user_id'])) ? intval($HTTP_POST_VARS['user_id']) : intval($HTTP_GET_VARS['user_id']);
}
if (empty($admin_user_id)) {
return false;
}
}
$admin_user_id = (isset($admin_user_id)) ? $admin_user_id : $user_info['user_id'];
$sql = "SELECT user_id, user_name, user_cat
FROM ".USERS_TABLE."
WHERE user_id = ".$admin_user_id;
$result = $site_db->query_firstrow($sql);
$admin_cat_owner = array();
$admin_cat_owner['user_id'] = $result['user_id'];
$admin_cat_owner['user_name'] = $result['user_name'];
$admin_cat_id = $result['user_cat'];
if ($admin_cat_id == 0 || !$cat_cache[$admin_cat_id]) {
return false;
}
return true;
}
function create_user_cat($user_id, $cat_name){
global $site_db, $user_info, $config, $admin_cat_id, $cat_cache;
$sql = "SELECT cat_order
FROM ".CATEGORIES_TABLE."
WHERE cat_parent_id = 0
ORDER BY cat_order DESC
LIMIT 1";
$catorder = $site_db->query_firstrow($sql);
$cat_order = $catorder['cat_order'] + 10;
$sql = "INSERT INTO ".CATEGORIES_TABLE."
(cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment)
VALUES
('$cat_name', '', ".$config['user_cat_parent'].", $cat_order, 3, 3, 3, 3, 0, 3, 3, 3, 3)";
$result = $site_db->query($sql);
$cat_id = $site_db->get_insert_id();
$sql = "UPDATE ".USERS_TABLE."
SET user_cat = ".$cat_id.", user_cat_active = 1
WHERE user_id = ".$user_id;
$site_db->query($sql);
$user_info['user_cat'] = $cat_id;
$admin_cat_id = $cat_id;
$cat_cache[$cat_id] = 1;
$auth = array(
"auth_viewcat" => 1,
"auth_viewimage" => 1,
"auth_download" => 1,
"auth_upload" => 1,
"auth_vote" => 1,
"auth_sendpostcard" => 1,
"auth_readcomment" => 1,
"auth_postcomment" => 1
);
if ($result && $cat_id) {
update_user_group($user_id, $cat_id, $auth);
if (create_cat_folder(MEDIA_PATH."/".$cat_id, CHMOD_DIRS) && create_cat_folder(THUMB_PATH."/".$cat_id, CHMOD_DIRS)){
return true;
}else{
return false;
}
}else{
return false;
}
}
function update_user_group($user_id, $cat_id, $auth) {
global $site_db;
$auth_field = "";
$auth_value = "";
foreach($auth as $key => $val){
$auth_field .= $key.", ";
$auth_value .= $val.", ";
}
$auth_field = trim($auth_field, ", ");
$auth_value = trim($auth_value, ", ");
$sql = "SELECT g.group_id, g.group_name
FROM ".GROUPS_TABLE." g, ".GROUP_MATCH_TABLE." gm
WHERE gm.user_id = $user_id AND g.group_id = gm.group_id";
$row = $site_db->query_firstrow($sql);
if (!$row) {
$row = update_single_usergroup($user_id);
}
$group_id = $row['group_id'];
$group_name = $row['group_name'];
$sql = "DELETE FROM ".GROUP_ACCESS_TABLE."
WHERE cat_id = $cat_id AND group_id = $group_id";
$site_db->query($sql);
$sql = "INSERT INTO ".GROUP_ACCESS_TABLE."
(group_id, cat_id, $auth_field)
VALUES
($group_id, $cat_id, $auth_value)";
$site_db->query($sql);
}
function update_single_usergroup($user_id) {
global $site_db, $user_table_fields;
$sql = "SELECT ".get_user_table_field("", "user_name")."
FROM ".USERS_TABLE."
WHERE ".get_user_table_field("", "user_id")." = $user_id";
$row = $site_db->query_firstrow($sql);
if (!$row) {
return false;
}
else {
$group_name = $row[$user_table_fields['user_name']];
unset($row);
}
$sql = "SELECT group_id
FROM ".GROUPS_TABLE."
WHERE group_name = '".addslashes($group_name)."' AND group_type = ".GROUPTYPE_SINGLE;
$row = $site_db->query_firstrow($sql);
if (!$row) {
$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 = $row['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 array("group_id" => $group_id, "group_name" => $group_name);
}
function create_cat_folder($path, $mode) {
if (@is_dir($path)) {
@chmod($path, $mode);
return true;
}
else {
$oldumask = umask(0);
$result = mkdir($path, $mode);
umask($oldumask);
if (!@is_dir($path) || !$result) {
$result = mkdir($path, 0755);
@chmod($path, $mode);
}
return $result;
}
}
function get_auth_array($admin = ""){
global $config;
$auth_conf = explode(",", ($admin) ? $admin : $config['user_cat_auth_array']);
$auth_array = array(
"auth_viewcat",
"auth_viewimage",
"auth_download",
"auth_upload",
"auth_directupload",
"auth_vote",
"auth_sendpostcard",
"auth_readcomment",
"auth_postcomment"
);
$auth = array();
for ($i = 0; $i < count($auth_array); $i++) {
if ($auth_conf[$i]){
$auth[] = $auth_array[$i];
}
}
return $auth;
}
//---- End User Cat -----------
Done with
/member.php Step 2.Open
/details.phpFind:
$comment_user_ip = ($user_info['user_level'] == ADMIN) ? $comment_row[$i]['comment_ip'] : "";
Replace with:
$comment_user_ip = ($user_info['user_level'] == ADMIN || $user_info['user_cat'] == $cat_id) ? $comment_row[$i]['comment_ip'] : "";
Step 2.2.Find:
elseif ($is_image_owner) {
$admin_links .= ($config['user_edit_comments'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=editcomment&".URL_COMMENT_ID."=".$comment_row[$i]['comment_id'])."\">".$lang['edit']."</a> ";
$admin_links .= ($config['user_delete_comments'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=removecomment&".URL_COMMENT_ID."=".$comment_row[$i]['comment_id'])."\">".$lang['delete']."</a>";
Replace with:
// elseif ($is_image_owner || $comment_user_id == $user_info['user_id'] && $user_info['user_level'] != GUEST || $user_info['user_cat'] == $cat_id) {
elseif ($is_image_owner || $user_info['user_cat'] == $cat_id) {
$admin_links .= ($config['user_edit_comments'] != 1 && $user_info['user_cat'] != $cat_id) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=editcomment&".URL_COMMENT_ID."=".$comment_row[$i]['comment_id'])."\">".$lang['edit']."</a> ";
$admin_links .= ($config['user_delete_comments'] != 1 && $user_info['user_cat'] != $cat_id) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=removecomment&".URL_COMMENT_ID."=".$comment_row[$i]['comment_id'])."\">".$lang['delete']."</a>";
Step 2.3.Find:
elseif ($is_image_owner) {
$admin_links .= ($config['user_edit_image'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=editimage&".URL_IMAGE_ID."=".$image_id)."\">".$lang['edit']."</a> ";
$admin_links .= ($config['user_delete_image'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=removeimage&".URL_IMAGE_ID."=".$image_id)."\">".$lang['delete']."</a>";
Replace with:
elseif ($is_image_owner || $user_info['user_cat'] == $cat_id) {
$admin_links .= ($config['user_edit_image'] != 1 && $user_info['user_cat'] != $cat_id) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=editimage&".URL_IMAGE_ID."=".$image_id)."\">".$lang['edit']."</a> ";
$admin_links .= ($config['user_delete_image'] != 1 && $user_info['user_cat'] != $cat_id) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=removeimage&".URL_IMAGE_ID."=".$image_id)."\">".$lang['delete']."</a>";
Done with
/details.phpStep 3.Open
/admin/settings.phpFind:
// end of functions
show_admin_header();
if ($action == "updatesettings") {
$setting_item = $HTTP_POST_VARS['setting_item'];
Replace with:
function show_categories_list($setting_name, $value_option = ""){
global $cat_parent_cache, $drop_down_cat_cache, $lang, $config;
$category = "\n<select name=\"setting_item[".$setting_name."]\" class=\"categoryselect\">\n";
$category .= "<option value=\"0\">".$lang['main_category']."</option>\n";
$category .= "<option value=\"0\">--------------</option>\n";
$drop_down_cat_cache = array();
$drop_down_cat_cache = $cat_parent_cache;
$category .= get_category_dropdown_bits($value_option);
$category .= "</select>\n";
echo $category;
}
function show_user_cat_perm_array($setting_name, $setting_value) {
global $config, $lang, $auth_array;
$auth_conf = explode(",", $config['user_cat_auth_array']);
$auth = array();
for ($i = 0; $i < count($auth_array); $i++) {
echo "<input type=\"checkbox\" name=\"user_cat_".$auth_array[$i]."\" value=\"1\"".(($auth_conf[$i]) ? " checked=\"checked\"" : "").">".$lang[$auth_array[$i]]."<br>\n";
}
return $auth;
}
// end of functions
show_admin_header();
if ($action == "updatesettings") {
$setting_item = $HTTP_POST_VARS['setting_item'];
$setting_item['user_cat_auth_array'] = "";
foreach ($auth_array as $key) {
$setting_item['user_cat_auth_array'] .= (($HTTP_POST_VARS['user_cat_'.$key]) ? 1 : 0).",";
}
$setting_item['user_cat_auth_array'] = trim($setting_item['user_cat_auth_array'], ",");
Step 3.2.Find:
show_form_footer($lang['save_changes'], "", 2);
Add before (above it):
show_table_separator($setting_group[10], 2, "#setting_group_10");
show_setting_row("user_cat", "radio");
show_setting_row("user_cat_new", "radio");
show_setting_row("user_cat_parent", "show_categories_list");
show_setting_row("user_cat_auth_array", "show_user_cat_perm_array");
NOTE: change
$setting_group[10], 2, "#setting_group_10" to whatever number is goin next, just scroll little bit up to find it out. REMEMBER THE NUMBER YOU ADDED, YOU WILL NEED IT IN
Step 7.Done with
/admin/settings.phpStep 4.Open
/admin/users.phpFind:
show_additional_fields("user", $user_row, USERS_TABLE);
Add before (above it):
$additional_user_fields['user_cat'][0] = "<a href=\"".ROOT_PATH."categories.php?cat_id=".$user_row['user_cat']."\" target=\"_blank\" />".$lang['user_cat']."</a>";
Done with
/admin/users.phpStep 5.Open
/includes/db_field_definitions.phpAt the end of the file, just before closing
?> add this:
$additional_user_fields['user_cat'] = array($lang['user_cat'], "text", 0);
$additional_user_fields['user_cat_active'] = array($lang['user_cat_active'], "radio", 0);
$additional_user_fields['user_cat_active_admin'] = array($lang['user_cat_active_admin'], "radio", 0);
$additional_user_fields['user_cat_terms'] = array($lang['user_cat_terms'], "radio", 0);
Done with
/includes/db_field_definitions.phpStep 6.Open
/lang/<yourlanguage>/main.phpAt the end of the file, just before closing
?> add this:
//----- User Cat -----
$lang['cancel'] = "Cancel";
$lang['not_in_list'] = "Dont have access";
$lang['in_list'] = "Have access";
$lang['auth_viewcat'] = "View Category";
$lang['auth_viewimage'] = "View Image";
$lang['auth_download'] = "Download";
$lang['auth_upload'] = "Upload";
$lang['auth_directupload'] = "Direct Upload";
$lang['auth_vote'] = "Vote";
$lang['auth_sendpostcard'] = "Send eCard";
$lang['auth_readcomment'] = "Read Comments";
$lang['auth_postcomment'] = "Post Comment";
$lang['added'] = "Added";
$lang['removed'] = "Removed";
$lang['user_cat'] = "Personal Category";
$lang['user_cat_for'] = "Personal Category Permissions for";
$lang['user_cat_active'] = "Activate Personal Category";
$lang['user_cat_active_admin'] = "Permit Personal Category";
$lang['user_cat_terms'] = "Members Personal Category Terms and Conditions";
$lang['permis'] = "Permissions";
$lang['user_cat_note'] = "** <b>All</b> - Everyone including guests (public).<br /><b> Registered Users</b> - guests not allowed.<br /><b> Private</b> - only selected members will have access.";
$lang['auth_warning'] = "NOTE: This will affect only selected in "".$lang['auth_viewcat']."" members.";
$lang['user_cat_help'] = "* Select from <b>left</b> side members who you want <b>add</b> to access list<br /> and from <b>right</b> side to <b>delete</b> members from access list.";
$lang['user_cat_terms_text'] = "Blah Blah Blah<br />Just accept it.";
$lang['user_cat_terms_must'] = "You must accept terms and conditions";
$lang['user_cat_activate_not'] = "Your ".$lang['user_cat']." is not activated";
$lang['user_cat_activate'] = "Activate";
$lang['user_cat_deactive_admin'] = "Your ".$lang['user_cat']." was terminated by administrator";
$user_cat_auth_type = array(
AUTH_ALL => "All",
AUTH_USER => "Registered Users",
AUTH_ACL => "Private"
);
//--- End User Cat ---
Done with
/lang/<yourlanguage>/main.phpStep 7.Open
/lang/<yourlanguage>/admin.phpAt the end of the file, just before closing
?> add this:
/*-- Setting-Group 10 --*/
$setting_group[10]="Member Personal Category";
$setting['user_cat'] = "Activate Member Personal Category";
$setting['user_cat_new'] = "Allow Create New Member Personal Categories";
$setting['user_cat_parent'] = "Parent Category";
$setting['user_cat_auth_array'] = "Allowed Change Permissions";
$auth_array = array(
"auth_viewcat",
"auth_viewimage",
"auth_download",
"auth_upload",
"auth_directupload",
"auth_vote",
"auth_sendpostcard",
"auth_readcomment",
"auth_postcomment"
);
NOTE: change
$setting_group[10] to whatever u changed in
Step 3.2.Done with
/lang/<yourlanguage>/admin.phpStep 8.Open
/templates/<yourtemplate>/member_editprofile.htmlAdd this:
{if lang_activate}
<tr>
<td colspan="2" valign="top" class="head1">{lang_user_cat} <sup class="new">{lang_new}</sup></td>
</tr>
<tr>
<td class="row1" colspan="2">
<input type="checkbox" name="user_cat_active" value="1"{user_cat_active_yes} /><b> {lang_activate}</b>
</td>
</tr>
{if user_cat_edit}
<tr>
<td class="row1" colspan="2">
<a href="{user_cat_edit}">{lang_edit}</a>
</td>
</tr>
{endif user_cat_edit}
{endif lang_activate}
Done with
/templates/<yourtemplate>/member_editprofile.htmlNext 3 steps u will need create new templates and then upload them to /templates/<yourtemplate>/ dir.Step 9.Create
member_cat_edit.html with this code:
{if auth_edit_js}
<script language="JavaScript">
var user_list="{user_list}";
var list=user_list.split(",");
var user_list = new Array();
var user_list_id = new Array();
var ii=0;
for (var i=0; i < (list.length/2); i++){
user_list[i] = list[ii+1];
user_list_id[i] = list[ii];
ii=ii+2;
}
var list = "{auth_list}";
var name = "{usercat_auth}";
var list = list.split(",");
var owner = {admin_cat_owner};
var owner_mark = "";
function print_list(type){
result="<select name='"+name+"_"+type+"[]' size='15' style='width:200;' multiple='multiple'>\n";
result +="<option value='0' selected='selected'></option>\n";
for (var i=0; i<user_list_id.length; i++){
if (owner == user_list_id[i]) {
owner_mark = " style='background-color: #FFCECE;'";
}else{
owner_mark = "";
}
if (type == 1){
if (!searchArray(user_list_id[i], list)) {
result +="<option value='"+user_list_id[i]+"'"+owner_mark+">» "+user_list[i]+"</option>\n";
}
}else{
if (searchArray(user_list_id[i], list)) {
result +="<option value='"+user_list_id[i]+"'"+owner_mark+"'>» "+user_list[i]+"</option>\n";
}
}
}
result +="</select>\n";
return result;
}
function searchArray(key, arr){
for (var i=0;i<arr.length;i++){
if (key==arr[i]) return true;
}
return false;
}
</script>
{endif auth_edit_js}
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="bordercolor">
<tr>
<td valign="top">
<table width="100%" border="0" cellpadding="3" cellspacing="1">
<tr>
<td valign="top" class="head1" colspan="4">{lang_auth}</td>
</tr>
{auth_bit}
</table>
</td>
</tr>
</table>