Add isUserHasPermission & isNodeAvailable function

增加判断用户是否有权限使用此节点以及节点是否可用的函数
This commit is contained in:
Akkariin Meiko 2020-12-03 04:20:22 +08:00 committed by GitHub
parent 8a25cedba3
commit 4f2b5c3c45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,6 +59,28 @@ class NodeManager {
return count($rs);
}
public function isUserHasPermission($user, $node)
{
$um = new SakuraPanel\UserManager();
$ns = $this->getNodeInfo($node);
$us = $um->getInfoByUser($user);
if(is_array($us) && is_array($ns)) {
if(stristr($ns['group'], "{$us['group']};")) {
return true;
} else {
return false;
}
} else {
return false;
}
}
public function isNodeAvailable($node)
{
$ns = $this->getNodeInfo($node);
return Intval($ns['status']) == 200;
}
public function addNode($data)
{
return Database::insert("nodes", $data);