diff --git a/contrib/openldap/dashboard-fd-conf.schema b/contrib/openldap/dashboard-fd-conf.schema new file mode 100644 index 0000000000000000000000000000000000000000..80e6a8ce7c4ccd2b75a4781c1350c168939c8278 --- /dev/null +++ b/contrib/openldap/dashboard-fd-conf.schema @@ -0,0 +1,29 @@ +## +## 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) ) diff --git a/plugins/addons/dashboard/class_dashBoard.inc b/plugins/addons/dashboard/class_dashBoard.inc new file mode 100644 index 0000000000000000000000000000000000000000..14a0290445c001dbf3af768446fd655ca6cef7a0 --- /dev/null +++ b/plugins/addons/dashboard/class_dashBoard.inc @@ -0,0 +1,104 @@ +<?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() + ); + } +} +?> diff --git a/plugins/addons/dashboard/class_dashBoardNetwork.inc b/plugins/addons/dashboard/class_dashBoardNetwork.inc new file mode 100644 index 0000000000000000000000000000000000000000..e8ade5e1a94893d5622e6b4e242a57bd6134333b --- /dev/null +++ b/plugins/addons/dashboard/class_dashBoardNetwork.inc @@ -0,0 +1,135 @@ +<?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() + ); + } +} +?> diff --git a/plugins/addons/dashboard/class_dashBoardSystems.inc b/plugins/addons/dashboard/class_dashBoardSystems.inc new file mode 100644 index 0000000000000000000000000000000000000000..2d679488696d9eb7e1c448d762b348253485e028 --- /dev/null +++ b/plugins/addons/dashboard/class_dashBoardSystems.inc @@ -0,0 +1,208 @@ +<?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() + ); + } +} +?> diff --git a/plugins/addons/dashboard/class_dashBoardUsers.inc b/plugins/addons/dashboard/class_dashBoardUsers.inc new file mode 100644 index 0000000000000000000000000000000000000000..386c2018e5194058e6e91711cb77e9fc617bdd1d --- /dev/null +++ b/plugins/addons/dashboard/class_dashBoardUsers.inc @@ -0,0 +1,161 @@ +<?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 = ""; + } + + $human_shadowExpire = date('d.m.Y', $attrs["shadowExpire"][0] * 86400); // 24 * 60 * 60 + + return array( + 'uid' => $attrs["uid"][0], + 'cn' => $attrs["cn"][0], + 'telephoneNumber' => (isset($attrs["telephoneNumber"][0])?$attrs["telephoneNumber"][0]:""), + 'mail' => (isset($attrs["mail"][0])?$attrs["mail"][0]:""), + 'manager_cn' => $manager_cn, + 'manager_mail' => $manager_mail, + 'manager_phone' => $manager_phone, + '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() + ); + } +} +?> diff --git a/plugins/addons/dashboard/contents.tpl b/plugins/addons/dashboard/contents.tpl new file mode 100644 index 0000000000000000000000000000000000000000..58a8cadd19acafcb1fe8eb08d9f9a58c285d8d85 --- /dev/null +++ b/plugins/addons/dashboard/contents.tpl @@ -0,0 +1,37 @@ +<div class="plugin_section"> + <span class="legend"> + {t}Statistics{/t} + </span> + <div> + <ul> + {foreach from=$stats item=stat} + <li style="list-style-image:url({$stat.img})"> + {$stat.nb} {$stat.name} + </li> + {/foreach} + </ul> + {if $nb_argonaut_server > 1} + <img src="images/small_warning.png" style="vertical-align:middle;margin-right:3px;" alt="warning"/>{t}There are several argonaut servers! (this is not yet supported){/t} + {elseif $nb_argonaut_server == 1} + {t 1=$argonaut_server.cn 2=$argonaut_server.ipHostNumber 3=$argonaut_server.argonautProtocol 4=$argonaut_server.argonautPort}There is an argonaut server running on %1 (%3://%2:%4){/t}<br/> + {if $nb_argonaut_clients > 0} + {t count=$nb_argonaut_clients 1=$nb_argonaut_clients plural="%1 systems are configured to run an argonaut client."}Only one system is configured to run an argonaut client.{/t}<br/> + {else} + {t}But no system is configured to run an argonaut client!{/t}<br/> + {/if} + {elseif $nb_argonaut_clients > 0} + <img src="images/small_warning.png" style="vertical-align:middle;margin-right:3px;" alt="warning"/>{t count=$nb_argonaut_clients 1=$nb_argonaut_clients plural="%1 systems are configured to run an argonaut client, but there is no argonaut server configured!"}A system is configured to run an argonaut client, but there is no argonaut server configured!{/t}<br/> + {/if} + </div> +</div> + +<div class="plugin_section"> + <span class="legend"> + {t}Computer name to use by unit{/t} + </span> + <div> + <table style="border:1px solid #B0B0B0; width:100%; vertical-align:top; text-align:left;border-spacing:0;"> + {$output_next_computer_ids} + </table> + </div> +</div> diff --git a/plugins/addons/dashboard/main.inc b/plugins/addons/dashboard/main.inc new file mode 100644 index 0000000000000000000000000000000000000000..e3cbd18812a509af4b296f30468c4640b149337d --- /dev/null +++ b/plugins/addons/dashboard/main.inc @@ -0,0 +1,22 @@ +<?php +/* + * This code is part of FusionDirectory (http://www.fusiondirectory.org) + * Copyright (C) 2013-2015 FusionDirectory + * + * 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. + */ + +simplePlugin::mainInc('dashboard', '', 'tabs_dashboard', FALSE); +?> diff --git a/plugins/addons/dashboard/main_stats.tpl b/plugins/addons/dashboard/main_stats.tpl new file mode 100644 index 0000000000000000000000000000000000000000..cff7e61bbcc8f34c5c968c0eca440277a3e8b17e --- /dev/null +++ b/plugins/addons/dashboard/main_stats.tpl @@ -0,0 +1,14 @@ +<div class="plugin_section"> + <span class="legend"> + {t}Statistics{/t} + </span> + <div> + <ul> + {foreach from=$attributes.stats item=stat} + <li style="list-style-image:url({$stat.img})"> + {$stat.nb} {$stat.name} + </li> + {/foreach} + </ul> + </div> +</div> diff --git a/plugins/addons/dashboard/network_dhcp.tpl b/plugins/addons/dashboard/network_dhcp.tpl new file mode 100644 index 0000000000000000000000000000000000000000..4f791e84400831cf68477e8b3df57e48b70b5b1c --- /dev/null +++ b/plugins/addons/dashboard/network_dhcp.tpl @@ -0,0 +1,23 @@ +<div id="{$sectionId}" class="plugin_section"> + <span class="legend"> + {$section} + </span> + <div> + {foreach from=$attributes item=infos} + <ul> + {foreach from=$infos item=server} + <li style="list-style-image:url(geticon.php?context=devices&icon=server&size=16)" id="server_{$server.name}"> + {$server.link} + <ul> + {foreach from=$server.zones item=zone} + <li style="list-style:disc"> + {$zone} + </li> + {/foreach} + </ul> + </li> + {/foreach} + </ul> + {/foreach} + </div> +</div> diff --git a/plugins/addons/dashboard/systems_pcids.tpl b/plugins/addons/dashboard/systems_pcids.tpl new file mode 100644 index 0000000000000000000000000000000000000000..817d217941e67bf1763b275dbcdeca38922f2578 --- /dev/null +++ b/plugins/addons/dashboard/systems_pcids.tpl @@ -0,0 +1,10 @@ +<div id="{$sectionId}" class="plugin_section"> + <span class="legend"> + {$section} + </span> + <div> + <table style="border-collapse:collapse; border:1px solid #B0B0B0; width:100%; vertical-align:top; text-align:left;"> + {$attributes.pc_ids} + </table> + </div> +</div> diff --git a/plugins/addons/dashboard/systems_stats.tpl b/plugins/addons/dashboard/systems_stats.tpl new file mode 100644 index 0000000000000000000000000000000000000000..6680da16f6a299b777e1e3c19579b8e1f73d7409 --- /dev/null +++ b/plugins/addons/dashboard/systems_stats.tpl @@ -0,0 +1,26 @@ +<div id="{$sectionId}" class="plugin_section"> + <span class="legend"> + {$section} + </span> + <div> + <ul> + {foreach from=$attributes.stats.systems item=stat} + <li style="list-style-image:url({$stat.img})"> + {$stat.nb} {$stat.name} + </li> + {/foreach} + </ul> + {if $attributes.stats.argonaut.nb_servers > 1} + <img src="images/small_warning.png" style="vertical-align:middle;margin-right:3px;" alt="warning"/>{t}There are several argonaut servers! (this is not yet supported){/t} + {elseif $attributes.stats.argonaut.nb_servers == 1} + {t escape=none 1=$attributes.stats.argonaut.server.link 2=$attributes.stats.argonaut.server.ipHostNumber 3=$attributes.stats.argonaut.server.argonautProtocol 4=$attributes.stats.argonaut.server.argonautPort}There is an argonaut server running on %1 (%3://%2:%4){/t}<br/> + {if $attributes.stats.argonaut.nb_clients > 0} + {t count=$attributes.stats.argonaut.nb_clients 1=$attributes.stats.argonaut.nb_clients plural="%1 systems are configured to run an argonaut client."}Only one system is configured to run an argonaut client.{/t}<br/> + {else} + {t}But no system is configured to run an argonaut client!{/t}<br/> + {/if} + {elseif $attributes.stats.argonaut.nb_clients > 0} + <img src="images/small_warning.png" style="vertical-align:middle;margin-right:3px;" alt="warning"/>{t count=$attributes.stats.argonaut.nb_clients 1=$attributes.stats.argonaut.nb_clients plural="%1 systems are configured to run an argonaut client, but there is no argonaut server configured!"}A system is configured to run an argonaut client, but there is no argonaut server configured!{/t}<br/> + {/if} + </div> +</div> diff --git a/plugins/addons/dashboard/tabs_dashBoard.inc b/plugins/addons/dashboard/tabs_dashBoard.inc new file mode 100644 index 0000000000000000000000000000000000000000..dfd493143a74b0a6c4987a77a3e195b1abb7d317 --- /dev/null +++ b/plugins/addons/dashboard/tabs_dashBoard.inc @@ -0,0 +1,46 @@ +<?php + +/* + This code is part of FusionDirectory (http://www.fusiondirectory.org/) + Copyright (C) 2003-2010 Cajus Pollmeier + Copyright (C) 2011-2015 FusionDirectory + + 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 tabs_dashboard extends tabs +{ + + function __construct($config, $data, $dn = NULL, $category = 'dashboard', $copied_object = NULL) + { + foreach ($data as $key => $infos) { + if (($infos['CLASS'] == 'dashboardSystems') && (!class_available('systemManagement'))) { + unset($data[$key]); + } + if (($infos['CLASS'] == 'dashboardNetwork') && + (!class_available('systemManagement') || !(class_available('dhcpService') || class_available('serviceDNS')))) { + unset($data[$key]); + } + } + $data = array_values($data); + parent::__construct($config, $data, $dn, $category); + } + + function save() + { + } +} + +?> diff --git a/plugins/addons/dashboard/users_accounts.tpl b/plugins/addons/dashboard/users_accounts.tpl new file mode 100644 index 0000000000000000000000000000000000000000..7f936105a483e391026b57f3de08133e390e66e7 --- /dev/null +++ b/plugins/addons/dashboard/users_accounts.tpl @@ -0,0 +1,104 @@ +<div id="{$sectionId}" class="plugin_section fullwidth"> + <span class="legend"> + {$section} + </span> + <div> + <h1> + {if $attributes.expired.accounts|@count > 0} + {t count=$attributes.expired.accounts|@count 1=$attributes.expired.accounts|@count plural="There are %1 expired accounts"}There is one expired account{/t} + {else} + {t}There is no expired account{/t} + {/if} + </h1> + {if $attributes.expired.accounts|@count > 0} + <table style="width: 100%;" class="listingTable"> + <colgroup> + <col width="10%"/> + <col width="15%"/> + <col width="15%"/> + <col width="15%"/> + <col width="15%"/> + <col width="10%"/> + </colgroup> + <thead> + <tr style="background-color: white; text-align:center;"> + <th colspan="4" style="background-color: white; padding:5px;"> + {t}Expired accounts{/t} + </th> + <th colspan="3" style="background-color: white; padding:5px;"> + {t}Manager concerned{/t} + </th> + </tr> + + + <tr style="background-color: #E8E8E8; height:26px;font-weight:bold;"> + <!-- uid/cn/telephonNumber/mail/shadowExpire/sambaKickoffTime --> + <th>{t}uid{/t}</th><th>{t}cn{/t}</th><th>{t}telephoneNumber{/t}</th><th>{t}shadowExpire{/t}</th> + <th>{t}manager{/t}</th><th>{t}mail{/t}</th><th>{t}telephoneNumber{/t}</th> + </tr> + </thead> + <tbody> + {foreach from=$attributes.expired.accounts item=account} + <tr> + <td> {$account.uid}</td> + <td> {$account.cn}</td> + <td> {$account.telephoneNumber}</td> + <td> {$account.shadowExpire}</td> + <td> {$account.manager_cn}</td> + <td><a href="mailto:{$account.manager_mail}">{$account.manager_mail}</a></td> + <td> {$account.manager_phone}</td> + </tr> + {/foreach} + </tbody> + </table> + {/if} + + <h1> + {if $attributes.expired.accounts_next_days|@count > 0} + {t count=$attributes.expired.accounts_next_days|@count 1=$attributes.expired.next_days 2=$attributes.expired.accounts_next_days|@count plural="There are %2 accounts expiring in the next %1 days"}There is one account expiring in the next %1 days{/t} + {else} + {t 1=$attributes.expired.next_days}There is no account expiring in the next %1 days{/t} + {/if} + </h1> + {if $attributes.expired.accounts_next_days|@count > 0} + <table style="width: 100%;" class="listingTable"> + <colgroup> + <col width="10%"/> + <col width="15%"/> + <col width="15%"/> + <col width="15%"/> + <col width="15%"/> + <col width="10%"/> + </colgroup> + <thead> + <tr style="background-color: white; text-align:center;"> + <th colspan="4" style="background-color: white; padding:5px;"> + {t}Next expired accounts{/t} + </th> + <th colspan="3" style="background-color: white; padding:5px;"> + {t}Manager concerned{/t} + </th> + </tr> + <tr> + <!-- uid/cn/telephonNumber/mail/shadowExpire/sambaKickoffTime --> + <th>{t}uid{/t}</th><th>{t}cn{/t}</th><th>{t}telephoneNumber{/t}</th><th>{t}shadowExpire{/t}</th> + <th>{t}manager{/t}</th><th>{t}mail{/t}</th><th>{t}telephoneNumber{/t}</th> + </tr> + </thead> + <tbody> + {foreach from=$attributes.expired.accounts_next_days item=account} + <tr> + <td> {$account.uid}</td> + <td> {$account.cn}</td> + <td> {$account.telephoneNumber}</td> + <td> {$account.shadowExpire}</td> + <td> {$account.manager_cn}</td> + <td><a href="mailto:{$account.manager_mail}">{$account.manager_mail}</a></td> + <td> {$account.manager_phone}</td> + </tr> + {/foreach} + </tbody> + </table> + {/if} + </div> +</div> diff --git a/plugins/addons/dashboard/users_stats.tpl b/plugins/addons/dashboard/users_stats.tpl new file mode 100644 index 0000000000000000000000000000000000000000..12cbb567dc43afc27bf0775500ffc43afe15174a --- /dev/null +++ b/plugins/addons/dashboard/users_stats.tpl @@ -0,0 +1,27 @@ +<div id="{$sectionId}" class="plugin_section"> + <span class="legend"> + {$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} + <ul> + {foreach from=$attributes.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} + {else} + {t 1=$acc.name}None of them have a %1 account{/t} + {/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} + {else} + {t}None of them is locked{/t} + {/if} + </li> + </ul> + </div> +</div> diff --git a/plugins/config/class_dashBoardConfig.inc b/plugins/config/class_dashBoardConfig.inc new file mode 100644 index 0000000000000000000000000000000000000000..7a247b6208ed142127f6e9a49aa3383159ef00f6 --- /dev/null +++ b/plugins/config/class_dashBoardConfig.inc @@ -0,0 +1,71 @@ +<?php +/* + This code is part of FusionDirectory (http://www.fusiondirectory.org/) + Copyright (C) 2013 FusionDirectory + + 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 dashboardConfig extends simplePlugin +{ + var $objectclasses = array('fdDashboardPluginConf'); + + static function plInfo() + { + return array( + 'plShortName' => _('Dashboard configuration'), + 'plDescription' => _('FusionDirectory dashboard plugin configuration'), + 'plSelfModify' => FALSE, + 'plCategory' => array('configuration'), + 'plObjectType' => array('smallConfig'), + + 'plProvidedAcls' => parent::generatePlProvidedAcls(self::getAttributesInfo()) + ); + } + + static function getAttributesInfo () + { + return array( + 'systems' => array( + 'name' => _('Dashboard name schema'), + 'attrs' => array( + new IntAttribute ( + _('Number of digits'), _('Number of digits to use after prefix'), + 'fdDashboardNumberOfDigit', FALSE, + 1, 20, 3 + ), + new SetAttribute ( + new StringAttribute ( + _('Prefixes'), _('Prefixes to be used for computer ids'), + 'fdDashboardPrefix', TRUE + ), + array("PC") + ) + ) + ), + 'users' => array( + 'name' => _('Dashboard expired users'), + 'attrs' => array( + new IntAttribute ( + _('Number of days'), _('Number of days before expiration needed for an account to show in the dashboard next expired accounts list'), + 'fdDashboardExpiredAccountsDays', FALSE, + 1, FALSE, 15 + ), + ) + ), + ); + } +} +?>