Permissions ============================================================================*/ $assignmentIsVisible = (bool) ($assignment->getVisibility() == 'VISIBLE'); $is_allowedToEditAll = (bool) claro_is_allowed_to_edit(); if (!$assignmentIsVisible && !$is_allowedToEditAll) { // if assignment is not visible and user is not course admin or upper claro_redirect(Url::Contextualize('work.php')); exit; } // upload or update is allowed between start and end date or after end date if late upload is allowed $uploadDateIsOk = $assignment->isUploadDateOk(); if ($assignment->getAssignmentType() == 'INDIVIDUAL') { // user is authed and allowed $userCanPost = (bool) (claro_is_user_authenticated() && claro_is_course_allowed() && claro_is_course_member()); } else { $userGroupList = get_user_group_list(claro_get_current_user_id()); // check if user is member of at least one group $userCanPost = (bool) (!empty($userGroupList)); } $is_allowedToSubmit = (bool) ($assignmentIsVisible && $uploadDateIsOk && $userCanPost) || $is_allowedToEditAll; /*============================================================================ Update notification ============================================================================*/ if (claro_is_user_authenticated()) { // call this function to set the __assignment__ as seen, all the submission as seen $claro_notifier->is_a_notified_ressource(claro_get_current_course_id(), $claro_notifier->get_notification_date(claro_get_current_user_id()), claro_get_current_user_id(), claro_get_current_group_id(), claro_get_current_tool_id(), $req['assignmentId']); } /*============================================================================ Prepare List ============================================================================*/ /* Prepare submission and feedback SQL filters - remove hidden item from count */
function get_access_mode_to_group_forum($forum) { if (claro_is_user_authenticated()) { $userGroupList = get_user_group_list(claro_get_current_user_id()); $userGroupList = array_keys($userGroupList); $tutorGroupList = get_tutor_group_list(claro_get_current_user_id()); } else { $userGroupList = array(); $tutorGroupList = array(); } $is_groupPrivate = claro_get_current_group_properties_data('private'); $group_id = is_null($forum['group_id']) ? null : (int) $forum['group_id']; if (!is_null($group_id)) { if (in_array($group_id, $userGroupList) || in_array($group_id, $tutorGroupList) || !$is_groupPrivate || claro_is_allowed_to_edit()) { if (is_array($tutorGroupList) && in_array($group_id, $tutorGroupList)) { $accessMode = 'tutor'; } elseif (is_array($userGroupList) && in_array($group_id, $userGroupList)) { $accessMode = 'member'; } else { $accessMode = 'visitor'; } } else { $accessMode = 'private'; } return $accessMode; } return false; }