blocklib: MDL-19010 once again you can add blocks, at least on the coures page.
This commit is contained in:
+6
-9
@@ -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 = '<div class="title"><h2>';
|
||||
$strblocks .= get_string('blocks');
|
||||
$strblocks .= '</h2></div>';
|
||||
|
||||
$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'));
|
||||
}
|
||||
|
||||
+7
-4
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user