Exemple #1
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';
     }
 }
Exemple #2
0
function claro_is_module_allowed()
{
    if (!array_key_exists('tlabelReq', $GLOBALS)) {
        return claro_failure::set_failure('MISSING TOOL LABEL');
    }
    $moduleLabel = $GLOBALS['tlabelReq'];
    $moduleData = get_module_data($moduleLabel);
    if ($moduleData['type'] == 'tool') {
        $contextList = get_module_context_list($moduleLabel);
        // pushClaroMessage(var_export(iterator_to_array($contextList), true),'kernel');
        if (!claro_is_in_a_course() && in_array('platform', iterator_to_array($contextList))) {
            return get_module_data($moduleLabel, 'activation') == 'activated';
        }
        // if a course tool, use claro_is_tool_allowed
        return claro_is_tool_allowed();
    } else {
        // if an applet "tool", return true if activated
        // and let module manage it's access by itself
        return $moduleData['activation'] == 'activated';
    }
}