Example #1
0
/**
 * Return the permissions of for the comments.
 *
 * @param  stdClass $params The parameters.
 * @return array
 */
function core_competency_comment_permissions($params)
{
    if (!get_config('core_competency', 'enabled')) {
        return array('post' => false, 'view' => false);
    }
    if ($params->commentarea == 'user_competency') {
        $uc = new user_competency($params->itemid);
        if ($uc->can_read()) {
            return array('post' => $uc->can_comment(), 'view' => $uc->can_read_comments());
        }
    } else {
        if ($params->commentarea == 'plan') {
            $plan = new plan($params->itemid);
            if ($plan->can_read()) {
                return array('post' => $plan->can_comment(), 'view' => $plan->can_read_comments());
            }
        }
    }
    return array('post' => false, 'view' => false);
}