Example #1
0
/**
 * Determines whether a ProjectUser object allows access to an object
 *
 * @param ApplicationDataObject $object
 * @param ProjectPermission $proj_perm
 * @return unknown
 */
function can_manage_type($object_type, $proj_perm, $access_level)
{
    if ($proj_perm) {
        switch ($object_type) {
            case 'ProjectEvents':
                if ($access_level == ACCESS_LEVEL_WRITE) {
                    return $proj_perm->getCanWriteEvents();
                } else {
                    if ($access_level == ACCESS_LEVEL_READ) {
                        return $proj_perm->getCanReadEvents();
                    } else {
                        return false;
                    }
                }
                break;
            case 'ProjectFiles':
                if ($access_level == ACCESS_LEVEL_WRITE) {
                    return $proj_perm->getCanWriteFiles();
                } else {
                    if ($access_level == ACCESS_LEVEL_READ) {
                        return $proj_perm->getCanReadFiles();
                    } else {
                        return false;
                    }
                }
                break;
            case 'ProjectMessages':
                if ($access_level == ACCESS_LEVEL_WRITE) {
                    return $proj_perm->getCanWriteMessages();
                } else {
                    if ($access_level == ACCESS_LEVEL_READ) {
                        return $proj_perm->getCanReadMessages();
                    } else {
                        return false;
                    }
                }
                break;
            case 'ProjectMilestones':
                if ($access_level == ACCESS_LEVEL_WRITE) {
                    return $proj_perm->getCanWriteMilestones();
                } else {
                    if ($access_level == ACCESS_LEVEL_READ) {
                        return $proj_perm->getCanReadMilestones();
                    } else {
                        return false;
                    }
                }
                break;
            case 'ProjectTasks':
                if ($access_level == ACCESS_LEVEL_WRITE) {
                    return $proj_perm->getCanWriteTasks();
                } else {
                    if ($access_level == ACCESS_LEVEL_READ) {
                        return $proj_perm->getCanReadTasks();
                    } else {
                        return false;
                    }
                }
                break;
            case 'ProjectWebpages':
                if ($access_level == ACCESS_LEVEL_WRITE) {
                    return $proj_perm->getCanWriteWeblinks();
                } else {
                    if ($access_level == ACCESS_LEVEL_READ) {
                        return $proj_perm->getCanReadWeblinks();
                    } else {
                        return false;
                    }
                }
                break;
            case 'MailContents':
                if ($access_level == ACCESS_LEVEL_WRITE) {
                    return $proj_perm->getCanWriteMails();
                } else {
                    if ($access_level == ACCESS_LEVEL_READ) {
                        return $proj_perm->getCanReadMails();
                    } else {
                        return false;
                    }
                }
                break;
            case 'Companies':
            case 'Contacts':
                if ($access_level == ACCESS_LEVEL_WRITE) {
                    return $proj_perm->getCanWriteContacts();
                } else {
                    if ($access_level == ACCESS_LEVEL_READ) {
                        return $proj_perm->getCanReadContacts();
                    } else {
                        return false;
                    }
                }
                break;
        }
    }
    return false;
}