Example #1
0
function init_default_right_profile()
{
    require_once get_conf('includePath') . '/lib/right/profileToolRight.class.php';
    $tbl_mdb_names = claro_sql_get_tbl(array('course_tool', 'right_profile', 'right_rel_profile_action', 'right_action'));
    $sql = " SELECT `id` as `toolId`\n             FROM `" . $tbl_mdb_names['course_tool'] . "`";
    $result = claro_sql_query_fetch_all_cols($sql);
    $toolList = $result['toolId'];
    /**
     * Initialise anonymous profile
     */
    $profile = new RightProfile();
    $profile->load(claro_get_profile_id(ANONYMOUS_PROFILE));
    $profileAction = new RightProfileToolRight();
    $profileAction->load($profile);
    $profileAction->setToolListRight($toolList, 'user');
    $profileAction->save();
    /**
     * Initialise guest profile
     */
    $profile = new RightProfile();
    $profile->load(claro_get_profile_id(GUEST_PROFILE));
    $profileAction = new RightProfileToolRight();
    $profileAction->load($profile);
    $profileAction->setToolListRight($toolList, 'user');
    $profileAction->save();
    /**
     * Initialise user profile
     */
    $profile = new RightProfile();
    $profile->load(claro_get_profile_id(USER_PROFILE));
    $profileAction = new RightProfileToolRight();
    $profileAction->load($profile);
    $profileAction->setToolListRight($toolList, 'user');
    $profileAction->save();
    /**
     * Initialise manager profile
     */
    $profile = new RightProfile();
    $profile->load(claro_get_profile_id(MANAGER_PROFILE));
    $profileAction = new RightProfileToolRight();
    $profileAction->load($profile);
    $profileAction->setToolListRight($toolList, 'manager');
    $profileAction->save();
    return true;
}