commit 718d9d4ffca22ad31924925b096b70db032749fb Author: Donnie Hedin Date: Tue May 18 09:05:22 2010 -0500 testing diff --git a/blocks/moodleblock.class.php b/blocks/moodleblock.class.php index 0eb96cd..f9af19a 100755 --- a/blocks/moodleblock.class.php +++ b/blocks/moodleblock.class.php @@ -397,120 +397,116 @@ class block_base { return $title; } - /** - * Sets class $edit_controls var with correct block manipulation links. - * - * @uses $CFG - * @uses $USER - * @param stdObject $options ? - * @todo complete documenting this function. Define $options. - */ - function _add_edit_controls($options) { - global $CFG, $USER, $PAGE; - - if (empty($this->instance->pinned)) { - $context = get_context_instance(CONTEXT_BLOCK, $this->instance->id); - } else { - $context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context - } - - // context for site or course, i.e. participant list etc - // check to see if user can edit site or course blocks. - // blocks can appear on other pages such as mod and blog pages... - - switch ($this->instance->pagetype) { - case 'course-view': - if (!has_capability('moodle/site:manageblocks', $context)) { - return null; - } - break; - default: - - break; - } - - - if (!isset($this->str)) { - $this->str->delete = get_string('delete'); - $this->str->moveup = get_string('moveup'); - $this->str->movedown = get_string('movedown'); - $this->str->moveright = get_string('moveright'); - $this->str->moveleft = get_string('moveleft'); - $this->str->hide = get_string('hide'); - $this->str->show = get_string('show'); - $this->str->configure = get_string('configuration'); - $this->str->assignroles = get_string('assignroles', 'role'); - } - - // RTL support - exchange right and left arrows - if (right_to_left()) { - $rightarrow = 'left.gif'; - $leftarrow = 'right.gif'; - } else { - $rightarrow = 'right.gif'; - $leftarrow = 'left.gif'; - } - - $movebuttons = '
'; - - if ($this->instance->visible) { - $icon = '/t/hide.gif'; - $title = $this->str->hide; - } else { - $icon = '/t/show.gif'; - $title = $this->str->show; - } - - if (empty($this->instance->pageid)) { - $this->instance->pageid = 0; - } - if (!empty($PAGE->type) and ($this->instance->pagetype == $PAGE->type) and $this->instance->pageid == $PAGE->id) { - $page = $PAGE; - } else { - $page = page_create_object($this->instance->pagetype, $this->instance->pageid); - } - $script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey)); - - if (empty($this->instance->pinned)) { - $movebuttons .= '' . - ''.$this->str->assignroles.''; - } - - if ($this->user_can_edit()) { - $movebuttons .= '' . - ''.$title.''; - } - - if ($options & BLOCK_CONFIGURE && $this->user_can_edit()) { - $movebuttons .= '' . - ''. $this->str->configure .''; - } - - if ($this->user_can_addto($page)) { - $movebuttons .= '' . - ''. $this->str->delete .''; - } - - if ($options & BLOCK_MOVE_LEFT) { - $movebuttons .= '' . - ''. $this->str->moveleft .''; - } - if ($options & BLOCK_MOVE_UP) { - $movebuttons .= '' . - ''. $this->str->moveup .''; - } - if ($options & BLOCK_MOVE_DOWN) { - $movebuttons .= '' . - ''. $this->str->movedown .''; - } - if ($options & BLOCK_MOVE_RIGHT) { - $movebuttons .= '' . - ''. $this->str->moveright .''; - } - - $movebuttons .= '
'; - $this->edit_controls = $movebuttons; - } + /** + * Sets class $edit_controls var with correct block manipulation links. + * + * @uses $CFG + * @uses $USER + * @param stdObject $options ? + * @todo complete documenting this function. Define $options. + */ + function _add_edit_controls($options) { + global $CFG, $USER, $PAGE; + + if (empty($this->instance->pinned)) { + $context = get_context_instance(CONTEXT_BLOCK, $this->instance->id); + } else { + $context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context + } + + // context for site or course, i.e. participant list etc + // check to see if user can edit site or course blocks. + // blocks can appear on other pages such as mod and blog pages... + + switch ($this->instance->pagetype) { + case 'course-view': + if (!has_capability('moodle/site:manageblocks', $context)) { + return null; + } + break; + default: + + break; + } + + + if (!isset($this->str)) { + $this->str->delete = get_string('delete'); + $this->str->moveup = get_string('moveup'); + $this->str->movedown = get_string('movedown'); + $this->str->moveright = get_string('moveright'); + $this->str->moveleft = get_string('moveleft'); + $this->str->hide = get_string('hide'); + $this->str->show = get_string('show'); + $this->str->configure = get_string('configuration'); + $this->str->assignroles = get_string('assignroles', 'role'); + } + + // RTL support - exchange right and left arrows + if (right_to_left()) { + $rightarrow = 'left.gif'; + $leftarrow = 'right.gif'; + } else { + $rightarrow = 'right.gif'; + $leftarrow = 'left.gif'; + } + + $movebuttons = '
'; + + if ($this->instance->visible) { + $icon = '/t/hide.gif'; + $title = $this->str->hide; + } else { + $icon = '/t/show.gif'; + $title = $this->str->show; + } + + if (empty($this->instance->pageid)) { + $this->instance->pageid = 0; + } + if (!empty($PAGE->type) and ($this->instance->pagetype == $PAGE->type) and $this->instance->pageid == $PAGE->id) { + $page = $PAGE; + } else { + $page = page_create_object($this->instance->pagetype, $this->instance->pageid); + } + $script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey)); + + if (empty($this->instance->pinned)) { + $movebuttons .= '' . + ''.$this->str->assignroles.''; + } + if ($this->user_can_edit()) { + $movebuttons .= '' . + ''.$title.''; + } + if ($options & BLOCK_CONFIGURE && $this->user_can_edit()) { + $movebuttons .= '' . + ''. $this->str->configure .''; + } + if ($options & BLOCK_MOVE_LEFT) { + $movebuttons .= '' . + ''. $this->str->moveleft .''; + } + if ($options & BLOCK_MOVE_UP) { + $movebuttons .= '' . + ''. $this->str->moveup .''; + } + if ($options & BLOCK_MOVE_DOWN) { + $movebuttons .= '' . + ''. $this->str->movedown .''; + } + if ($options & BLOCK_MOVE_RIGHT) { + $movebuttons .= '' . + ''. $this->str->moveright .''; + } + if ($this->user_can_addto($page)) { + $movebuttons .= '' . + ''. $this->str->delete .''; + } + + $movebuttons .= '
'; + $this->edit_controls = $movebuttons; + } /** * Tests if this block has been implemented correctly.