diff --git a/include/management/class_managementListing.inc b/include/management/class_managementListing.inc index 7c033209cc1ef67afee7ba20523c8c6b0aad2983..bf629ca30a685ff5be9b8186f58484213124202b 100644 --- a/include/management/class_managementListing.inc +++ b/include/management/class_managementListing.inc @@ -207,7 +207,7 @@ class managementListing new ObjectTypeColumn(), new LinkColumn('sn', 'Last name'), new LinkColumn('givenName', 'First name'), - new StringColumn('uid', 'Login'), + new Column('uid', 'Login'), new PropertiesColumn(NULL, 'Properties'), new ActionsColumn(NULL, 'Actions'), ); diff --git a/include/management/columns/class_ActionsColumn.inc b/include/management/columns/class_ActionsColumn.inc new file mode 100644 index 0000000000000000000000000000000000000000..4ea91a97914ae6a43e125b762b8bcfe51a49e211 --- /dev/null +++ b/include/management/columns/class_ActionsColumn.inc @@ -0,0 +1,40 @@ +<?php +/* + This code is part of FusionDirectory (http://www.fusiondirectory.org/) + Copyright (C) 2017-2018 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. +*/ + +/*! + * \brief Column showing the actions available on the object + */ +class ActionsColumn extends Column +{ + function isSortable() + { + return FALSE; + } + + function getRowClasses(ListingEntry $entry) + { + return $this->parent->parent->getActionRowClasses($entry); + } + + function renderCell(ListingEntry $entry) + { + return $this->parent->parent->renderActionColumn($entry); + } +} diff --git a/include/management/class_managementColumn.inc b/include/management/columns/class_Column.inc similarity index 51% rename from include/management/class_managementColumn.inc rename to include/management/columns/class_Column.inc index 2fdb54b668d4d61794f34f84a60f7df28b9fbf21..980e1c6f991523395af752c44a6dda61c3f9f2e9 100644 --- a/include/management/class_managementColumn.inc +++ b/include/management/columns/class_Column.inc @@ -21,7 +21,7 @@ /*! * \brief Column base class */ -class StringColumn +class Column { protected $attribute; protected $label; @@ -161,123 +161,3 @@ class StringColumn } } } - -class LinkColumn extends StringColumn -{ - function renderCell(ListingEntry $entry) - { - $attribute = $this->attribute; - if (isset($this->templateAttribute) && $entry->isTemplate()) { - $attribute = $this->templateAttribute; - } - if (isset($entry[$attribute])) { - return '<a href="?plug='.$_GET['plug'].'&PID='.$entry->getPid().'&act=listing_edit_'.$entry->row.'" title="'.$entry->dn.'">'.htmlentities($entry[$attribute], ENT_COMPAT, 'UTF-8').'</a>'; - } else { - return ' '; - } - } -} - -class ObjectTypeColumn extends StringColumn -{ - function isSortable() - { - return FALSE; - } - - function renderCell(ListingEntry $entry) - { - if ($entry->isTemplate()) { - $infos = objects::infos($entry->getTemplatedType()); - return '<img title="'.$entry->dn.'" src="'.htmlentities('geticon.php?context=devices&icon=template&size=16', ENT_COMPAT, 'UTF-8').'" alt="'.sprintf(_('%s template'), $infos['name']).'"/>'; - } elseif ($entry->type) { - $infos = objects::infos($entry->type); - return '<img title="'.$entry->dn.'" src="'.htmlentities($infos['icon'], ENT_COMPAT, 'UTF-8').'" alt="'.$infos['name'].'"/>'; - } else { - return ' '; - } - } -} - -class ActionsColumn extends StringColumn -{ - function isSortable() - { - return FALSE; - } - - function getRowClasses(ListingEntry $entry) - { - return $this->parent->parent->getActionRowClasses($entry); - } - - function renderCell(ListingEntry $entry) - { - return $this->parent->parent->renderActionColumn($entry); - } -} - -class PropertiesColumn extends StringColumn -{ - function isSortable() - { - return FALSE; - } - - function fillNeededAttributes(array &$attrs) - { - $attrs['objectClass'] = '*'; - } - - function renderCell(ListingEntry $entry) - { - global $config; - - $infos = objects::infos($entry->getTemplatedType()); - - static $tabs = array(); - - if (empty($tabs[$entry->type])) { - $tabs[$entry->type] = array(); - foreach ($config->data['TABS'][$infos['tabGroup']] as $plug) { - if ($plug['CLASS'] == $infos['mainTab']) { - continue; - } - if (class_available($plug['CLASS'])) { - $name = $plug['CLASS']; - - $tabs[$entry->type][$name] = new $name('new'); - } - } - } - - /* Main tab is always there */ - $pInfos = pluglist::pluginInfos($infos['mainTab']); - $result = '<input type="image" src="'.htmlentities($pInfos['plSmallIcon'], ENT_COMPAT, 'UTF-8').'" '. - 'alt="'.$pInfos['plShortName'].'" title="'.$pInfos['plShortName'].'" '. - 'name="listing_edit_tab_'.$infos['mainTab'].'_'.$entry->row.'"/>'; - if (!empty($entry)) { - if ($entry->isTemplate()) { - $attrs = $entry->getTemplatedFields(); - } else { - $attrs = $entry; - } - foreach ($tabs[$entry->type] as $class => $tab) { - if ($tab->is_this_account($attrs)) { - $pInfos = pluglist::pluginInfos($class); - if (isset($pInfos['plSmallIcon'])) { - $result .= '<input type="image" src="'.htmlentities($pInfos['plSmallIcon'], ENT_COMPAT, 'UTF-8').'" '. - 'alt="'.$pInfos['plShortName'].'" title="'.$pInfos['plShortName'].'" '. - 'name="listing_edit_tab_'.$class.'_'.$entry->row.'"/>'; - } else { - @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $pInfos['plShortName']." ($class)", 'No icon for'); - } - } else { - $result .= '<img src="images/empty.png" alt="" class="optional '.$class.'"/>'; - } - } - } - - return $result; - } -} diff --git a/include/management/columns/class_LinkColumn.inc b/include/management/columns/class_LinkColumn.inc new file mode 100644 index 0000000000000000000000000000000000000000..185e836de456dcac950857c09d2b21b6dd7b7756 --- /dev/null +++ b/include/management/columns/class_LinkColumn.inc @@ -0,0 +1,38 @@ +<?php +/* + This code is part of FusionDirectory (http://www.fusiondirectory.org/) + Copyright (C) 2017-2018 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. +*/ + +/*! + * \brief Column rendering a link to edit the object + */ +class LinkColumn extends Column +{ + function renderCell(ListingEntry $entry) + { + $attribute = $this->attribute; + if (isset($this->templateAttribute) && $entry->isTemplate()) { + $attribute = $this->templateAttribute; + } + if (isset($entry[$attribute])) { + return '<a href="?plug='.$_GET['plug'].'&PID='.$entry->getPid().'&act=listing_edit_'.$entry->row.'" title="'.$entry->dn.'">'.htmlentities($entry[$attribute], ENT_COMPAT, 'UTF-8').'</a>'; + } else { + return ' '; + } + } +} diff --git a/include/management/columns/class_ObjectTypeColumn.inc b/include/management/columns/class_ObjectTypeColumn.inc new file mode 100644 index 0000000000000000000000000000000000000000..8e3038745a67ec1276aad09d0dd2c34dac8c6636 --- /dev/null +++ b/include/management/columns/class_ObjectTypeColumn.inc @@ -0,0 +1,43 @@ +<?php +/* + This code is part of FusionDirectory (http://www.fusiondirectory.org/) + Copyright (C) 2017-2018 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. +*/ + +/*! + * \brief Column showing the icon of the objectType + */ +class ObjectTypeColumn extends Column +{ + function isSortable() + { + return FALSE; + } + + function renderCell(ListingEntry $entry) + { + if ($entry->isTemplate()) { + $infos = objects::infos($entry->getTemplatedType()); + return '<img title="'.$entry->dn.'" src="'.htmlentities('geticon.php?context=devices&icon=template&size=16', ENT_COMPAT, 'UTF-8').'" alt="'.sprintf(_('%s template'), $infos['name']).'"/>'; + } elseif ($entry->type) { + $infos = objects::infos($entry->type); + return '<img title="'.$entry->dn.'" src="'.htmlentities($infos['icon'], ENT_COMPAT, 'UTF-8').'" alt="'.$infos['name'].'"/>'; + } else { + return ' '; + } + } +} diff --git a/include/management/columns/class_PropertiesColumn.inc b/include/management/columns/class_PropertiesColumn.inc new file mode 100644 index 0000000000000000000000000000000000000000..dd202df0668dbbf65da4ff52a8bcca53fa056df0 --- /dev/null +++ b/include/management/columns/class_PropertiesColumn.inc @@ -0,0 +1,87 @@ +<?php +/* + This code is part of FusionDirectory (http://www.fusiondirectory.org/) + Copyright (C) 2017-2018 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. +*/ + +/*! + * \brief Column showing the activated tabs of the object + */ +class PropertiesColumn extends Column +{ + function isSortable() + { + return FALSE; + } + + function fillNeededAttributes(array &$attrs) + { + $attrs['objectClass'] = '*'; + } + + function renderCell(ListingEntry $entry) + { + global $config; + + $infos = objects::infos($entry->getTemplatedType()); + + static $tabs = array(); + + if (empty($tabs[$entry->type])) { + $tabs[$entry->type] = array(); + foreach ($config->data['TABS'][$infos['tabGroup']] as $plug) { + if ($plug['CLASS'] == $infos['mainTab']) { + continue; + } + if (class_available($plug['CLASS'])) { + $name = $plug['CLASS']; + + $tabs[$entry->type][$name] = new $name('new'); + } + } + } + + /* Main tab is always there */ + $pInfos = pluglist::pluginInfos($infos['mainTab']); + $result = '<input type="image" src="'.htmlentities($pInfos['plSmallIcon'], ENT_COMPAT, 'UTF-8').'" '. + 'alt="'.$pInfos['plShortName'].'" title="'.$pInfos['plShortName'].'" '. + 'name="listing_edit_tab_'.$infos['mainTab'].'_'.$entry->row.'"/>'; + if (!empty($entry)) { + if ($entry->isTemplate()) { + $attrs = $entry->getTemplatedFields(); + } else { + $attrs = $entry; + } + foreach ($tabs[$entry->type] as $class => $tab) { + if ($tab->is_this_account($attrs)) { + $pInfos = pluglist::pluginInfos($class); + if (isset($pInfos['plSmallIcon'])) { + $result .= '<input type="image" src="'.htmlentities($pInfos['plSmallIcon'], ENT_COMPAT, 'UTF-8').'" '. + 'alt="'.$pInfos['plShortName'].'" title="'.$pInfos['plShortName'].'" '. + 'name="listing_edit_tab_'.$class.'_'.$entry->row.'"/>'; + } else { + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $pInfos['plShortName']." ($class)", 'No icon for'); + } + } else { + $result .= '<img src="images/empty.png" alt="" class="optional '.$class.'"/>'; + } + } + } + + return $result; + } +}