50 lines
1.4 KiB
Plaintext
50 lines
1.4 KiB
Plaintext
module NaiveDAC{
|
|
function initDAC(req){
|
|
Global.acceptList = {
|
|
};
|
|
Global.applyList = {
|
|
};
|
|
Global.owner = req;
|
|
}
|
|
function checkPermission(req){
|
|
return (Global.acceptList[req]!=undefined);
|
|
}
|
|
export function hasPermission(arg){
|
|
return (Global.acceptList[requester]!=undefined);
|
|
}
|
|
export function accept(req){
|
|
if (requester==Global.owner){
|
|
Global.acceptList[req] = Global.applyList[req];
|
|
if (Global.applyList[req] != undefined)
|
|
Global.applyList[req] = undefined;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
export function cancel(req){
|
|
if (requester==Global.owner){
|
|
Global.applyList[req] = Global.acceptList[req];
|
|
if (Global.acceptList[req] != undefined)
|
|
Global.acceptList[req] = undefined;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
export function apply(remark){
|
|
if (remark != undefined && requester !=undefined){
|
|
Global.applyList[requester] = remark;
|
|
return "success";
|
|
}
|
|
return "failed"
|
|
}
|
|
export function isOwner(arg){
|
|
return Global.owner==requester;
|
|
}
|
|
export function getApplyList(arg){
|
|
return JSON.stringify(Global.applyList);
|
|
}
|
|
export function getAcceptList(arg){
|
|
return JSON.stringify(Global.acceptList);
|
|
}
|
|
}
|