Exemplo n.º 1
0
 * @reauthor   Valery Fremaux <*****@*****.**>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
defined('MOODLE_INTERNAL') || die;
require_once $CFG->dirroot . '/local/my/lib.php';
$localmyconfig = get_config('local_my');
/*
 * This hook redraws the my routing policy using local/my:overridemy switch and my force setting.
 */
if (get_home_page() != HOMEPAGE_SITE && !isguestuser($USER->id)) {
    // Redirect logged-in users to My Moodle overview if required.
    if (optional_param('setdefaulthome', false, PARAM_BOOL)) {
        set_user_preference('user_home_page_preference', HOMEPAGE_SITE);
    } else {
        if (!empty($CFG->defaulthomepage) && $CFG->defaulthomepage == HOMEPAGE_MY) {
            if ($localmyconfig->force && !local_has_myoverride_somewhere()) {
                redirect(new moodle_url('/my'));
            }
            if (optional_param('redirect', 1, PARAM_BOOL) === 1) {
                redirect(new moodle_url('/my'));
            }
        } else {
            if (!empty($CFG->defaulthomepage) && $CFG->defaulthomepage == HOMEPAGE_USER) {
                $linkurl = new moodle_url('/', array('setdefaulthome' => true));
                $PAGE->settingsnav->get('usercurrentsettings')->add(get_string('makethismyhome'), $linkurl, navigation_node::TYPE_SETTING);
            }
        }
    }
}
if (isguestuser($USER->id)) {
    if ($localmyconfig->force && $CFG->allowguestmymoodle) {
Exemplo n.º 2
0
function local_my_hide_home()
{
    $config = get_config('local_my');
    if ($config->enable) {
        return false;
    }
    if ($config->force) {
        if (local_has_myoverride_somewhere()) {
            return false;
        }
        return true;
    }
}