Author Topic: Nudity Toggle in User Control panel, Images in Search, Warning under Thumbnail  (Read 13973 times)

0 Members and 1 Guest are viewing this topic.

Offline LadyCherry

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
You can view this working at:
http://rendervisions.com -Click on the galleries link at the top-

1) The first part is creating a warning that an image contains nudity under the thumbnail of that image.
2) The second part is creating a toggle in the Users control panel that allows the user to select yes or no to viewing nudity in the search, categories and details pages of the gallery.
3) The third part is the mod to hide the images that contain nudity if the user has selected No to viewing Nudity in the gallery, in his/her control panel (You must complete step 1 and 2 for this to work).

(Remember its allways good practice to backup the files you are going to modify, just in case you need to restore before your changes)

Part 1
Displaying a Warning message under images that contain nudity.

OPEN: includes/db_field_definitions.php

Near the bottom ADD:
Code: [Select]
$additional_image_fields['Nudity'] = array("Image contains nudity", "radio", 1);
OPEN:  templates/*Your Template*/member_uploadform.html

FIND:
Code: [Select]
            <td class="row2"><b>{lang_image_name}</b></td>
            <td class="row2"><input type="text" name="image_name"  size="30" value="{image_name}" class="input" /></td>
          </tr>

After ADD:
Code: [Select]
            <tr><td class="row1" align="left"><center>
              <div align="left"><u><b>Image Contains</b></u><br>
              </div>
              <div align="left"><u><b> Nudity?</b></u><br>
              </div>
              <div align="left"><font size="1">(shows up under the thumbnail image)</font></div>
</center></td>
            <td align="left" class="row1">
              <div align="left">
              </div>
              <b>Image Contains Nudity</b><br>

-Click below if applicable-<br>


              <div align="left">
              </div>
              <input type="radio" name="Nudity" value="1"> Yes&nbsp;&nbsp;&nbsp;
              <input type="radio" name="Nudity" value="0" checked="checked"> No
<br>


              <div align="left">

              <br>
              <br>
              </div>
</td>
          </tr>

OPEN: templates/*Your Theme*/thumbnail_bit.html

FIND:
Code: [Select]
{if allow_comments}{lang_comments} {image_comments}{endif allow_comments}<br />
After ADD:
Code: [Select]
{if Nudity}<font color=red>Warning: Nudity</font><br>
        {endif Nudity}

Open Your Mysql with something like phpmyadmin.

In the following tables: 4images_images, 4images_images_temp
Add the following fields:

Feild Name: Nudity
Type: TINYINT
Length/Values: 4
Default: 0

Now when your Users go to upload thier image they will have a nudity check box. The user will be able to select yes or no if their image has nudity or not. This will also display a Tag under the thumbnail of the image that says Warning: Nudity if the image contains nudity


Part 2
What I wanted to create was a Yes no toggle in the control panel for users to be able to select yes or no to viewing Nudity in the new images, Categories, and details pages.

I created the toggle in the control for users to select Yes or no to view nudity:

Open: includes/db_field_definitions.php

Near the bottom add:
Code: [Select]
$additional_user_fields['user_gallerynudity'] = array("Show Nudity In Gallery", "radio", 1);

Open: templates/*YourTemplate*/member_editprofile.html

Find
Code: [Select]
          <tr>
            <td class="row1"><b>{lang_invisible}</b></td>
            <td class="row1">
              <input type="radio" name="user_invisible" value="1"{user_invisible_yes} />
              {lang_yes}&nbsp;&nbsp;&nbsp;
              <input type="radio" name="user_invisible" value="0"{user_invisible_no} />
              {lang_no}
                        </td>
          </tr>

After ADD:
Code: [Select]
          <tr>
            <td class="row2"><b>Show Nudity in Gallery</b></td>
            <td class="row2">
              <input type="radio" name="user_gallerynudity" value="1"{user_gallerynudity_yes} />
              {lang_yes}&nbsp;&nbsp;&nbsp;
              <input type="radio" name="user_gallerynudity" value="0"{user_gallerynudity_no} />
              {lang_no}
                        </td>
          </tr>

Next open your MYSQL user table using something like phpmyadmin and add the following field to your 4images_users table:

Feild: user_gallerynudity
Type: TINYINT
Length/Value: 4
Default: 0

Part 3
Hiding the thumbnails of Nude images if the user has selected NO to viewing Nude images in the gallery user control panel.

(I wanted to give a very sincere thank you to V@no for showing me exactly what needed to be done to get this part working. *Thank you V@no!!*)

The search.php file will also hide or unhide nude images in your "New Images" page.

OPEN: search.php

FIND:
Code: [Select]
          WHERE i.image_active = 1
          $sql_where_query
          AND c.cat_id = i.cat_id AND i.cat_id IN ($cat_id_sql)

After ADD:
Code: [Select]
".(($user_info['user_gallerynudity']) ? "" : " AND i.Nudity <> 1")."
END RESULT WILL LOOK LIKE:
Code: [Select]
  $sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
          FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c
        LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
          WHERE i.image_active = 1
          $sql_where_query
          AND c.cat_id = i.cat_id AND i.cat_id IN ($cat_id_sql)".(($user_info['user_gallerynudity']) ? "" : " AND i.Nudity <> 1")."
          ORDER BY ".$config['image_order']." ".$config['image_sort']."
          LIMIT $offset, $perpage";

OPEN: categories.php

FIND:
Code: [Select]
        WHERE i.image_active = 1 AND i.cat_id = $cat_id AND c.cat_id = i.cat_id
After ADD:
Code: [Select]
".(($user_info['user_gallerynudity']) ? "" : " AND i.Nudity <> 1")."
END Result will Look Like:
Code: [Select]
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
        FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c
        LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
        WHERE i.image_active = 1 AND i.cat_id = $cat_id AND c.cat_id = i.cat_id ".(($user_info['user_gallerynudity']) ? "" : " AND i.Nudity <> 1")."
        ORDER BY ".$config['image_order']." ".$config['image_sort']."
        LIMIT $offset, $perpage";

OPEN: index.php

FIND:
Code: [Select]
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")
After ADD:
Code: [Select]
".(($user_info['user_gallerynudity']) ? "" : " AND i.Nudity <> 1")."
End result will Look Like:
Code: [Select]
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
        FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c
        LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")".(($user_info['user_gallerynudity']) ? "" : " AND i.Nudity <> 1")."
        ORDER BY i.image_date DESC
        LIMIT $num_new_images";

Save all files and exit.

Again I wanted to thank you V@no for your help, I couldnt have completed Part 3 without you!

I hope this helps anyone out there that needs to exclude images when a user selects to in the user control panel.

Thank you
-Lady Cherry



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
You will need use Nudity <> 1 in the mysql queries  (I also suggest you not use capital letters in field names) ...and unfrotunetly there are alot of them needs to be changed...
i.e. in categories.php query looks like this:
Quote
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
        FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c
        LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
        WHERE i.image_active = 1 AND i.cat_id = $cat_id AND c.cat_id = i.cat_id
        ORDER BY ".$config['image_order']." ".$config['image_sort']."
        LIMIT $offset, $perpage";
Then end result should looks like this:
Quote
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
        FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c
        LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
        WHERE i.image_active = 1 AND i.cat_id = $cat_id AND c.cat_id = i.cat_id".(($user_info['user_gallerynudity']) ? "AND i.Nudity <> 1" : "")."
        ORDER BY ".$config['image_order']." ".$config['image_sort']."
        LIMIT $offset, $perpage";

Hope you got the idea ;)
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 TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Or, if I may add, rather than simply doing it with $additional_user_fields, you could always do it with check_permission function.

For instance, if you add a group field name inside your SQL GROUP_TABLE, you could assign this permission (or not) into the appropriate action.

Example :

Quote

if (!check_permission("auth_nudity", $cat_id)) {
header ("Location: ".$site_sess->url(ROOT_PATH."index.php", "&"));
exit;
} ###### End of if statement.


Is this something like you were looking for to do ? ;)

Offline LadyCherry

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
Ok so in the search.php I replace:
Code: [Select]
          WHERE i.image_active = 1
          $sql_where_query
          AND c.cat_id = i.cat_id AND i.cat_id IN ($cat_id_sql)
          ORDER BY ".$config['image_order']." ".$config['image_sort']." 


With:
Code: [Select]
          WHERE i.image_active = 1
          $sql_where_query
          AND c.cat_id = i.cat_id AND i.cat_id ".(($user_info['user_gallerynudity']) ? "AND i.Nudity <> 1" : "")." IN ($cat_id_sql)
          ORDER BY ".$config['image_order']." ".$config['image_sort']."

It seems to have no effect on the nude images is there something I am missing still?

-Lady Cherry

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
1) did you try my example and did it work? if you didnt, then perhaps you should do that before you do something else.
2) you must insert the new code at the end of WHERE part of the query but what you did - inserting it in the middle - might break the whole query. In your case if you didnt see any error messages, then either $user_info['user_gallerynudity'] is empty or contains 0 otherwise you should see mysql error message, because you added the new code in the wrong place.
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 LadyCherry

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
Hi Vano.

In your example you do not have this:
Code: [Select]
IN ($cat_id_sql)
Did you purposly remove that?

It is odd that I dont get a SQL error.

In Fact I just realized that if I set Nudity to Yes in the user control panel ALL I see is nude images lol.

Any ideas on why that is?

Also Are you missing something from this:

Code: [Select]
(($user_info['user_gallerynudity']) ? "AND i.Nudity <> 1" : "")
Shouldnt it be something like this statement?:
Code: [Select]
(($user_info['user_gallerynudity'] == 1) ? "AND i.Nudity <> 1" : "")
Thanks for your time

-Lady Cherry

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
1) in MySQL as in most of the program languages the condition can have more then one codition parameter (probably in english there is a better way to call these things, but I dont know...). Each condition parameter can be separated by AND or OR depence on the situation and the needed result. So, just look at the original query and compare with the changed one.

2) use this condition instead:
Code: [Select]
(($user_info['user_gallerynudity']) ? "" : "AND i.Nudity <> 1") this should be the way you wanted it to ;)
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 LadyCherry

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
Im sort of new and I appreciate your help very much so.

I get the following error with that line of code:

Code: [Select]
parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
Thank you again for all of your patience.

-Lady Cherry

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
I get the following error with that line of code:
then you inserted it wrong...cant really help you without seeing the line, right?
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 LadyCherry

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
Opps Sorry V@no I should have posted how I put the line in.

Dont laugh if im completely wrong Im very new to this.

Code: [Select]
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
          FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c
        LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
          WHERE i.image_active = 1
          $sql_where_query
          AND c.cat_id = i.cat_id AND i.cat_id (($user_info['user_gallerynudity']) ? "" : "AND i.Nudity <> 1") IN ($cat_id_sql)
          ORDER BY ".$config['image_order']." ".$config['image_sort']."
          LIMIT $offset, $perpage";
  $result = $site_db->query($sql);

  $thumbnails = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">\n";

Thank You for all of your help hun I appreicate it,

-Lady Cherry

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
Code: [Select]
          AND c.cat_id = i.cat_id AND i.cat_id IN ($cat_id_sql)".(($user_info['user_gallerynudity']) ? "" : " AND i.Nudity <> 1")."
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 LadyCherry

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
Oh My!! You are my GOD V@no!!

*Hugs and Kisses*

It looks like its working!!

I also did this to the categories.php and it works too!

I will add that to my tutorial at the top if its ok with you?

-Lady Cherry

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
I will add that to my tutorial at the top if its ok with you?
Why would I be? ;)

P.S. since in the database only stored 0 or 1, you could save some space by using TINYINT(1) instead of TINYINT(4) type of field ;)
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 MaskimXul

  • Pre-Newbie
  • Posts: 2
    • View Profile
I like this, but how would I only display a nudity tag?