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
83d8a1d7
Commit
83d8a1d7
authored
Feb 26, 2015
by
Benoit Mortier
Browse files
Fixes:
#3596
Dashboard plugin should go into core
parent
02c09e1d
Changes
15
Hide whitespace changes
Inline
Side-by-side
contrib/openldap/dashboard-fd-conf.schema
0 → 100644
View file @
83d8a1d7
##
## dashboard-fd.schema - Needed by Fusion Directory for dashboard plugin
##
# Attributes
attributetype ( 1.3.6.1.4.1.38414.27.1.1 NAME 'fdDashboardPrefix'
DESC 'FusionDirectory - Dashboard computer name prefix'
EQUALITY caseExactIA5Match
SUBSTR caseExactIA5SubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26)
attributetype ( 1.3.6.1.4.1.38414.27.1.2 NAME 'fdDashboardNumberOfDigit'
DESC 'FusionDirectory - Dashboard number of digits after prefixes in computer names'
EQUALITY integerMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.38414.27.1.3 NAME 'fdDashboardExpiredAccountsDays'
DESC 'FusionDirectory - Dashboard number of days before expiration to be shown in board user tab'
EQUALITY integerMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
SINGLE-VALUE )
# Object Class
objectclass ( 1.3.6.1.4.1.38414.27.2.1 NAME 'fdDashboardPluginConf'
DESC 'FusionDirectory dashboard plugin configuration'
SUP top AUXILIARY
MUST ( cn )
MAY ( fdDashboardPrefix $ fdDashboardNumberOfDigit $ fdDashboardExpiredAccountsDays) )
plugins/addons/dashboard/class_dashBoard.inc
0 → 100644
View file @
83d8a1d7
<?php
/*
* This code is part of FusionDirectory (http://www.fusiondirectory.org)
* Copyright (C) 2010 Antoine Gallavardin
* Copyright (C) 2011-2013 FusionDirectory project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class
dashboard
extends
simplePlugin
{
/* Generic */
var
$view_logged
=
FALSE
;
function
__construct
(
&
$config
,
$dn
=
NULL
,
$object
=
NULL
)
{
parent
::
__construct
(
$config
,
$dn
,
$object
);
$this
->
stats
=
$this
->
overview_stats
();
}
/* Compute some statistics */
function
overview_stats
()
{
$ldap
=
$this
->
config
->
get_ldap_link
();
$ldap
->
cd
(
$this
->
config
->
current
[
'BASE'
]);
$ldap
->
search
(
"(&(!(objectClass=gosaUserTemplate))(objectClass=gosaAccount))"
,
array
(
"cn"
));
$nb_accounts
=
$ldap
->
count
();
$ldap
->
cd
(
$this
->
config
->
current
[
'BASE'
]);
$ldap
->
search
(
"(objectClass=posixGroup)"
,
array
(
"cn"
));
$nb_groups
=
$ldap
->
count
();
$ldap
->
search
(
"(objectClass=gosaGroupOfNames)"
,
array
(
"cn"
));
$nb_ogroups
=
$ldap
->
count
();
$stats
=
array
(
array
(
'name'
=>
'Accounts'
,
'nb'
=>
$nb_accounts
,
'img'
=>
'geticon.php?context=types&icon=user&size=16'
),
array
(
'name'
=>
'Groups'
,
'nb'
=>
$nb_groups
,
'img'
=>
'geticon.php?context=types&icon=user-group&size=16'
),
array
(
'name'
=>
'Object groups'
,
'nb'
=>
$nb_ogroups
,
'img'
=>
'geticon.php?context=types&icon=resource-group&size=16'
),
);
if
(
class_available
(
"systemManagement"
))
{
$ldap
->
cd
(
$this
->
config
->
current
[
'BASE'
]);
$workstations
=
'(objectClass=gotoWorkstation)'
;
$servers
=
'(objectClass=goServer)'
;
$winstations
=
'(&(objectClass=sambaSamAccount)(uid=*$))'
;
$terminals
=
'(objectClass=gotoTerminal)'
;
$printers
=
'(objectClass=gotoPrinter)'
;
$phones
=
'(objectClass=goFonHardware)'
;
$devices
=
'(objectClass=ieee802Device)'
;
$ldap
->
search
(
"(|
$workstations$servers$winstations$terminals$printers$phones$devices
)"
,
array
(
"cn"
)
);
$nb_systems
=
$ldap
->
count
();
array_unshift
(
$stats
,
array
(
'name'
=>
'Systems'
,
'nb'
=>
$nb_systems
,
'img'
=>
'geticon.php?context=devices&icon=server&size=16'
)
);
}
return
$stats
;
}
static
function
getAttributesInfo
()
{
return
array
(
'stats'
=>
array
(
'name'
=>
_
(
'Statistics'
),
'attrs'
=>
array
(
new
FakeAttribute
(
'stats'
)),
'template'
=>
get_template_path
(
'main_stats.tpl'
,
TRUE
,
dirname
(
__FILE__
)),
),
);
}
/* Return plugin informations for acl handling */
static
function
plInfo
()
{
return
array
(
'plShortName'
=>
_
(
'Dashboard'
),
'plDescription'
=>
_
(
'Statistics and various informations'
),
'plIcon'
=>
'geticon.php?context=applications&icon=utilities-system-monitor&size=48'
,
'plObjectType'
=>
array
(
'dashboard'
=>
array
(
'name'
=>
_
(
'Dashboard'
))),
'plSection'
=>
'addons'
,
'plPriority'
=>
2
,
'plProvidedAcls'
=>
array
()
);
}
}
?>
plugins/addons/dashboard/class_dashBoardNetwork.inc
0 → 100644
View file @
83d8a1d7
<?php
/*
* This code is part of FusionDirectory (http://www.fusiondirectory.org)
* Copyright (C) 2010 Antoine Gallavardin
* Copyright (C) 2011-2013 FusionDirectory project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class
dashboardNetwork
extends
simplePlugin
{
function
__construct
(
&
$config
,
$dn
=
NULL
,
$object
=
NULL
)
{
parent
::
__construct
(
$config
,
$dn
,
$object
);
$this
->
dhcp_infos
=
$this
->
dhcp_infos
();
if
(
empty
(
$this
->
dhcp_infos
))
{
unset
(
$this
->
attributesInfo
[
'dhcp'
]);
}
$this
->
dns_infos
=
$this
->
dns_infos
();
if
(
empty
(
$this
->
dns_infos
))
{
unset
(
$this
->
attributesInfo
[
'dns'
]);
}
}
function
dhcp_infos
()
{
if
(
!
class_available
(
"dhcpService"
))
{
return
array
();
}
$ldap
=
$this
->
config
->
get_ldap_link
();
$ldap
->
cd
(
$this
->
config
->
current
[
'BASE'
]);
$ldap
->
search
(
"(objectClass=dhcpServer)"
,
array
(
"cn"
,
"dhcpServiceDN"
));
$servers
=
array
();
while
(
$attrs
=
$ldap
->
fetch
())
{
$zones
=
array
();
$ldap_zone
=
$this
->
config
->
get_ldap_link
();
$ldap_zone
->
cd
(
$attrs
[
'dhcpServiceDN'
][
0
]);
$ldap_zone
->
search
(
"(objectClass=dhcpSubnet)"
,
array
(
"cn"
,
"dhcpNetMask"
));
while
(
$attrs_zone
=
$ldap_zone
->
fetch
())
{
$zones
[]
=
$attrs_zone
[
'cn'
][
0
]
.
"/"
.
$attrs_zone
[
'dhcpNetMask'
][
0
];
}
$servers
[]
=
array
(
'name'
=>
$attrs
[
'cn'
][
0
],
'link'
=>
objects
::
link
(
$attrs
[
'dn'
],
'server'
,
'service_serviceDHCP'
,
$attrs
,
FALSE
),
'zones'
=>
$zones
);
}
return
$servers
;
}
function
dns_infos
()
{
if
(
!
class_available
(
"DNS"
))
{
return
array
();
}
$ldap
=
$this
->
config
->
get_ldap_link
();
$ldap
->
cd
(
$this
->
config
->
current
[
'BASE'
]);
$ldap
->
search
(
"(&(objectClass=dNSZone)(zoneName=*))"
,
array
(
"dn"
,
"zoneName"
));
$servers
=
array
();
while
(
$attrs
=
$ldap
->
fetch
())
{
$dn
=
preg_replace
(
"/^zoneName=[^,]+,/"
,
""
,
$attrs
[
'dn'
]);
if
(
preg_match
(
"/^cn=/"
,
$dn
))
{
$cn
=
preg_replace
(
"/^cn=([^,]+),.*$/"
,
"$1"
,
$dn
);
if
(
!
isset
(
$servers
[
$dn
]))
{
$servers
[
$dn
]
=
array
(
'name'
=>
$cn
,
'link'
=>
objects
::
link
(
$dn
,
'server'
,
'service_serviceDNS'
,
$cn
,
FALSE
),
'zones'
=>
array
()
);
}
$servers
[
$dn
][
'zones'
][
$attrs
[
'zoneName'
][
0
]]
=
$attrs
[
'zoneName'
][
0
];
}
elseif
(
preg_match
(
"/^zoneName=/"
,
$dn
))
{
$reverseName
=
preg_replace
(
"/^zoneName=([^,]+),.*$/"
,
"$1"
,
$attrs
[
'dn'
]);
$zoneName
=
preg_replace
(
"/^zoneName=([^,]+),.*$/"
,
"$1"
,
$dn
);
$dn
=
preg_replace
(
"/^zoneName=[^,]+,/"
,
""
,
$dn
);
$IP
=
DNS
::
FlipIp
(
str_replace
(
DNS
::
getInAddrArpa
(),
""
,
$reverseName
));
for
(
$dots
=
count
(
explode
(
"."
,
$IP
));
$dots
<
4
;
$dots
++
)
{
$IP
.
=
".0"
;
}
$servers
[
$dn
][
'zones'
][
$zoneName
]
.
=
" (
$IP
)"
;
}
}
return
array_values
(
$servers
);
}
static
function
getAttributesInfo
()
{
return
array
(
'dhcp'
=>
array
(
'name'
=>
_
(
'DHCP'
),
'attrs'
=>
array
(
new
FakeAttribute
(
'dhcp_infos'
)),
'template'
=>
get_template_path
(
'network_dhcp.tpl'
,
TRUE
,
dirname
(
__FILE__
)),
),
'dns'
=>
array
(
'name'
=>
_
(
'DNS'
),
'attrs'
=>
array
(
new
FakeAttribute
(
'dns_infos'
)),
'template'
=>
get_template_path
(
'network_dhcp.tpl'
,
TRUE
,
dirname
(
__FILE__
)),
),
);
}
/* Return plugin informations for acl handling */
static
function
plInfo
()
{
return
array
(
'plShortName'
=>
_
(
'Network'
),
'plDescription'
=>
_
(
'Statistics and various informations'
),
'plObjectType'
=>
array
(
'dashboard'
),
'plProvidedAcls'
=>
array
()
);
}
}
?>
plugins/addons/dashboard/class_dashBoardSystems.inc
0 → 100644
View file @
83d8a1d7
<?php
/*
* This code is part of FusionDirectory (http://www.fusiondirectory.org)
* Copyright (C) 2010 Antoine Gallavardin
* Copyright (C) 2011-2013 FusionDirectory project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class
dashboardSystems
extends
simplePlugin
{
/* default values*/
var
$default_start_computer_id
=
0
;
function
__construct
(
&
$config
,
$dn
=
NULL
,
$object
=
NULL
)
{
parent
::
__construct
(
$config
,
$dn
,
$object
);
$this
->
stats
=
array
(
'systems'
=>
$this
->
systems_stats
(),
'argonaut'
=>
$this
->
argonaut_stats
(),
);
$this
->
pc_ids
=
$this
->
computer_ids_rules
();
}
function
systems_stats
()
{
$ldap
=
$this
->
config
->
get_ldap_link
();
$ldap
->
cd
(
$this
->
config
->
current
[
'BASE'
]);
/* Statistics */
$stats
=
array
(
array
(
'name'
=>
_
(
'Workstations'
),
'filter'
=>
'objectClass=gotoWorkstation'
,
'img'
=>
'geticon.php?context=devices&icon=computer&size=16'
),
array
(
'name'
=>
_
(
'Servers'
),
'filter'
=>
'objectClass=goServer'
,
'img'
=>
'geticon.php?context=devices&icon=server&size=16'
),
array
(
'name'
=>
_
(
'Windows Workstations'
),
'filter'
=>
'(&(objectClass=sambaSamAccount)(uid=*$))'
,
'img'
=>
'geticon.php?context=devices&icon=computer-windows&size=16'
),
array
(
'name'
=>
_
(
'Terminals'
),
'filter'
=>
'objectClass=gotoTerminal'
,
'img'
=>
'geticon.php?context=devices&icon=terminal&size=16'
),
array
(
'name'
=>
_
(
'Printers'
),
'filter'
=>
'objectClass=gotoPrinter'
,
'img'
=>
'geticon.php?context=devices&icon=printer&size=16'
),
array
(
'name'
=>
_
(
'Phones'
),
'filter'
=>
'objectClass=goFonHardware'
,
'img'
=>
'geticon.php?context=devices&icon=telephone&size=16'
),
array
(
'name'
=>
_
(
'Components'
),
'filter'
=>
'objectClass=ieee802Device'
,
'img'
=>
'geticon.php?context=devices&icon=network-device&size=16'
),
array
(
'name'
=>
_
(
'Mobile phones'
),
'filter'
=>
'objectClass=fdMobilePhone'
,
'img'
=>
'geticon.php?context=devices&icon=phone&size=16'
),
);
$ldap
->
cd
(
$this
->
config
->
current
[
'BASE'
]);
foreach
(
$stats
as
&
$stat
)
{
$ldap
->
search
(
$stat
[
'filter'
],
array
(
"cn"
));
$stat
[
'nb'
]
=
$ldap
->
count
();
}
unset
(
$stat
);
return
$stats
;
}
function
argonaut_stats
()
{
$ldap
=
$this
->
config
->
get_ldap_link
();
$ldap
->
cd
(
$this
->
config
->
current
[
'BASE'
]);
$ldap
->
search
(
"(objectClass=argonautServer)"
,
array
(
'cn'
,
'ipHostNumber'
,
'argonautProtocol'
,
'argonautPort'
));
$nb_argonaut_server
=
$ldap
->
count
();
$argonaut_server
=
array
();
if
(
$nb_argonaut_server
==
1
)
{
$attrs
=
$ldap
->
fetch
();
foreach
(
array
(
'cn'
,
'ipHostNumber'
,
'argonautProtocol'
,
'argonautPort'
)
as
$key
)
{
$argonaut_server
[
$key
]
=
$attrs
[
$key
][
0
];
}
$argonaut_server
[
'link'
]
=
objects
::
link
(
$attrs
[
'dn'
],
'server'
,
'service_serviceArgonaut'
,
$attrs
);
}
$ldap
->
search
(
"(objectClass=argonautClient)"
,
array
(
'cn'
));
$nb_argonaut_clients
=
$ldap
->
count
();
return
array
(
'nb_servers'
=>
$nb_argonaut_server
,
'server'
=>
$argonaut_server
,
'nb_clients'
=>
$nb_argonaut_clients
,
);
}
function
computer_ids_rules
()
{
$ldap
=
$this
->
config
->
get_ldap_link
();
$ldap
->
cd
(
$this
->
config
->
current
[
'BASE'
]);
/* Begin of code for selecting next computer IDs
* Global variable is board_next_computer_ids_rule
* syntax is :
* 7 : nb total of digit
* LYP3 : prefix to use
* each prefix is followed by the first item flagged by an equal sign
* ex : "7;LYP0=3;LYP1=6;LYP2;LYP3"
* if to item is doned it's 0 by default
*
*/
$output_next_computer_ids
=
""
;
$computer_ids_rules
=
$this
->
config
->
get_cfg_value
(
'dashboardPrefix'
,
array
(
'PC'
));
if
(
!
is_array
(
$computer_ids_rules
))
{
$computer_ids_rules
=
array
(
$computer_ids_rules
);
}
/* $get_cfg_value return the OU like ou=computer .. */
$winstation_ou
=
mb_substr
(
$this
->
config
->
get_cfg_value
(
'sambaMachineAccountRDN'
),
3
);
//FIXME use get_ou
$nb_digits
=
$this
->
config
->
get_cfg_value
(
'dashboardNumberOfDigit'
,
3
);
/* running all the table */
foreach
(
$computer_ids_rules
as
$rule
)
{
/* aray initialization*/
$array_complete_list
=
array
();
$array_real_list
=
array
();
$unused_computer_ids
=
array
();
/* get computer ids configuration */
$config_ids
=
explode
(
"="
,
$rule
);
/* fist is is the prefix */
$prefix
=
$config_ids
[
0
];
/* second (if specified) is the first item */
if
(
!
isset
(
$config_ids
[
1
]))
{
$start_id
=
$this
->
default_start_computer_id
;
}
else
{
$start_id
=
$config_ids
[
1
];
}
$output_next_computer_ids
=
$output_next_computer_ids
.
'<tr><th style="padding:4px;border:1px solid #BBB;">'
.
$prefix
.
"</th>"
;
$nb_digits_suffix
=
$nb_digits
-
strlen
(
$prefix
);
/* generation of list of suffixe */
for
(
$d
=
$start_id
;
$d
<
pow
(
10
,
$nb_digits_suffix
);
$d
++
)
{
/* padding : 34 on 4 digit become : 0034*/
$array_complete_list
[]
=
str_pad
(
$d
,
$nb_digits_suffix
,
"0"
,
STR_PAD_LEFT
);
}
/* request of all computer beginning by the prefix */
$request
=
"(&(|(objectClass=sambaSamAccount)(objectClass=GOhard))(cn=
$prefix
*)(|(ou:dn:=
$winstation_ou
)(ou:dn:=systems)))"
;
$ldap
->
search
(
$request
,
array
(
"cn"
));
while
(
$attrs
=
$ldap
->
fetch
())
{
/* if a computer is a windows host, we have to delete the $ at the end */
$computer_id
=
str_replace
(
"$"
,
""
,
$attrs
[
"cn"
][
0
]);
$array_real_list
[]
=
substr
(
$computer_id
,
-
$nb_digits_suffix
);
}
/* make dfference between real and complete list */
$unused_computer_ids
=
array_diff
(
$array_complete_list
,
$array_real_list
);
asort
(
$unused_computer_ids
);
$unused_computer_ids
=
array_values
(
$unused_computer_ids
);
/* we take the 5 first */
for
(
$r
=
0
;
$r
<=
5
;
$r
++
)
{
$output_next_computer_ids
.
=
'<td style="padding:4px;border-bottom:1px solid #BBB;">'
.
$prefix
.
$unused_computer_ids
[
$r
]
.
"</td>"
;
}
$output_next_computer_ids
.
=
"</tr>"
;
}
return
$output_next_computer_ids
;
}
static
function
getAttributesInfo
()
{
return
array
(
'stats'
=>
array
(
'name'
=>
_
(
'Statistics'
),
'attrs'
=>
array
(
new
FakeAttribute
(
'stats'
)),
'template'
=>
get_template_path
(
'systems_stats.tpl'
,
TRUE
,
dirname
(
__FILE__
)),
),
'pc_ids'
=>
array
(
'name'
=>
_
(
'Computer name to use by unit'
),
'attrs'
=>
array
(
new
FakeAttribute
(
'pc_ids'
)),
'template'
=>
get_template_path
(
'systems_pcids.tpl'
,
TRUE
,
dirname
(
__FILE__
)),
),
);
}
/* Return plugin informations for acl handling */
static
function
plInfo
()
{
return
array
(
'plShortName'
=>
_
(
'Systems'
),
'plDescription'
=>
_
(
'Statistics and informations about systems'
),
'plIcon'
=>
'plugins/dashboard/images/icon.png'
,
'plObjectType'
=>
array
(
'dashboard'
),
'plProvidedAcls'
=>
array
()
);
}
}
?>
plugins/addons/dashboard/class_dashBoardUsers.inc
0 → 100644
View file @
83d8a1d7
<?php
/*
* This code is part of FusionDirectory (http://www.fusiondirectory.org)
* Copyright (C) 2010 Antoine Gallavardin
* Copyright (C) 2011-2013 FusionDirectory project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class
dashboardUsers
extends
simplePlugin
{
function
__construct
(
&
$config
,
$dn
=
NULL
,
$object
=
NULL
)
{
parent
::
__construct
(
$config
,
$dn
,
$object
);
$this
->
stats
=
$this
->
users_stats
();
$this
->
expired
=
$this
->
expired_accounts_info
();
}
function
users_stats
()
{
/* User accounts statistics */
$ldap
=
$this
->
config
->
get_ldap_link
();
$ldap
->
cd
(
$this
->
config
->
current
[
'BASE'
]);
$ldap
->
search
(
"(&(!(objectClass=gosaUserTemplate))(objectClass=gosaAccount))"
,
array
(
"userPassword"
));
$nb_accounts
=
$ldap
->
count
();
$nb_locked_accounts
=
0
;
while
(
$attrs
=
$ldap
->
fetch
())
{
if
(
isset
(
$attrs
[
'userPassword'
][
0
])
&&
preg_match
(
"/^\{[^\}]/"
,
$attrs
[
'userPassword'
][
0
]))
{
if
(
preg_match
(
"/^[^\}]*+\}!/"
,
$attrs
[
'userPassword'
][
0
]))
{
$nb_locked_accounts
++
;
}
}
}
$ldap
->
search
(
"(&(!(objectClass=gosaUserTemplate))(objectClass=gosaAccount)(objectClass=gosaMailAccount))"
,
array
(
"cn"
));
$nb_mail_accounts
=
$ldap
->
count
();
$ldap
->
search
(
"(&(!(objectClass=gosaUserTemplate))(objectClass=gosaAccount)(objectClass=posixAccount))"
,
array
(
"cn"
));
$nb_posix_accounts
=
$ldap
->
count
();
$ldap
->
search
(
"(&(!(objectClass=gosaUserTemplate))(objectClass=gosaAccount)(objectClass=sambaSamAccount))"
,
array
(
"cn"
));
$nb_samba_accounts
=
$ldap
->
count
();
return
array
(
'accounts'
=>
array
(
array
(
'name'
=>
'mail'
,
'nb'
=>
$nb_mail_accounts
,
'img'
=>
'geticon.php?context=applications&icon=internet-mail&size=16'
),
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'
,
'locked_accounts'
=>
array
(
'nb'
=>
$nb_locked_accounts
,
'img'
=>
"geticon.php?context=status&icon=object-locked&size=16"
),
);
}
function
expired_accounts_info
()
{
/*
* Begin of code for selecting expired account
*/
/* getting the date in TIMESTAMP UNIX format */
$today
=
floor
(
time
()
/
86400
);
// 24 * 60 * 60
/* Fetch global value from fusiondirectory.conf */
$next_expired_days
=
$this
->
config
->
get_cfg_value
(
'dashboardExpiredAccountsDays'
,
15
);
$next_expired_date
=
(
$today
+
$next_expired_days
);
/* search all account with all date, mail, telephone */
$ldap
=
$this
->
config
->
get_ldap_link
();
$ldap
->
cd
(
$this
->
config
->
current
[
'BASE'
]);
$ldap
->
search
(
'(&(|(objectClass=posixAccount)(objectClass=sambaSamAccount))(shadowExpire=*))'
,
array
(
'uid'
,
'shadowExpire'
,
'mail'
,
'telephoneNumber'
,
'cn'
,
'manager'
));
$expired_accounts
=
array
();
$next_expired_accounts
=
array
();
while
(
$attrs
=
$ldap
->
fetch
())
{
// Test if account is expired now
if
(
$attrs
[
'shadowExpire'
][
0
]
<=
$today
)
{
$expired_accounts
[]
=
$this
->
get_user_infos
(
$attrs
);
}
elseif
(
$attrs
[
'shadowExpire'
][
0
]
<=
$next_expired_date
)
{
$next_expired_accounts
[]
=
$this
->
get_user_infos
(
$attrs
);
}
}
return
array
(
'accounts'
=>
$expired_accounts
,
'accounts_next_days'
=>
$next_expired_accounts
,
'next_days'
=>
$next_expired_days
,
);
}
function
get_user_infos
(
$attrs
)
{
if
(
isset
(
$attrs
[
"manager"
][
0
]))
{
$ldap_manager
=
$this
->
config
->
get_ldap_link
();
$ldap_manager
->
cd
(
$this
->
config
->
current
[
'BASE'
]);
$manager_cn
=
$ldap_manager
->
get_attribute
(
$attrs
[
"manager"
][
0
],
"cn"
);
$manager_mail
=
$ldap_manager
->
get_attribute
(
$attrs
[
"manager"
][
0
],
"mail"
);
$manager_phone
=
$ldap_manager
->
get_attribute
(
$attrs
[
"manager"
][
0
],
"telephoneNumber"
);
}
else
{
$manager_cn
=
""
;
$manager_mail
=
""
;
$manager_phone
=
""
;