[BETA] Separate Login and Username 0.0.4

Post your MODs, receive and provide feedback!
Topics in this forum are not for MOD support, they are for giving the author feedback.
Forum rules
The topics in this forum are not for general MOD support, they are for giving the MOD author some feedback, ideas and bug reports.
Post Reply
xceler8shun
New member
New member
Posts: 14
Joined: 07 Aug 2008, 23:32

[BETA] Separate Login and Username 0.0.4

Post by xceler8shun »

MOD title: Separate Login And Username
MOD description: Creates a login name that is separate from the forum username. Can be controlled via the ACP / UCP. Saves people forgetting their login name if "allow username changes" permissions are enabled and the users constantly change and forget their username.
MOD version: 0.0.4
phpBB version: 3.0.2

Development stage: Developmental

MOD Format: MOD / MODX

MOD download: attached

Demo: None yet

Credits: None yet

Looking for user to test, report bugs or offer any ideas or suggestions.

Cheers
Shane
Attachments
separate_login_username_0_0_4.zip
(64.9 KiB) Downloaded 65 times
Last edited by xceler8shun on 27 Oct 2008, 04:00, edited 3 times in total.
harmlessgoat22
Supporter
Supporter
Posts: 316
Joined: 18 Sep 2007, 14:35
Real name: David
Contact:

Re: Separate Login and Username 0.0.3

Post by harmlessgoat22 »

How does this work? What if user 1 makes a username this_username, then changes it to that_username, so it keeps this_username for login? Or what? And what if user 2 tries changing his username to this_username. Then, when you try and login, what happens? This is a cool idea, if you made sure to close any problems that could arise in situations like the top one (which may not be an issue, I don't know...haven't tried the MOD).
Image
That's like, I can't beat my neighbor in an argument, so instead I kill his dog.
-Best English Teacher Ever
xceler8shun
New member
New member
Posts: 14
Joined: 07 Aug 2008, 23:32

Re: Separate Login and Username 0.0.3

Post by xceler8shun »

Ok, will try to explain as best I can.

For example,

My loginname: xceler8shun
Username: shane

Your loginname: harmlessgoat22
Username: david

If I try to make my login name harmlessgoat22 I cant, as it performs the same checks as the usual username function., the same if I tried to change my username to david.

If I tried to change my login name to david, I would also be denied as I will receive an error stating that I caanot not use a persons username as a login name

Now if you changed your username from david to davey, I would then be able to to change my username to david or my loginname to david.

It works the same way that I tried to change my username to be harmlessgoat22 goat which is your loginname, I would receive another error saying that I cannot use someones loginname as my username.
User avatar
House
Member
Member
Posts: 70
Joined: 23 Feb 2008, 12:49
Real name: Sean
Location: Hiding in Tree.

Re: [DEV] Separate Login and Username 0.0.3

Post by House »

Yay! This feature finally made it's way into a MOD for Olympus. :strawkiwi:


Now to look at the code for later. :twisted:

Edit: Whoa. Impressive MOD file. O.o **House walks backwards from installation. XD I'll have to try it later today, if I can. ;)
Women should be obscene and not heard. X)
xceler8shun
New member
New member
Posts: 14
Joined: 07 Aug 2008, 23:32

Re: [BETA] Separate Login and Username 0.0.3

Post by xceler8shun »

Yea I know, the install file shocks a few people.

It takes me 28 minutes to complete all code changes, sql queries, run the install files and clear the cache a few times.

I could probably streamline the install file a little as well.
Last edited by xceler8shun on 27 Oct 2008, 04:02, edited 1 time in total.
harmlessgoat22
Supporter
Supporter
Posts: 316
Joined: 18 Sep 2007, 14:35
Real name: David
Contact:

Re: [DEV] Separate Login and Username 0.0.3

Post by harmlessgoat22 »

Question: Can you change your own username to your login name? Eg if I want to go by harmlessgoat22 on the board instead of as David, Davey, Dave, John, for instance?
Image
That's like, I can't beat my neighbor in an argument, so instead I kill his dog.
-Best English Teacher Ever
xceler8shun
New member
New member
Posts: 14
Joined: 07 Aug 2008, 23:32

Re: [BETA] Separate Login and Username 0.0.3

Post by xceler8shun »

Yes, If for instance your login name was harmlessgoat22 and your username was David, you can change your username to be harmlessgoat22 as well.
Last edited by xceler8shun on 27 Oct 2008, 04:02, edited 1 time in total.
harmlessgoat22
Supporter
Supporter
Posts: 316
Joined: 18 Sep 2007, 14:35
Real name: David
Contact:

Re: [DEV] Separate Login and Username 0.0.3

Post by harmlessgoat22 »

Ok good :P

This sounds really cool! Does it work functionally yet?
Image
That's like, I can't beat my neighbor in an argument, so instead I kill his dog.
-Best English Teacher Ever
xceler8shun
New member
New member
Posts: 14
Joined: 07 Aug 2008, 23:32

Re: [BETA] Separate Login and Username 0.0.3

Post by xceler8shun »

I believe it is complete, but would like others to test and comment for me and offer suggestions.

I'm just holding off submission for validation until I get some more feedback.
Last edited by xceler8shun on 27 Oct 2008, 04:02, edited 2 times in total.
igorw
Past Contributor
Past Contributor
Posts: 1967
Joined: 01 Jun 2006, 20:48
Real name: Igor

Re: [DEV] Separate Login and Username 0.0.3

Post by igorw »

Cool MOD idea, let me give you a bit of feedback.

You SQL should go into an SQL installation file.

This should use set_config():
INSERT INTO `phpbb_config` (`config_name`, `config_value`, `is_dynamic`) VALUES ('allow_loginnamechange', '0', '0');
INSERT INTO `phpbb_config` (`config_name`, `config_value`, `is_dynamic`) VALUES ('max_loginname_chars', '20', '0');
INSERT INTO `phpbb_config` (`config_name`, `config_value`, `is_dynamic`) VALUES ('min_loginname_chars', '3', '0');
INSERT INTO `phpbb_config` ( `config_name` , `config_value` , `is_dynamic` ) VALUES ('allow_loginname_chars', 'LOGINNAME_CHARS_ANY', '0');


This should use auth_admin from includes/acp/auth.php.

Code: Select all

INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('u_chgloginname', 0, 1);
INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('a_loginnames', 0, 1);


This should use db_tools::sql_add_column() from includes/db/db_tools.php:
ALTER TABLE `phpbb_users` ADD `loginname` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL AFTER `username_clean` ;
ALTER TABLE `phpbb_users` ADD `loginname_clean` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL AFTER `loginname` ;
UPDATE phpbb_users SET loginname=username;
UPDATE phpbb_users SET loginname_clean=username_clean;


And this should use create_schema_files:

Code: Select all

CREATE TABLE `phpbb_disallow_login` (
`disallow_login_id` mediumint( 8 ) unsigned NOT NULL AUTO_INCREMENT ,
`disallow_loginname` varchar( 255 ) COLLATE utf8_bin NOT NULL default '',
PRIMARY KEY ( `disallow_login_id` )
) ENGINE = MYISAM DEFAULT CHARSET = utf8 COLLATE = utf8_bin AUTO_INCREMENT =1;


References:
[url=http://phpbbmodders.net/articles/3.0/create_table/]Article - Create a new table[/url]
[url=http://phpbbmodders.net/articles/3.0/dbal/]Article - DBAL, includes info about db_tools[/url]
[url=http://code.phpbb.com/devwiki/Permissions#Using_the_API_.28recommended.29]Devwiki - how to add permissions using phpBB3 api[/url]

Looking at the install file... it's huge! I bet it could be cut down a lot. You don't have to replace all the function and variable names. Reuse them! But pass a differen't variable. In fact, you could cut it down even more by not modifying auth_db, and simply adding a new auth plugin. If you need more help regarding this, post in here or send me a PM or whatever. ;)
xceler8shun
New member
New member
Posts: 14
Joined: 07 Aug 2008, 23:32

Re: [BETA] Separate Login and Username 0.0.3

Post by xceler8shun »

Will take you up on that offer eviL<3

This is mod attempt no 3 for me and I learned heaps just getting this far on this one about how phpbb3 operates.

I would assume that many of the language edits could go into their own language file as well to help cut the steps down.

Will look at the links you provided a little later today, it is currently 12.15am and I'm spent!
Last edited by xceler8shun on 27 Oct 2008, 04:01, edited 1 time in total.
xceler8shun
New member
New member
Posts: 14
Joined: 07 Aug 2008, 23:32

Re: [BETA] Separate Login and Username 0.0.3

Post by xceler8shun »

The schema files are being created with no problems.

They simply won't install now with the install script provided by evil3

This is the install script

Code: Select all

<?php
/**
 * Load a schema (and execute)
 *
 * @param string $install_path Path to folder containing schema files
 * @param mixed $install_dbms Alternative database system than $dbms
 */

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup(array('acp/common', 'acp/modules'));

// Did the user forget to login? Give 'em a chance to here ...
if ($user->data['user_id'] == ANONYMOUS)
{
   login_box('', $user->lang['LOGIN_ADMIN'], $user->lang['LOGIN_ADMIN_SUCCESS'], false);
}

// Is the user any type of admin? No, then stop here, each script needs to
// check specific permissions but this is a catchall
if (!$auth->acl_get('a_'))
{
   trigger_error('NO_ADMIN');
}
   
function load_schema($install_path = 'install/schemas/', $install_dbms = false)
{
       global $db;
       global $table_prefix;

       if ($install_dbms === false)
       {
          global $dbms;
          $install_dbms = $dbms;
       }

       static $available_dbms = false;

       if (!$available_dbms)
       {
          if (!function_exists('get_available_dbms'))
          {
             global $phpbb_root_path, $phpEx;
             include($phpbb_root_path . 'includes/functions_install.' . $phpEx);
          }

          $available_dbms = get_available_dbms($install_dbms);

          if ($install_dbms == 'mysql')
          {
             if (version_compare($db->mysql_version, '4.1.3', '>='))
             {
                $available_dbms[$install_dbms]['SCHEMA'] .= '_41';
             }
             else
             {
                $available_dbms[$install_dbms]['SCHEMA'] .= '_40';
             }
          }
       }

       $remove_remarks = $available_dbms[$install_dbms]['COMMENTS'];
       $delimiter = $available_dbms[$install_dbms]['DELIM'];

       $dbms_schema = $install_path . $available_dbms[$install_dbms]['SCHEMA'] . '_schema.sql';

       if (file_exists($dbms_schema))
       {
          $sql_query = @file_get_contents($dbms_schema);
          $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query);

          $remove_remarks($sql_query);

          $sql_query = split_sql_file($sql_query, $delimiter);

          foreach ($sql_query as $sql)
          {
             $db->sql_query($sql);
          }
          unset($sql_query);
       }

       if (file_exists($install_path . 'schema_data.sql'))
       {
          $sql_query = file_get_contents($install_path . 'schema_data.sql');

          switch ($install_dbms)
          {
             case 'mssql':
             case 'mssql_odbc':
                $sql_query = preg_replace('#\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \##s', 'SET IDENTITY_INSERT \1 \2;', $sql_query);
             break;

             case 'postgres':
                $sql_query = preg_replace('#\# POSTGRES (BEGIN|COMMIT) \##s', '\1; ', $sql_query);
             break;
          }

          $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query);
          $sql_query = preg_replace_callback('#\{L_([A-Z0-9\-_]*)\}#s', 'adjust_language_keys_callback', $sql_query);

          remove_remarks($sql_query);

          $sql_query = split_sql_file($sql_query, ';');

          foreach ($sql_query as $sql)
          {
             $db->sql_query($sql);
          }
          unset($sql_query);
       }
}

$cache->purge();
add_log('admin', 'LOG_PURGE_CACHE');

?>
Last edited by xceler8shun on 27 Oct 2008, 04:01, edited 1 time in total.
xceler8shun
New member
New member
Posts: 14
Joined: 07 Aug 2008, 23:32

Re: [BETA] Separate Login and Username 0.0.4

Post by xceler8shun »

I've updated to version 0.0.4

Borrowed the install script from evil3's troll MOD and moved most language edits into their own language files.
Post Reply