Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
4346cb59
Commit
4346cb59
authored
Nov 23, 2015
by
Aaron Wells
Committed by
Gerrit Code Review
Nov 23, 2015
Browse files
Merge "Automatically generate "Institution name" field (Bug #1394812)"
parents
31256ffb
bd50524c
Changes
4
Hide whitespace changes
Inline
Side-by-side
htdocs/admin/users/institutions.php
View file @
4346cb59
...
...
@@ -261,17 +261,6 @@ if ($institution || $add) {
safe_require
(
'artefact'
,
'internal'
);
$elements
=
array
(
'name'
=>
array
(
'type'
=>
'text'
,
'title'
=>
get_string
(
'institutionname'
,
'admin'
),
'rules'
=>
array
(
'required'
=>
true
,
'maxlength'
=>
255
,
'regex'
=>
'/^[a-zA-Z]+$/'
),
'ignore'
=>
!
$add
,
'help'
=>
true
,
),
'add'
=>
array
(
'type'
=>
'hidden'
,
'value'
=>
true
,
...
...
@@ -290,7 +279,7 @@ if ($institution || $add) {
),
'displayname'
=>
array
(
'type'
=>
'text'
,
'title'
=>
get_string
(
'institution
display
name'
,
'admin'
),
'title'
=>
get_string
(
'institutionname'
,
'admin'
),
'defaultvalue'
=>
$data
->
displayname
,
'rules'
=>
array
(
'required'
=>
true
,
...
...
@@ -664,12 +653,26 @@ EOF;
exit
;
}
// Generate random lower-case alpha-only institution name.
function
generate_institution_name
()
{
$i
=
substr
(
str_shuffle
(
"abcdefghijklmnopqrstuvwxyz"
),
0
,
6
);
if
(
$institution
=
get_record
(
'institution'
,
'name'
,
$i
))
{
// try again
generate_institution_name
();
}
else
{
return
$i
;
}
}
function
institution_validate
(
Pieform
$form
,
$values
)
{
global
$USER
;
global
$USER
,
$institution
,
$add
;
if
(
!
empty
(
$values
[
'name'
])
&&
!
$form
->
get_error
(
'name'
)
&&
record_exists
(
'institution'
,
'name'
,
$values
[
'name'
]))
{
$form
->
set_error
(
'name'
,
get_string
(
'institutionnamealreadytaken'
,
'admin'
));
// Automatically generate institution name when adding new institution
if
(
$add
)
{
$institution
=
generate_institution_name
();
}
if
(
$USER
->
get
(
'admin'
)
||
get_config_plugin
(
'artefact'
,
'file'
,
'institutionaloverride'
))
{
if
(
get_config_plugin
(
'artefact'
,
'file'
,
'maxquotaenabled'
)
&&
get_config_plugin
(
'artefact'
,
'file'
,
'maxquota'
)
<
$values
[
'defaultquota'
])
{
$form
->
set_error
(
'defaultquota'
,
get_string
(
'maxquotatoolow'
,
'artefact.file'
));
...
...
@@ -722,7 +725,7 @@ function institution_submit(Pieform $form, $values) {
// Update the basic institution record...
if
(
$add
)
{
$newinstitution
=
new
Institution
();
$newinstitution
->
initialise
(
$
values
[
'name'
]
,
$values
[
'displayname'
]);
$newinstitution
->
initialise
(
$
institution
,
$values
[
'displayname'
]);
$institution
=
$newinstitution
->
name
;
}
else
{
...
...
test/behat/features/account/user_change_password.feature
View file @
4346cb59
...
...
@@ -14,8 +14,7 @@ Scenario: Creating an Institution assigning users and changing their passwords
And
I follow
"Institution"
And
I press
"Add institution"
And I fill in the following
:
|
Institution
name
|
institutionone
|
|
Institution
display
name
|
institution
One
|
|
Institution
name
|
Institution
One
|
And
I
press
"Submit"
# Creating user 1
And
I follow
"Users"
...
...
@@ -26,7 +25,7 @@ Scenario: Creating an Institution assigning users and changing their passwords
|
email
|
bob@example.com
|
|
username
|
bob
|
|
password
|
mahara1
|
And
I select
"
i
nstitution One"
from
"Institution"
And
I select
"
I
nstitution One"
from
"Institution"
And
I check
"Institution administrator"
And
I press
"Create user"
# Creating user 2
...
...
@@ -38,7 +37,7 @@ Scenario: Creating an Institution assigning users and changing their passwords
|
email
|
jen@example.com
|
|
username
|
jen
|
|
password
|
mahara1
|
And
I select
"
i
nstitution One"
from
"Institution"
And
I select
"
I
nstitution One"
from
"Institution"
And
I press
"Create user"
# Log out as user admin
And
I follow
"Logout"
...
...
test/behat/features/institution/add_institution.feature
View file @
4346cb59
...
...
@@ -14,8 +14,7 @@ Scenario: Creating an institution (selenium test)
And
I follow
"Institutions"
And
I press
"Add institution"
And I fill in the following
:
|
Institution
name
|
institutionone
|
|
Institution
display
name
|
institution
One
|
|
Institution
name
|
Institution
One
|
And
I
press
"Submit"
# Verifying the institution has been created
Then
I should see
"Institution added successfully"
...
...
test/behat/features/institution/institution_configuration.feature
View file @
4346cb59
...
...
@@ -11,7 +11,6 @@ Scenario: Turning switches on and off on Edit Institution page (Bug 1431569)
# Checking the default settings are correct
And the following fields match these values
:
|
Institution
name
*
|
|
|
Institution
display
name
*
|
|
|
Registration
allowed
|
0
|
|
Confirm
registration
|
1
|
|
Drop-down
navigation
|
0
|
...
...
@@ -20,8 +19,7 @@ Scenario: Turning switches on and off on Edit Institution page (Bug 1431569)
|
Maximum
user
accounts
allowed
|
|
# Turning the switches on and off
And I set the following fields to these values
:
|
Institution
display
name
*
|
The
Avenger
|
|
Institution
display
name
*
|
Team
Awesome
|
|
Institution
name
*
|
Team
Awesome
|
|
Registration
allowed
|
1
|
|
Confirm
registration
|
0
|
|
Drop-down
navigation
|
1
|
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment