From: tjhunt Date: Wed, 6 May 2009 09:23:37 +0000 (+0000) Subject: moodle_page: MDL-12212 eliminate page_my_moodle X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=1b6b940022added8307083c26fdea41da3003b76;p=moodle.git moodle_page: MDL-12212 eliminate page_my_moodle --- diff --git a/admin/stickyblocks.php b/admin/stickyblocks.php index 644f13f1e4..15b7e4637b 100644 --- a/admin/stickyblocks.php +++ b/admin/stickyblocks.php @@ -1,13 +1,12 @@ dirroot.'/my/pagelib.php'); require_once($CFG->dirroot.'/lib/pagelib.php'); $pt = optional_param('pt', null, PARAM_SAFEDIR); //alhanumeric and - - $pagetypes = array(PAGE_MY_MOODLE => array('id' => PAGE_MY_MOODLE, - 'lib' => '/my/pagelib.php', + $pagetypes = array('my-index' => array('id' => 'my-index', + 'lib' => '/lib/pagelib.php', 'name' => get_string('mymoodle','admin')), PAGE_COURSE_VIEW => array('id' => PAGE_COURSE_VIEW, 'lib' => '/lib/pagelib.php', diff --git a/lib/blocklib.php b/lib/blocklib.php index 814eecec9a..de6dcd5163 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -718,26 +718,8 @@ function blocks_print_group($page, $blockmanager, $position) { } } // End foreach - // Check if - // we are on the default position/side AND - // we're editing the page AND - // ( - // we have the capability to manage blocks OR - // we are in myMoodle page AND have the capibility to manage myMoodle blocks - // ) - - // for constant PAGE_MY_MOODLE - include_once($CFG->dirroot.'/my/pagelib.php'); - - $coursecontext = get_context_instance(CONTEXT_COURSE, $COURSE->id); - $myownblogpage = (isset($page->filtertype) && isset($page->filterselect) && $page->pagetype=='blog-view' && $page->filtertype=='user' && $page->filterselect == $USER->id); - - $managecourseblocks = has_capability('moodle/site:manageblocks', $coursecontext); - $editmymoodle = $page->pagetype == PAGE_MY_MOODLE && has_capability('moodle/my:manageblocks', $coursecontext); - - if ($page->blocks->get_default_region() == $position && $page->user_is_editing() && - ($managecourseblocks || $editmymoodle || $myownblogpage || defined('ADMIN_STICKYBLOCKS'))) { - + if ($page->blocks->get_default_region() == $position && + $page->user_is_editing() && $page->user_can_edit_blocks()) { blocks_print_adminblock($page, $blockmanager); } } diff --git a/my/index.php b/my/index.php index 788063219c..ddd6cfdd20 100644 --- a/my/index.php +++ b/my/index.php @@ -2,27 +2,25 @@ // this is the 'my moodle' page - require_once('../config.php'); + require_once(dirname(__FILE__) . '/../config.php'); require_once($CFG->dirroot.'/course/lib.php'); - require_once('pagelib.php'); require_login(); - $mymoodlestr = get_string('mymoodle','my'); + $strmymoodle = get_string('mymoodle','my'); if (isguest()) { - print_header($mymoodlestr); - notice_yesno(get_string('noguest', 'my').'

'.get_string('liketologin'), - get_login_url(), $CFG->wwwroot); + print_header($strmymoodle); + notice_yesno(get_string('noguest', 'my') . '

' . + get_string('liketologin'), get_login_url(), $CFG->wwwroot); print_footer(); - die(); + die; } - - $edit = optional_param('edit', -1, PARAM_BOOL); + $edit = optional_param('edit', -1, PARAM_BOOL); $blockaction = optional_param('blockaction', '', PARAM_ALPHA); - $PAGE = page_create_instance($USER->id); + $PAGE->set_context(get_context_instance(CONTEXT_USER, $USER->id)); $PAGE->set_url('my/index.php'); $PAGE->set_blocks_editing_capability('moodle/my:manageblocks'); @@ -32,7 +30,22 @@ $USER->editing = $edit; } - $PAGE->print_header($mymoodlestr); + $button = update_mymoodle_icon($USER->id); + $header = $SITE->shortname . ': ' . $strmymoodle; + $navigation = build_navigation($strmymoodle); + $loggedinas = user_login_string(); + + if (empty($CFG->langmenu)) { + $langmenu = ''; + } else { + $currlang = current_language(); + $langs = get_list_of_languages(); + $langlabel = get_accesshide(get_string('language')); + $langmenu = popup_form($CFG->wwwroot . '/my/index.php?lang=', $langs, + 'chooselang', $currlang, '', '', '', true, 'self', $langlabel); + } + + print_header($strmymoodle, $header, $navigation, '', '', true, $button, $loggedinas . $langmenu); echo ''; echo ''; diff --git a/my/pagelib.php b/my/pagelib.php deleted file mode 100644 index d70811758b..0000000000 --- a/my/pagelib.php +++ /dev/null @@ -1,47 +0,0 @@ -libdir.'/pagelib.php'); - -class page_my_moodle extends page_base { - - function print_header($title) { - - global $USER, $CFG; - - $replacements = array( - '%fullname%' => get_string('mymoodle','my') - ); - foreach($replacements as $search => $replace) { - $title = str_replace($search, $replace, $title); - } - - $site = get_site(); - - $button = update_mymoodle_icon($USER->id); - $nav = get_string('mymoodle','my'); - $header = $site->shortname.': '.$nav; - $navlinks = array(array('name' => $nav, 'link' => '', 'type' => 'misc')); - $navigation = build_navigation($navlinks); - - $loggedinas = user_login_string($site); - - if (empty($CFG->langmenu)) { - $langmenu = ''; - } else { - $currlang = current_language(); - $langs = get_list_of_languages(); - $langlabel = get_accesshide(get_string('language')); - $langmenu = popup_form($CFG->wwwroot .'/my/index.php?lang=', $langs, 'chooselang', $currlang, '', '', '', true, 'self', $langlabel); - } - - print_header($title, $header,$navigation,'','',true, $button, $loggedinas.$langmenu); - - } -} - -define('PAGE_MY_MOODLE', 'my-index'); -define('MY_MOODLE_FORMAT', 'my'); //doing this so we don't run into problems with applicable formats. - -page_map_class(PAGE_MY_MOODLE, 'page_my_moodle'); - -?>