Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
t3o
my.typo3.org
Commits
cf898242
Commit
cf898242
authored
Jul 10, 2017
by
Sorin Loghin
Browse files
[WIP][TASK] Add proof of concept for the Femanager hooks
parent
742d33f2
Pipeline
#1454
passed with stages
in 5 minutes and 19 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
html/typo3conf/ext/t3omy/Classes/Hooks/FeManagerHooks.php
View file @
cf898242
<?php
namespace
T3o\T3omy\Hooks
;
/***************************************************************
* Copyright notice
*
...
...
@@ -25,79 +25,118 @@ namespace T3o\T3omy\Hooks;
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use
TYPO3\CMS\Extbase\Utility\DebuggerUtility
;
use
T
3o\T3oLdap\
Utility
;
use
In2code\Femanager\Domain\Model\User
;
use
T
YPO3\CMS\Core\Utility\General
Utility
;
/**
* Hook Functions for \
*/
class
FeManagerHooks
{
class
Tx_T3omy_Hooks_FeUsers
{
/**
*/
protected
$ldap
Operation
;
protected
$ldap
;
/**
* DataHandlerHook constructor
*/
public
function
__construct
()
{
$this
->
ldapOperation
=
new
UserCreateUpdateDelete
();
public
function
__construct
()
{
$this
->
ldap
=
new
Tx_T3oLdap_Utility_UserCreateUpdateDelete
();
}
/**
* Use DataHandler "afterAllOperations" hook to update or create FE Users
* in LDAP.
*
* @param $user $user
* @return void
*/
public
function
createUser
()
{
# $this->ldap->
public
function
createUser
(
User
$user
)
{
$result
=
$this
->
ldap
->
updateUser
(
$user
->
getUid
(),
$this
->
userObjectToArray
(
$user
));
// TODO: Create log entry if user has been successfully added or throw an exception othwerwise
if
(
$result
===
true
)
{
}
else
{
}
}
/**
* Use DataHandler "afterAllOperations" hook to update or create FE Users
* in LDAP.
*
* @param $user $user
* @return void
*/
public
function
updateUser
()
{
# $this->signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__ . 'BeforePersist', [$user, $this]);
public
function
updateUser
(
User
$user
)
{
$result
=
$this
->
ldap
->
updateUser
(
$user
->
getUid
(),
$this
->
userObjectToArray
(
$user
));
// TODO: Create log entry if user has been successfully updated or throw an exception othwerwise
if
(
$result
===
true
)
{
}
else
{
}
}
/**
* Use DataHandler "afterAllOperations" hook to update or create FE Users
* in LDAP.
*
* @param $user $user
* @return void
*/
public
function
deleteUser
()
{
public
function
deleteUser
(
User
$user
)
{
// TODO: Add this function in Tx_T3oLdap_Utility_UserCreateUpdateDelete
$userData
=
$this
->
userObjectToArray
(
$user
);
/** @var Tx_T3oLdap_Connectors_Ldap $ldap */
$ldap
=
GeneralUtility
::
makeInstance
(
Tx_T3oLdap_Connectors_Ldap
::
class
);
#$this->signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__, [$user, $this]);
if
(
$ldap
->
userExists
(
$userData
[
'username'
]))
{
$ret
=
$ldap
->
deleteUser
(
$userData
[
'username'
]);
// TODO: Handle the resonse as needed
if
(
$ret
===
true
)
{
}
else
{
}
}
}
/**
* // TODO: Options: Leave this here, move it into a service or move it to t3o_ldap
*
* @param User $user
* @return array
*/
protected
function
userObjectToArray
(
User
$user
)
{
$userArray
=
[];
$userArray
[
'username'
]
=
$user
->
getUsername
();
// TODO: Add all needed fields for LDAP
return
$userArray
;
}
/**
* @param $_funcRef
* @param $_params
* @param
$this
* @param
bool
*/
public
function
writePassword
(
$_funcRef
,
$_params
,
$felogin
)
{
DebuggerUtility
::
var_dump
(
$_funcRef
,
'$_funcRef'
);
DebuggerUtility
::
var_dump
(
$_params
,
'$_params'
);
DebuggerUtility
::
var_dump
(
$felogin
,
'$felogin'
);
public
function
writePassword
(
$_funcRef
,
$_params
,
$felogin
)
{
\
TYPO3\CMS\Extbase\Utility\DebuggerUtility
::
var_dump
(
$_funcRef
,
'$_funcRef'
);
\
TYPO3\CMS\Extbase\Utility\DebuggerUtility
::
var_dump
(
$_params
,
'$_params'
);
\
TYPO3\CMS\Extbase\Utility\DebuggerUtility
::
var_dump
(
$felogin
,
'$felogin'
);
die
(
'halt'
);
$feUserUid
=
0
;
$feUserUid
=
0
;
$userData
=
array
();
$createIfNotExists
=
false
;
$result
=
$this
->
ldap
Operation
->
updateUser
(
$feUserUid
,
$userData
,
$createIfNotExists
);
$result
=
$this
->
ldap
->
updateUser
(
$feUserUid
,
$userData
,
$createIfNotExists
);
}
}
html/typo3conf/ext/t3omy/ext_localconf.php
View file @
cf898242
...
...
@@ -6,6 +6,29 @@ if (!defined('TYPO3_MODE')) {
#######################################
###
#######################################
/**
* Register signal slots
* TODO: add the signal names
*/
$dispatcher
=
\
TYPO3\CMS\Core\Utility\GeneralUtility
::
makeInstance
(
\
TYPO3\CMS\Extbase\SignalSlot\Dispatcher
::
class
);
$dispatcher
->
connect
(
\
In2code\Femanager\Controller\UserBackendController
::
class
,
''
,
Tx_T3omy_Hooks_FeUsers
::
class
,
'createUser'
);
$dispatcher
->
connect
(
\
In2code\Femanager\Controller\UserBackendController
::
class
,
''
,
Tx_T3omy_Hooks_FeUsers
::
class
,
'updateUser'
);
$dispatcher
->
connect
(
\
In2code\Femanager\Controller\UserBackendController
::
class
,
''
,
Tx_T3omy_Hooks_FeUsers
::
class
,
'deleteUser'
);
$GLOBALS
[
'TYPO3_CONF_VARS'
][
'EXTCONF'
][
'felogin'
][
'password_changed'
][]
=
\
T3o\T3omy\Hooks\FeManagerHooks
::
class
.
'->writePassword'
;
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment