HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Username listed as UNKNOWN when replying to comment

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#108568 (In Topic #21156)
TQ
Avatar

Honoured member

I have an odd situation with a user that has a numeric username, when I quote the user his numeric id is correct ...



but when I post the reply his username becomes UNKNOWN.



TQ
Can be viewed here
Back to the top
 
Posted
Rating:
#108571
Avatar

Community saint

As a workaround, you would have to add some non-numeric text before or after the numeric name like this (note the space after the username):

[quote="163248 "]

A number as a quote parameter tells ocPortal to lookup that user number. If numeric usernames are allowed, there is no easy and guaranteed way to tell whether you meant to lookup that user number or whether you are specifying a username. Something new would probably have to be coded into the quote tag to specify which way to treat the parameter.
Back to the top
 
Posted
Rating:
#108572
TQ
Avatar

Honoured member

Jason Verhagen said

If numeric usernames are allowed …
Hi Jason,

Thanks for responding  :thumbs:

Is there an option to insist on alphanumeric usernames, I don't seem to be able to find it.

TQ
Back to the top
 
Posted
Rating:
#108573
Avatar

Community saint

I don't think there is an option to force alphanumeric usernames, but I think I've got a code fix for it. My fix adds an id parameter that must be set to 'true' if the quote is using a member ID number. By default, the quote tag will assume it's a username if the id parameter is left off or is not set to true. In sources/comcode_renderer.php starting at or near line 1982, I changed this:

Code (php)

                case 'quote':
                        $cite=array_key_exists('cite',$attributes)?$attributes['cite']:NULL;
                        if (!is_null($cite))
                        {
                                $temp_tpl=test_url($cite,'del',$cite,$source_member);
                        }

                        if ($attributes['param']!='')
                        {
                                if (is_numeric($attributes['param']))
to this:

Code (php)

                case 'quote':
                        $cite=array_key_exists('cite',$attributes)?$attributes['cite']:NULL;
                        $use_id=array_key_exists('id',$attributes)?$attributes['id']:NULL;
                        if (!is_null($cite))
                        {
                                $temp_tpl=test_url($cite,'del',$cite,$source_member);
                        }

                        if ($attributes['param']!='')
                        {
                                if (is_numeric($attributes['param']) && strtolower($use_id) == 'true')

Using this code, [quote="1"] would say "1 said" in the quote box.

Using [quote="1" id="true"] would say "guest said" in the quote box (since user ID 1 is assigned to the guest account).

If you want the new id parameter to show up in the comcode tag assistant, there are two more edits that are needed. At or near line 45 of sources/comcode_add.php, changes this line:

Code (php)

                'quote'=>array('param','saidless','cite'),
 
to this:

Code (php)

                'quote'=>array('param','id','saidless','cite'),
 

And near line 160 (not really important where, but probably good to keep it in the same COMCODE_TAG_quote_PARAM_* grouping) in lang/EN/comcode.ini, insert this new line:

Code

COMCODE_TAG_quote_PARAM_id=Set this to 'true' (without quotes) if Param is a member ID number instead of a username.
Back to the top
 
Posted
Rating:
#108581
TQ
Avatar

Honoured member

Hi Jason,

That is massive, thanks for the time you spent on this subject.

I'm not sure if I will go down this route or if I'd be as well stipulating that a user name must contain at least 1 alpha character when they sign-up (in the hope that new users actually read the text) as I only have one user out of over 9,000 members that have chosen a purely numerical user name.

As this is an issue with the way OCP works I think this is better fixed at the user name creation stage rather than work around the problem. I can always ask the (one) user with a numerical ID to add a letter to it if he make a comment about being quoted as 'Unknown'.

Again, thank you for the time and effort you've put into this.

TQ
Back to the top
 
Posted
Rating:
#108586
Avatar

Yeah, I think this is best done by blocking numeric usernames. It's too big a can of worms.

Usernames are probably a better 'key' than a member ID really. That's kind of backwards to normal thinking, but the username is chosen, while an ID may change across DB migrations. Esp with v10 because we're getting display names, so people are less likely to want to change their usernames.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Item has a rating of 5 (Liked by Jason Verhagen)  
Rating:
#108587
Avatar

Ok this change will be in the next patch release. I don't think people will need a hotfix as this is the first time in our history anyone found it, so I think it's very rare for people to try that :).


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#108595
TQ
Avatar

Honoured member

Hi Chris,

Thanks very much for your thoughts on this issue.

I can manage quite well as I am at the moment and will monitor all future username additions (no more than 10-20 per day) and ask them (if they haven't read my username language message) to change it to a Alphanumeric name.

Appreciated.

TQ
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: