Author Topic: [MOD] - Profile invisible.  (Read 12778 times)

0 Members and 1 Guest are viewing this topic.

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
[MOD] - Profile invisible.
« on: July 28, 2007, 12:08:46 AM »
Hi, I would like to share my MOD to see if anyone would be interested. It allows users to put their profile invisible.

1 - When profile is invisible and another user try to view it, it will re-forward the request towards another user account.
2 - If all users account are invisible, it will re-forward to the index page (except for admins).

- Step 1.

In member.php file,

Find:

Quote
if ($user_row = get_user_info($user_id)) {
    $user_homepage = (isset($user_row['user_homepage'])) ? format_url($user_row['user_homepage']) : REPLACE_EMPTY;

replace with:

Quote
if ($user_row = get_user_info($user_id)) {
// Profile invisible.
      if ($user_row['user_id'] != $user_info['user_id'] && $user_info['user_level'] != ADMIN && defined('PROFILE_INVISIBLE') && PROFILE_INVISIBLE == 1 && $user_row['profile_invisible'] == 1) {         
          if (function_exists('get_profile_visible') && $visible_row = get_profile_visible($user_id)) {
              redirect("member.php?action=showprofile&" . URL_USER_ID . "=" . $visible_row['user_id']);                   
          } else {
              redirect($url);
          }
          unset ($user_id);
      }
      // End of profile invisible.
     
    $user_homepage = (isset($user_row['user_homepage'])) ? format_url($user_row['user_homepage']) : REPLACE_EMPTY;

- Step 2.

In includes/functions.php file,

add above ?> tag:

Quote
function get_profile_visible($user_id = 0) {
    global $site_db, $user_table_fields, $user_row;
    $user_info = 0;
    if ($user_id != 0 && $user_id != GUEST) {
       
        if (isset($user_row[$user_id]) && !isset($user_row['profile_invisible'])) {
           
            $sql_alter = "ALTER TABLE " . USERS_TABLE . " ADD profile_invisible TINYINT(1) DEFAULT 0 NOT NULL";
            $result = $site_db->query($sql_alter);
           
            if (isset($result) && isset($user_row['profile_invisible'])) {
                if (is_object($site_email) && !empty($site_email)) {
                    unset ($site_email);
                }
               
                if (defined('PROFILE_INVISIBLE_EMAIL_ANNOUNCEMENT') && PROFILE_INVISIBLE_EMAIL_ANNOUNCEMENT == 1) {
                    @include_once(ROOT_PATH.'includes/email.php');
                    $site_email = new Email();
                   
                    $sql_email_all_wanted_email_users = "
                   
                    SELECT " . get_user_table_field("", "user_name"). get_user_table_field(", ", "user_email") . "
                    FROM " . USERS_TABLE . "
                    WHERE " . get_user_table_field("", "user_level") . " >= " . USER . " AND " . get_user_table_field("", "user_allowemails") . " = 1

                    ";
                   
                    $result1 = $site_db->query($sql_email_all_wanted_email_users);
                   
                    if (isset($result1) && $site_db->get_numrows($result1) > 0) {
                        while ($user_email_info = $site_db->fetch_array($result1)) {
                            $user_name = $user_email_info[$user_table_fields['user_name']];
                            $user_email = $user_email_info[$user_table_fields['user_email']];                           
                        }
                       
                        if (isset($user_name) && isset($user_email)) {
                            $site_email->set_to(stripslashes($user_email));
                            $site_email->set_from(stripslashes($config['site_email'])); // Change this line with the email address of your choice IF ONLY it does not work from your admin settings (make sure to change BEFORE executing this MOD for the first time and to set the activation value from your constant file).
                            $site_email->set_subject($lang['profile_invisible_email_subject']);
                           
                            $site_email->register_vars(array(
                            "user_name" => trim($user_name),
                            "site_name" => trim($config['site_name']),
                            "site_email" => trim($config['site_email']),
                            "site_url" => format_url($script_url . "/index.php")
                            ));
                           
                            $site_email->set_body("profile_invisible_announcement", $config['language_dir_default']);
                            $site_email->send_email();
                        }
                    }
                }
            }
        }
           
        $sql = "
       
        SELECT DISTINCT " . get_user_table_field("", "user_id") . "
        FROM " . USERS_TABLE . "       
        WHERE " . get_user_table_field("", "user_level") . " >= " . USER . " AND profile_invisible = 0
        ORDER BY rand()
        LIMIT 1
       
        ";
       
        if ($user_info = $site_db->query_firstrow($sql)) {
            foreach ($user_table_fields as $key => $val) {
                if (isset($user_info[$val])) {
                    $user_info[$key] = $user_info[$val];
                }
                elseif (!isset($user_info[$key])) {
                    $user_info[$key] = "";
                }
            }
        }
    }
  return $user_info;
}               

- Step 3.

In includes/db_field_definitions.php file,

add above the ?> tag:

Quote
$additional_user_fields['profile_invisible'] = array($lang['profile_invisible'], "radio", 1);

- Step 4.

In includes/constants.php file,

add above the ?> tag:

Quote
// Profile invisible.
define('PROFILE_INVISIBLE', 1); // 0 to deactivate and 1 to activate.
define('PROFILE_INVISIBLE_EMAIL_ANNOUNCEMENT', 1); // 0 to deactivate and 1 to activate the email announcement for this feature to ALL users who has set their emails for allowance (once per install only).

For the PROFILE_INVISIBLE_EMAIL_ANNOUNCEMENT, this is for sending an automated email message (once) to all your users (must accept emails from your gallery). If this is set to '0', your users will not receive the email message.

- Step 5.

In lang/english/main.php file,

add above the ?> tag:

Quote
//-----------------------------------------------------
//--- Profile invisible -------------------------------
//-----------------------------------------------------
$lang['profile_invisible'] = "Make my profile invisible to others:<br /><span class=\"smalltext\"><b>(Note: This option disregards the administrators.)</span>";
$lang['profile_invisible_email_subject'] = "Profile invisible feature - added on your profile.";

- Step 6.

In lang/english/email folder, create file called: profile_invisible_announcement.html and place content inside:

Quote
Dear {user_name},

{site_name} gallery has intergrated a new feature called:

- Profile invisible.

This will allow you to hide your profile from other users.
Note: This feature disregards the ADMIN level since they
can still see your profile even when restricted.

Now, other users who will try to see your profile will
be forwarded 'randomly' to other accounts where other
users will NOT consider this new option.

Visit our URL: {site_url} and modify your profile setting
if needed.

If you have any questions regarding this feature, please
send an email to us at: {site_email} .
Your suggestions are important to us. We will reply as
soon as possible.

Regards.

{site_name} .

Remember, constant file must be configured when consider this file.

- Step 7.

In templates/your_template/member_editprofile.html file,

find:

Quote
<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>         

add below:

Quote
<tr>
            <td class="row2"><b>{lang_profile_invisible}</b></td>
            <td class="row2">
              <input type="radio" name="profile_invisible" value="1"{profile_invisible_yes} />
              {lang_yes}&nbsp;&nbsp;&nbsp;
              <input type="radio" name="profile_invisible" value="0"{profile_invisible_no} />
              {lang_no}
         </td>
          </tr> 

- [2007-10-04 - Step 8]

With this MOD: http://www.4homepages.de/forum/index.php?topic=19254.0) -

add this (expert mode):

Code: [Select]
ALTER TABLE 4images_users ADD profile_invisible tinyint(1) NOT NULL default '0';

Hope you like it. :)

Cheers.
« Last Edit: November 05, 2007, 01:05:32 AM by thunderstrike »
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [MOD] - Profile invisible.
« Reply #1 on: July 28, 2007, 12:35:43 AM »
Sorry, just realize I forgot step 7.

Cheers. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [MOD] - Profile invisible.
« Reply #2 on: July 29, 2007, 03:47:35 PM »
Just corrected step 1.
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [MOD] - Profile invisible.
« Reply #3 on: August 20, 2007, 11:16:34 PM »
Anyone interest for this MOD ? Is bug free.  :|
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: [MOD] - Profile invisible.
« Reply #4 on: August 28, 2007, 10:37:04 PM »
mod moved.

thunderstrike, thank you!
cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi

Offline m.a

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
Re: [MOD] - Profile invisible.
« Reply #5 on: November 04, 2007, 11:37:25 PM »
Anyone interest for this MOD ? Is bug free.  :|


Hallo,
gute Idee!

du hast aber schon SQL-Befehl und Datenbank-updat :!: vergessen!!


Tabelle 4images_users muss geändert werden.
SQL-Befehl:
ALTER TABLE `4images_users` ADD `profile_invisible` TINYINT( 1 ) DEFAULT '1' NOT NULL AFTER `user_email` ;

Oder?

Grüss
m.a


Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [MOD] - Profile invisible.
« Reply #6 on: November 05, 2007, 12:41:41 AM »
Anyone interest for this MOD ? Is bug free.  :|


Hallo,
gute Idee!

du hast aber schon SQL-Befehl und Datenbank-updat :!: vergessen!!


Tabelle 4images_users muss geändert werden.
SQL-Befehl:
ALTER TABLE `4images_users` ADD `profile_invisible` TINYINT( 1 ) DEFAULT '1' NOT NULL AFTER `user_email` ;

Oder?

Grüss
m.a



Oh ... this is right ...  :oops:

I add step 8 - thank for posting.  :)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline kai

  • Administrator
  • Addicted member
  • *****
  • Posts: 1.423
    • View Profile
    • 4images - Image Gallery Management System
Re: [MOD] - Profile invisible.
« Reply #7 on: November 05, 2007, 11:37:02 AM »
Thanks! Please use "code" bbcode for marking code sections. :)
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [MOD] - Profile invisible.
« Reply #8 on: November 05, 2007, 12:28:10 PM »
Quote
Thanks! Please use "code" bbcode for marking code sections.

I use - step 8 is date include ...
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?