4
Hi mith,
i need a little support.
I have this php function which delete non-empty folders:
/**
* Delete a file, or a folder and its contents
*
* @author Aidan Lister
* @version 1.0
* @param string $dirname The directory to delete
* @return bool Returns true on success, false on failure
*/
//added by me start
//include 'mainfile.php';
global $xoopsUser;
$username = $xoopsUser->getVar('uname');
$dirname = XOOPS_ROOT_PATH."/uploads/$username";
//added by me end
function rmdirr($dirname)
{
// Simple delete for a file
if (is_file($dirname)) {
return unlink($dirname);
}
// Loop through the folder
$dir = dir($dirname);
while (false !== $entry = $dir->read()) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
}
// Deep delete directories
if (is_dir("$dirname/$entry")) {
rmdirr("$dirname/$entry");
} else {
unlink("$dirname/$entry");
}
}
// Clean up
$dir->close();
return rmdir($dirname);
}
?>
I have to perform the function right after a user has been deleted(by the admin).
I have tried to include the file in \modules\system\admin\users\main.php
it doesn't work.
Can you help me further,please?
Updates...
I've found this piece of code that is dedicated to user's deletion:
case "delUser":
xoops_cp_header();
$member_handler =& xoops_gethandler('member');
$userdata =& $member_handler->getUser($uid);
xoops_confirm(array('fct' => 'users', 'op' => 'delUserConf', 'del_uid' => $userdata->getVar('uid')), 'admin.php', sprintf(_AM_AYSYWTDU,$userdata->getVar('uname')));
xoops_cp_footer();
break;
How can i edit it o reach my goal?