1
ralf57
Which object/class handles directories creation/deletion?
  • 2004/9/5 8:42

  • ralf57

  • Quite a regular

  • Posts: 231

  • Since: 2003/2/3 1


Hi all,
i need to get this goal:
each time a new user gets the "active" status a new directory
named as the new user has to be automatically created inside
xoops_install/uploads/ folder.
And so the opposite:when a user is deleted,the relative folder
in xoops_install/uploads/ has to be deleted too.
I guess XOOPS has a built-in function to do this but wasn't able to find it.
Any help is appreciated.
ATB,ralf.

2
Mithrandir
Re: Which object/class handles directories creation/deletion?

Not really, no built-in function in XOOPS - except for the PHP functions for making and deleting files/directories; file(), fwrite(), fread(), unlink()

3
ralf57
Re: Which object/class handles directories creation/deletion?
  • 2004/9/5 12:36

  • ralf57

  • Quite a regular

  • Posts: 231

  • Since: 2003/2/3 1


Thank you mith,
this is the code i was able to write:
if (is_dir(XOOPS_ROOT_PATH."/uploads/$username)) {
    echo 
' ';
} else {
mkdir(XOOPS_ROOT_PATH."/uploads/$username"0755);
chmod(XOOPS_ROOT_PATH."/uploads/$username"0777);
}

It creates the folder only if the folder doesn't exists.
I have no errors from phpìs debug.
I'm in doubt if i have to also use the umask() function for the code to work properly in Unix systems.

4
ralf57
Re: Which object/class handles directories creation/deletion?
  • 2004/9/5 14:27

  • ralf57

  • Quite a regular

  • Posts: 231

  • Since: 2003/2/3 1


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?

5
Dave_L
Re: Which object/class handles directories creation/deletion?
  • 2004/9/5 16:48

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


You might run into problems with usernames as directory names. It would be safer to use user numbers. For example, the directory for user #123 could be /uploads/user123.

6
ralf57
Re: Which object/class handles directories creation/deletion?
  • 2004/9/5 17:58

  • ralf57

  • Quite a regular

  • Posts: 231

  • Since: 2003/2/3 1


Thank you dave,
i'll try to follow your suggestion.
But what about my specific problem?
Any idea?

7
Mithrandir
Re: Which object/class handles directories creation/deletion?

Also, the clause in main.php you should look for the
case "delUserConf":

as the one you posted is just the confirmation screen. Alternatively, you can add the code to the XoopsUserHandler::delete() method.

8
ralf57
Re: Which object/class handles directories creation/deletion?
  • 2004/9/5 18:03

  • ralf57

  • Quite a regular

  • Posts: 231

  • Since: 2003/2/3 1


Alternativelyyou can add the code to the XoopsUserHandler::delete() method.


Thanks mith,
where is it located?

Login

Who's Online

359 user(s) are online (302 user(s) are browsing Support Forums)


Members: 0


Guests: 359


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits