4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: V@no on May 02, 2005, 08:29:02 AM

Title: [MOD] Categories upload dropdown form
Post by: V@no on May 02, 2005, 08:29:02 AM
As many of you know 4images has a build-in categories dropdown form on upload page if u access it without specifying a category id (http://example.com/4images/member.php?action=uploadform)
Its all good, but if u have different upload permissions for the categories, visitor might get upset if they select a category, select a file, hit upload button and see error messages that sais "you dont have permission to upload in that category"... In other words, the build-in dropdown form does not show which category is allowed for uploading.

This mod will fix that issue, it will show in different colors the categories with upload permissions and without:
(http://img68.echo.cx/img68/5797/upload21on.png)



--------- [ Changed files ] -----------

member.php
includes/functions.php
templates/<your template>/style.css
templates/<your template>/member_uploadform.html
(optional)



----------- [ Installation ] -------------

Step 1
Open member.php
Find:
Code: [Select]
    "cat_name" => ($cat_id != 0) ? htmlspecialchars($cat_cache[$cat_id]['cat_name']) : get_category_dropdown($cat_id),Replace it with:
Code: [Select]
/*
  MOD UPLOAD CATEGORIES DROPDOWN
  ORIGINAL LINE:
    "cat_name" => ($cat_id != 0) ? htmlspecialchars($cat_cache[$cat_id]['cat_name']) : get_category_dropdown($cat_id),
*/
/*
  MOD UPLOAD CATEGORIES DROPDOWN
  BEGIN REPLACE
*/
//    "cat_name" => get_category_dropdown_upload($cat_id),
    "cat_name" => ($cat_id != 0 && (!isset($HTTP_POST_VARS['showdropdown']))) ? htmlspecialchars($cat_cache[$cat_id]['cat_name']) : get_category_dropdown_upload($cat_id)."<input type=\"hidden\" name=\"showdropdown\" value=\"1\">",
    "cat_name_required" => addslashes(preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['category']), $lang['field_required'])),
/*
  MOD UPLOAD CATEGORIES DROPDOWN
  END REPLACE
*/



Step 2
Open includes/functions.php
At the end, above closing ?> insert:
Code: [Select]
/*
  MOD UPLOAD CATEGORIES DROPDOWN
  BEGIN INSERT
*/
function get_category_dropdown_upload_bits($cat_id = 0, $cid = 0, $depth = 1)
{
  global $site_db, $drop_down_cat_cache, $cat_cache, $config;

  if (!isset($drop_down_cat_cache[$cid]))
  {
    return "";
  }
  $category_list = "";
  foreach ($drop_down_cat_cache[$cid] as $key => $category_id)
  {
    if (check_permission("auth_viewcat", $category_id))
    {
      if (check_permission("auth_upload", $category_id))
      {
        $disable = 0;
      }
      else
      {
        $disable = 1;
      }
      $category_list .= "<option value=\"".(($disable) ? 0 : $category_id)."\"";
      if ($cat_id == $category_id)
      {
        $category_list .= " selected=\"selected\"";
      }
      if ($disable)
      {
        if (($cat_cache[$category_id]['cat_parent_id'] == 0))
        {
          $category_list .= " class=\"dropdowndisable\""; //upload not avalable and this is a main category
        }
        else
        {
          $category_list .= " class=\"dropdowndisable\""; //upload not avalable
        }
      }
      else
      {
        if (($cat_cache[$category_id]['cat_parent_id'] == 0))
        {
//          $category_list .= " class=\"dropdownmarker\""; //upload avalable and this is a main category
        }
        else
        {
//        $category_list .= " class=\"dropdownok\""; //upload avalable
        }
      }

//      $category_list .= ">".(($disable) ? "- " : "+ ");
      $category_list .= ">";
      if ($depth > 1)
      {
        $category_list .= str_repeat("--", $depth - 1)." ";
      }
      $category_list .= $cat_cache[$category_id]['cat_name']."</option>\n";
      $category_list .= get_category_dropdown_upload_bits($cat_id, $category_id, $depth + 1);
    }
  }
  unset($drop_down_cat_cache[$cid]);
  return $category_list;
}
function get_category_dropdown_upload($cat_id = 0)
{
  global $lang, $drop_down_cat_cache, $cat_parent_cache;
  $category = "\n<select name=\"cat_id\" class=\"categoryselect\">\n";
  $category .= "<option value=\"0\">".$lang['select_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_upload_bits($cat_id);
  $category .= "</select>\n";
  return $category;
}
/*
  MOD UPLOAD CATEGORIES DROPDOWN
  END INSERT
*/



Step 3
Open templates/<your template>/style.css
Add this block:
Code: [Select]
/* parent category, not allowed upload */
.dropdownmarkerdisable {
  font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
  background-color: #EEEEEE;
  color: #A7A7A7;
  font-size: 11px;
}

/* child category, not allowed upload */
.dropdowndisable {
  font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
  color: #BEBEBE;
  font-size: 11px;
}

/* child category, allowed upload */
.dropdownok {
  font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
  color: #136c99;
  font-size: 11px;
}
(the style is based on default template)



Step 4
This is an optional step. It will show an alert message if visitor selected a category where they are not allowed upload in to.
Open templates/<your template>/member_uploadform.html
Insert inside <form> this:
Code: [Select]
onsubmit="if(cat_id.value==0){alert('{cat_name_required}');return false;}"In the default template the result would be the following:
Quote
<form method="post" action="{url_member}" enctype="multipart/form-data" onsubmit="if(cat_id.value==0){alert('{cat_name_required}');return false;} uploadbutton.disabled=true;">



--------- [ Tweaks ] ----------



NOTE:
Opera users will see dropdown with one color, because Opera does not support style for individual items in the dropdown.
Title: Re: [MOD] Categories upload dropdown form
Post by: vanish on May 02, 2005, 01:38:00 PM
Step 4 don't working. Alert never shown...
This code is right:
Code: [Select]
onsubmit="if (cat_id.options[cat_id.selectedIndex].value==0){ alert('{cat_name_required}'); return false;} uploadbutton.disabled=true;"
Title: Re: [MOD] Categories upload dropdown form
Post by: ascanio on May 03, 2005, 06:19:18 AM
Quote
It will show an alert message if visitor selected a category where they are not allowed upload in to.

I don't  see any alert  :roll: :roll:  :?:
Title: Re: [MOD] Categories upload dropdown form
Post by: V@no on May 03, 2005, 06:51:30 AM
yes, vanish, thank you.
my JS knowlege is very limited, but this also worked fine in my tests:
Code: [Select]
onSubmit="if(cat_id.value==0){alert('{cat_name_required}');return false;}"
Step 4 is updated.
Title: Re: [MOD] Categories upload dropdown form
Post by: ascanio on May 03, 2005, 07:22:00 AM
I have update step 4 and i still don see the message http://69.56.196.226/~ascanio/member.php?action=uploadform
Title: Re: [MOD] Categories upload dropdown form
Post by: vanish on May 03, 2005, 09:41:47 AM
V@no, you have made misprint:
Quote
onsubmit="if(cat_id.value==0){alert('{cat_name_required}');return false;} return false;} uploadbutton.disabled=true;"
and ascanio paste this code in his page...
Title: Re: [MOD] Categories upload dropdown form
Post by: ascanio on May 03, 2005, 04:23:46 PM
where it is supose to apear the alert message cuz i don't see anything :S
Title: Re: [MOD] Categories upload dropdown form
Post by: vanish on May 03, 2005, 09:47:01 PM
Right is:
Code: [Select]
onsubmit="if (cat_id.value==0){ alert('{cat_name_required}'); return false;} uploadbutton.disabled=true;"
or
Code: [Select]
onsubmit="if (cat_id.options[cat_id.selectedIndex].value==0){ alert('{cat_name_required}'); return false;} uploadbutton.disabled=true;"
Title: Re: [MOD] Categories upload dropdown form
Post by: himu on March 03, 2006, 06:52:35 AM
Hey V@no,
After installing this MOD
i am having following problem.. although the function "image upload" and "category dropdown" is working properly ...
check the attached file:
if i choose following settings, i only get this error if i choose member.php?action=uploadform:
Quote
//    "cat_name" => get_category_dropdown_upload($cat_id),
    "cat_name" => ($cat_id != 0 && (!isset($HTTP_POST_VARS['showdropdown']))) ? htmlspecialchars($cat_cache[$cat_id]['cat_name']) : get_category_dropdown_upload($cat_id)."<input type=\"hidden\" name=\"showdropdown\" value=\"1\">",
but member.php?action=uploadform&cat_id=37 does not show this error.
BUT if i choose following settings, i get this error for both the options:
Quote
    "cat_name" => get_category_dropdown_upload($cat_id),
//    "cat_name" => ($cat_id != 0 && (!isset($HTTP_POST_VARS['showdropdown']))) ? htmlspecialchars($cat_cache[$cat_id]['cat_name']) : get_category_dropdown_upload($cat_id)."<input type=\"hidden\" name=\"showdropdown\" value=\"1\">",

HELP  :( :oops:
Title: Re: [MOD] Categories upload dropdown form
Post by: V@no on March 03, 2006, 07:15:58 AM
And what if you replace
Code: [Select]
      $category_list .= $cat_cache[$category_id]['cat_name']."</option>\n";with:
Code: [Select]
      $category_list .= str_replace("\"", "&quot;", str_replace("<", "&lt;", str_replace(">", "&gt;", $cat_cache[$category_id]['cat_name'])))."</option>\n";
Title: Re: [MOD] Categories upload dropdown form
Post by: himu on March 03, 2006, 07:33:33 AM
That's in function.php .. the problem might be in member.php  :?:
anyway still no change ...  :(

And what if you replace
Code: [Select]
      $category_list .= $cat_cache[$category_id]['cat_name']."</option>\n";with:
Code: [Select]
      $category_list .= str_replace("\"", "&quot;", str_replace("<", "&lt;", str_replace(">", "&gt;", $cat_cache[$category_id]['cat_name'])))."</option>\n";
Title: Re: [MOD] Categories upload dropdown form
Post by: himu on March 04, 2006, 07:44:01 AM
V@no,

I also see following stuff in the Title bar:
Please Help...  :cry:
Title: Re: [MOD] Categories upload dropdown form
Post by: webslingers on April 19, 2006, 11:49:17 PM
In step 1 it says to search for:
"cat_name" => ($cat_id != 0) ? htmlspecialchars($cat_cache[$cat_id]['cat_name']) : get_category_dropdown($cat_id),

but I have:
"cat_name" => ($cat_id != 0) ? format_text($cat_cache[$cat_id]['cat_name']) : get_category_dropdown($cat_id

What should I do about this?

Thanks
Title: Re: [MOD] Categories upload dropdown form
Post by: V@no on April 20, 2006, 01:24:09 AM
just replace it with the new block of code and then replace htmlspecialchars with format_text
Title: Re: [MOD] Categories upload dropdown form
Post by: sy4k4 on July 25, 2006, 12:37:59 AM
i have error message

Please fill out the Category field!

4images 1.72
Title: Re: [MOD] Categories upload dropdown form
Post by: V@no on July 25, 2006, 12:48:55 AM
i have error message

Please fill out the Category field!

4images 1.72
Using custom template?
make sure you have this patch applyed:
http://www.4homepages.de/forum/index.php?topic=5935.0
Title: Re: [MOD] Categories upload dropdown form
Post by: sy4k4 on July 26, 2006, 12:38:24 AM
 :D :D :D .... thanks v@no
Title: Re: [MOD] Categories upload dropdown form
Post by: terryjianlin on August 21, 2006, 11:14:52 PM
V@no,
I am confuse, there is no drop down form on my member upload form.  still display category name on that filed. Am I missed something? or {cat_name} on member upload form have to replace with some else?
Title: Re: [MOD] Categories upload dropdown form
Post by: V@no on August 22, 2006, 07:02:42 AM
It doesnt show dropdown (without the tweek at the end of the post) if cat_id specifyed in the url.
Title: Re: [MOD] Categories upload dropdown form
Post by: jackald on September 25, 2006, 03:37:43 PM
Is it compatible with 1.7.3 i edited member.php and i cant find

"cat_name" => ($cat_id != 0) ? htmlspecialchars($cat_cache[$cat_id]['cat_name']) : get_category_dropdown($cat_id),

Title: Re: [MOD] Categories upload dropdown form
Post by: JensF on February 03, 2007, 05:54:04 PM
Hey V@no,
After installing this MOD
i am having following problem.. although the function "image upload" and "category dropdown" is working properly ...
check the attached file:
if i choose following settings, i only get this error if i choose member.php?action=uploadform:
Quote
//    "cat_name" => get_category_dropdown_upload($cat_id),
    "cat_name" => ($cat_id != 0 && (!isset($HTTP_POST_VARS['showdropdown']))) ? htmlspecialchars($cat_cache[$cat_id]['cat_name']) : get_category_dropdown_upload($cat_id)."<input type=\"hidden\" name=\"showdropdown\" value=\"1\">",
but member.php?action=uploadform&cat_id=37 does not show this error.
BUT if i choose following settings, i get this error for both the options:
Quote
    "cat_name" => get_category_dropdown_upload($cat_id),
//    "cat_name" => ($cat_id != 0 && (!isset($HTTP_POST_VARS['showdropdown']))) ? htmlspecialchars($cat_cache[$cat_id]['cat_name']) : get_category_dropdown_upload($cat_id)."<input type=\"hidden\" name=\"showdropdown\" value=\"1\">",

HELP  :( :oops:

HI,

i have the same problem with the 1.7.4 Version. Can anyone say me what is wrong here????
Title: Re: [MOD] Categories upload dropdown form
Post by: Acidgod on February 03, 2007, 06:03:07 PM
Schicke mir mal einen FTP Zugang und einen Test User per PN...
Title: Re: [MOD] Categories upload dropdown form
Post by: glitzer on October 26, 2007, 11:41:02 AM
Hi!

Sorry for the stupid question, but i donīt have a dropdown in my member_upload file.

Where can i get it?

thank you
Title: Re: [MOD] Categories upload dropdown form
Post by: thunderstrike on October 26, 2007, 12:08:40 PM
"cat_name" => ($cat_id != 0) ? htmlspecialchars($cat_cache[$cat_id]['cat_name']) : get_category_dropdown($cat_id),

Please change this to:

Code: [Select]
"cat_name" => ($cat_id != 0) ? format_text(trim($cat_cache[$cat_id]['cat_name']), 2) : get_category_dropdown($cat_id),

Hi!

Sorry for the stupid question, but i donīt have a dropdown in my member_upload file.

Where can i get it?

thank you

From ... 1st post ? ...
Title: Re: [MOD] Categories upload dropdown form
Post by: __G__ on February 12, 2009, 08:15:35 PM
Hi i really need this so i can put a link rite on home page to upload page with categ drop down list im running 1.7.6 but on the very first step the orignal line i have is


    "cat_name" => ($cat_id != 0) ? format_text($cat_cache[$cat_id]['cat_name'], 2) : get_category_dropdown($cat_id),
 

This

and the one we should search is     "cat_name" => ($cat_id != 0) ? htmlspecialchars($cat_cache[$cat_id]['cat_name']) : get_category_dropdown($cat_id),

i m not sure if this is gonna work with 1.7.6 does anyone has try this on 1.7.6 or if there is a easy way to create an extra template page that i can make like a form with drop down list of categorieis and give a link to that page in my home page so people can upload images from that page :D
Title: Re: [MOD] Categories upload dropdown form
Post by: __G__ on February 12, 2009, 09:04:34 PM
i figured it out thanks guys and yes it works with 1.7.6


all i did was in first step i replaced it like this

Quote
/*
  MOD UPLOAD CATEGORIES DROPDOWN
  ORIGINAL LINE:
    "cat_name" => ($cat_id != 0) ? format_text($cat_cache[$cat_id]['cat_name'], 2) : get_category_dropdown($cat_id),
*/
/*
  MOD UPLOAD CATEGORIES DROPDOWN
  BEGIN REPLACE
*/
//    "cat_name" => get_category_dropdown_upload($cat_id),
    "cat_name" => ($cat_id != 0 && (!isset($HTTP_POST_VARS['showdropdown']))) ? format_text($cat_cache[$cat_id]['cat_name'], 2) : get_category_dropdown_upload($cat_id)."<input type=\"hidden\" name=\"showdropdown\" value=\"1\">",
    "cat_name_required" => addslashes(preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['category']), $lang['field_required'])),
/*
  MOD UPLOAD CATEGORIES DROPDOWN
  END REPLACE
*/
Title: Re: [MOD] Categories upload dropdown form
Post by: __G__ on February 12, 2009, 09:25:27 PM
ok everything works but now if someone try to click direct on  http://www.yoursite.com/member.php?action=uploadform if the person is not logged in the page still shows so can we edit the code somehow so when person is not logged in it redirects to the login page or something :D
Title: Re: [MOD] Categories upload dropdown form
Post by: V@no on February 13, 2009, 01:44:29 AM
in member.php find:
if ($action == "uploadform") {
  if ($cat_id != 0 && (!isset($cat_cache[$cat_id]) || !check_permission("auth_upload", $cat_id))) {

Replace with:
if ($action == "uploadform") {
  if (($cat_id != 0 && (!isset($cat_cache[$cat_id]) || !check_permission("auth_upload", $cat_id))) || $user_info['user_level'] < USER) {
Title: Re: [MOD] Categories upload dropdown form
Post by: __G__ on February 13, 2009, 02:10:41 AM
thanks v@no quick question after doing this code when i click submit that's when it says you are not logged in is that's how it suppose to work, cause i thought it wont even show the upload forum and it will just tell use to first login before even they see the upload form BTW thanks though even if this doesn't happen atleast now it does say to login after clicking submit when guest try to upload :D
Title: Re: [MOD] Categories upload dropdown form
Post by: V@no on February 13, 2009, 02:15:14 AM
ops, that was my bad, in the first line supposed to be "uploadform" and not "uploadimage".
I've corrected my post above.
Title: Re: [MOD] Categories upload dropdown form
Post by: __G__ on February 13, 2009, 02:56:42 AM
works like a charm thanks v@no
Title: Re: [MOD] Categories upload dropdown form
Post by: marw on March 15, 2009, 01:50:10 PM
And what about warning when user dont choose a cattegory?

I have javascript window without text now...
Title: Re: [MOD] Categories upload dropdown form
Post by: komsho24 on March 19, 2009, 11:23:18 AM
Hi,

V@no i have problem.. when i use standard url.. to upload file with dropdown form..

i mean "http://www.yoursite.com/member.php?action=uploadform" .. when i select category, select file and click on UPLOAD button.. i have error message. This is for language main file.. -> "$lang['field_required'] = "Please fill out the {field_name} field!";"


So how i can fix this ?


Thank you !
Title: Re: [MOD] Categories upload dropdown form
Post by: V@no on March 19, 2009, 02:00:03 PM
what error message exactly?

also check out this bug fix:

[1.7] Can not upload images when no cat_id specified (http://www.4homepages.de/forum/index.php?topic=5935.0)
Title: Re: [MOD] Categories upload dropdown form
Post by: Lesik on August 02, 2009, 10:28:17 AM
Hey V@no,
After installing this MOD
i am having following problem.. although the function "image upload" and "category dropdown" is working properly ...
check the attached file:
if i choose following settings, i only get this error if i choose member.php?action=uploadform:
Quote
//    "cat_name" => get_category_dropdown_upload($cat_id),
    "cat_name" => ($cat_id != 0 && (!isset($HTTP_POST_VARS['showdropdown']))) ? htmlspecialchars($cat_cache[$cat_id]['cat_name']) : get_category_dropdown_upload($cat_id)."<input type=\"hidden\" name=\"showdropdown\" value=\"1\">",
but member.php?action=uploadform&cat_id=37 does not show this error.
BUT if i choose following settings, i get this error for both the options:
Quote
    "cat_name" => get_category_dropdown_upload($cat_id),
//    "cat_name" => ($cat_id != 0 && (!isset($HTTP_POST_VARS['showdropdown']))) ? htmlspecialchars($cat_cache[$cat_id]['cat_name']) : get_category_dropdown_upload($cat_id)."<input type=\"hidden\" name=\"showdropdown\" value=\"1\">",

HELP  :( :oops:

HI,

i have the same problem with the 1.7.4 Version. Can anyone say me what is wrong here????

sorry my english
maybe, see in header.html delet in string  <meta name="keywords" content="{cat_name}">
Title: Re: [MOD] Categories upload dropdown form
Post by: Rinner on August 12, 2009, 06:04:05 PM
Hi! How can i make link http://example.com/4images/member.php?action=uploadform visible only for registered users?
Title: Re: [MOD] Categories upload dropdown form
Post by: mawenzi on August 12, 2009, 06:25:26 PM
Hello Rinner and welcome to 4images forum ...

... use it as following in your templates ...
Code: [Select]
{if user_loggedin}
<a href="http://example.com/4images/member.php?action=uploadform">Member Uploadform</a>
{endif user_loggedin}
Title: Re: [MOD] Categories upload dropdown form
Post by: Rinner on August 12, 2009, 06:43:30 PM
Thank you !
Title: Re: [MOD] Categories upload dropdown form
Post by: komsho24 on April 03, 2010, 12:16:10 AM
I have version 1.7.4 and i try everything .. but not work..

Actually, i only see new colour in category list, who have permission.. and nothing else..

This code not work when i select category with permission:

onsubmit="if(cat_id.value==0){alert('{cat_name_required}');return false;}"

One more thing ..

Is it possible to do, that normal user can't see categories (who don't have permission for upload) on category dropdown list ?

Thank you !
Title: Re: [MOD] Categories upload dropdown form
Post by: V@no on April 03, 2010, 04:12:55 AM
Is it possible to do, that normal user can't see categories (who don't have permission for upload) on category dropdown list ?

In step 2 find
        $disable = 1;

Insert above:
        continue;
Title: Re: [MOD] Categories upload dropdown form
Post by: henary on December 16, 2010, 04:19:15 PM
Hello,

i've just tested to use this in my fresh 1.7.9, but dosn't work.

To find out any problem i've gone back to default memberupload and find out:

Upload by using member.php?action=uploadform without cat_id every time send error "Please fill out the category field!" - but i did  :wink:

EDIT: I'm sorry, i've find this: http://www.4homepages.de/forum/index.php?topic=5935.0 some lines above. Today i'm without DSL, only 64kbit and i'm slow even in mind  :wink:

I'm confused  :? I'm fine  :mrgreen:
Henry
Title: Re: [MOD] Categories upload dropdown form
Post by: chrissim on December 06, 2011, 01:59:57 PM
hi

Does this mod work on new version 1.7.10

i installed them but it seem not working. i tested the upload and it works fine but in the admin it doesn't showed any new images for validation