Author Topic: [MOD] Members Personal Category (obsolete, not supported)  (Read 140412 times)

0 Members and 1 Guest are viewing this topic.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[MOD] Members Personal Category (obsolete, not supported)
« on: April 18, 2003, 10:28:09 AM »
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=3383
This 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.html


New templates:
member_cat_edit.html
member_cat_edit_bit.html
member_cat_terms.html


--- Installation ---------

Step 1.
Open /member.php
Find
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
 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:
Code: [Select]
 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:
Code: [Select]
   "user_name" => htmlspecialchars(stripslashes($user_name)),Add before (obove it):
Code: [Select]
"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:
Code: [Select]
//-----------------------------------------------------
//--- 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):
Code: [Select]
//-------------------------
//---- 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>&nbsp;**\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 :D


Step 2.
Open /details.php
Find:
Code: [Select]
     $comment_user_ip = ($user_info['user_level'] == ADMIN) ? $comment_row[$i]['comment_ip'] : "";Replace with:
Code: [Select]
     $comment_user_ip = ($user_info['user_level'] == ADMIN || $user_info['user_cat'] == $cat_id) ? $comment_row[$i]['comment_ip'] : "";
Step 2.2.
Find:
Code: [Select]
     elseif ($is_image_owner) {
        $admin_links .= ($config['user_edit_comments'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=editcomment&amp;".URL_COMMENT_ID."=".$comment_row[$i]['comment_id'])."\">".$lang['edit']."</a>&nbsp;";
        $admin_links .= ($config['user_delete_comments'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=removecomment&amp;".URL_COMMENT_ID."=".$comment_row[$i]['comment_id'])."\">".$lang['delete']."</a>";
Replace with:
Code: [Select]
//      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&amp;".URL_COMMENT_ID."=".$comment_row[$i]['comment_id'])."\">".$lang['edit']."</a>&nbsp;";
        $admin_links .= ($config['user_delete_comments'] != 1 && $user_info['user_cat'] != $cat_id) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=removecomment&amp;".URL_COMMENT_ID."=".$comment_row[$i]['comment_id'])."\">".$lang['delete']."</a>";

Step 2.3.
Find:
Code: [Select]
elseif ($is_image_owner) {
  $admin_links .= ($config['user_edit_image'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=editimage&amp;".URL_IMAGE_ID."=".$image_id)."\">".$lang['edit']."</a>&nbsp;";
  $admin_links .= ($config['user_delete_image'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=removeimage&amp;".URL_IMAGE_ID."=".$image_id)."\">".$lang['delete']."</a>";
Replace with:
Code: [Select]
     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&amp;".URL_IMAGE_ID."=".$image_id)."\">".$lang['edit']."</a>&nbsp;";
  $admin_links .= ($config['user_delete_image'] != 1 && $user_info['user_cat'] != $cat_id) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=removeimage&amp;".URL_IMAGE_ID."=".$image_id)."\">".$lang['delete']."</a>";

Done with /details.php


Step 3.
Open /admin/settings.php
Find:
Code: [Select]
// end of functions

show_admin_header();

if ($action == "updatesettings") {
  $setting_item = $HTTP_POST_VARS['setting_item'];
Replace with:
Code: [Select]
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:
Code: [Select]
 show_form_footer($lang['save_changes'], "", 2);Add before (above it):
Code: [Select]
 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.php


Step 4.
Open /admin/users.php
Find:
Code: [Select]
 show_additional_fields("user", $user_row, USERS_TABLE);Add before (above it):
Code: [Select]
$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.php


Step 5.
Open /includes/db_field_definitions.php
At the end of the file, just before closing ?> add this:
Code: [Select]
$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.php


Step 6.
Open /lang/<yourlanguage>/main.php
At the end of the file, just before closing ?> add this:
Code: [Select]
//----- 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'] = "**&nbsp;<b>All</b> - Everyone including guests (public).<br /><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Registered Users</b> - guests not allowed.<br /><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Private</b> - only selected members will have access.";
$lang['auth_warning'] = "NOTE: This will affect only selected in &quot;".$lang['auth_viewcat']."&quot; members.";
$lang['user_cat_help'] = "*&nbsp;&nbsp;&nbsp;Select from <b>left</b> side members who you want <b>add</b> to access list<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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.php


Step 7.
Open /lang/<yourlanguage>/admin.php
At the end of the file, just before closing ?> add this:
Code: [Select]
/*-- 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.php


Step 8.
Open /templates/<yourtemplate>/member_editprofile.html
Add this:
Code: [Select]
{if lang_activate}
          <tr>
            <td colspan="2" valign="top" class="head1">{lang_user_cat}&nbsp;<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>&nbsp;{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.html


Next 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:
Code: [Select]
{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+">&raquo; "+user_list[i]+"</option>\n";
            }
         }else{
            if (searchArray(user_list_id[i], list)) {
               result +="<option value='"+user_list_id[i]+"'"+owner_mark+"'>&raquo; "+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>
« Last Edit: April 08, 2005, 12:37:01 AM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Continue [MOD] Members Personal Category
« Reply #1 on: April 18, 2003, 10:29:02 AM »
Step 10.
Create member_cat_edit_bit.html with this code:
Code: [Select]
<tr class="row2" valign="top">
<td  width="120" align="left">
{usercat_auth_show}
</td>
{if auth_edit_link}
<td colspan="3" align="left" width="90%">
<a href="{auth_edit_link}">{lang_edit}</a>&nbsp;&nbsp;&nbsp;({auth_cur})
</td>
{endif auth_edit_link}
{if auth_edit_prv}
<td>
<table width="300" border="0" cellpadding="3" cellspacing="0" align="left">
<form name="usercatpermform" action="{self}" method="post">
{if auth_edit}
<tr>
<td align="center"><b>{lang_not_in_list}</b>&nbsp;*</td>
<td>
</td>
<td align="center"><b>{lang_in_list}</b>&nbsp;*</td>
</tr>
<tr>
<td align="center">
<script language="JavaScript">
document.writeln(print_list(1));
</script>
</td>
<td valign="middle" align="center">
<===&nbsp;<br><br>
&nbsp;===>
</td>
<td align="center">
<script language="JavaScript">
document.writeln(print_list(2));
</script>
</td>
</tr>
{endif auth_edit}
<tr>
<td align="center" nowrap colspan="3">
<input type="hidden" name="action" value="usercatpermedit" />
<input type="hidden" name="auth" value="{usercat_auth}" />
{admin_cat}
{auth_type}<br /><br />
<input type="submit" name="postbutton" value="{lang_save}" class="button" />
</td>
</tr>
<tr>
<td align="left" colspan="4">
{user_cat_help}
</td>
</tr>
<tr>
<td align="left" colspan="3">
{user_cat_note}
</td>
</tr>
</form>
</table>
</td>
{if user_list_added}
<td width="200" align="left" valign="top">
<br /><b>{lang_added}:</b><br /><br />
<div style="overflow-y: auto; width: 200px; height: 270px;">
{user_list_added}
</div>
</td>
{endif user_list_added}
{if user_list_rmvd}
<td width="200" align="left" valign="top">
<br /><b>{lang_rmvd}:</b><br /><br />
<div style="overflow-y: auto; width: 200px; height: 270px;">
{user_list_rmvd}
</div>
</td>
{endif user_list_rmvd}
{endif auth_edit_prv}
</tr>


Step 11.
Create member_cat_terms.html with this code:
Code: [Select]
<table border="0" cellpadding="0" cellspacing="0"  width="100%" class="bordercolor" align="center">
  <tr>
    <td>
      <table width="100%" border="0" cellpadding="3" cellspacing="1">
        <tr>
          <td valign="top" class="head1">{lang_user_cat_terms}</td>
        </tr>
        <tr>
          <td class="row2">{lang_agreement_terms}</td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table border="0" cellspacing="1" cellpadding="1" width="100%" align="center">
<tr>
<td align="right">
<form method="post" action="{self}">
<input type="hidden" name="action" value="usercatpermedit" />
<input type="hidden" name="user_cat_accept" value="1" />
<input type="submit" value="{lang_agree}" class="button" />
</form>
</td>
<td align="left">
<form method="post" action="{url_home}">
<input type="submit" value="{lang_agree_not}" class="button" />
</form>
</td>
</tr>
</table>
<br />


Step 12. (Final)
Download "Install MPC" installer. Unpack it and upload to your 4images root dir. Then start it by something like (http://youdomain.com/4images/install_mpc.php)


---- How To Use --------
By default this MOD is disabled.
To activate it, go to ACP -> settings and at the very bottom u should see new options.
Members: go to "Control Panel", u should see new option. First they must activate it, then there should be showed new link to edit permissions for their category.

NOTE:
1. The layout doesnt looks too good with default template and screen resolution less then 1024x768 :roll:
2. direct_upload by default is set to ALL, that means, no admin aproval requered when new images uploaded in members category, MPC owner can not change permissions for direct_upload, can change permissions for "upload". I would not recomend let MPC owners set permission for direct_upload.
3. In steps: 1. ; 1.2. ; 1.3. ; 1.4. and 2.2. I add commented lines. If u want owners of comments to be able edit or delete their comments, uncoment those lines, and comment lines below.
I think thats not fair when I cant edit or delete comment I posted... :roll:
« Last Edit: March 08, 2005, 12:45:06 AM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline freak

  • Newbie
  • *
  • Posts: 13
    • View Profile
[MOD] Members Personal Category
« Reply #2 on: April 18, 2003, 02:18:01 PM »
control panel:

Parse error: parse error, unexpected ':', expecting ')' in e:\www\main2\member.php on line 1114

Offline Shap

  • Full Member
  • ***
  • Posts: 114
    • View Profile
[MOD] Members Personal Category
« Reply #3 on: April 18, 2003, 09:33:46 PM »
have not tried it out yet, but ohhh yeah I've been waiting for this much needed MOD! :wink:

Offline toto1

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
    • http://www.gifanimer.com
[MOD] Members Personal Category
« Reply #4 on: April 19, 2003, 01:04:17 AM »
very good mod thk veno

Offline dezmarie

  • Pre-Newbie
  • Posts: 5
    • View Profile
[MOD] Members Personal Category
« Reply #5 on: April 19, 2003, 10:39:21 AM »
When I run the installer, I receive this error:

DB Error: Bad SQL Query: ALTER TABLE 4images_users ADD `user_cat` MEDIUMINT( 8 ) NOT NULL , ADD `user_cat_active` TINYINT( 2 ) NOT NULL , ADD `user_cat_active_admin` TINYINT( 2 ) DEFAULT '1' NOT NULL , ADD `user_cat_terms` TINYINT( 2 ) NOT NULL ;
You have an error in your SQL syntax near '; ' at line 1

Where is the syntax error in the installer? I tried running it through phpmyadmin and got the same error. I don't know enough about php to know what the error is

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[MOD] Members Personal Category
« Reply #6 on: April 19, 2003, 12:29:52 PM »
Quote from: dezmarie
When I run the installer, I receive this error:

DB Error: Bad SQL Query: ALTER TABLE 4images_users ADD `user_cat` MEDIUMINT( 8 ) NOT NULL , ADD `user_cat_active` TINYINT( 2 ) NOT NULL , ADD `user_cat_active_admin` TINYINT( 2 ) DEFAULT '1' NOT NULL , ADD `user_cat_terms` TINYINT( 2 ) NOT NULL ;
You have an error in your SQL syntax near '; ' at line 1

Where is the syntax error in the installer? I tried running it through phpmyadmin and got the same error. I don't know enough about php to know what the error is

Sorry, the installation mysql query was created by my phpmyadmin, so, probably my version of mysql support that kind format...but try to delete " ; ":
Quote
                  "ALTER TABLE ".USERS_TABLE." ADD `user_cat` MEDIUMINT( 8 ) NOT NULL , ADD `user_cat_active` TINYINT( 2 ) NOT NULL , ADD `user_cat_active_admin` TINYINT( 2 ) DEFAULT '1' NOT NULL , ADD `user_cat_terms` TINYINT( 2 ) NOT NULL ; "


P.S. Just in case I reuploaded installer without ;
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline dezmarie

  • Pre-Newbie
  • Posts: 5
    • View Profile
[MOD] Members Personal Category
« Reply #7 on: April 19, 2003, 01:05:59 PM »
Thank you for posting that fix  :D  i'm sure that this mod will be useful for many people.

Offline ai-gu

  • Newbie
  • *
  • Posts: 29
    • View Profile
[MOD] Members Personal Category
« Reply #8 on: April 19, 2003, 03:40:38 PM »
hello,
I installed this MOD, it seems that there was no error and the Admin Control Panel was OK, however, I did not see and new feature when I logged on as a normal member . .
I cant find where & how to create my own Cartegory . . . .

Could you please give me some suggestion to solve this??

thanks in advance!

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[MOD] Members Personal Category
« Reply #9 on: April 19, 2003, 03:58:20 PM »
as I mentioned by default the mod is not activated. u must activated in 4images settings. (first option)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline ai-gu

  • Newbie
  • *
  • Posts: 29
    • View Profile
[MOD] Members Personal Category
« Reply #10 on: April 19, 2003, 04:05:56 PM »
I did activate it from the Admin Control panel already . . .

So now, how?

Offline lakeside

  • Full Member
  • ***
  • Posts: 123
    • View Profile
[MOD] Members Personal Category
« Reply #11 on: April 24, 2003, 04:36:57 AM »
Will this mod conflict with the user upload limits mod?

Offline ai-gu

  • Newbie
  • *
  • Posts: 29
    • View Profile
[MOD] Members Personal Category
« Reply #12 on: April 24, 2003, 05:03:57 AM »
Quote from: lakeside
Will this mod conflict with the user upload limits mod?


so how can we solve this problem???
I also installed the member upload limit MOD

Offline lakeside

  • Full Member
  • ***
  • Posts: 123
    • View Profile
[MOD] Members Personal Category
« Reply #13 on: April 24, 2003, 05:07:02 AM »
I havnt actually installed this mod yet, Im *asking* if it will conflict before I install it, as the user upload limits mod is of the utmost importance to my site.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[MOD] Members Personal Category
« Reply #14 on: April 24, 2003, 03:13:12 PM »
Quote from: lakeside
I havnt actually installed this mod yet, Im *asking* if it will conflict before I install it, as the user upload limits mod is of the utmost importance to my site.

I can not be sure, but I think it shouldnt.



P.S.
also, I forgot mention in the original post, that incase user's category was deleted by admin, next time user upadate hes profile it will create new category...
let me know if this is a bad idea, it's easy to fix.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)