Can find the user or the group associated with a virtual directory.

This commit is contained in:
Pierre HUBERT 2018-07-14 13:31:14 +02:00
parent b5e4e52272
commit b1e01dbb09

View File

@ -0,0 +1,42 @@
<?php
/**
* Virtual directory controller
*
* @author Pierre HUBERT
*/
class VirtualDirectoryController {
/**
* Find a group / user using a given virtual directory
*
* @url POST /virtualDirectory/find
*/
public function findVirtualDirectory(){
//Get the virtual directory to analyze
$virtualDirectory = getPostVirtualDirectory("directory");
//Check if the directory is a user or group
$userID = components()->user->findByFolder($virtualDirectory);
$groupID = components()->groups->findByVirtualDirectory($virtualDirectory);
if($userID != 0){
$kind = "user";
$id = $userID;
}
else if($groupID != 0){
$kind = "group";
$id = $groupID;
}
else
Rest_fatal_error(404, "Specified user / group virtual directory not found !");
return array(
"kind" => $kind,
"id" => $id
);
}
}