...
 
Commits (10)
......@@ -391,6 +391,22 @@ class objects
return static::open('new', $type);
}
static function createTemplate ($type)
{
$infos = static::infos($type);
$tabClass = $infos['tabClass'];
/* Pass fake attrs object to force template mode */
$attrsObject = new stdClass();
$attrsObject->attrs = [];
$attrsObject->is_template = TRUE;
$tabObject = new $tabClass($type, 'new', $attrsObject);
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, "Create template of $type");
return $tabObject;
}
static function &infos ($type)
{
global $config;
......
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2003-2010 Cajus Pollmeier
Copyright (C) 2011-2016 FusionDirectory
Copyright (C) 2011-2019 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
......@@ -33,9 +32,8 @@
*/
class pluglist
{
var $menu = "";
var $iconmenu = "";
var $current = "";
var $menu = '';
protected $iconmenu = '';
/*!
* \brief The plInfo result for all plugin, using class as key.
......@@ -56,8 +54,8 @@ class pluglist
/*!
* \brief List plugin indexes of all plugin that the user have acl for
*/
var $allowed_plugins = [];
var $silly_cache = [];
protected $allowed_plugins = [];
protected $silly_cache = [];
/*!
* \brief List the plugins
......@@ -506,6 +504,19 @@ class pluglist
return isset($this->allowed_plugins[$plug_id]);
}
/*!
* \brief Resets menu and ACL cache
*
* Called when user ACL rights may have changed
*/
public function resetCache ()
{
$this->menu = '';
$this->iconmenu = '';
$this->silly_cache = [];
$this->allowed_plugins = [];
}
static function pluginInfos ($cname)
{
$plist = session::get('plist');
......
......@@ -129,7 +129,8 @@ class userinfo
*/
function loadACL ()
{
global $config;
global $config, $plist;
$this->ACL = [];
$this->groups = [];
$this->roles = [];
......@@ -330,6 +331,11 @@ class userinfo
if (isset($all_acl[$dn])) {
$this->ACLperPath[$this->dn] = $all_acl[$dn];
}
/* Reset plist menu and ACL cache if needed */
if (is_object($plist)) {
$plist->resetCache();
}
}
/*!
......
......@@ -722,9 +722,15 @@ class management
if (static::$skipTemplates) {
return;
}
$action['subaction'] = preg_replace('/^template_/', '', $action['subaction']);
$this->newEntry($action);
$this->tabObject->setTemplateMode('template_cn');
$type = preg_replace('/^template_/', '', $action['subaction']);
$this->currentDn = 'new';
set_object_info($this->currentDn);
// Open object
$this->openTabObject(objects::createTemplate($type));
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->currentDn, 'Create template entry initiated');
}
function newEntryFromTemplate (array $action)
......
......@@ -96,5 +96,11 @@ class hooksConfig extends simplePlugin
parent::__construct($dn, $object, $parent, $mainTab);
$this->attributesAccess['fdTabHook']->setLinearRendering(FALSE);
$this->attributesAccess['fdTabHook']->setHeaders([
_('Tab'),
_('Mode'),
_('Command'),
'',
]);
}
}
......@@ -256,6 +256,10 @@ class user extends simplePlugin
{
parent::__construct($dn, $object, $parent, $mainTab);
if ($this->is_template && !$this->initially_was_account) {
$this->attributesAccess['userPassword']->setValue('%askme%');
}
$this->attributesAccess['uid']->setUnique('whole');
$this->attributesAccess['uid']->setAutocomplete(FALSE);
$this->attributesAccess['uid']->setDisabled($this->initially_was_account && !$this->is_template);
......
......@@ -184,10 +184,11 @@ class setupStepMigrate extends setupStep
var $rootOC_details = [];
/* Entries needing migration */
protected $orgUnits_toMigrate = [];
protected $accounts_toMigrate = [];
protected $outsideUsers_toMigrate = [];
protected $outsideGroups_toMigrate = [];
protected $orgUnits_toMigrate = [];
protected $accounts_toMigrate = [];
protected $outsideUsers_toMigrate = [];
protected $outsideOGroups_toMigrate = [];
protected $outsidePosixGroups_toMigrate = [];
/* check for multiple use of same uidNumber */
var $check_uidNumber = [];
......@@ -258,18 +259,22 @@ class setupStepMigrate extends setupStep
$config->resetDepartmentCache();
$checks = [
'baseOC' => new StepMigrateCheck($this, 'baseOC', _('Inspecting object classes in root object')),
'permissions' => new StepMigrateCheck($this, 'permissions', _('Checking permission for LDAP database')),
'accounts' => new StepMigrateCheck($this, 'accounts', _('Checking for invisible users')),
'adminAccount' => new StepMigrateCheck($this, 'adminAccount', _('Checking for super administrator')),
'defaultACLs' => new StepMigrateCheck($this, 'defaultACLs', _('Checking for default ACL roles and groups')),
'outsideUsers' => new StepMigrateCheck($this, 'outsideUsers', _('Checking for users outside the people tree')),
'outsideGroups' => new StepMigrateCheck($this, 'outsideGroups', _('Checking for groups outside the groups tree')),
'orgUnits' => new StepMigrateCheck($this, 'orgUnits', _('Checking for invisible departments')),
'uidNumber' => new StepMigrateCheck($this, 'uidNumber', _('Checking for duplicated UID numbers')),
'gidNumber' => new StepMigrateCheck($this, 'gidNumber', _('Checking for duplicated GID numbers')),
'baseOC' => new StepMigrateCheck($this, 'baseOC', _('Inspecting object classes in root object')),
'permissions' => new StepMigrateCheck($this, 'permissions', _('Checking permission for LDAP database')),
'accounts' => new StepMigrateCheck($this, 'accounts', _('Checking for invisible users')),
'adminAccount' => new StepMigrateCheck($this, 'adminAccount', _('Checking for super administrator')),
'defaultACLs' => new StepMigrateCheck($this, 'defaultACLs', _('Checking for default ACL roles and groups')),
'outsideUsers' => new StepMigrateCheck($this, 'outsideUsers', _('Checking for users outside the people tree')),
'outsideOGroups' => new StepMigrateCheck($this, 'outsideOGroups', _('Checking for groups outside the groups tree')),
'orgUnits' => new StepMigrateCheck($this, 'orgUnits', _('Checking for invisible departments')),
];
if (class_available('posixAccount')) {
$checks['outsidePosixGroups'] = new StepMigrateCheck($this, 'outsidePosixGroups', _('Checking for POSIX groups outside the groups tree'));
$checks['uidNumber'] = new StepMigrateCheck($this, 'uidNumber', _('Checking for duplicated UID numbers'));
$checks['gidNumber'] = new StepMigrateCheck($this, 'gidNumber', _('Checking for duplicated GID numbers'));
}
$this->checks = $checks;
}
......@@ -1182,25 +1187,25 @@ class setupStepMigrate extends setupStep
}
/* Search for groups outside the group ou */
function check_outsideGroups (&$checkobj)
function check_outsideOGroups (&$checkobj)
{
list($sizeLimitHit,$count) = $this->check_outsideObjects_generic($checkobj, '(objectClass=posixGroup)', 'groupRDN');
list($sizeLimitHit,$count) = $this->check_outsideObjects_generic($checkobj, '(objectClass=groupOfNames)', 'ogroupRDN');
if ($count > 0) {
if ($sizeLimitHit) {
$message = sprintf(_('Found more than %d groups outside the configured tree "%s".'), static::$objectNumberLimit, trim(get_ou('groupRDN')));
$message = sprintf(_('Found more than %d groups outside the configured tree "%s".'), static::$objectNumberLimit, trim(get_ou('ogroupRDN')));
} else {
$message = sprintf(_('Found %d groups outside the configured tree "%s".'), $count, trim(get_ou('groupRDN')));
$message = sprintf(_('Found %d groups outside the configured tree "%s".'), $count, trim(get_ou('ogroupRDN')));
}
throw new CheckFailedException(
"<div style='color:#F0A500'>"._("Warning")."</div>",
'<div style="color:#F0A500">'._('Warning').'</div>',
$message.
$checkobj->submit()
);
}
}
function check_outsideGroups_migrate (&$checkobj)
function check_outsideOGroups_migrate (&$checkobj)
{
global $config;
$this->check_multipleGeneric_migrate(
......@@ -1214,7 +1219,7 @@ class setupStepMigrate extends setupStep
);
}
function check_outsideGroups_migrate_refresh (&$checkobj)
function check_outsideOGroups_migrate_refresh (&$checkobj)
{
global $config;
return $this->check_multipleGeneric_migrate_refresh(
......@@ -1228,7 +1233,59 @@ class setupStepMigrate extends setupStep
);
}
function check_outsideGroups_migrate_confirm (&$checkobj, $only_ldif = FALSE)
function check_outsideOGroups_migrate_confirm (&$checkobj, $only_ldif = FALSE)
{
return $this->check_outsideUsers_migrate_confirm($checkobj, $only_ldif, 'ogroupRDN');
}
/* Search for POSIX groups outside the group ou */
function check_outsidePosixGroups (&$checkobj)
{
list($sizeLimitHit,$count) = $this->check_outsideObjects_generic($checkobj, '(objectClass=posixGroup)', 'groupRDN');
if ($count > 0) {
if ($sizeLimitHit) {
$message = sprintf(_('Found more than %d POSIX groups outside the configured tree "%s".'), static::$objectNumberLimit, trim(get_ou('groupRDN')));
} else {
$message = sprintf(_('Found %d POSIX groups outside the configured tree "%s".'), $count, trim(get_ou('groupRDN')));
}
throw new CheckFailedException(
'<div style="color:#F0A500">'._('Warning').'</div>',
$message.
$checkobj->submit()
);
}
}
function check_outsidePosixGroups_migrate (&$checkobj)
{
global $config;
$this->check_multipleGeneric_migrate(
$checkobj,
[
'title' => _('Move POSIX groups into configured groups tree'),
'outside' => TRUE,
'ous' => $config->getDepartmentList(),
'destination' => (isset($_POST['destination']) ? $_POST['destination'] : ''),
]
);
}
function check_outsidePosixGroups_migrate_refresh (&$checkobj)
{
global $config;
return $this->check_multipleGeneric_migrate_refresh(
$checkobj,
[
'title' => _('Move POSIX groups into configured groups tree'),
'outside' => TRUE,
'ous' => $config->getDepartmentList(),
'destination' => (isset($_POST['destination']) ? $_POST['destination'] : ''),
]
);
}
function check_outsidePosixGroups_migrate_confirm (&$checkobj, $only_ldif = FALSE)
{
return $this->check_outsideUsers_migrate_confirm($checkobj, $only_ldif, 'groupRDN');
}
......