-
Matthew Newton authoredf26c13e2
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2007 Fabian Hickert
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
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.
*/
/****************
* FUNCTIONS
setupStepMigrate - Constructor.
update_strings - Used to update the displayed step information.
initialize_checks - Initialize migration steps.
check_ldap_permissions - Check if the used admin account has full access to the ldap database.
check_accounts - Check if there are users without the required objectClasses.
migrate_accounts - Migrate selected users to FusionDirectory user accounts.
check_orgUnits - Check if there are departments, that are not visible for FusionDirectory
migrate_orgUnits - Migrate selected departments
check_adminAccount - Check if there is at least one acl entry available
checkBase - Check if there is a root object available
get_user_list - Get list of available users
create_admin
create_admin_user
readPost - Save posts
update - Update state
render - Generate html output of this plugin
array_to_ldif - Create ldif output of an ldap result array
****************/
class CheckFailedException extends FusionDirectoryException
{
private $error;
public function __construct ($msg, $error)
{
parent::__construct($msg);
$this->error = $error;
}
public function getError ()
{
return $this->error;
}
}
class StepMigrateDialog implements FusionDirectoryDialog
{
protected $post_cancel = 'dialog_cancel';
protected $post_finish = 'dialog_confirm';
private $infos;
private $tplfile;
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
private $check;
public function __construct (&$check, $tpl, $infos)
{
$this->infos = $infos;
$this->tplfile = $tpl;
$this->check = $check;
}
public function readPost ()
{
if (isset($_POST[$this->post_cancel])) {
$this->handleCancel();
} elseif (isset($_POST[$this->post_finish]) || isset($_GET[$this->post_finish])) {
$this->handleFinish();
} elseif (
isset($_POST['dialog_showchanges']) ||
isset($_POST['dialog_hidechanges']) ||
isset($_POST['dialog_refresh'])) {
$this->infos = $this->check->dialog_refresh();
}
}
public function update (): bool
{
return isset($this->check);
}
public function render (): string
{
$smarty = get_smarty();
$smarty->assign('infos', $this->infos);
return $smarty->fetch(get_template_path($this->tplfile, TRUE, dirname(__FILE__)));
}
protected function handleFinish ()
{
if ($this->check->migrate_confirm()) {
unset($this->check);
}
}
protected function handleCancel ()
{
unset($this->check);
}
public function getInfos (): array
{
return $this->infos;
}
}
class StepMigrateCheck
{
public $name;
public $title;
public $status = FALSE;
public $msg = '';
public $error = '';
public $fnc;
private $step;
public function __construct (setupStepMigrate $step, string $name, string $title)
{
$this->name = $name;
$this->title = $title;
$this->fnc = 'check_'.$name;
$this->step = $step;
}