Exemplo n.º 1
0
/**
 * Get profileName
 * @param integer $profileId profile identifier
 * @return array ['tool_id']['action_name'] value
 */
function claro_get_profile_label($profileId)
{
    $profileList = claro_get_all_profile_name_list();
    if (isset($profileList[$profileId]['label'])) {
        return $profileList[$profileId]['label'];
    } else {
        return false;
    }
}
Exemplo n.º 2
0
/**
 * Display form to edit course user properties
 * @author Mathieu Laurent <*****@*****.**>
 * @param $data array to fill the form
 * @todo $courseManagerChecked never used
 */
function course_user_html_form($data, $courseId, $userId, $hiddenParam = null)
{
    // TODO $courseManagerChecked never used
    //$courseManagerChecked = $data['isCourseManager'] == 1 ? 'checked="checked"':'';
    $tutorChecked = $data['isTutor'] == 1 ? 'checked="checked"' : '';
    $selectedProfileId = isset($data['profileId']) ? (int) $data['profileId'] : 0;
    $form = '';
    $form .= '<form action="' . claro_htmlspecialchars($_SERVER['PHP_SELF']) . '" method="post">' . "\n" . claro_form_relay_context() . '<input type="hidden" name="cmd" value="exUpdateCourseUserProperties" />' . "\n";
    if (!is_null($hiddenParam) && is_array($hiddenParam)) {
        foreach ($hiddenParam as $name => $value) {
            $form .= '<input type="hidden" name="' . claro_htmlspecialchars($name) . '" value="' . claro_htmlspecialchars($value) . '" />' . "\n";
        }
    }
    $form .= '<table class="claroTable" cellpadding="3" cellspacing="0" border="0">' . "\n";
    // User firstname and lastname
    $form .= '<tr >' . "\n" . '<td align="right">' . get_lang('Name') . ' :</td>' . "\n" . '<td ><b>' . claro_htmlspecialchars($data['firstName']) . ' ' . claro_htmlspecialchars($data['lastName']) . '</b></td>' . "\n" . '</tr>' . "\n";
    // Profile select box
    $profileList = claro_get_all_profile_name_list();
    $form .= '<tr >' . "\n" . '<td align="right"><label for="profileId">' . get_lang('Profile') . ' :</label></td>' . "\n" . '<td>';
    if ($userId == $GLOBALS['_uid']) {
        $form .= '<input type="text" name="profileIdDisabled" value="' . claro_htmlspecialchars($profileList[$selectedProfileId]['name']) . '" disabled="disabled" id="profileId" />';
    } else {
        $form .= '<select name="profileId" id="profileId">';
        foreach ($profileList as $id => $info) {
            if ($info['label'] != 'anonymous' && $info['label'] != 'guest') {
                $form .= '<option value="' . $id . '" ' . ($selectedProfileId == $id ? 'selected="selected"' : '') . '>' . get_lang($info['name']) . '</option>' . "\n";
            }
        }
        $form .= '</select>';
    }
    $form .= '</td>' . "\n" . '</tr>' . "\n";
    // User role label
    $form .= '<tr >' . "\n" . '<td align="right"><label for="role">' . get_lang('Role') . ' (' . get_lang('Optional') . ')</label> :</td>' . "\n" . '<td ><input type="text" name="role" id="role" value="' . claro_htmlspecialchars($data['role']) . '" maxlength="40" /></td>' . "\n" . '</tr>' . "\n";
    // User is tutor
    $form .= '<tr >' . "\n" . '<td align="right"><label for="isTutor">' . get_lang('Group Tutor') . '</label> :</td>' . "\n" . '<td><input type="checkbox" name="isTutor" id="isTutor" value="1" ' . $tutorChecked . ' /></td>' . "\n" . '</tr>' . "\n";
    $form .= '<tr >' . "\n" . '<td align="right"><label for="applyChange">' . get_lang('Save changes') . '</label> :</td>' . "\n" . '<td><input type="submit" name="applyChange" id="applyChange" value="' . get_lang('Ok') . '" />&nbsp;' . claro_html_button(claro_htmlspecialchars(Url::Contextualize($_SERVER['HTTP_REFERER'])), get_lang('Cancel')) . '</td>' . "\n" . '</tr>' . "\n";
    $form .= '</table>' . "\n" . '</form>' . "\n";
    return $form;
}
Exemplo n.º 3
0
    }
}
//---------------------------------
// Build list of profile to display
//---------------------------------
$display_profile_list = array();
$display_profile_url_param = null;
if (!empty($display_profile)) {
    if (is_numeric($display_profile)) {
        $display_profile_list[] = $display_profile;
        $display_profile_url_param = $display_profile;
    }
}
// default : display all profile
if (empty($display_profile_list)) {
    $profileNameList = claro_get_all_profile_name_list();
    $display_profile_list = array_keys($profileNameList);
    $display_profile_url_param = 'all';
}
//=================================
// Display section
//=================================
// define bredcrumb
ClaroBreadCrumbs::getInstance()->prepend(get_lang('Course profile list'), 'profile_list.php');
$out = '';
// Set display right
$profileRightHtml = new RightProfileToolRightHtml();
$profileRightHtml->addUrlParam('display_profile', $display_profile_url_param);
$profileFoundCount = 0;
foreach ($display_profile_list as $profileId) {
    $profile = new RightProfile();
Exemplo n.º 4
0
/**
 * Store all unique info about a tool during install
 * @param integer $moduleId
 * @param array $moduleToolData, data from manifest
 * @return int tool id or false
 */
function register_module_tool($moduleId, $module_info)
{
    $tbl = claro_sql_get_tbl('course_tool');
    if (is_array($module_info)) {
        $icon = array_key_exists('ICON', $module_info) ? "'" . claro_sql_escape($module_info['ICON']) . "'" : 'NULL';
        if (!isset($module_info['ENTRY'])) {
            $module_info['ENTRY'] = 'entry.php';
        }
        // find max rank in the course_tool table
        $sql = "SELECT MAX(def_rank) AS maxrank FROM `" . $tbl['course_tool'] . "`";
        $maxresult = claro_sql_query_get_single_row($sql);
        // insert the new course tool
        $sql = "INSERT INTO `" . $tbl['course_tool'] . "`\n                SET\n                claro_label = '" . claro_sql_escape($module_info['LABEL']) . "',\n                script_url = '" . claro_sql_escape($module_info['ENTRY']) . "',\n                icon = " . $icon . ",\n                def_access = 'ALL',\n                def_rank = (" . (int) $maxresult['maxrank'] . "+1),\n                add_in_course = 'AUTOMATIC',\n                access_manager = 'COURSE_ADMIN' ";
        $tool_id = claro_sql_query_insert_id($sql);
        // Init action/right
        // Manage right - Add read action
        $action = new RightToolAction();
        $action->setName('read');
        $action->setToolId($tool_id);
        $action->save();
        // Manage right - Add edit action
        $action = new RightToolAction();
        $action->setName('edit');
        $action->setToolId($tool_id);
        $action->save();
        // Init all profile/right
        $profileList = array_keys(claro_get_all_profile_name_list());
        foreach ($profileList as $profileId) {
            $profile = new RightProfile();
            $profile->load($profileId);
            $profileRight = new RightProfileToolRight();
            $profileRight->load($profile);
            if (claro_get_profile_id('manager') == $profileId) {
                $profileRight->setToolRight($tool_id, 'manager');
            } else {
                $profileRight->setToolRight($tool_id, 'user');
            }
            $profileRight->save();
        }
        return $tool_id;
    } else {
        return false;
    }
}