4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started 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: "cat_name" => ($cat_id != 0) ? htmlspecialchars($cat_cache[$cat_id]['cat_name']) : get_category_dropdown($cat_id),
Replace it with:/*
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:
/*
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:/* 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:onsubmit="if(cat_id.value==0){alert('{cat_name_required}');return false;}"
In the default template the result would be the following:<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 ] ----------
- If you would like to see categories dropdown even if a category id specifyed (http://example.com/4images/member.php?action=uploadform&cat_id=123) then in Step 1 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\">",
With this: "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\">",
- If you would like see different styles for allowed upload parent categories and allowed upload child categories (subcategories), uncomment commented lines in Step 2 (read the comments for more info which line uses when)
NOTE:
Opera users will see dropdown with one color, because Opera does not support style for individual items in the dropdown.
-
Step 4 don't working. Alert never shown...
This code is right:
onsubmit="if (cat_id.options[cat_id.selectedIndex].value==0){ alert('{cat_name_required}'); return false;} uploadbutton.disabled=true;"
-
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: :?:
-
yes, vanish, thank you.
my JS knowlege is very limited, but this also worked fine in my tests:
onSubmit="if(cat_id.value==0){alert('{cat_name_required}');return false;}"
Step 4 is updated.
-
I have update step 4 and i still don see the message http://69.56.196.226/~ascanio/member.php?action=uploadform
-
V@no, you have made misprint:
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...
-
where it is supose to apear the alert message cuz i don't see anything :S
-
Right is:
onsubmit="if (cat_id.value==0){ alert('{cat_name_required}'); return false;} uploadbutton.disabled=true;"
or
onsubmit="if (cat_id.options[cat_id.selectedIndex].value==0){ alert('{cat_name_required}'); return false;} uploadbutton.disabled=true;"
-
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:
// "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:
"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:
-
And what if you replace
$category_list .= $cat_cache[$category_id]['cat_name']."</option>\n";
with: $category_list .= str_replace("\"", """, str_replace("<", "<", str_replace(">", ">", $cat_cache[$category_id]['cat_name'])))."</option>\n";
-
That's in function.php .. the problem might be in member.php :?:
anyway still no change ... :(
And what if you replace $category_list .= $cat_cache[$category_id]['cat_name']."</option>\n";
with: $category_list .= str_replace("\"", """, str_replace("<", "<", str_replace(">", ">", $cat_cache[$category_id]['cat_name'])))."</option>\n";
-
V@no,
I also see following stuff in the Title bar:
Please Help... :cry:
-
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
-
just replace it with the new block of code and then replace htmlspecialchars with format_text
-
i have error message
Please fill out the Category field!
4images 1.72
-
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
-
:D :D :D .... thanks v@no
-
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?
-
It doesnt show dropdown (without the tweek at the end of the post) if cat_id specifyed in the url.
-
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),
-
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:
// "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:
"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????
-
Schicke mir mal einen FTP Zugang und einen Test User per PN...
-
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
-
"cat_name" => ($cat_id != 0) ? htmlspecialchars($cat_cache[$cat_id]['cat_name']) : get_category_dropdown($cat_id),
Please change this to:
"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 ? ...
-
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
-
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
/*
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
*/
-
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
-
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) {
-
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
-
ops, that was my bad, in the first line supposed to be "uploadform" and not "uploadimage".
I've corrected my post above.
-
works like a charm thanks v@no
-
And what about warning when user dont choose a cattegory?
I have javascript window without text now...
-
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 !
-
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)
-
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:
// "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:
"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}">
-
Hi! How can i make link http://example.com/4images/member.php?action=uploadform visible only for registered users?
-
Hello Rinner and welcome to 4images forum ...
... use it as following in your templates ...
{if user_loggedin}
<a href="http://example.com/4images/member.php?action=uploadform">Member Uploadform</a>
{endif user_loggedin}
-
Thank you !
-
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 !
-
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;
-
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
-
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