diff --git a/src/includes/addons/LSaddons.posix.php b/src/includes/addons/LSaddons.posix.php index 2a6c7488..8db3fa7e 100644 --- a/src/includes/addons/LSaddons.posix.php +++ b/src/includes/addons/LSaddons.posix.php @@ -24,16 +24,22 @@ // Support LSerror :: defineError('POSIX_SUPPORT_01', - ___("POSIX Support : The constant %{const} is not defined.") + ___("POSIX Support: The constant %{const} is not defined.") ); LSerror :: defineError('POSIX_SUPPORT_02', - ___("POSIX Support : Unable to load LSaddon::FTP.") + ___("POSIX support: Unable to load LSaddon::FTP.") ); // Autres erreurs LSerror :: defineError('POSIX_01', - ___("POSIX : The attribute %{dependency} is missing. Unable to forge the attribute %{attr}.") + ___("POSIX: The attribute %{dependency} is missing. Unable to forge the attribute %{attr}.") +); +LSerror :: defineError('POSIX_02', + ___("POSIX: Fail to create user home directory.") +); +LSerror :: defineError('POSIX_03', + ___("POSIX: Fail to delete user home directory.") ); /** @@ -189,6 +195,30 @@ function createHomeDirectoryByFTP($ldapObject) { return true; } +/** + * Delete home directory by FTP + * + * @author Benjamin Renard + * + * @param LSldapObject $ldapObject L'objet ldap + * + * @return bool True on success, false otherwise + */ +function deleteHomeDirectoryByFTP($ldapObject) { + $dir = getFData(LS_POSIX_HOMEDIRECTORY_FTP_PATH, $ldapObject, 'getValue'); + if ( + !removeDirsByFTP( + LS_POSIX_HOMEDIRECTORY_FTP_HOST, LS_POSIX_HOMEDIRECTORY_FTP_PORT, + LS_POSIX_HOMEDIRECTORY_FTP_USER, LS_POSIX_HOMEDIRECTORY_FTP_PWD, + $dir + ) + ) { + LSerror :: addErrorCode('POSIX_03'); + return false; + } + return true; +} + /** * Generate member attribute value from memberUid *