• [MOD] User Categories Area 5 0 5 1
Currently:  

Author Topic: [MOD] User Categories Area  (Read 71928 times)

0 Members and 1 Guest are viewing this topic.

Offline budduke

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • http://www.budduke.com
[MOD] User Categories Area
« on: April 19, 2009, 11:10:01 PM »
MOD 2.02 User Categories Area

This mod was a big undertaking on my part out of necessity to use on my own website.
I saw other attempts to create this but they leave out things I needed so I borrowed their creations and made them work nicely together along with some of my own improvements

This mod makes changes to your database so please backup and test on a testing server before undertaking a public site!! You have been warned!!!

The mods that I used to create this one are…
http://www.4homepages.de/forum/index.php?topic=18564.0[MOD] V1.3 Let users add (sub-)categories / User erstellen (Sub-)Kategorien
http://www.4homepages.de/forum/index.php?topic=20657.0[MOD] - Multiupload (thunderstrike version)

I actually used the attachment on reply #35 of this thread, it worked fine for me.
Version 2.0 has added support for dropdown fields for additional user field MOD
http://www.4homepages.de/forum/index.php?topic=7112.0[MOD] Dropdown options for custom database fields
and
http://www.4homepages.de/forum/index.php?topic=7385.0[MOD] Select country and gender with gif when register
as my test fields.
you will need to install at least the first one to work with this mod. If you do not use these mods, my script will detect that and just not let you use that part of the setup.

Could not remember link of mod that I used but it was the auto resize mod with big folder mod
(if you need to use make sure you add all of this mod to your site first)

What does this mod do?
1. As administrator you can create a category that will house user categories of your choosing that they can upload files to and create/delete categories of their choosing under their user area.
1a. (NEW IN VER 2.0) Administrator can now set home categories based on additional_user_fields Dropdown lists MOD
2. You can set each user as either direct upload or validation on files.
3. When you give a user permission the system will create their category for them under the category that you choose in admin panel and give them the correct permissions to modify under their own sub categories.
3a. (NEW IN VER 2.0) You can set settings so any new user can create an area without your input
4. You can have a log of category creation/deletions created for this area to see if you have any problems with certain users.
5. With the multiupload mod added to this mod, the users can upload more than one file at a time.
6. I have added the big folder mod for uploading (can be turned on/off)
7. I have added if no image name inserted then it will use the filename instead (can be turned on/off)
8. Mod is template friendly (at least the templates I was playing with)
9. Look at screen shots attached to understand MOD better (Sorry, no demo site)

I have tested this mod on a fresh install of 4images 1.7.7 using the default template and everything works as it should.


A couple of notes before you get started.
1. I have always noticed that in the auto resize big folder mod, unless I installed in incorrectly, it would copy the original file to the big folder and resize the image to the max values set in the admin panel and displayed in the upload form. For the end user, I needed it to give them a max upload value like 1920X1200 and resize down to 480X480 for the details page, so I set the admin panel to 1920X1200 and in the constants.php file I made two new values of 480X480 for the details page. The end user now sees the 1920X1200 on the upload form and errors out when they try to upload bigger and I still get smaller file on my detail page. In order for this to work I had to do this modification to original auto resize mod

 In the includes/upload.php file
look for
Code: [Select]
if ($this->auto_image[$this->image_type]) {
        $ok = 1;
     }
replace with…
Code: [Select]
/*if ($this->auto_image[$this->image_type]) {
        $ok = 1;
     }*/ 

If you do not make this modification then the user can upload any dimension file they want as long as it does not reach the megabyte file size limit set in the admin panel.
2. I saw the [all in one] mod that does watermarks and histograms as well as the resize on upload; I do not use them so I have never installed that mod. If enough people ask I may install it and see how to insert that code into this mod.
3. I am not sure how this stands up in security. I tried all hacks I could think of and it seems pretty stable/secure,
4. If you look at the addition to the style.css file, you should be able to modify the colors/fonts to fit into your site without modifying a bunch of my code.
5. To make this mod fit into your template better, instead of using my user_categoriesform.html file, use one of your templates other main display files and place this information in the main body of the page and save it as user_categoriesform.html and it should work.
Code: [Select]
<span class="title">{lang_user_area}</span>
<hr size="1" />
{content}
{msg}

Revisions history…
2.02 major mistake in my coding regarding sessions
Changed files in version 2.02
Added new lang data to main.php file so admin.php language is not needed for end users and used just for the admin panel.
Please download new zip file for the changed files and also place the new language data in the main.php file.
  • changed user_multiupload.php in zip file.
  • changed includes/user_functions.php in zip file.
  • changed templates/default/member_user_multiupload_content.html in zip file.
2.01 major mistake in my coding,
Changed files in version 2.01
Please download new zip file
  • changed user_categories.php in zip file
  • changed user_multiupload.php in zip file.
  • changed includes/user_functions.php in zip file.
2.00 Added support for additional_user_fields dropdown MOD, cleaned some of the code up a little
1.03 found error when I added Captcha, updated user_categories.php file in zip file again.
1.02 found error in the database install file. please read note at bottom of post
1.01 added Captcha to adding new categories to stop automated scripts from killing site
Changed files in version 1.01
  • changed user_categories.php in zip file, please download new file
  • changed Global.php, look at first two changes in mods to see what is different
1.0 first try at it.

Things I would like to see added/modified are…
1. the [all in one mod] to handle everyone’s needs.
2. Would like a plug-in in the admin panel that could list all users with fields to change multiple settings for this mod in one shot like the batch image edit mod that V@no created.
3. make the log better, not sure if I did it correctly but it works for my purposes.
4. would like to give users the ability to move images between their own categories (don’t even know where to begin on that one) for now, they can just contact the admin to do it.



If you are ready to begin adding this mod, let’s get started…
Warning (NOT a 5 minute install) Took me 5 weeks to get it running this smooth for you…
BACKUP YOUR DATABASE AND FILES BEFORE YOU START!

New files added included in attached zip file…
install_user_categories.php  (delete after you run this file once!)
user_categories.php (UPDATED FILE FOR VER 2.0)
user_multiupload.php
includes/user_functions.php (UPDATED FILE FOR VER 2.0)
admin/plugins/user_categories_mod.php (NEW FILE FOR VER 2.0)
templates/your template folder/user_categoriesform.html
templates/your template folder/member_user_multiuploadform.html
templates/your template folder/member_user_multiuploadform_select.html
templates/your template folder/member_user_multiupload_content.html
templates/your template folder/images/user_multiupload.gif
templates/your template folder/images/user_multiupload_off.gif
templates/your template folder/images/folder_path.gif

Place the install_user_categories.php file in your gallery root directory and run the file to add the fields to your databases.
Delete this file from your root after you run it!
(Do not need to run this installer is upgrading from version 1.03 to 2.0 version of this mod)

The following fields are created in case you need to remove them for troubleshooting
Settings table-   
  • user_submitted_enable
  • user_submitted_maincat
  • user_submitted_default_direct
  • user_submitted_log
  • user_multiupload_size
  • user_submitted_default_create (NEW FOR ver2.0, will be autocreated if not there)
Groupaccess table-
  • auth_user_manage
   
Categories table-
  • auth_user_manage
   
Users table-
  • user_submitted_allow
  • user_submitted_direct
  • user_submitted_parent

The following files are modified (BACKUP FIRST!)
Categories.php
Global.php
Login.php (maybe?)
Logout.php (maybe?)
registar.php (new to list for ver 2.0)
Admin/admin_functions.php (new to list for ver 2.0)
Admin/categories.php
Admin/settings.php (mod can be removed from this file for ver 2.0)
Admin/usergroups.php
Includes/auth.php
Includes/constants.php
Includes/db_field_definitions.php
Includes/functions.php
Includes/page_header.php
Includes/sessions.php
Lang/English/main.php
Lang/English/admin.php
Templates/your template/categories.html
Templates/your template/style.css


Start of modifications...

in admin/admin_functions.php file... (New Modification for ver 2.0)

look for...
Code: [Select]
show_input_row($val[0], $field_name, $value);Replace with
Code: [Select]
  //MOD User Categories
  if (substr($field_name,0,21)=='user_submitted_parent'){
    show_user_parent_input_row($val[0],$field_name,$value);
  }
  else{
        show_input_row($val[0], $field_name, $value);
      }
  //END MOD User Categories

look for...
Code: [Select]
?>insert Before
Code: [Select]
//MOD User Categories
function show_user_parent_input_row($title, $name, $value = "", $size = "") {
  global $HTTP_POST_VARS;
  if (isset($HTTP_POST_VARS[$name])/* && $value == ""*/) {
    $value = stripslashes($HTTP_POST_VARS[$name]);
  }
  echo "<tr class=\"".get_row_bg()."\">\n<td><p class=\"rowtitle\">".$title."</p></td>\n<td><p>".show_user_parent_dropdown_list_mod($name,$value)."</p></td>\n</tr>\n";
}
function show_user_parent_dropdown_list_mod($setting_name, $setting_value){
$var = get_user_parent_dropdown_mod($setting_value,$setting_name);
return $var;
}
function get_user_parent_dropdown_mod($cat_id,$setting_name) {
  global $lang, $drop_down_cat_cache, $cat_parent_cache;
    $category = "\n<select name=\"".$setting_name."\" class=\"categoryselect\">\n";
    $category .= "<option value=\"0\">".$lang['no_category']."</option>\n";
    $category .= "<option value=\"0\">-------------------------------</option>\n";
    $drop_down_cat_cache = array();
    $drop_down_cat_cache = $cat_parent_cache;
$category .= get_user_category_dropdown_bits($cat_id);
    $category .= "</select>\n";
return $category;
}
//END MOD User Categories

in admin/categories.php file...

look for
Code: [Select]
  "auth_postcomment" => AUTH_USERreplace with
Code: [Select]
  "auth_postcomment" => AUTH_USER,
  "auth_user_manage" => AUTH_ACL

look for
Code: [Select]
      $error_log[] = $lang['cat_delete_error']." <b>".format_text($cats['cat_name'], 2)."</b> (ID: ".$cats['cat_id'].")";
    }
insert after
Code: [Select]
//MOD User Categories
$sql = "UPDATE ".USERS_TABLE."
SET user_submitted_parent = 0
WHERE user_submitted_parent = ".$cats['cat_id'];
    $site_db->query($sql);
//END MOD User Categories
         

look for
Code: [Select]
    $error_log[] = $lang['cat_delete_error']." <b>".format_text($cat_cache[$cat_id]['cat_name'], 2)."</b> (ID: ".$cat_id.")";
  }
insert after
Code: [Select]
//MOD User Categories
$sql = "UPDATE ".USERS_TABLE."
SET user_submitted_parent = 0
WHERE user_submitted_parent = ".$cat_id;
    $site_db->query($sql);
//END MOD User Categories
         

look for Twice
Code: [Select]
  $auth_postcomment = $HTTP_POST_VARS['auth_postcomment'];insert after both places
Code: [Select]
  $auth_user_manage = $HTTP_POST_VARS['auth_user_manage'];
look for
Code: [Select]
(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
replace with
Code: [Select]
(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, auth_user_manage
look for
Code: [Select]
('$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";
replace with
Code: [Select]
('$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, $auth_user_manage
look for
Code: [Select]
$sql = "SELECT cat_name, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
replace with
Code: [Select]
$sql = "SELECT cat_name, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, auth_user_manage

look for
Code: [Select]
SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment
replace with
Code: [Select]
SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment, auth_user_manage = $auth_user_manage

look for
Code: [Select]
$sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
replace with
Code: [Select]
$sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, auth_user_manage

look for twice
Code: [Select]
$sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
replace Both with
Code: [Select]
$sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, auth_user_manage


in the admin/settings.php file (no longer needed for Ver 2.0) (mods can be removed from this file)

look for
Code: [Select]
// end of functionsinsert before (Remove this code for ver 2.0)
Code: [Select]
//MOD user categories
function show_category_dropdown_list($setting_name, $setting_value){
$var = get_user_category_dropdown($setting_value,"",2);
echo $var;
}
function show_user_submitted_log_options($setting_name, $setting_value) {
  global $user_submitted_log_optionlist;
  foreach ($user_submitted_log_optionlist as $key => $val) {
    echo "<input type=\"radio\" name=\"setting_item[".$setting_name."]\" value=\"$key\"";
    if ($setting_value == $key) {
      echo " checked=\"checked\"";
    }
    echo "> ".$val."<br />";
  }
}
//END MOD user categories

look for
Code: [Select]
  show_form_footer($lang['save_changes'], "", 2);
}
insert before (Remove this code for ver 2.0)
Code: [Select]
// MOD user Categories area
  show_table_separator($setting_group[XX], 2, "setting_group_XX");//replace XX with next number in sequence looking at above $setting_group
  show_setting_row("user_submitted_enable","radio");
  show_setting_row("user_submitted_maincat","show_category_dropdown_list");
  show_setting_row("user_submitted_default_direct", "radio");
  show_setting_row("user_submitted_log", "show_user_submitted_log_options");
  show_setting_row("user_multiupload_size");
//END MOD user Categories area

look at $setting_group[##] before this insert and add 1 to the number and replace both XX in the above insert with that new number
Write this new number down for later insert!
example, if last number is 10 your line from insert above should look like this...
 
Code: [Select]
show_table_separator($setting_group[11], 2, "setting_group_11");//replace XX with next number in sequence looking at above $setting_group 
in admin/usergroups.php file

look for
Code: [Select]
  "auth_postcomment"replace with
Code: [Select]
  "auth_postcomment",
  "auth_user_manage"

look for
Code: [Select]
    $auth_postcomment = (isset($auth[$key]['auth_postcomment']) && $auth[$key]['auth_postcomment'] == 1) ? 1 : 0;insert after
Code: [Select]
    $auth_user_manage = (isset($auth[$key]['auth_user_manage']) && $auth[$key]['auth_user_manage'] == 1) ? 1 : 0;
look for
Code: [Select]
    if ($auth_viewcat || $auth_viewimage || $auth_download || $auth_upload || $auth_directupload || $auth_vote || $auth_sendpostcard || $auth_readcomment || $auth_postcomment) {
      $sql = "INSERT INTO ".GROUP_ACCESS_TABLE."
              (group_id, cat_id, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment)
              VALUES
              ($group_id, $key, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment)";
replace with.. (make sure you do not have any other mod fields added in this area, you will need to re-add them)
Code: [Select]
    if ($auth_viewcat || $auth_viewimage || $auth_download || $auth_upload || $auth_directupload || $auth_vote || $auth_sendpostcard || $auth_readcomment || $auth_postcomment || $auth_user_manage) {
      $sql = "INSERT INTO ".GROUP_ACCESS_TABLE."
              (group_id, cat_id, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, auth_user_manage)
              VALUES
              ($group_id, $key, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment, $auth_user_manage)";

in registar.php file (New modification for ver 2.0)

look for
Code: [Select]
    $activationkey = get_random_key(USERS_TABLE, get_user_table_field("", $user_table_fields['user_activationkey']));
insert Before
Code: [Select]
//MOD User Categories
    $additional_field_sql .= ", user_submitted_allow, user_submitted_direct, user_submitted_parent";
    $additional_value_sql .= ", '".$config['user_submitted_default_create']."', '".$config['user_submitted_default_direct']."', '0'";
//END MOD User categories

in global.php file

look for
Code: [Select]
$captcha_path                = ROOT_PATH.'captcha';insert before changed in version 1.01
Code: [Select]
$captcha_enable_user_multiupload  = 0;//set to what you want it to be
$captcha_enable_user_category_add = 1;//set to what you want it to be

look for
Code: [Select]
if (!$captcha_enable) {
  $captcha_enable_comments     = 0;
  $captcha_enable_upload       = 0;
insert after changed in version 1.01
Code: [Select]
  $captcha_enable_user_multiupload  = 0;
  $captcha_enable_user_category_add = 0;
 
look for
Code: [Select]
$sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
replace with
Code: [Select]
$sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment,auth_user_manage

in categories.php file in your gallery root directory

look for
Code: [Select]
//-----------------------------------------------------
//--- Show Categories ---------------------------------
//-----------------------------------------------------
if (!check_permission("auth_upload", $cat_id)) {
  $upload_url = "";
  $upload_button = "<img src=\"".get_gallery_image("upload_off.gif")."\" border=\"0\" alt=\"\" />";
}
else {
  $upload_url = $site_sess->url(ROOT_PATH."member.php?action=uploadform&amp;".URL_CAT_ID."=".$cat_id);
  $upload_button = "<a href=\"".$upload_url."\"><img src=\"".get_gallery_image("upload.gif")."\" border=\"0\" alt=\"\" /></a>";
}
replace with
Code: [Select]
//-----------------------------------------------------
//--- Show Categories ---------------------------------
//-----------------------------------------------------
/*if (!check_permission("auth_upload", $cat_id)) {
  $upload_url = "";
  $upload_button = "<img src=\"".get_gallery_image("upload_off.gif")."\" border=\"0\" alt=\"\" />";
}
else {
  $upload_url = $site_sess->url(ROOT_PATH."member.php?action=uploadform&amp;".URL_CAT_ID."=".$cat_id);
  $upload_button = "<a href=\"".$upload_url."\"><img src=\"".get_gallery_image("upload.gif")."\" border=\"0\" alt=\"\" /></a>";
}
*/
if (!check_permission("auth_upload", $cat_id)) {
  $upload_url = "";
  $upload_button = "<img src=\"".get_gallery_image("upload_off.gif")."\" border=\"0\" alt=\"\" />";
  if (isset($config['user_multiupload_size']) && $config['user_multiupload_size'] > 1 ) {
    $user_multiupload_url = "";
    $user_multiupload_button = "<img src=\"".get_gallery_image("user_multiupload_off.gif")."\" border=\"0\" alt=\"\" />";
  }
}
else {
  $upload_url = $site_sess->url(ROOT_PATH."member.php?action=uploadform&amp;".URL_CAT_ID."=".$cat_id);
  $upload_button = "<a href=\"".$upload_url."\"><img src=\"".get_gallery_image("upload.gif")."\" border=\"0\" alt=\"\" /></a>";
  if (isset($config['user_multiupload_size']) && $config['user_multiupload_size'] > 1 ) {
    if ($user_info['user_level'] == GUEST) {
      $user_multiupload_url = "";
      $user_multiupload_button = "<img src=\"".get_gallery_image("user_multiupload_off.gif")."\" border=\"0\" alt=\"\" />";
    }
    else {
      $user_multiupload_url = $site_sess->url(ROOT_PATH."user_multiupload.php?action=multiuploadform&amp;".URL_CAT_ID."=".$cat_id);
      $user_multiupload_button = "<a href=\"".$user_multiupload_url."\"><img src=\"".get_gallery_image("user_multiupload.gif")."\" border=\"0\" alt=\"\" /></a>";
    }
  }
}

look for
Code: [Select]
  "upload_button" => $upload_button,insert after
Code: [Select]
  "user_multiupload_button" => $user_multiupload_button,
in the includes/auth.php file

look for
Code: [Select]
, a.auth_postcommentreplace with
Code: [Select]
, a.auth_postcomment, a.auth_user_manage
in the includes/constants.php file

look for
Code: [Select]
?>insert before
Code: [Select]
//MOD user categories
define('USER_BIG_FOLDER' , '/big');//name of directory you are using for big or alternate download directory for big images
define('USER_DETAIL_WIDTH',480);// size width to display on detail page
define('USER_DETAIL_HEIGHT',480);// size height to display on detail page
define('USER_LOG_DIR', 'data/logs'); // directory to store log file in
define('USER_LOG_FILENAME', 'user_categories.log'); //name of log file
define('USER_AUTO_FILENAME', '1');//make 0 if you want to make user put a imageame in or set to 1 to use filename as imagename if left blank
define('USER_CAT_DESC', '1');//1= use auto description for main user cat description or 0 to leave blank
define('USER_AUTO_RESIZE', '1');// 1= use auto resize on upload, 0= do not use
//END MOD user categories

in the includes/db_field_definitions.php file

look for
Code: [Select]
?>insert before
Code: [Select]
//MOD user categories
$additional_user_fields['user_submitted_allow'] = array("Allowed to create a user category area", "radio", 1);
$additional_user_fields['user_submitted_direct'] = array("Allowed to direct upload to user category area", "radio", 1);
$additional_user_fields['user_submitted_parent'] = array("parent category for this user category area", "text", 1);
//END MOD user categories

in the includes/functions.php file

look for
Code: [Select]
?>insert before
Code: [Select]
// MOD user categories
function get_user_category_dropdown($cat_id, $jump = 0, $admin = 0, $i = 0) {
  global $lang, $drop_down_cat_cache, $cat_parent_cache;
  // $admin = 1  Main Cat (update/add cats)
  // $admin = 2  All Cats (find/validate images...)
  // $admin = 3  Select Cat (update/add image)
  // $admin = 4  No Cat (check new images)
  switch ($admin) {
  case 1:
    $category = "\n<select name=\"cat_id\" class=\"categoryselect\">\n";
    $category .= "<option value=\"156\">"."Your Main Root Gallery"."</option>\n";
    $category .= "<option value=\"156\">--------------</option>\n";
    break;

  case 2:
    $category = "\n<select name=\"setting_item[user_submitted_maincat]\" 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_user_category_dropdown_bits($cat_id);
    $category .= "</select>\n";
return $category;
break;

  case 3:
    $i = ($i) ? "_".$i : "";
    $category = "\n<select name=\"cat_id".$i."\" class=\"categoryselect\">\n";
    $category .= "<option value=\"0\">".$lang['select_category']."</option>\n";
    $category .= "<option value=\"0\">-------------------------------</option>\n";
    break;

  case 4:
    $category = "\n<select name=\"cat_id\" class=\"categoryselect\">\n";
    $category .= "<option value=\"0\">".$lang['no_category']."</option>\n";
    $category .= "<option value=\"0\">-------------------------------</option>\n";
    break;

  case 0:
  default:
    if ($jump) {
      $category = "\n<select name=\"".URL_CAT_ID."\" onchange=\"if (this.options[this.selectedIndex].value != 0){ forms['jumpbox'].submit() }\" class=\"categoryselect\">\n";
    }
    else {
      $category = "\n<select name=\"".URL_CAT_ID."\" class=\"categoryselect\">\n";
    }
    $category .= "<option value=\"0\">".$lang['select_category']."</option>\n";
    $category .= "<option value=\"0\">-------------------------------</option>\n";
  } // end switch

  $drop_down_cat_cache = array();
  $drop_down_cat_cache = $cat_parent_cache;
  $category .= get_user_category_dropdown_bits($cat_id, $cat_id);
  $category .= "</select>\n";
  return $category;
}
function get_user_category_dropdown_bits($cat_id, $cid = 0, $depth = 1) {
  global $site_db, $drop_down_cat_cache, $cat_cache;
  if (!isset($drop_down_cat_cache[$cid])) {
    return "";
  }
  $category_list = "";
  foreach ($drop_down_cat_cache[$cid] as $key => $category_id) {
    if (check_permission("auth_upload", $category_id)) {
      $category_list .= "<option value=\"".$category_id."\"";
      if ($cat_id == $category_id) {
        $category_list .= " selected=\"selected\"";
      }
      if ($cat_cache[$category_id]['cat_parent_id'] == 0) {
        $category_list .= " class=\"dropdownmarker\"";
      }

      if ($depth > 1) {
        $category_list .= ">".str_repeat("--", $depth - 1)." ".format_text($cat_cache[$category_id]['cat_name'], 2)."</option>\n";
      }
      else {
        $category_list .= ">".format_text($cat_cache[$category_id]['cat_name'], 2)."</option>\n";
      }
      $category_list .= get_user_category_dropdown_bits($cat_id, $category_id, $depth + 1);
    }
  }
  unset($drop_down_cat_cache[$cid]);
  return $category_list;
}
// END MOD user categories

in the includes/page_header.php file

look for
Code: [Select]
  "url_upload" => (!empty($url_upload)) ? $site_sess->url($url_upload) : $site_sess->url(ROOT_PATH."member.php?action=uploadform"),insert after
Code: [Select]
  "url_user_multiupload" => (!empty($url_user_multiupload)) ? $site_sess->url($url_user_multiupload) : $site_sess->url(ROOT_PATH."user_multiupload.php"),
look for
Code: [Select]
//-----------------------------------------------------
//--- User Box ----------------------------------------
//-----------------------------------------------------
if ($user_info['user_level'] >= USER) {
  $site_template->register_vars("lang_loggedin_msg", preg_replace("/".$site_template->start."loggedin_user_name".$site_template->end."/siU", format_text($user_info['user_name'], 2), $lang['lang_loggedin_msg']));
insert after
Code: [Select]
// MOD User categories area
$user_submitted_allowed = 0;
if ($config['user_submitted_enable'] && $user_info['user_submitted_allow']){
$user_submitted_allowed = 1;
}
if ($user_info['user_submitted_parent']==0){
$user_submitted_url = "user_categories.php?action=createuser";
}
else {
$user_submitted_url = "user_categories.php";
}
$site_template->register_vars(array(
"user_submitted_allowed"   => $user_submitted_allowed,
"user_submitted_url" => $site_sess->url(ROOT_PATH.$user_submitted_url),
"lang_user_area" => $lang['usercat_user_area']
));
unset($user_submitted_allowed);
unset($user_submitted_url);
//END MOD User categories area
   
in the includes/sessions.php file

look for
Code: [Select]
  function logout($user_id) {
    global $site_db;
replace with
Code: [Select]
  function logout($user_id) {
    global $site_db,$site_sess;
$user_categories_log = $site_sess->get_session_var("user_categories_log");
if(isset($user_categories_log)){
include(ROOT_PATH.'includes/user_functions.php');
$var= user_categories_log_file($user_categories_log);
}

in the lang/english/admin.php file

look for
Code: [Select]
?>insert before (Updated insert for version 2.0)
Code: [Select]
// MOD user submited area
$lang['auth_user_manage'] = "User Manage";
$setting["user_submitted_area"] = "User Categories Area";
$setting["user_submitted_enable"] = "Enable user category area";
$setting["user_submitted_maincat"] = "Parent category for this area";
$setting["user_submitted_default_direct"] = "Allow direct upload as default setting";
$setting['user_submitted_log'] = "Would you like to record a log file for user activity?";
$setting['user_submitted_continue']= "Continue";
$user_submitted_log_optionlist = array(
  "0"  => "No",
  "1"  => "Yes, Record only errors",
  "2"  => "Yes, Record all activity"
);
// added for version 2.0
$user_submitted_enable_optionlist = array(
  "0"  => "No",
  "1"  => "Yes, Using one main area",
  "2"  => "Yes, Using category based on Additional User Field Dropdown Mod"
);
$setting['user_multiupload_size'] = "Set max value for user to upload images to gallery";
$setting['user_submitted_maincat_field']="Additional User Field Dropdown Field to use";
$setting['user_submitted_maincat1']="Main User Category Area using \"";
$setting['user_submitted_maincat2']="\" Dropdown Field";
$setting['user_submitted_maincat3']="Main User Category Area";
$setting['user_submitted_default_create']="Allow new users to create area without Admin involvement";
//end MOD user submitted area

in the lang/english/main.php file

look for
Code: [Select]
?>insert before (modified insert for version 2.0)
Code: [Select]
//-----------------------------------------------------
//--- User category area -------------------------------------
//-----------------------------------------------------
$lang['usercat_no_rights'] = 'You do not have the permission to access this page!';
$lang['usercat_create_abort'] = 'Your area was not created at this time.';
$lang['usercat_return_gallery'] = 'return to gallery';
$lang['usercat_aborted'] = 'changes were aborted';
$lang['usercat_catname1'] = ''; // this is the name of users main category when it is created(format "$lang['usercat_catname1'].$user_info['user_name'].$lang['usercat_catname2']")
$lang['usercat_catname2'] = '&#39;s collection'; //  (default is "username's collection")
$lang['usercat_catdesc1'] = 'This is '; //this is the description of users main category (format "$lang['usercat_catdesc1'].$user_info['user_name'].$lang['usercat_catdesc2']")
$lang['usercat_catdesc2'] = '&#39;s collection of uploaded files.'; // (default is "This is username's collection of files.")
$lang['usercat_deletehead'] = 'Summary of Deleting Categories';
$lang['usercat_create_main'] = 'Your area has not been created yet';
$lang['usercat_create_question'] = 'Do you wish to create your area now?';
$lang['usercat_area']= 'Your user area</span>';
$lang['usercat_editcat'] = 'Editing categories';
$lang['usercat_inside'] = ' inside ';
$lang['usercat_user_area'] = 'Your User Area';
$lang['usercat_edit'] = "[Edit]";
$lang['usercat_delete'] = "[Delete]";
$lang['usercat_add'] = "[Add Subcategory]";
$lang['usercat_upload'] = "[Upload Files]";
$lang['user_multiupload_file_title'] = "File no. ";
$lang['user_multiupload_select'] = "Select the number of images for upload:<br /><span class=\"smalltext\"><font color=\"red\">Note:</font> Check all field before upload.</span>";
$lang['user_multiupload_select_title'] = "Multiupload - select";
$lang['user_multiupload_file'] = "Multiupload files";
$lang['user_multiupload_empty_filename'] = "<br><span class='smalltext'>Will use filename if left blank</span>";
$lang['usercat_no_rights2'] = 'Based on your selections in your profile, You do not have the permission create an user area. Please contact Admin if you feel this is an error';
$lang['sub_categories'] = "Subcategories";
$lang['no_subcategories'] = "No subcategories added";
$lang['delete_cat_confirm'] = "Do you want to delete this category?<br />All subcategories as well as attached images and comments will be deleted!";
$lang['delete_cat_files_confirm'] = "Delete all image files from the server?";
$lang['cat_add_success'] = "Category added";
$lang['cat_add_error'] = "Error adding category";
$lang['cat_edit_success'] = "Category edited";
$lang['cat_edit_error'] = "Error editing category";
$lang['cat_delete_success'] = "Category deleted";
$lang['cat_delete_error'] = "Error while deleting category";
$lang['cat_order'] = "Category Order";
$lang['at_beginning'] = "At Beginning";
$lang['at_end'] = "At End";
$lang['after'] = "After";
$lang['nav_categories_add'] = "Add categories";
$lang['lostfield_error'] = "Please recheck the marked fields.";
$lang['image_delete_success'] = "Image deleted";
$lang['image_delete_error'] = "Error deleting image";
$lang['file_delete_success'] = "Image file deleted";
$lang['file_delete_error'] = "Error deleting image file.";
$lang['thumb_delete_success'] = "Thumbnail file deleted";
$lang['thumb_delete_error'] = "Error deleting thumbnail file";
$lang['comments_delete_success'] = "Comments deleted";
$lang['comments_delete_error'] = "Error deleting comments";
$lang['error_log_desc'] = "The following errors occurred:";
$lang['back_overview'] = "Back to overview";
$lang['save_changes'] = "Save changes";
$lang['back'] = "Back";
$lang['reset'] = "Reset";
$lang['add'] = "Add";
$lang['delete'] = "Delete";
$lang['field_category_name'] = "Category name";
$lang['field_description'] = "Description";
$lang['usercat_upload1'] = "Upload:";
$lang['usercat_url'] = "Url:";

in the templates/your template folder/categories.html file

look for
Code: [Select]
{upload_button}insert after or replace with
Code: [Select]
{user_multiupload_button}
in the templates/your template folder/user_logininfo.html file

look for
Code: [Select]
  &raquo; <a href="{url_control_panel}">{lang_control_panel}</a><br />insert after
Code: [Select]
{if user_submitted_allowed}
  &raquo; <a href="{user_submitted_url}">{lang_user_area}</a><br />
{endif user_submitted_allowed}

in the templates/your template folder/style.css file

insert at end of file
Code: [Select]
/* MOD User Categories
userhead1 is text in header at top
userhead2 is link text in header at top
user1 is text in table
user2 is link text in table
*/

.userhead1 {
  background-color: #004C75;
  color: #fcdc43;
  font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: bold;
}

.userhead2 {
  background-color: #004C75;
  color: #fcdc43;
  font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: bold;
}
.userhead2:link {
  background-color: #004C75;
  color: #fcdc43;
  font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: bold;
}
.userhead2:visited {
  background-color: #004C75;
  color: #fcdc43;
  font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: bold;
}
.userhead2:hover {
  background-color: #004C75;
  color: #FFFFFF;
  font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: bold;
}
.user1 {
  color: #004C75;
}

.user2 {
  color: #004C75;
}
.user2:link {
  color: #004C75;
}
.user2:visited {
  color: #004C75;
}
.user2:hover {
  color: #000000;
}
/*END MOD user categories*/

not sure if you need these mods or not...
I had to insert them to get the site to redirect to the correct page when I login/logout.

in the login.php file

look for twice
Code: [Select]
&& !ereg("member.php", $url)replace Both with
Code: [Select]
&& !ereg("member.php", $url) && !ereg("user_multiupload.php", $url)
in the logout.php file

look for
Code: [Select]
&& !ereg("member.php", $url)replace with
Code: [Select]
&& !ereg("member.php", $url) && !ereg("user_multiupload.php", $url) && !ereg("user_categories.php", $url)

changes in 1.02
I made a big mistake in the install_user_categories.php file.
When it created the fields for the user database the field `user_submitted_parent` is suppose to be MEDIUMINT and not TINYINT(1)
I have changed the file to correct the error. You will need to delete the database fields created with the old one and run the new install_user_categories.php file to correct the error or if you know how to go into phpadmin and change the field to the correct fieldtype would be easier. I found it worked fine until you reached 128 for a category number.
Sorry for the oversite...
« Last Edit: July 04, 2010, 09:18:08 PM by budduke »
Buddy Duke
www.budduke.com

Offline Anarchology

  • Jr. Member
  • **
  • Posts: 60
  • I LULZ too much!
    • View Profile
    • Tainted Pix
Re: [MOD] User Categories Area
« Reply #1 on: April 24, 2009, 08:59:11 AM »
This is one whopper of a mod. I'm going to work on this one for my newly created site! It looks great man! I'll post feedback on how it all turns out!

-Anarchology
A personal THANK YOU to all of the great programmers on this site for helping me get my site from something basic to what it is today!

My site: http://taintedpix.com
(warning: some adult content)

Offline Sumale.my

  • Addicted member
  • ******
  • Posts: 1.786
  • Neverdie
    • View Profile
Re: [MOD] User Categories Area
« Reply #2 on: April 24, 2009, 09:07:27 AM »
Können User damit eigene Kategorie erstellen?

Offline budduke

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • http://www.budduke.com
Re: [MOD] User Categories Area
« Reply #3 on: April 24, 2009, 12:11:37 PM »
Können User damit eigene Kategorie erstellen?
The easy answer is Yes,
As an administrator, the last thing I want to do is create folders for each user and then give them rights. So I let PHP do it all for me.
When You give an user right to have an area like this in the admin panel, when they first click on thier user area, the site creates thier category for them and gives them rights and the ability to create/edit/delete categories inside this main category.
That is why I call it User categories, They can not modify any one else's area but their own so it sure has saved me allot of work.

hope it works for you!
Buddy Duke
www.budduke.com

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [MOD] User Categories Area
« Reply #4 on: April 24, 2009, 01:31:18 PM »
@ budduke,

... thanks for this great modification ...
... moved to Mods & Plugins (Releases & Support) ...
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

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

rinaldos

  • Guest
Re: [MOD] User Categories Area
« Reply #5 on: April 24, 2009, 04:55:30 PM »
Hi,
I have tried this mod, but if i kilck on the link "Your User Area",the page directs me to this one

 user_cat.htm?action=createuser

But i did't found that template or the php file :-( Something wrong in your description? Or I have to built in the other two mod's?

Gruß

« Last Edit: April 24, 2009, 05:57:05 PM by rinaldos »

Offline budduke

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • http://www.budduke.com
Re: [MOD] User Categories Area
« Reply #6 on: April 25, 2009, 12:30:52 AM »
Hi,
I have tried this mod, but if i kilck on the link "Your User Area",the page directs me to this one

 user_cat.htm?action=createuser

But i did't found that template or the php file :-( Something wrong in your description? Or I have to built in the other two mod's?

Gruß



Doublecheck the mod, user_cat.htm is from one of the other mods I was playing with at the time but I do not see any reference to it anywhere in my code.
look the the include/pageheader.php file under the userbox insert to make sure you placed it correctly and the template where it is displayed is near the bottom of my insertions.
the template folder/user_logininfo.html file would be where it will call that url the link should sat user_categories.php?action=createuser
Buddy Duke
www.budduke.com

rinaldos

  • Guest
Re: [MOD] User Categories Area
« Reply #7 on: April 25, 2009, 06:27:48 AM »
OK, i will try and recheck all, I answer later what happens :-)
Thanks for the hint ...

gruß
Ingo

Offline 4ella

  • Jr. Member
  • **
  • Posts: 90
    • View Profile
    • http://www.dancersrecruit.com/pictures/
Re: [MOD] User Categories Area
« Reply #8 on: April 25, 2009, 11:17:07 PM »
That's exactly what I was searching for , I will be very happy if i will make it work , I also need some people (dancers - hostesses) to make their own profiles and night clubs to make their portfolios and then I would be happy when they will also have the possibility to edit and delete only theirs cats in their area .Thanks a lot Budduke , I will let you know if i will manage to get to make it work . It will be very helpful to me , Daniel

http://www.dancersrecruit.com/pictures/
4IMAGES 1.7.6 version/default theme
Apache version   2.2.11 (Unix)
PHP version   5.2.9
MySQL version   5.0.75-community-log
Architecture   x86_64
Operating system   Linux

Offline lkl231

  • Pre-Newbie
  • Posts: 2
    • View Profile
Re: [MOD] User Categories Area
« Reply #9 on: April 26, 2009, 01:09:29 PM »
Amazing .....

thanks for sharing it ....

I just have a request.

Since you have tested this mod on a fresh 4images 1.7.6, could you please provide us with a copy of it?

 :wink:

Offline budduke

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • http://www.budduke.com
Re: [MOD] User Categories Area
« Reply #10 on: April 26, 2009, 02:07:20 PM »
Amazing .....

thanks for sharing it ....

I just have a request.

Since you have tested this mod on a fresh 4images 1.7.6, could you please provide us with a copy of it?

 :wink:

You can download version 1.7.6 on the main site...
http://www.4homepages.de/
Buddy Duke
www.budduke.com

Offline lkl231

  • Pre-Newbie
  • Posts: 2
    • View Profile
Re: [MOD] User Categories Area
« Reply #11 on: April 26, 2009, 02:20:12 PM »

You can download version 1.7.6 on the main site...
http://www.4homepages.de/

Oh no ...

I was taking about a copy with your mod installed.

I tried to install the mod twice. However, this error appeared.

Quote
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\localhost\www\4images\admin\categories.php on line 515


I'll be grateful if you can upload version 1.7.6 with the mod.

 :roll:

Offline budduke

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • http://www.budduke.com
Re: [MOD] User Categories Area
« Reply #12 on: April 26, 2009, 07:22:17 PM »

You can download version 1.7.6 on the main site...
http://www.4homepages.de/

Oh no ...

I was taking about a copy with your mod installed.

I tried to install the mod twice. However, this error appeared.

Quote
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\localhost\www\4images\admin\categories.php on line 515


I'll be grateful if you can upload version 1.7.6 with the mod.

 :roll:

I have attached the file with the changed files in my first post in this thread.
I looked around that line number and do not see anything that should have been changed in that area...
If you find the problem and it is something not correct in my instructions, please let me know so I can fix the instructions.
I have followed them twice and they work for me but then again I have been working on this mod for over a month so I may just be overlooking something...

You may want to make sure you are modifying the correct categories.php file. There is one in the admin folder and one in the root. Both have different changes to be made to each of them.
Buddy Duke
www.budduke.com

Offline 4ella

  • Jr. Member
  • **
  • Posts: 90
    • View Profile
    • http://www.dancersrecruit.com/pictures/
Re: [MOD] User Categories Area
« Reply #13 on: May 08, 2009, 12:30:28 AM »
Tomorrow Im going to try to install this for me very useful MOD , I have a question for Budduke , I made my website especially for 3 groups:

1.Dancers                           I would like to let dancers to make their picture portfolio
2.Hostesses                        I would like to let hostesses to make their picture portfolio

and on contrary :
3.NightClubs                       I would like to let NightClubs to make their club portfolio with their subportfolios like subcategory accomodation for girls etc.

I would like to make for everyone their  button:
e.g.:

New Dancer Profile (under category e.g id=500)
New Hostess Profile (under category e.g id=501)
New Club Portfolio (under category e.g id=502)

and lead every button directly to their own tree of categories which would start on Main Category page, I hope that it has to be simple to divide categories in some place in the code rather than to install this mod 3x and somewhere rename it , but i ask you before to make those big changes , would be glad to implement it on the fly , at this moment with your MOD as i understand it good I can only make the ONE User area , if I will have 3 areas immediately , it would save me a lot of time and too many explanations to everyone how to make his own portfolio and not only how but mainly to put it everyone on right place , dont want to mess night clubs with girls but divide them , like this eveyone will only click on his button and they can easily make everything what they want under 3 main categories which i will dedicate only to them .
Hope that you understand . Pls. Let me know if it is possible to create , thanks Daniel


« Last Edit: May 08, 2009, 01:02:54 AM by 4ella »

http://www.dancersrecruit.com/pictures/
4IMAGES 1.7.6 version/default theme
Apache version   2.2.11 (Unix)
PHP version   5.2.9
MySQL version   5.0.75-community-log
Architecture   x86_64
Operating system   Linux

Offline budduke

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • http://www.budduke.com
Re: [MOD] User Categories Area
« Reply #14 on: May 08, 2009, 02:06:19 AM »
to 4ella,
When I first started making this mod I was using group permissions but I was having trouble getting it to work correctly. It seemed to ignore the permissions that I set for the group.
I then read other posts about people having problems getting group permission to work correctly so I bagged it and just stuck with user controls.

I played with a quick test tonight and I think I may still be able to give you what you are wanting,
the only thing, is that everyone has the same permissions that you setup in the config part of user_categories.php file and not the permissions for that group.
The only thing it will be looking at the group permissions for is to see what categorie is that group's parent location. Will that work?
You will have to give me a little time. I have had a bunch of personal stuff crop up that has put me behind some of my other projects.

The only problem I see is with your last request for the clubs having control of areas that their dancers upload pics to... when I am done,
you may have to create a usergroup for each club and set the dancers for that club in the correct group so it will be their upload area but I think it will work...

I see another revision to my code coming....
Buddy Duke
www.budduke.com

 

Post your comments here