Commit a67320b3 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

User stats added to Institutions page

parent a1fee4fb
...@@ -273,12 +273,24 @@ else { ...@@ -273,12 +273,24 @@ else {
else { else {
$where = ''; $where = '';
$smarty->assign('siteadmin', true); $smarty->assign('siteadmin', true);
$defaultinstmembers = count_records_sql('
SELECT COUNT(u.id) FROM {usr} u LEFT OUTER JOIN {usr_institution} i ON u.id = i.usr
WHERE u.deleted = 0 AND i.usr IS NULL
');
} }
$institutions = get_records_sql_array('SELECT i.name, i.displayname, i.registerallowed, COUNT(u.usr) AS hasmembers $institutions = get_records_sql_assoc('
SELECT
i.name, i.displayname, i.maxuseraccounts,
COUNT(ui.usr) AS members, SUM(ui.staff) AS staff, SUM(ui.admin) AS admins
FROM {institution} i FROM {institution} i
LEFT OUTER JOIN {usr_institution} u ON (u.institution = i.name) ' . $where . ' LEFT OUTER JOIN {usr_institution} ui ON (ui.institution = i.name)
GROUP BY 1, 2, 3 LEFT OUTER JOIN {usr} u ON (u.id = ui.usr AND u.deleted = 0) ' . $where . '
GROUP BY
i.name, i.displayname, i.maxuseraccounts
ORDER BY i.name', array()); ORDER BY i.name', array());
if (isset($defaultinstmembers)) {
$institutions['mahara']->members = $defaultinstmembers;
}
$smarty->assign('institutions', $institutions); $smarty->assign('institutions', $institutions);
} }
......
...@@ -323,6 +323,11 @@ $string['maxuseraccountsdescription'] = 'The maximum number of user accounts tha ...@@ -323,6 +323,11 @@ $string['maxuseraccountsdescription'] = 'The maximum number of user accounts tha
$string['institutionuserserrortoomanyusers'] = 'The users were not added. The number of members cannot exceed the maximum allowed for the institution. You can add fewer users, remove some users from the institution, or ask the site administrator to increase the maximum number of users.'; $string['institutionuserserrortoomanyusers'] = 'The users were not added. The number of members cannot exceed the maximum allowed for the institution. You can add fewer users, remove some users from the institution, or ask the site administrator to increase the maximum number of users.';
$string['institutionuserserrortoomanyinvites'] = 'Your invitations were not sent. The number of existing members plus the number of outstanding invitations cannot exceed the institution\'s maximum number of users. You can invite fewer users, remove some users from the institution, or ask the site administrator to increase the maximum number of users.'; $string['institutionuserserrortoomanyinvites'] = 'Your invitations were not sent. The number of existing members plus the number of outstanding invitations cannot exceed the institution\'s maximum number of users. You can invite fewer users, remove some users from the institution, or ask the site administrator to increase the maximum number of users.';
$string['Members'] = 'Members';
$string['Maximum'] = 'Maximum';
$string['Staff'] = 'Staff';
$string['Admins'] = 'Admins';
// Admin User Search // Admin User Search
$string['Query'] = 'Query'; $string['Query'] = 'Query';
$string['Institution'] = 'Institution'; $string['Institution'] = 'Institution';
......
...@@ -774,6 +774,9 @@ p { ...@@ -774,6 +774,9 @@ p {
border: 0px; border: 0px;
} }
.maincontent th.center {
text-align: center;
}
.maincontent th { .maincontent th {
text-align: left; text-align: left;
color: #3a5813; color: #3a5813;
......
...@@ -21,8 +21,10 @@ ...@@ -21,8 +21,10 @@
<thead> <thead>
<tr> <tr>
<th>{str tag="institution"}</th> <th>{str tag="institution"}</th>
<th>{str tag="authplugin" section="admin"}</th> <th class="center">{str tag="Members" section="admin"}</th>
<th>{str tag="registrationallowed" section="admin"}</th> <th class="center">{str tag="Maximum" section="admin"}</th>
<th class="center">{str tag="Staff" section="admin"}</th>
<th class="center">{str tag="Admins" section="admin"}</th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
...@@ -30,13 +32,21 @@ ...@@ -30,13 +32,21 @@
<tbody> <tbody>
<tr class="{cycle values=r1,r0}"> <tr class="{cycle values=r1,r0}">
<td>{$institution->displayname|escape}</td> <td>{$institution->displayname|escape}</td>
<td>{$institution->authplugin}</td> <td class="center">
<td>{if $institution->authplugin == 'internal'}{if $institution->registerallowed}{str tag="yes"}{else}{str tag="no"}{/if}{else}-{/if}</td> {if $institution->name != 'mahara'}
<a href="{$WWWROOT}admin/users/institutionusers.php?usertype=members&institution={$institution->name}">{$institution->members}</a>
{else}
{$institution->members}
{/if}
</td>
<td class="center">{$institution->maxuseraccounts}</td>
<td class="center"><a href="{$WWWROOT}admin/users/institutionstaff.php?institution={$institution->name}">{$institution->staff}</a></td>
<td class="center"><a href="{$WWWROOT}admin/users/institutionadmins.php?institution={$institution->name}">{$institution->admins}</a></td>
<td> <td>
<form action="" method="post"> <form action="" method="post">
<input type="hidden" name="i" value="{$institution->name}"> <input type="hidden" name="i" value="{$institution->name}">
<input type="submit" class="submit" name="edit" value="{str tag="edit"}" id="admininstitution_edit"> <input type="submit" class="submit" name="edit" value="{str tag="edit"}" id="admininstitution_edit">
{if $siteadmin && !$institution->hasmembers && $institution->name != 'mahara'}<input type="submit" class="submit" name="delete" value="{str tag="delete"}" id="admininstitution_delete">{/if} {if $siteadmin && !$institution->members && $institution->name != 'mahara'}<input type="submit" class="submit" name="delete" value="{str tag="delete"}" id="admininstitution_delete">{/if}
</form> </form>
</td> </td>
</tr> </tr>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment