Beispiel #1
0
function check_chart_public($id, $callback)
{
    $chart = ChartQuery::create()->findPK($id);
    $loggedUser = DatawrapperSession::getUser();
    if ($chart) {
        $user = $chart->getUser();
        if ($user->isAbleToPublish()) {
            if ($chart->isPublic() || $user == $loggedUser) {
                call_user_func($callback, $user, $chart);
            } else {
                if ($chart->_isDeleted()) {
                    error_chart_deleted();
                } else {
                    error_chart_not_published();
                }
            }
        } else {
            // no such chart
            error_not_allowed_to_publish();
        }
    } else {
        // no such chart
        error_chart_not_found($id);
    }
}
Beispiel #2
0
function check_chart_public($id, $callback)
{
    $chart = ChartQuery::create()->findPK($id);
    if ($chart) {
        $user = $chart->getUser();
        // if ($user->isAbleToPublish()) {
        if ($chart->isPublic()) {
            call_user_func($callback, $user, $chart);
        } else {
            if ($chart->_isDeleted()) {
                error_chart_deleted();
            } else {
                error_chart_not_published();
            }
        }
        // } else {
        //     // no such chart
        //     error_not_allowed_to_publish();
        // }
    } else {
        // no such chart
        error_chart_not_found($id);
    }
}