From 4a8725b8dcac3bd0e7afe463968d281e4cf8df6c Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 20 May 2014 19:20:02 +0200 Subject: JS Stuff for Taskmanager interaction More work on AD wizard --- modules/sysconfig/addmodule_ad.inc.php | 89 ++++++++++++++++++++++++++++++---- 1 file changed, 79 insertions(+), 10 deletions(-) (limited to 'modules/sysconfig/addmodule_ad.inc.php') diff --git a/modules/sysconfig/addmodule_ad.inc.php b/modules/sysconfig/addmodule_ad.inc.php index abc55df5..ab897096 100644 --- a/modules/sysconfig/addmodule_ad.inc.php +++ b/modules/sysconfig/addmodule_ad.inc.php @@ -14,13 +14,15 @@ class AdModule_Start extends AddModule_Base protected function renderInternal() { - Session::set('ad_stuff', false); + Session::set('ad_check', false); + Session::save(); Render::addDialog('Active Directory Authentifizierung', false, 'sysconfig/ad-start', array( 'step' => 'AdModule_CheckConnection', 'server' => Request::post('server'), 'searchbase' => Request::post('searchbase'), 'binddn' => Request::post('binddn'), 'bindpw' => Request::post('bindpw'), + 'token' => Session::get('token') )); } @@ -28,9 +30,8 @@ class AdModule_Start extends AddModule_Base class AdModule_CheckConnection extends AddModule_Base { - - private $taskId = false; - + private $taskIds; + protected function preprocessInternal() { $server = Request::post('server'); @@ -39,19 +40,87 @@ class AdModule_CheckConnection extends AddModule_Base $bindpw = Request::post('bindpw'); if (empty($server) || empty($searchbase) || empty($binddn)) { Message::addError('empty-field'); - AddModule_Base::setStep('AdModule_Start'); + AddModule_Base::setStep('AdModule_Start'); // Continues with AdModule_Start for render() return; } - $this->taskId = 'ad_' . mt_rand() . '-' . microtime(true); - Taskmanager::submit('LdapSearch', array( + /* + $data = Taskmanager::submit('LdapSearch', array( 'id' => $this->taskId, 'uri' => '' - ), true); + )); + */ + $ldapSearch = Taskmanager::submit('DummyTask', array()); + if (isset($ldapSearch['id'])) { + $dummy = Taskmanager::submit('DummyTask', array('parentTask' => $ldapSearch['id'])); + } + if (!isset($ldapSearch['id']) || !isset($dummy['id'])) { + AddModule_Base::setStep('AdModule_Start'); // Continues with AdModule_Start for render() + return; + } + $this->taskIds = array( + 'tm-search' => $ldapSearch['id'], + 'tm-dummy' => $dummy['id'] + ); } protected function renderInternal() { - Message::addInfo('missing-file'); + Render::addDialog('Active Directory Authentifizierung', false, 'sysconfig/ad-checkconnection', + array_merge($this->taskIds, array( + 'server' => Request::post('server'), + 'searchbase' => Request::post('searchbase'), + 'binddn' => Request::post('binddn'), + 'bindpw' => Request::post('bindpw'), + 'token' => Session::get('token'), + 'step' => 'AdModule_Finish' + )) + ); + } + +} + +class AdModule_Finish extends AddModule_Base +{ + + private $taskIds; + + protected function preprocessInternal() + { + $data = json_encode(array( + 'server' => Request::post('server'), + 'searchbase' => Request::post('searchbase'), + 'binddn' => Request::post('binddn'), + 'bindpw' => Request::post('bindpw'), + )); + Database::exec("INSERT INTO configtgz_module (title, moduletype, filename, contents) " + . " VALUES (:title, 'AD_AUTH', '', :content)", array( + 'title' => 'AD: ' . Request::post('server'), + 'content' => $data)); + $id = Database::lastInsertId(); + $name = CONFIG_TGZ_LIST_DIR . '/modules/AD_AUTH_id_' . $id . '.' . mt_rand() . '.tgz'; + Database::exec("UPDATE configtgz_module SET filename = :filename WHERE moduleid = :id LIMIT 1", array( + 'id' => $id, + 'filename' => $name + )); + $tgz = Taskmanager::submit('DummyTask', array()); + if (isset($tgz['id'])) { + $ldadp = Taskmanager::submit('DummyTask', array('parentTask' => $tgz['id'])); + } + if (!isset($tgz['id']) || !isset($ldadp['id'])) { + AddModule_Base::setStep('AdModule_Start'); // Continues with AdModule_Start for render() + return; + } + $this->taskIds = array( + 'tm-module' => $tgz['id'], + 'tm-ldadp' => $ldadp['id'] + ); } -} \ No newline at end of file + protected function renderInternal() + { + Render::addDialog('Active Directory Authentifizierung', false, 'sysconfig/ad-finish', + $this->taskIds + ); + } + +} -- cgit v1.2.3-55-g7522