MediaWiki: Special "Create an account" behaviour - mediawiki

When a new user account is created in our MediaWiki system, the admin specifies the desired user login name and the real name. I'd like to automatically fill the user page and also create a special page according to these rules:
Provided the login of the new user is "LOGIN" and the real name is "FIRST SECOND",
1) a new page should be created named "SECFIR" (i.e. 3 letters of surname and 3 letters of first name), containing just "#REDIRECT:[[user:LOGIN]]", i.e. redirecting to the user page;
2) the user page should contain "{{getuser|SECFIR}}"
Any suggestions?

Create a custom hook function (event handler) using http://www.mediawiki.org/wiki/Manual:Hooks/AddNewAccount - relatively straightforward PHP to do this
Same answer...
More at https://stackoverflow.com/a/8514696

Related

How to check the age of a person if it is less than 18 show an alert on Microsoft Dynamics 365 (Model driven app)?

I am new to MS Dynamics 365 (Power App) and want to create a function where it checks if the age is less than 18 or not and displays an alert if the person is less than 18.
I have developed a model driven app using solution and table (entity) and want to know if the person is less than 18, when the person enters the age in the text column.
Any help will be appreciated.
Thank you.
You can use a business rule for this. I am assuming that when you say "text column" is really an integer value and you are referring it as text.
So you have a column named "Age" of type "Whole number"
Now, you can create a business rule (Define if you need this only or the form or the entity)
On the condition box, configure something like this and click "Apply" at the bottom of the window
From the "Components" tab select "Show Error Message" and add the configuration
Select the scope for the Business rule and save it. After it saves you have to activate it so it starts working.
Now, when the user enters the age and it is less than 18, you'll get the error message and this will prevent the record from saving until valid data is entered.
If you are using a text or date type for the age, or you just want an alert without validating the data onSave, then you'll have to add some JavaScript code, please note that this is just an example and you should follow best practices for resource naming, validations and JavaScript encapsulation.
function validateAge(exContext) {
if ( !exContext )
return;
let formContext = exContext.getFormContext();
if ( formContext.getAttribute("new_age").getValue() < 18 )
{
alert("Less than 18");
}
}
Open the form where you want the validation and add or create the library for your JavaScript
If you are creating the web resource
Select the field that will trigger the validation, select the "Events" tab and click on "+ Event Handler"
Configure the event handler, save and publish

"Create or update" form behavior when hitting back button

I have the following workflow on a website:
Some user John Doe declares a company through form 1
(fields: name, head office location)
After John Doe submits (HTTP POST) form 1, he is redirected (HTTP 302) to company form 2 with additional legal information about the company.
The problem is, if John Doe hits the back button of his browser during step 2, he will land on the form 1, with data filled by the browser (using values he already submitted — that's what Firefox and major browsers seem to do).
John Doe might then think he can use this form to update some information (e.g. fix a typo in the name of the company) whereas he will actually create a new company doing so, as we don't know on the server side whether he wants to declare a new company or update the one he just created.
Do you know any simple solution to handle that problem ?
Use javascript/jquery script after the page is loaded to empty all the inputs. This will prevent confusion of "updating the company".
jQuery would look something like this:
$('#elementID').val('');
You can also handle the situation by manipulating the browser history
on load of form 2, and pass the CompanyId generated on submit of form 1 using querystring. So that you can actually update the company as the user
Suppose John submits form1.html, a unique CompanyId "1001" is generated and redirected to form2.html. Now on load of form2 you can modify the browser history form1.html?companyid=1001 using
var stateObj = { foo: "bar" };
history.pushState(stateObj, "page 1", "form1.html?companyid=1001");
Now, when the user click back button and submits the form1 again. you can check for companyid in querystring and update the company.
I think it is more user-friendly when user can return back to previous form and update it (instead preventing the described behavior).
I use in most cases similar way to handle described problem:
Let's assume that user is on the page /some-page, that contains "Create new company" button.
When the user opens this page, will be executed special method createOrFindCompanyDraft() on the server-side. This method creates new company "draft" record in DB (only for the current user). For example, draft record has primary key id=473. When you execute this method again it will return the same record with the id=473 (with "draft" status). "Draft" record should't display on any other interfaces.
And "Create new company" has link /company/common/473.
When user go to /company/common/473, you display form 1, that will be filled from "draft" record. At first time user will see empty form.
Technically user will update the existing record, but you can display "Create new company" title on the page.
Then user go to form 2, for example, /company/legal-info/473, you create similar draft record for the this form (similar to step 1).
When user submit the form 2, you will remove "draft" status from the record id=473 (and any related records).
Next time when user open page /some-page, will be created new draft record for the current user.
Browser history will contain:
/some-page
/company/common/473
/company/legal-info/473
/some-page2
I like this approach, because all form only update records. You can go to previous/next form many times (for example "Back"/"Forward" browser buttons). You can close browser, and open not completed forms tomorrow. This way doesn't require any additional manipulation with the browser history.
try this
<form autocomplete="off" ...></form>
And Another
Use temporary tables or session to store the Page 1 form data. If the page 2 form is submitted use the temporary data of page 1 which is stored in database or in session.
Use a Separate key (Hidden field ) in both page 1 and page 2.
Actually I thought of a trick to obtain that "create on first post, update after" behavior (just like the user thinks it should behave).
Let's say the step 1 form is at the URL /create_company/. Then I could have that page generate a random code XXX and redirect to /create_company/?token=XXX. When I create the company I save the information that it was created through page with token XXX (for instance, I save it in user's session as we don't need to keep that information forever) and when the form is submitted, if I know that a company was already generated using this token, I know the user used the same form instance and must have used the back button since the token would be different if he explicitly asked for another company.
What do you think ? (I initially thought there should be a simpler solution, as this seems a little bit over-engineered for such a simple issue)
This is more like a UX question.
I'd think that the solution lies within the information given to the user on that form, to help them understand what they're doing.
Set a title that says 'Create a company', for example, and set your submit button as 'Create Company' will help your user with that. Use a unique id when you create the company object, and pass the id back to the same URL in order to perform an update. You should then update your title and button that tells user that they are updating instead of creating.
In that sense I'd say it's better to use a more generic URL like /company and /company?id=12345.
You could also consider using Restful API protocol to help your server identifies the CRUD operation. http://www.restapitutorial.com/lessons/httpmethods.html
Without the "routing" part of django it is hard to help. I can just answer my experience from the express.js-router functionality:
you can specify a post on /company, which is for new users.
you can specify another route for post on /company/:companyid for a changing form
and as a response from the create-post you can redirect to the different location.

How to store hidden fields inside message in web application?

I have web app (laravel 5.3, mysql) where users can comment any entity in project (almost every page contains something like chat)
I want to add possibility to mention other users inside message via '#' symbol ("Hello, #John, see here", for example).
When this message is posted to chat user named John must get notification about new message (via email, if he is offline).
Every message is connected to some page (/object/45, for example), so when email is sent user will know the page where he was mentioned.
The question is how to store this inside database?
message field has type text
In this example row would contain this data "Hello, #John, see here" (without quotes).
Problem is that there can be many users with name "John" so I can not not do simple:
select email from users where username = 'John' -- email is used as login
Also username can be something like #John Malkovich, so I have to parse string to find out, if "John" or "John Malkovich" was mentioned.
What is unique - user id.
So how to store this inside database?
Possible solution:
Hello, [user=34], see here - field in database
Parse string before displaying to web browser and replace this string with
Hello, #John, see here
but, obviously, no one can paste literal text '[user=123]' inside message, because it would be interpreted as userid.
P.S. Inside one message many users can be mentioned.
Maybe you could create something like <span value="user34">John Malkovich</span> and parse the value?
Or <span data-user-id="user34">John Malkovich</span> is probably better semantically.
Have absolutely no experience in this kind of stuff though, so don't take me too seriously ;)

How to implement 'To' field functionality present in Windows Phone 8 inbuild message application

I need to implement functionality similar to 'To' field present in the Windows Phone 8 in build message application.
Whenever user wants to remove any name from 'To' field, he needs to tap on that name then one message pop up will be displayed with remove, open, copy and cancel
User cannot place the cursor in between of the name, once the name is ended with the semicolon
Can anyone suggest me the approach to implement this feature?
Thanks in advance
This is a custom control you would have to write. It is not delivered along the other Windows Phone Controls.
Here is a scetch of how you could achieve this: The custom control is a combination of a TextBlock ("To:" Field) followed by a GridView, Followed by a TextBox (Input Field).
Now at the beginning, the GridView has no entries and is therefore not visible. If the user selects an Email from the type ahead or closes the input by a semicolon (listen to the KeyUp Event of the TextBox), your control logic creates an instance of a datamodel which then holds the ID, Email Address, Name and whatever you would need. This instance is then added to an ObservableCollection which is bound to the GridView. Having the ObservableCollection in place will result in an automatic display of the entry in the GridView. Now clear the TextBox and be prepared for the next entry.
The rest is only layout stuff to have no borders on your TextBox, have the GridView display the Names with Semicolons etc.
Finally react on GridView selections with the Popup to delete or Update its content.

html multiple fields differentiation on a form

i'm new to website development and i'm unsure of the technical word for this but i have a form with fields on it e.g.
User Info
Name
Surname
Address
User Modules
Module Name
Module Day
....
At present i have these fields in a form showing one after another, there is no separation between them. Is there a function in html that i can use to make the form a bit more readable? e.g. (like a group separation?) i know i can just indent the title but would like to know the proper way to do this.
User Info
Name
Surname
Address
User Modules
Module Name
Module Day
....
Use a FIELDSET and a LEGEND.