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
34866a4f
Commit
34866a4f
authored
Feb 01, 2012
by
Richard Mansfield
Committed by
Gerrit Code Review
Feb 01, 2012
Browse files
Merge "Check for authinstances in use when deleting institutions (bug #917873)"
parents
368e865f
d1310840
Changes
4
Hide whitespace changes
Inline
Side-by-side
htdocs/admin/users/institutions.php
View file @
34866a4f
...
...
@@ -82,8 +82,28 @@ if ($institution || $add) {
if
(
$delete
)
{
function
delete_validate
(
Pieform
$form
,
$values
)
{
if
(
get_field
(
'usr_institution'
,
'COUNT(*)'
,
'institution'
,
$values
[
'i'
]))
{
throw
new
ConfigException
(
'Attempt to delete an institution that has members'
);
// Ensure the institution has no members left
if
(
$members
=
get_field
(
'usr_institution'
,
'COUNT(*)'
,
'institution'
,
$values
[
'i'
]))
{
$form
->
set_error
(
'submit'
,
get_string
(
'institutionstillhas'
,
'admin'
,
get_string
(
'nmembers'
,
'group'
,
$members
)));
}
// If some users are still using one of this institution's authinstances, it's okay if
// we can find a default authinstance for those users, otherwise it's an error.
if
(
$authinstanceids
=
get_column
(
'auth_instance'
,
'id'
,
'institution'
,
$values
[
'i'
]))
{
$badusers
=
count_records_select
(
'usr'
,
'authinstance IN ('
.
join
(
','
,
array_fill
(
0
,
count
(
$authinstanceids
),
'?'
))
.
')'
,
$authinstanceids
);
if
(
$badusers
)
{
$defaultauth
=
record_exists
(
'auth_instance'
,
'institution'
,
'mahara'
,
'authname'
,
'internal'
);
if
(
$values
[
'i'
]
==
'mahara'
||
!
$defaultauth
)
{
$form
->
set_error
(
'submit'
,
get_string
(
'institutionauthinuseby'
,
'admin'
,
get_string
(
'nusers'
,
'mahara'
,
$badusers
))
);
}
}
}
}
...
...
@@ -117,6 +137,19 @@ if ($institution || $add) {
}
}
}
// If any users are still using this institution's authinstances, change them now.
if
(
$authinstanceids
)
{
execute_sql
(
"
UPDATE
{
usr
}
SET authinstance = (
SELECT MIN(id) FROM
{
auth_instance
}
WHERE institution = 'mahara' AND authname = 'internal'
)
WHERE authinstance IN ("
.
join
(
','
,
array_fill
(
0
,
count
(
$authinstanceids
),
'?'
))
.
')'
,
$authinstanceids
);
}
foreach
(
$authinstanceids
as
$id
)
{
delete_records
(
'auth_instance_config'
,
'instance'
,
$id
);
}
...
...
htdocs/lang/en.utf8/admin.php
View file @
34866a4f
...
...
@@ -683,6 +683,8 @@ $string['addinstitution'] = 'Add Institution';
$string
[
'authplugin'
]
=
'Authentication plugin'
;
$string
[
'deleteinstitution'
]
=
'Delete Institution'
;
$string
[
'deleteinstitutionconfirm'
]
=
'Are you really sure you wish to delete this institution?'
;
$string
[
'institutionstillhas'
]
=
'This institution still has %s'
;
$string
[
'institutionauthinuseby'
]
=
"This institution's authentication is still in use by %s"
;
$string
[
'institutiononly'
]
=
'Institution only'
;
$string
[
'institutionaddedsuccessfully2'
]
=
'Institution added successfully'
;
$string
[
'institutiondeletedsuccessfully'
]
=
'Institution deleted successfully'
;
...
...
htdocs/lang/en.utf8/group.php
View file @
34866a4f
...
...
@@ -130,6 +130,10 @@ $string['invites'] = "Invites";
$string
[
'member'
]
=
'member'
;
$string
[
'members'
]
=
'members'
;
$string
[
'Members'
]
=
'Members'
;
$string
[
'nmembers'
]
=
array
(
'1 member'
,
'%s members'
,
);
$string
[
'memberrequests'
]
=
'Membership requests'
;
$string
[
'declinerequest'
]
=
'Decline request'
;
...
...
htdocs/lang/en.utf8/mahara.php
View file @
34866a4f
...
...
@@ -951,6 +951,10 @@ $string['Visits'] = 'Visits';
$string
[
'after'
]
=
'after'
;
$string
[
'before'
]
=
'before'
;
$string
[
'Visibility'
]
=
'Visibility'
;
$string
[
'nusers'
]
=
array
(
'1 user'
,
'%s users'
,
);
// import related strings (maybe separated later)
$string
[
'importedfrom'
]
=
'Imported from %s'
;
...
...
Write
Preview
Supports
Markdown
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