Author Topic: [MOD in dev] User profile privacy  (Read 2154 times)

0 Members and 1 Guest are viewing this topic.

Offline Lucifix

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
    • http://www.slo-foto.net
[MOD in dev] User profile privacy
« on: April 24, 2008, 09:39:31 AM »
I'm trying to make mod that would allow users to regulate who can see their profiles.

User has 3 options who can view his/her profile:
- all users and members (user_privacy field: 0)
- only members (user_privacy field: 2)
- only hi/she (private profile) (user_privacy field: 1)

I created new field in 4images_users table called user_privacy

This is the code that I put in members.php
Quote
//----------------------------------------------------------------------------------
//--- USER PRIVACY ---------------
//----------------------------------------------------------------------------------
if ($user_row['user_privacy'] == 1 ) { // only for owner and admin
   
   if ($user_info['user_id'] != $user_row['user_id'] && $user_info['user_level'] != ADMIN) {
      echo "<div align=\"center\" style=\"width: 100%; text-align: center\">User privacy <b>".$user_row['user_name']."</b></div>";
      //echo "<div align=\"center\" style=\"padding: 20px 0 20px 7px; width: 100%; text-align: center\"><img src=\"/images/galerija/locked_icon.gif\" width=\"96\" height=\"101\"></div>";
      echo "<div align=\"center\" style=\"padding: 20px 0 20px 7px; width: 100%; text-align: center\">";
      echo ($config['avatar_use']) ? "<img src=\"/".TEMPLATE_PATH."/avatars/".(($user_row['user_avatar'] == "") ? "blank.gif" : $user_row['user_avatar'])."\" name=\"icons\" border=\"0\" class=\"pic\" alt=\"\" height=\"50\" width=\"50\" />" : "";
      echo "</div><div align=\"center\" style=\"width: 100%; text-align: center\"><a href=\"/index.php\">Home</a></div>";

      exit;
   } else {   
      echo "<div style=\"border: 2px solid #CC0000; background-color:#FFCCFF; width:300px; margin: 0 auto; text-align: center; font\">&nbsp;<br />WARNING! Your profile is hidden.<br />&nbsp;</div>";
   }
} elseif ($user_row['user_privacy'] == 2) { // only for users on friends list
   $sql_friends = "SELECT *
        FROM ".USERS_TABLE."
        WHERE user_id = ".$user_row['user_id']."";
   $friends_row = $site_db->query_firstrow($sql_friends);

   // CE IMA PRIJATELJE
  if (!empty($friends_row['user_friend_ids'])) {
    $split_keywords = explode(" ", $friends_row['user_friend_ids']);
       foreach ($split_keywords as $key => $val) {
      $sql1 = "SELECT *
        FROM ".USERS_TABLE."
        WHERE user_id = $val
      ORDER BY user_id ASC";
   $friends_name = $site_db->query_firstrow($sql1);
   $fname = $friends_name['user_id'];
   
   // IF USER DOESN'T HAVE FRIENDS ON LIST
   if ($fname != $user_info['user_id']) {
      echo "<div align=\"center\" style=\"width: 100%; text-align: center\">Private profile</div>";
      echo "<div align=\"center\" style=\"padding: 20px 0 20px 7px; width: 100%; text-align: center\"><img src=\"/images/galerija/locked_icon.gif\" width=\"96\" height=\"101\"></div>";
      echo "<div align=\"center\" style=\"width: 100%; text-align: center\"><a href=\"/index.php\">Home</a></div>";
      exit;
         }
      }

   } else {
      echo "<div align=\"center\" style=\"width: 100%; text-align: center\">Private profile.</div>";
      echo "<div align=\"center\" style=\"padding: 20px 0 20px 7px; width: 100%; text-align: center\"><img src=\"/images/galerija/locked_icon.gif\" width=\"96\" height=\"101\"></div>";
      echo "<div align=\"center\" style=\"width: 100%; text-align: center\"><a href=\"/index.php\">Home</a></div>";
      exit;
   }
}

Add this in members_editprofile.html

Quote
                <tr>
                      <td class="row1"><b>Who can view your profile</b></td>
                    <td class="row1"><div align="left">
                          <input type="radio" name="user_privacy" value="0"{user_privacy_no} />
                      all users and members
                      <input type="radio" name="user_privacy" value="1"{user_privacy_yes} />
                     Hidden profile
                      <input type="radio" name="user_privacy" value="2"{user_privacy} />
                     Only members</div></td>
                 </tr>

Add this to db_field_definitions.php
Code: [Select]
$additional_user_fields['user_privacy'] = array("Profile privacy", "radio", 0);

The only problem I found now is if user allow only members to view his/her profile, so next time he/she edit profile the input won't be selected.

Any suggestion?

Please don't use this mod yet, because it's still in development.
« Last Edit: April 24, 2008, 11:41:34 AM by Lucifix »