mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-27 07:49:27 +00:00
Can find the user or the group associated with a virtual directory.
This commit is contained in:
parent
b5e4e52272
commit
b1e01dbb09
42
RestControllers/VirtualDirectoryController.php
Normal file
42
RestControllers/VirtualDirectoryController.php
Normal 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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user