Example #1
0
 /**
  *
  * @param AuthProfile $userAuthProfile profile of the user we want to enrol to the cours
  * @param Claro_Course $course kernel object representing the course
  * @param type $givenCourseKey optionnal given registration key (default null)
  * @param type $categoryId optionnal given categoryId (default null)
  */
 public function __construct(AuthProfile $userAuthProfile, Claro_Course $course, $givenCourseKey = null, $categoryId = null)
 {
     $this->userAuthProfile = $userAuthProfile;
     $this->course = $course;
     $this->givenCourseKey = $givenCourseKey;
     $this->categoryId = $categoryId;
     // is the user doing the registration a super user ?
     if (claro_is_in_a_course() && claro_get_current_course_id() == $this->course->courseId) {
         $this->isSuperUser = claro_is_platform_admin() || claro_is_course_manager() || claro_is_allowed_tool_edit(get_module_data('CLUSER', 'id'));
     } else {
         $this->isSuperUser = claro_is_platform_admin();
     }
 }
Example #2
0
 protected function isModuleAllowed()
 {
     $moduleData = get_module_data($this->moduleLabel);
     if ($moduleData['type'] == 'tool') {
         $contextList = get_module_context_list($this->moduleLabel);
         if (claro_is_in_a_course()) {
             $_mainToolId = get_tool_id_from_module_label($this->moduleLabel);
             $_profileId = claro_get_current_user_profile_id_in_course();
             $_cid = claro_get_current_course_id();
             if (claro_is_in_a_group()) {
                 $_groupProperties = claro_get_main_group_properties(claro_get_current_course_id());
                 $_mainToolId = get_tool_id_from_module_label('CLGRP');
                 $is_toolAllowed = array_key_exists($this->moduleLabel, $_groupProperties['tools']) && $_groupProperties['tools'][$this->moduleLabel] && claro_is_allowed_tool_read($_mainToolId, $_profileId, $_cid);
                 if ($_groupProperties['private']) {
                     $is_toolAllowed = $is_toolAllowed && (claro_is_group_member() || claro_is_group_tutor());
                 }
                 $is_toolAllowed = $is_toolAllowed || (claro_is_course_manager() || claro_is_platform_admin());
             } else {
                 // we ignore course visibility
                 if (!claro_is_allowed_tool_edit($_mainToolId, $_profileId, $_cid) && !claro_is_allowed_tool_read($_mainToolId, $_profileId, $_cid)) {
                     $is_toolAllowed = false;
                 } else {
                     $is_toolAllowed = true;
                 }
             }
         } else {
             if (in_array('platform', iterator_to_array($contextList))) {
                 $is_toolAllowed = get_module_data($this->moduleLabel, 'activation') == 'activated';
             } else {
                 $is_toolAllowed = false;
             }
         }
         return $is_toolAllowed;
     } else {
         // if an applet "tool", return true if activated
         // and let module manage it's access by itself
         return $moduleData['activation'] == 'activated';
     }
 }
Example #3
0
    $is_groupAllowed = !empty($_SESSION['is_groupAllowed']) ? $_SESSION['is_groupAllowed'] : null;
}
/*---------------------------------------------------------------------------
  COURSE TOOL / USER / GROUP REL. INIT
 ---------------------------------------------------------------------------*/
if ($uidReset || $cidReset || $gidReset || $tidReset) {
    if ($_tid && $_gid) {
        //echo 'passed here';
        $toolLabel = trim($_courseTool['label'], '_');
        $is_toolAllowed = array_key_exists($toolLabel, $_groupProperties['tools']) && $_groupProperties['tools'][$toolLabel] && claro_is_allowed_tool_read(get_tool_id_from_module_label('CLGRP'), $_profileId, $_cid);
        if ($_groupProperties['private']) {
            $is_toolAllowed = $is_toolAllowed && ($is_groupMember || claro_is_group_tutor());
        }
        $is_toolAllowed = $is_toolAllowed || ($is_courseAdmin || $is_platformAdmin);
    } elseif ($_tid) {
        if (!$_courseTool['visibility'] && !claro_is_allowed_tool_edit($_mainToolId, $_profileId, $_cid) || !claro_is_allowed_tool_read($_mainToolId, $_profileId, $_cid)) {
            $is_toolAllowed = false;
        } else {
            $is_toolAllowed = true;
        }
    } else {
        $is_toolAllowed = false;
    }
} else {
    $is_toolAllowed = !empty($_SESSION['is_toolAllowed']) ? $_SESSION['is_toolAllowed'] : null;
}
/*---------------------------------------------------------------------------
  Course tool list initialisation for current user
 ---------------------------------------------------------------------------*/
if ($uidReset || $cidReset) {
    if ($_cid) {
Example #4
0
/**
 * Is tool read action allowed
 *
 * @param string $actionName name of the action
 * @param integer $tid tool identifier
 * @param integer $profileId profile identifier
 * @param string $courseId course identifier
 * @return boolean 'true' if it's allowed
 */
function claro_is_allowed_tool_read($tid = null, $profileId = null, $courseId = null)
{
    if (claro_is_tool_activated($tid, $courseId)) {
        if (claro_is_allowed_tool_action('read', $tid, $profileId, $courseId)) {
            if (claro_is_tool_visible($tid, $courseId)) {
                return true;
            } else {
                // if tool isn't visible, only user with edit right have read right
                if (claro_is_allowed_tool_edit($tid, $profileId, $courseId)) {
                    return true;
                } else {
                    return false;
                }
            }
        } else {
            // no read right
            return false;
        }
    } else {
        // tool deactivated
        return false;
    }
}
Example #5
0
/**
 * Function that removes the need to directly use is_courseAdmin global in
 * tool scripts. It returns true or false depending on the user's rights in
 * this particular course.
 *
 * @version 1.1, February 2004
 * @return boolean true: the user has the rights to edit, false: he does not
 * @author Roan Embrechts
 * @author Patrick Cool
 */
function claro_is_allowed_to_edit()
{
    if (claro_is_course_manager()) {
        $isAllowedToEdit = true;
    } else {
        if (claro_is_in_a_tool()) {
            $isAllowedToEdit = claro_is_allowed_tool_edit();
        } else {
            $isAllowedToEdit = false;
        }
    }
    if (claro_is_display_mode_available()) {
        return $isAllowedToEdit && claro_get_tool_view_mode() != 'STUDENT';
    } else {
        return $isAllowedToEdit;
    }
}