4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: Rembrandt on January 09, 2010, 08:44:06 AM

Title: [Mod] User registry restriction
Post by: Rembrandt 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
Title: Re: [Mod] User registry restriction
Post by: Sun Zaza 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

Title: Re: [Mod] User registry restriction
Post by: V@no 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']);
  }
}
Title: Re: [Mod] User registry restriction
Post by: Rembrandt 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
Title: Re: [Mod] User registry restriction
Post by: Sun Zaza 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?
Title: Re: [Mod] User registry restriction
Post by: Rembrandt 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
Title: Re: [Mod] User registry restriction
Post by: Sun Zaza on January 09, 2010, 10:43:47 PM
No problem Andy. I understand.
Bye bro.