關鍵在於 DataSource->CmdExecution
這是一個 Run time 的 Property,決定在 BeforeExecuteInsert, BeforeExecuteUpdate or BeforeExecuteDelete 這幾個事件執行 Insert, Update or Delete 前是否要被執行。
function Tasks_DataSource_BeforeExecuteInsert(& $sender) {
global $Tasks;
if (CCGetUserID() == $Tasks->user_id_assign_to->GetValue()) {
$Tasks->DataSource->CmdExecution = false;
}
}
function Tasks_DataSource_BeforeExecuteUpdate(& $sender) {
global $Tasks;
if (CCGetUserID() != $Tasks->user_id_assign_to->GetValue()) {
$Tasks->DataSource->CmdExecution = false;
}
}
function Tasks_DataSource_BeforeExecuteDelete(& $sender) {
global $Tasks;
if (CCGetUserID() != $Tasks->user_id_assign_by->GetValue()) {
$Tasks->DataSource->CmdExecution = false;
}
}
沒有留言:
張貼留言