Small upgrade to fix some guest->mnethostid. MDL-10375
[pfb-moodle.git] / my / pagelib.php
blobb003bf62d2eef0f8d2f9fa8915a6af12b4aaac38
1 <?php //$Id$
3 require_once($CFG->libdir.'/pagelib.php');
5 class page_my_moodle extends page_base {
7 function get_type() {
8 return PAGE_MY_MOODLE;
11 function user_allowed_editing() {
12 page_id_and_class($id,$class);
13 if ($id == PAGE_MY_MOODLE) {
14 return true;
15 } else if (has_capability('moodle/my:manageblocks', get_context_instance(CONTEXT_SYSTEM, SITEID)) && defined('ADMIN_STICKYBLOCKS')) {
16 return true;
18 return false;
21 function user_is_editing() {
22 global $USER;
23 if (has_capability('moodle/my:manageblocks', get_context_instance(CONTEXT_SYSTEM, SITEID)) && defined('ADMIN_STICKYBLOCKS')) {
24 return true;
26 return (!empty($USER->editing));
29 function print_header($title) {
31 global $USER;
33 $replacements = array(
34 '%fullname%' => get_string('mymoodle','my')
36 foreach($replacements as $search => $replace) {
37 $title = str_replace($search, $replace, $title);
40 $site = get_site();
42 $button = update_mymoodle_icon($USER->id);
43 $nav = get_string('mymoodle','my');
44 $header = $site->shortname.': '.$nav;
46 $loggedinas = user_login_string($site);
47 print_header($title, $header,$nav,'','',true, $button, $loggedinas);
51 function url_get_path() {
52 global $CFG;
53 page_id_and_class($id,$class);
54 if ($id == PAGE_MY_MOODLE) {
55 return $CFG->wwwroot.'/my/index.php';
56 } elseif (defined('ADMIN_STICKYBLOCKS')){
57 return $CFG->wwwroot.'/'.$CFG->admin.'/stickyblocks.php';
61 function url_get_parameters() {
62 if (defined('ADMIN_STICKYBLOCKS')) {
63 return array('pt' => ADMIN_STICKYBLOCKS);
64 } else {
65 return array();
69 function blocks_default_position() {
70 return BLOCK_POS_LEFT;
73 function blocks_get_positions() {
74 return array(BLOCK_POS_LEFT, BLOCK_POS_RIGHT);
77 function blocks_move_position(&$instance, $move) {
78 if($instance->position == BLOCK_POS_LEFT && $move == BLOCK_MOVE_RIGHT) {
79 return BLOCK_POS_RIGHT;
80 } else if ($instance->position == BLOCK_POS_RIGHT && $move == BLOCK_MOVE_LEFT) {
81 return BLOCK_POS_LEFT;
83 return $instance->position;
86 function get_format_name() {
87 return MY_MOODLE_FORMAT;
92 define('PAGE_MY_MOODLE', 'my-index');
93 define('MY_MOODLE_FORMAT', 'my'); //doing this so we don't run into problems with applicable formats.
95 page_map_class(PAGE_MY_MOODLE, 'page_my_moodle');