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
fusiondirectory
fusiondirectory
Commits
7c0f4019
Commit
7c0f4019
authored
Mar 09, 2015
by
Côme Bernigaud
Committed by
Benoit Mortier
Mar 09, 2015
Browse files
Fixes
#3600
Added a group section to dashboard
parent
395245f8
Changes
4
Hide whitespace changes
Inline
Side-by-side
plugins/addons/dashboard/class_dashBoard.inc
View file @
7c0f4019
...
...
@@ -62,7 +62,7 @@ class dashboard extends simplePlugin
$nb
=
objects
::
count
(
$type
);
}
catch
(
Exception
$e
)
{
$nb
=
0
;
trigger_error
(
$e
->
getMessage
());
trigger_error
(
"Problem with
$type
:"
.
$e
->
getMessage
());
}
if
(
$nb
==
0
)
{
continue
;
...
...
plugins/addons/dashboard/class_dashBoardUsers.inc
View file @
7c0f4019
...
...
@@ -23,17 +23,50 @@
class
dashboardUsers
extends
simplePlugin
{
static
function
plInfo
()
{
return
array
(
'plShortName'
=>
_
(
'Users'
),
'plDescription'
=>
_
(
'Statistics about users'
),
'plObjectType'
=>
array
(
'dashboard'
),
'plProvidedAcls'
=>
array
()
);
}
static
function
getAttributesInfo
()
{
return
array
(
'userstats'
=>
array
(
'name'
=>
_
(
'Users statistics'
),
'attrs'
=>
array
(
new
FakeAttribute
(
'users_stats'
)),
'template'
=>
get_template_path
(
'users_stats.tpl'
,
TRUE
,
dirname
(
__FILE__
)),
),
'groupstats'
=>
array
(
'name'
=>
_
(
'Groups statistics'
),
'attrs'
=>
array
(
new
FakeAttribute
(
'groups_stats'
)),
'template'
=>
get_template_path
(
'groups_stats.tpl'
,
TRUE
,
dirname
(
__FILE__
)),
),
'expired_accounts'
=>
array
(
'name'
=>
_
(
'Expired accounts'
),
'attrs'
=>
array
(
new
FakeAttribute
(
'expired'
)),
'template'
=>
get_template_path
(
'users_accounts.tpl'
,
TRUE
,
dirname
(
__FILE__
)),
),
);
}
function
__construct
(
&
$config
,
$dn
=
NULL
,
$object
=
NULL
)
{
parent
::
__construct
(
$config
,
$dn
,
$object
);
$this
->
stats
=
$this
->
users_stats
();
$this
->
expired
=
$this
->
expired_accounts_info
();
$this
->
users_stats
=
$this
->
computeUsersStats
();
$this
->
groups_stats
=
$this
->
computeGroupsStats
();
$this
->
expired
=
$this
->
expired_accounts_info
();
}
function
u
sers
_s
tats
()
function
computeU
sers
S
tats
()
{
/* User
accounts
statistics */
/* User statistics */
$ldap
=
$this
->
config
->
get_ldap_link
();
$ldap
->
cd
(
$this
->
config
->
current
[
'BASE'
]);
$ldap
->
search
(
"(&(!(objectClass=gosaUserTemplate))(objectClass=gosaAccount))"
,
array
(
"userPassword"
));
...
...
@@ -59,12 +92,34 @@ class dashboardUsers extends simplePlugin
array
(
'name'
=>
'posix'
,
'nb'
=>
$nb_posix_accounts
,
'img'
=>
'geticon.php?context=applications&icon=os-linux&size=16'
),
array
(
'name'
=>
'samba'
,
'nb'
=>
$nb_samba_accounts
,
'img'
=>
'geticon.php?context=applications&icon=os-windows&size=16'
)
),
'nb
_accounts
'
=>
$nb_accounts
,
'
user_
img'
=>
'geticon.php?context=types&icon=user&size=16'
,
'nb'
=>
$nb_accounts
,
'img'
=>
'geticon.php?context=types&icon=user&size=16'
,
'locked_accounts'
=>
array
(
'nb'
=>
$nb_locked_accounts
,
'img'
=>
"geticon.php?context=status&icon=object-locked&size=16"
),
);
}
function
computeGroupsStats
()
{
/* Group statistics */
$ldap
=
$this
->
config
->
get_ldap_link
();
$ldap
->
cd
(
$this
->
config
->
current
[
'BASE'
]);
$ldap
->
search
(
'(objectClass=posixGroup)'
,
array
(
'cn'
));
$nb
=
$ldap
->
count
();
$ldap
->
search
(
'(&(objectClass=posixGroup)(objectClass=gosaMailAccount))'
,
array
(
'cn'
));
$nb_mail_groups
=
$ldap
->
count
();
$ldap
->
search
(
'(&(objectClass=posixGroup)(objectClass=sambaSamAccount))'
,
array
(
'cn'
));
$nb_samba_groups
=
$ldap
->
count
();
return
array
(
'groups'
=>
array
(
array
(
'name'
=>
'mail'
,
'nb'
=>
$nb_mail_groups
,
'img'
=>
'geticon.php?context=applications&icon=internet-mail&size=16'
),
array
(
'name'
=>
'samba'
,
'nb'
=>
$nb_samba_groups
,
'img'
=>
'geticon.php?context=applications&icon=os-windows&size=16'
)
),
'nb'
=>
$nb
,
'img'
=>
'geticon.php?context=types&icon=user-group&size=16'
,
);
}
function
expired_accounts_info
()
{
/*
...
...
@@ -130,33 +185,5 @@ class dashboardUsers extends simplePlugin
'shadowExpire'
=>
$human_shadowExpire
,
);
}
static
function
getAttributesInfo
()
{
return
array
(
'stats'
=>
array
(
'name'
=>
_
(
'Statistics'
),
'attrs'
=>
array
(
new
FakeAttribute
(
'stats'
)),
'template'
=>
get_template_path
(
'users_stats.tpl'
,
TRUE
,
dirname
(
__FILE__
)),
),
'expired_accounts'
=>
array
(
'name'
=>
_
(
'Expired accounts'
),
'attrs'
=>
array
(
new
FakeAttribute
(
'expired'
)),
'template'
=>
get_template_path
(
'users_accounts.tpl'
,
TRUE
,
dirname
(
__FILE__
)),
),
);
}
/* Return plugin informations for acl handling */
static
function
plInfo
()
{
return
array
(
'plShortName'
=>
_
(
'Users'
),
'plDescription'
=>
_
(
'Statistics about users'
),
'plObjectType'
=>
array
(
'dashboard'
),
'plProvidedAcls'
=>
array
()
);
}
}
?>
plugins/addons/dashboard/groups_stats.tpl
0 → 100644
View file @
7c0f4019
<div
id=
"
{
$sectionId
}
"
class=
"plugin_section"
>
<span
class=
"legend"
>
{
$section
}
</span>
<div>
<img
src=
"
{
$attributes.groups_stats.img
}
"
alt=
"group icon"
/>
{
t
count
=
$attributes.groups_stats.nb
1
=
$attributes.groups_stats.nb
plural
=
"There are %1 groups:"
}
There is 1 group:
{/
t
}
<ul>
{
foreach
from
=
$attributes.groups_stats.groups
item
=
g
}
<li
style=
"list-style-image:url(
{
$g.img
}
)"
>
{
if
$g.nb
>
0
}
{
t
count
=
$g.nb
1
=
$g.name
2
=
$g.nb
plural
=
"%2 are %1 groups"
}
One of them is a %1 group
{/
t
}
{
else
}
{
t
1
=
$g.name
}
There is no %1 group
{/
t
}
{/
if
}
</li>
{/
foreach
}
</ul>
</div>
</div>
plugins/addons/dashboard/users_stats.tpl
View file @
7c0f4019
...
...
@@ -3,10 +3,10 @@
{
$section
}
</span>
<div>
<img
src=
"
{
$attributes.stats.
user_
img
}
"
alt=
"user icon"
/>
{
t
count
=
$attributes.stats.nb
_accounts
1
=
$attributes.stats.nb
_accounts
plural
=
"There are %1 users:"
}
There is 1 user:
{/
t
}
<img
src=
"
{
$attributes.
users_
stats.img
}
"
alt=
"user icon"
/>
{
t
count
=
$attributes.
users_
stats.nb
1
=
$attributes.
users_
stats.nb
plural
=
"There are %1 users:"
}
There is 1 user:
{/
t
}
<ul>
{
foreach
from
=
$attributes.stats.accounts
item
=
acc
}
{
foreach
from
=
$attributes.
users_
stats.accounts
item
=
acc
}
<li
style=
"list-style-image:url(
{
$acc.img
}
)"
>
{
if
$acc.nb
>
0
}
{
t
count
=
$acc.nb
1
=
$acc.name
2
=
$acc.nb
plural
=
"%2 of them have a %1 account"
}
One of them have a %1 account
{/
t
}
...
...
@@ -15,9 +15,9 @@
{/
if
}
</li>
{/
foreach
}
<li
style=
"list-style-image:url(
{
$attributes.stats.locked_accounts.img
}
)"
>
{
if
$attributes.stats.locked_accounts.nb
>
0
}
{
t
count
=
$attributes.stats.locked_accounts.nb
1
=
$attributes.stats.locked_accounts.nb
plural
=
"%1 of them are locked"
}
One of them is locked
{/
t
}
<li
style=
"list-style-image:url(
{
$attributes.
users_
stats.locked_accounts.img
}
)"
>
{
if
$attributes.
users_
stats.locked_accounts.nb
>
0
}
{
t
count
=
$attributes.
users_
stats.locked_accounts.nb
1
=
$attributes.
users_
stats.locked_accounts.nb
plural
=
"%1 of them are locked"
}
One of them is locked
{/
t
}
{
else
}
{
t
}
None of them is locked
{/
t
}
{/
if
}
...
...
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