Author Topic: [MOD] User GIS  (Read 88261 times)

0 Members and 1 Guest are viewing this topic.

Offline brandkanne

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
    • http://www.jan-hendrik.com
[MOD] User GIS
« on: June 02, 2003, 02:12:19 PM »
be sure BACKUP your data first at all !!!!!!!
-------------------------------------------------

Mini MOD: User Gender Info Signs


Hi,

this is my first Mini MOD posting, so please don't hit me, if something wrong...

I add some user gender information like this:

Name1
Name2


Ok, here is the code:

Step 1
Code: [Select]
Add a new field "user_sex" in "4images_users" table
Step 1a!
At first setup, you must edit for each existing user the user_sex field by hand with m or w
i hope your database is not so huge :oops: (m=male, w=female)


Step 2
Open db_field_definitions.php

find
Code: [Select]
?>
add above
Code: [Select]
$additional_user_fields['user_sex'] = array($lang['user_sex'], "radio", 1);
Step 3
Open register_form.html

find
Code: [Select]
<form method="POST" action="{url_register}">
<table>

add after
Code: [Select]
         <tr>
            <td class="row1"><font size=-1> <b>Gender:</b></td>
            <td class="row1">
<font size=-1>
              <input type="radio" name="user_sex" value="m" checked />
              male&nbsp;&nbsp;&nbsp;
              <input type="radio" name="user_sex" value="w" />
              female</font>

</td>
          </tr>


Step 4
Save and   from here

Step 5
Upload these two images to your default template directory

Step 6
Open member_profile.html

find
Code: [Select]
{user_name}
add after
Code: [Select]
<img src="templates/default/images/{user_sex}.gif">

I thing you can repeat Step 6 on any template file...


I guess thats all!



But if you use MOD Memberlist, try this too:

Step 7
find
Code: [Select]
               case 'user_joindate':
                        $order_by = "user_joindate $sort_order";
                        break;

add above
Code: [Select]
               case 'user_sex':
                        $order_by = "user_sex $sort_order";
                        break;


Step 8
find
Code: [Select]
                       $order_by = "user_name $sort_order";

replace with
Code: [Select]
                       $order_by = "user_sex $sort_order";

Step 9
find
Code: [Select]
 while ($user_row = $site_db->fetch_array($result)){
  $user_id = "";

add after
Code: [Select]
                     $user_sex = "";
Step 10
find a few lines below
Code: [Select]
$user_homepage = (isset($user_row['user_homepage'])) ? format_url($user_row['user_homepage']) : REPLACE_EMPTY;

add above
Code: [Select]
                    $user_sex = "<img src=\"templates/default/images/".htmlspecialchars($user_row['user_sex']).".gif\">".$var_name." ";



Step 11
find a few lines below
Code: [Select]
    $userlist .= "<td valign=\"top\" align=\"left\">".$session_ip." ".$user_name."</td>\n";

replace with
Code: [Select]
   $userlist .= "<td valign=\"top\" align=\"left\">".$session_ip." ".$user_name." ".$user_sex."</td>\n";


I guess i forgot nothing... i hope so
be sure BACKUP your data first at all !!!!!!!
« Last Edit: July 25, 2011, 07:21:46 PM by Rembrandt »
I do not have anything against it, if you try all possible out on my side, but please announce you on not with TESTACCOUNT's to test purposes... Thank you for the understanding.

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
Mini MOD: User GIS
« Reply #1 on: June 02, 2003, 10:04:44 PM »
very nice! good job!

maybe good idea support this too:
;) u never know :D

P.S. moving this MOD into MODs forum ;)
« Last Edit: April 07, 2005, 06:52:43 AM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline brandkanne

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
    • http://www.jan-hendrik.com
Mini MOD: User GIS
« Reply #2 on: June 02, 2003, 10:29:57 PM »
:oops: maybe, maybe...


New additional...

Step 3
Save this sign too ()
Open register_form.html

find
Code: [Select]
<form method="POST" action="{url_register}">
<table>

add after
Code: [Select]
         <tr>
            <td class="row1"><font size=-1> <b>Gender:</b></td>
            <td class="row1">
              <input type="radio" name="user_sex" value="b" checked />
              not sure&nbsp;&nbsp;&nbsp;
              <input type="radio" name="user_sex" value="m" />
              male&nbsp;&nbsp;&nbsp;
              <input type="radio" name="user_sex" value="w" />
              female</font>
              </td>
          </tr>



but, in this case better is a new tag in member_editprofile.html
for opt. change gender later... or not?  :D
« Last Edit: April 07, 2005, 06:56:05 AM by V@no »
I do not have anything against it, if you try all possible out on my side, but please announce you on not with TESTACCOUNT's to test purposes... Thank you for the understanding.

Offline ib41

  • Full Member
  • ***
  • Posts: 171
    • View Profile
installed -success ( ALMOST )
« Reply #3 on: June 03, 2003, 08:05:00 AM »
Images not showing :(
I get the vicious RED X next to members  name in profile.

 :?:  :?:  :?:

the m.gif and w.gif ARE located in  templates/default/images
 folder

help please

Thanks inadvance
People gain a lil authority and suddenly they think they're god
then you tell them the truth and they can't handle it
so they abuse the power bestowed upon them

drhtm

  • Guest
Mini MOD: User GIS
« Reply #4 on: June 03, 2003, 09:09:43 AM »
i'm sorry, but how do you add a new field to the database?

Offline brandkanne

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
    • http://www.jan-hendrik.com
Mini MOD: User GIS
« Reply #5 on: June 03, 2003, 09:59:48 AM »
Quote
i'm sorry, but how do you add a new field to the database?


i use phpMyAdmin... http://phpwizard.net/projects/phpMyAdmin/

browse to your database in 4images_users

click on:   Add new field: 1 At End of Table

choose varchar(1), set default to m

that's it.
I do not have anything against it, if you try all possible out on my side, but please announce you on not with TESTACCOUNT's to test purposes... Thank you for the understanding.

Offline brandkanne

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
    • http://www.jan-hendrik.com
Re: installed -success ( ALMOST )
« Reply #6 on: June 03, 2003, 10:09:37 AM »
Quote from: ib41
Images not showing :(
I get the vicious RED X next to members  name in profile.

 :?:  :?:  :?:

the m.gif and w.gif ARE located in  templates/default/images
 folder


i guess, your probl. is the empty database field in user_sex for your existing users, right?

!
At first setup, you must edit each user_sex field by hand with m or w
i hope your database is not so huge :oops:
I do not have anything against it, if you try all possible out on my side, but please announce you on not with TESTACCOUNT's to test purposes... Thank you for the understanding.

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
Re: installed -success ( ALMOST )
« Reply #7 on: June 03, 2003, 02:09:26 PM »
Quote from: brandkanne
!
At first setup, you must edit each user_sex field by hand with m or w
i hope your database is not so huge :oops:

actualy when u are adding new field, just make default ('m')
if u already added that field, run this query to update all enteries:
Code: [Select]
UPDATE 4images_users SET user_sex = 'm'
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Mini MOD: User GIS
« Reply #8 on: June 06, 2003, 05:01:55 AM »
just notised, instead of
Quote
<img src="templates/default/images/{user_sex}.gif">
better use this:
Quote
<img src="{template_image_url}/{user_sex}.gif">
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 spoiledRHOtten

  • Newbie
  • *
  • Posts: 42
    • View Profile
Mini MOD: User GIS
« Reply #9 on: June 17, 2003, 06:56:39 AM »
Hi!

Okay...my question is this...if we set the user to default as "male" is there a way for them to change it?

I added the field that we added to the register_form.html form to the member_editprofile.html. BUT....it resets back to the male selection because it is set as marked. Is there a way to recall what the user marked so they dont have to keep changing it everytime they update their profile. I'm sure many people will forget to mark Female if they are female everytime the update their profile.

Please help!

Thank you!

Offline uksoreeyes

  • Full Member
  • ***
  • Posts: 117
    • View Profile
    • http://www.myleeneklass.com
Mini MOD: User GIS
« Reply #10 on: June 17, 2003, 09:18:52 AM »
Post updated on: 19 June 2003, 03:21am
Quote from: spoiledRHOtten
Hi!

Okay...my question is this...if we set the user to default as "male" is there a way for them to change it?

There is but it's going to require a few changes to the original mod.

First open: includes/db_field_definitions.php

Find:
Code: [Select]
$additional_user_fields['user_sex'] = array($lang['user_sex'], "radio", 1);
Change to:
Code: [Select]
$additional_user_fields['user_sex'] = array($lang['user_sex'], "text", 0);

Open: member.php

Find:
Code: [Select]
   else {
      $user_icq_button = REPLACE_EMPTY;
    }

Below add:
Code: [Select]
// User Gender Switch
$gender_array = array("Male", "Female", "None Specified");
$user_gender = $gender_array[$user_row['user_sex']]." <img src=\"".TEMPLATE_PATH."/images/gender".$user_row['user_sex'].".gif\">";

Rename images to gender0.gif = male gender1.gif = female and gender3.gif = blank (nothing)

Find:
Code: [Select]
     "lang_email" => $lang['email'],
      "lang_homepage" => $lang['homepage'],
      "lang_icq" => $lang['icq']

Change to:
Code: [Select]
     "lang_email" => $lang['email'],
      "lang_homepage" => $lang['homepage'],
      "lang_icq" => $lang['icq'],
 "user_gender" => $user_gender,

Find:
Code: [Select]
   $sql = "UPDATE ".USERS_TABLE."
            SET ".get_user_table_field("", "user_email")." = '$user_email', ".get_user_table_field("", "user_showemail")." = $user_showemail, ".get_user_table_field("", "user_allowemails")." = $user_allowemails, ".get_user_table_field("", "user_invisible")." = $user_invisible, ".get_user_table_field("", "user_homepage")." = '$user_homepage', ".get_user_table_field("", "user_icq")." = '$user_icq'

Change to:
Code: [Select]
   $sql = "UPDATE ".USERS_TABLE."
            SET ".get_user_table_field("", "user_email")." = '$user_email', ".get_user_table_field("", "user_showemail")." = $user_showemail, ".get_user_table_field("", "user_allowemails")." = $user_allowemails, ".get_user_table_field("", "user_invisible")." = $user_invisible, ".get_user_table_field("", "user_homepage")." = '$user_homepage', ".get_user_table_field("", "user_icq")." = '$user_icq', user_sex = '$user_gender'

Find:
Code: [Select]
 if ($config['account_activation'] == 2 && $user_info['user_level'] != ADMIN) {
    $edit_profile_msg .= $lang['edit_profile_email_msg_admin'];
  }

Below add:
Code: [Select]
// User Gender Switch
if($user_info['user_sex'] == 1){
$user_gender = "<input type=\"radio\" name=\"user_gender\" value=\"1\" checked />
              male&nbsp;&nbsp;&nbsp;
              <input type=\"radio\" name=\"user_gender\" value=\"2\" />
              female</font>";
} else if($user_info['user_sex'] == 2){
$user_gender = "<input type=\"radio\" name=\"user_gender\" value=\"1\"/>
              male&nbsp;&nbsp;&nbsp;
              <input type=\"radio\" name=\"user_gender\" value=\"2\" checked  />
              female</font>";
} else {
$user_gender = "<input type=\"radio\" name=\"user_gender\" value=\"1\"/>
              male&nbsp;&nbsp;&nbsp;
              <input type=\"radio\" name=\"user_gender\" value=\"2\"/>
              female</font>";
}

Find:
Code: [Select]
   "lang_edit_profile_msg" => $edit_profile_msg,
    "lang_yes" => $lang['yes'],
    "lang_no" => $lang['no']

Replace with:
Code: [Select]
   "lang_edit_profile_msg" => $edit_profile_msg,
    "lang_yes" => $lang['yes'],
    "lang_no" => $lang['no'],
"user_gender" => $user_gender,

Open: templates/default/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>

Below add:
Code: [Select]
         <tr>
            <td class="row2"><b>Gender</b></td>
            <td class="row2">{user_gender}</td>
          </tr>

Open: templates/default/member_profile

Find:
Code: [Select]
<img src="templates/default/images/{user_sex}.gif">
Remove it.

Find:
Code: [Select]
       <tr>
          <td class="row2"><b>{lang_icq}</b></td>
          <td class="row2">{if user_icq}<a href="http://wwp.icq.com/scripts/search.dll?to={user_icq}">{user_icq}</a>
            (<b>{user_icq_status}</b>){endif user_icq}</td>
        </tr>

Below add:
Code: [Select]
       <tr>
          <td class="row1"><b>Gender</b></td>
          <td class="row1">{user_gender}</td>
        </tr>


Thats about it I think, Save and close the files. I have tested on a fresh install of 4images and it works great.

Please inform me of any problems.

Carl

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
Mini MOD: User GIS
« Reply #11 on: June 17, 2003, 11:12:35 AM »
@uksoreeyes:
first off, u shouldnt delete
Code: [Select]
$additional_user_fields['user_sex'] = array($lang['user_sex'], "radio", 1);simply change it to
Code: [Select]
$additional_user_fields['user_sex'] = array($lang['user_sex'], "text", 0);this way, u'll have an option in ACP when u edit or create new user.
also, if u use values as 1 = male, 2 = female and 3 = none then u'll save some headache and instead of:
Code: [Select]
// User Gender Switch
if($user_row['user_sex'] == 1){
   $user_gender = "Male <img src=\"templates/default/images/m.gif\">";
} else if($user_row['user_sex'] == 2){
   $user_gender = "Female <img src=\"templates/default/images/w.gif\">";
} else {
   $user_gender = "None Specified";
}
u could use:
Code: [Select]
// User Gender Switch
$gender_array = array("Male", "Female", "None Specified");
$user_gender = $gender_array[$user_row['user_sex']]." <img src=\"".TEMPLATE_PATH."/images/gender".$user_row['user_sex'].".gif\">";

for that u must rename images to gender0.gif = male gender1.gif = female and gender3.gif = blank (nothing)
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 uksoreeyes

  • Full Member
  • ***
  • Posts: 117
    • View Profile
    • http://www.myleeneklass.com
Mini MOD: User GIS
« Reply #12 on: June 18, 2003, 11:08:20 AM »
Quote from: V@no
Code: [Select]
// User Gender Switch
$gender_array = array("Male", "Female", "None Specified");
$user_gender = $gender_array[$user_row['user_sex']]." <img src=\"".TEMPLATE_PATH."/images/gender".$user_row['user_sex'].".gif\">";

I like how you done that V@no. could we do something like that with:

Code: [Select]
  // User Gender Switch
   if($user_info['user_sex'] == 1){
   $user_gender = "<input type=\"radio\" name=\"user_gender\" value=\"1\" checked />
              male&nbsp;&nbsp;&nbsp;
              <input type=\"radio\" name=\"user_gender\" value=\"2\" />
              female</font>";
   } else if($user_info['user_sex'] == 2){
   $user_gender = "<input type=\"radio\" name=\"user_gender\" value=\"1\"/>
              male&nbsp;&nbsp;&nbsp;
              <input type=\"radio\" name=\"user_gender\" value=\"2\" checked  />
              female</font>";
   } else {
   $user_gender = "<input type=\"radio\" name=\"user_gender\" value=\"1\"/>
              male&nbsp;&nbsp;&nbsp;
              <input type=\"radio\" name=\"user_gender\" value=\"2\"/>
              female</font>";
   }

That seems like such a lot of code for such a simple task and would like it if it could be simplified like the code you done above.

Carl

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
Mini MOD: User GIS
« Reply #13 on: June 18, 2003, 12:48:35 PM »
here is a code I use at my site:
Code: [Select]
$i = 0;
$gender = "";
$user_gender_select = array("none", "Male", "Female", "Both");
foreach ($user_gender_select as $key) {
$gender .= "<option value=\"".$i."\"".(($user_info['user_gender'] == $i) ? " selected" : "").">".$key."</option>\n";
$i++;
}

this will store dropdown options in $gender variable.
u may need change the array too.
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 uksoreeyes

  • Full Member
  • ***
  • Posts: 117
    • View Profile
    • http://www.myleeneklass.com
Mini MOD: User GIS
« Reply #14 on: June 18, 2003, 01:59:33 PM »
I got this error
Quote
Warning: Invalid argument supplied for foreach()