Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan-Hendrik Willms
Stud.IP
Commits
1d48e606
Commit
1d48e606
authored
2 years ago
by
Elmar Ludwig
Committed by
David Siegfried
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
count in SQL, not in PHP, fixes #1677
Closes #1677 Merge request
studip/studip!1080
parent
8306d1a7
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/controllers/admin/domain.php
+1
-1
1 addition, 1 deletion
app/controllers/admin/domain.php
app/views/admin/domain/index.php
+3
-3
3 additions, 3 deletions
app/views/admin/domain/index.php
lib/models/UserDomain.php
+24
-0
24 additions, 0 deletions
lib/models/UserDomain.php
with
28 additions
and
4 deletions
app/controllers/admin/domain.php
+
1
−
1
View file @
1d48e606
...
...
@@ -138,7 +138,7 @@ class Admin_DomainController extends AuthenticatedController
CSRFProtection
::
verifyUnsafeRequest
();
$domain
=
new
UserDomain
(
$id
);
if
(
count
(
$domain
->
u
sers
)
==
0
)
{
if
(
$domain
->
countU
sers
(
)
==
=
0
)
{
$domain
->
delete
();
}
else
{
PageLayout
::
postError
(
_
(
'Domänen, denen noch Personen zugewiesen sind, können nicht gelöscht werden.'
));
...
...
This diff is collapsed.
Click to expand it.
app/views/admin/domain/index.php
+
3
−
3
View file @
1d48e606
...
...
@@ -28,13 +28,13 @@
<tr>
<td>
<?=
htmlReady
(
$domain
->
name
)
?>
</td>
<td>
<?=
htmlReady
(
$domain
->
id
)
?>
</td>
<td>
<?=
count
(
$domain
->
u
sers
)
?>
</td>
<td>
<?=
count
(
$domain
->
courses
)
?>
</td>
<td>
<?=
$domain
->
countU
sers
(
)
?>
</td>
<td>
<?=
$domain
->
cou
ntCou
rses
(
)
?>
</td>
<td
class=
"actions"
>
<a
href=
"
<?=
$controller
->
link_for
(
"admin/domain/edit/
{
$domain
->
id
}
"
)
?>
"
data-dialog=
"size=auto"
>
<?=
Icon
::
create
(
'edit'
)
->
asImg
(
tooltip2
(
_
(
'bearbeiten'
)))
?>
</a>
<?
if
(
count
(
$domain
->
u
sers
)
===
0
)
:
?>
<?
if
(
$domain
->
countU
sers
(
)
===
0
)
:
?>
<?=
Icon
::
create
(
'trash'
)
->
asInput
(
tooltip2
(
_
(
'löschen'
))
+
[
'class'
=>
'text-top'
,
'formaction'
=>
$controller
->
url_for
(
"admin/domain/delete/
{
$domain
->
id
}
"
),
...
...
This diff is collapsed.
Click to expand it.
lib/models/UserDomain.php
+
24
−
0
View file @
1d48e606
...
...
@@ -48,6 +48,30 @@ class UserDomain extends SimpleORMap
return
self
::
findBySQL
(
'1 ORDER BY name'
);
}
/**
* Count the number of courses associated with this user domain.
*
* @return int number of courses
*/
public
function
countCourses
():
int
{
$query
=
'SELECT COUNT(*) FROM seminar_userdomains WHERE userdomain_id = ?'
;
return
(
int
)
DBManager
::
get
()
->
fetchColumn
(
$query
,
[
$this
->
id
]);
}
/**
* Count the number of courses associated with this user domain.
*
* @return int number of users
*/
public
function
countUsers
():
int
{
$query
=
'SELECT COUNT(*) FROM user_userdomains WHERE userdomain_id = ?'
;
return
(
int
)
DBManager
::
get
()
->
fetchColumn
(
$query
,
[
$this
->
id
]);
}
/**
* Add a user to this user domain.
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment