function executeChange($userID, $recordID, $newRecordStatus)
{
    if ($newRecordStatus !== "1" && $newRecordStatus !== "2" && $newRecordStatus !== "3") {
        return "Invalid status!";
    }
    $userDAO = new UserDAO();
    $user = $userDAO->getUserByID($userID);
    $recordDAO = new RecordDAO();
    $record = $recordDAO->getRecordByID($recordID);
    if ($record === null) {
        return "Could not find this record!";
    }
    if ($record->getDisplayStatus() === $newRecordStatus) {
        return "Old status is equal to new status, don't need to change!";
    }
    if ($user->getRole()->getRoleID() === "3") {
        if ($record->getUser()->getUserID() !== $userID) {
            return "You have no right to change group status!";
        }
        if ($newStatus === "3") {
            return "You have no right to delete this record!";
        }
    }
    if ($newRecordStatus !== "3") {
        $record->setDisplayStatus($newRecordStatus);
        $recordDAO->updateRecord($record);
        // Do not have updateRecord function
    } else {
        $recordDAO->deleteRecord($record);
        //Do not have this function
    }
    return true;
}
Exemplo n.º 2
0
function changeRecordStatus($adminID, $recordID, $displayStatus)
{
    $userDAO = new UserDAO();
    $admin = $userDAO->getUserByID($adminID);
    if ($admin->getRole()->getRoleID !== 1 || $admin->getRole()->getRoleID !== 2) {
        return "You do not have the right to change record status!";
    }
    $recordDAO = new RecordDAO();
    $record = $recordDAO->getRecordByID($recordID);
    //need function
    if ($record->getDisplayStatus() === $displayStatus) {
        return "Same Status, no need to change it!";
    }
    $record->setDisplayStatus($displayStatus);
    $recordDAO->updateRecord($record);
    //need function
}