forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pagelib.php
99 lines (77 loc) · 2.78 KB
/
pagelib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php //$Id$
require_once($CFG->libdir.'/pagelib.php');
class page_my_moodle extends page_base {
function get_type() {
return PAGE_MY_MOODLE;
}
function user_allowed_editing() {
page_id_and_class($id,$class);
if ($id == PAGE_MY_MOODLE) {
return true;
} else if (has_capability('moodle/my:manageblocks', get_context_instance(CONTEXT_SYSTEM)) && defined('ADMIN_STICKYBLOCKS')) {
return true;
}
return false;
}
function user_is_editing() {
global $USER;
if (has_capability('moodle/my:manageblocks', get_context_instance(CONTEXT_SYSTEM)) && defined('ADMIN_STICKYBLOCKS')) {
return true;
}
return (!empty($USER->editing));
}
function print_header($title) {
global $USER;
$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);
print_header($title, $header,$navigation,'','',true, $button, $loggedinas);
}
function url_get_path() {
global $CFG;
page_id_and_class($id,$class);
if ($id == PAGE_MY_MOODLE) {
return $CFG->wwwroot.'/my/index.php';
} elseif (defined('ADMIN_STICKYBLOCKS')){
return $CFG->wwwroot.'/'.$CFG->admin.'/stickyblocks.php';
}
}
function url_get_parameters() {
if (defined('ADMIN_STICKYBLOCKS')) {
return array('pt' => ADMIN_STICKYBLOCKS);
} else {
return array();
}
}
function blocks_default_position() {
return BLOCK_POS_LEFT;
}
function blocks_get_positions() {
return array(BLOCK_POS_LEFT, BLOCK_POS_RIGHT);
}
function blocks_move_position(&$instance, $move) {
if($instance->position == BLOCK_POS_LEFT && $move == BLOCK_MOVE_RIGHT) {
return BLOCK_POS_RIGHT;
} else if ($instance->position == BLOCK_POS_RIGHT && $move == BLOCK_MOVE_LEFT) {
return BLOCK_POS_LEFT;
}
return $instance->position;
}
function get_format_name() {
return MY_MOODLE_FORMAT;
}
}
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');
?>