Author Topic: [Mod] User registry restriction  (Read 12889 times)

0 Members and 1 Guest are viewing this topic.

Rembrandt

  • Guest
[Mod] User registry restriction
« on: January 09, 2010, 08:44:06 AM »
This Modification enables one user registry restriction.
The desire comes from here: http://www.4homepages.de/forum/index.php?topic=26585.msg144344#msg144344

1.) copy the contents of  attachment "install_user_limitation.php" in your root and call it to.

2.) search in lang/english/admin.php:

$setting_group
[7]="Session and User Settings";

insert below:

//#################################### Mod User Limitation ###################################################################
$setting['user_limit'] = "User Limit:";
//#################################### Mod User Limitation ###################################################################


3.) search in lang/english/main.php

$lang
['register_msg']

insert above:

$lang
['not_allowed'] = "<p style=\"text-align:center\">An registration is currently not possible !.</p>";


4.)search in admin/settings.php:

show_table_separator
($setting_group[7], 2"setting_group_7");

insert below:

//#################################### Mod User Limitation ###################################################################
show_setting_row("user_limit");
//#################################### Mod User Limitation ###################################################################


5.) search in register.php

if ($action == "signup") {
  
$site_template->register_vars(array(
    
"lang_agreement" => $lang['agreement'],
    
"lang_agreement_terms" => $lang['agreement_terms'],
    
"lang_agree" => $lang['agree'],
    
"lang_agree_not" => $lang['agree_not']
  ));
  
$content $site_template->parse_template("register_signup");
}

replace it:

if ($action == "signup" || $action == "register")
{
//uncomment lines below (remove /* and */) to automatically delete users who didn't visit gallery for more then 2 months
/*
  $expiry = time() - 60 * 60 * 24 * 62; //2 months
  $sql = "DELETE FROM ".USERS_TABLE."
          WHERE (".get_user_table_field("", "user_lastaction")." < $expiry) AND ".get_user_table_field("", "user_level")." = ".USER;
  $site_db->query($sql);
*/
  
$sql "SELECT COUNT(user_id) AS count_user 
          FROM " 
USERS_TABLE "
          WHERE " 
get_user_table_field("""user_level") . " NOT IN (" GUEST ", " ADMIN ")";
  
$row $site_db->query_firstrow($sql);

  if(
$row['count_user'] >= $config['user_limit'])
  {
  
$site_template->register_vars(array(
    
"lang_agreement" => $lang['agreement'],
    
"lang_not_allowed" => $lang['not_allowed']
));
 
$content $site_template->parse_template("not_allowed");
}
else{

  
$site_template->register_vars(array(
    
"lang_agreement" => $lang['agreement'],
    
"lang_agreement_terms" => $lang['agreement_terms'],
    
"lang_agree" => $lang['agree'],
    
"lang_agree_not" => $lang['agree_not']
  ));
  
$content $site_template->parse_template("register_signup");
}
}


6.) create a new file called "not_allowed.html" and store in you templates folder:
Code: [Select]
<table width="100%" border="0" cellspacing="0" cellpadding="1">
  <tr>
    <td valign="top" class="head1">
      <table width="100%" border="0" cellpadding="4" cellspacing="0">
                <tr>
          <td class="row2">{lang_not_allowed}</td>
        </tr>
      </table>
    </td>
  </tr>
</table>


7. ) Have fun :)


mfg Andi
« Last Edit: January 09, 2010, 10:02:42 PM by Rembrandt »

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: [Mod] User registry restriction
« Reply #1 on: January 09, 2010, 04:49:31 PM »
Very good job Andy. I just installed it and it is working perfect. Many thanks from me.
It is very useful :wink:

I have an idea for this mod to make it more professional. I am sure you or someone else can code it:


Let's add another option to the first option:

Option 1:
User limit is 1000
Massage: An registration is currently not possible, because....

Option 2:
A private gallery
Massage: To register you have to be a member of the football club "Barcelona". Please contact us for more information.

I appreciate your time and support,
Cruxy


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: [Mod] User registry restriction
« Reply #2 on: January 09, 2010, 09:01:33 PM »
I guess this mod would be useful with an additional feature that would delete users if they didn't visit the gallery for NN number of days, otherwise what are you going to do when the limit is reached?

@Rembrandt:
Step 4 is left of from your v0.1 ;) is not needed as it's not used anywhere.
Steps 6 and 7 can be combined into one:
find:
//-----------------------------------------------------
//--- Signup ------------------------------------------
//-----------------------------------------------------


insert above:
if ($action == "signup" || $action == "register")
{
//uncomment lines below (remove /* and */) to automatically delete users who didn't visit gallery for more then 2 months
/*
  $expiry = time() - 60 * 60 * 24 * 62; //2 months
  $sql = "DELETE FROM ".USERS_TABLE."
          WHERE (".get_user_table_field("", "user_lastaction")." < $expiry) AND ".get_user_table_field("", "user_level")." = ".USER;
  $site_db->query($sql);
*/
  
$sql "SELECT COUNT(user_id) AS count_user 
          FROM " 
USERS_TABLE "
          WHERE " 
get_user_table_field("""user_level") . " NOT IN (" GUEST ", " ADMIN ")";
  
$row $site_db->query_firstrow($sql);

  if(
$row['count_user'] >= $config['user_limit'])
  {
    
show_error_page($lang['not_allowed']);
  }
}
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)

Rembrandt

  • Guest
Re: [Mod] User registry restriction
« Reply #3 on: January 09, 2010, 09:57:54 PM »
...Step 4 is left of from your v0.1 ;) is not needed as it's not used anywhere.
Now I know why I always needed for so long.  :oops:  :)   thank you for this illustrative !

Quote
Steps 6 and 7 can be combined into one
ok I combine the code, the error page does not please me.

mfg Andi

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: [Mod] User registry restriction
« Reply #4 on: January 09, 2010, 10:02:20 PM »
Thanks Andy about your code improvement.

Have you think about my request of:


Quote
Let's add another option to the first option:

Option 1:
User limit is 1000
Massage: An registration is currently not possible, because....

Option 2:
A private gallery
Massage: To register you have to be a member of the football club "Barcelona". Please contact us for more information.


Do you have any idea how we can do that?

Rembrandt

  • Guest
Re: [Mod] User registry restriction
« Reply #5 on: January 09, 2010, 10:20:03 PM »
...
Do you have any idea how we can do that?
not at the moment.. sry


mfg Andi

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: [Mod] User registry restriction
« Reply #6 on: January 09, 2010, 10:43:47 PM »
No problem Andy. I understand.
Bye bro.