diff --git a/lib/blocklib.php b/lib/blocklib.php index a2d3876a81e..7df64a96ab7 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -1051,7 +1051,7 @@ function blocks_execute_action($page, &$blockmanager, $blockaction, $instanceori } $region = $page->blocks->get_default_region(); - $weight = $DB->get_field_sql("SELECT MAX(weight) FROM {block_instances} + $weight = $DB->get_field_sql("SELECT MAX(defaultweight) FROM {block_instances} WHERE contextid = ? AND defaultregion = ?", array($page->context->id, $region)); $pagetypepattern = $page->pagetype; if (strpos($pagetypepattern, 'course-view') === 0) { @@ -1295,21 +1295,18 @@ function blocks_print_adminblock($page, $blockmanager) { $strblocks = '

'; $strblocks .= get_string('blocks'); $strblocks .= '

'; + $stradd = get_string('add'); foreach ($missingblocks as $blockid) { $block = blocks_get_record($blockid); $blockobject = block_instance($block->name); - if ($blockobject === false) { - continue; + if ($blockobject !== false && $blockobject->user_can_addto($page)) { + $menu[$block->id] = $blockobject->get_title(); } - if(!$blockobject->user_can_addto($page)) { - continue; - } - $menu[$block->id] = $blockobject->get_title(); } - asort($menu); + asort($menu, SORT_LOCALE_STRING); - $target = $page->url->out(array('sesskey' => sesskey(), 'blockaction' => 'add')); + $target = $page->url->out(false, array('sesskey' => sesskey(), 'blockaction' => 'add')); $content = popup_form($target.'&blockid=', $menu, 'add_block', '', $stradd .'...', '', '', true); print_side_block($strblocks, $content, NULL, NULL, NULL, array('class' => 'block_adminblock')); } diff --git a/lib/weblib.php b/lib/weblib.php index cc08fa943ff..2c67564d7f1 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -373,18 +373,21 @@ class moodle_url { /** * Output url * - * @param boolean $noquerystring whether to output page params as a query string in the url. + * @param boolean $omitquerystring whether to output page params as a query string in the url. * @param array $overrideparams params to add to the output url, these override existing ones with the same name. * @return string url */ - public function out($noquerystring = false, $overrideparams = array()) { + public function out($omitquerystring = false, $overrideparams = array()) { $uri = $this->scheme ? $this->scheme.':'.((strtolower($this->scheme) == 'mailto') ? '':'//'): ''; $uri .= $this->user ? $this->user.($this->pass? ':'.$this->pass:'').'@':''; $uri .= $this->host ? $this->host : ''; $uri .= $this->port ? ':'.$this->port : ''; $uri .= $this->path ? $this->path : ''; - if (!$noquerystring) { - $uri .= (count($this->params)||count($overrideparams)) ? '?'.$this->get_query_string($overrideparams) : ''; + if (!$omitquerystring) { + $querystring = $this->get_query_string($overrideparams); + if ($querystring) { + $uri .= '?' . $querystring; + } } $uri .= $this->fragment ? '#'.$this->fragment : ''; return $uri;