Commit 775812a5 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Don't base block configuration on template status, apart from showing blog...


Don't base block configuration on template status, apart from showing blog advanced copy options for templates only
Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent b9f8357b
......@@ -150,7 +150,7 @@ class PluginBlocktypeBlog extends PluginBlocktype {
}
public static function artefactchooser_element($default=null, $istemplate=false) {
$element = array(
return array(
'name' => 'artefactid',
'type' => 'artefactchooser',
'title' => get_string('blog', 'artefact.blog'),
......@@ -161,12 +161,6 @@ class PluginBlocktypeBlog extends PluginBlocktype {
'artefacttypes' => array('blog'),
'template' => 'artefact:blog:artefactchooser-element.tpl',
);
if (!$istemplate) {
$element['rules'] = array(
'required' => true,
);
}
return $element;
}
/**
......
......@@ -126,7 +126,7 @@ class PluginBlocktypeBlogpost extends PluginBlocktype {
// Note: the owner check will have to change when we do group/site
// blogs
if (empty($configdata['artefactid']) || $blog->get('owner') == $USER->get('id')) {
$elements[] = self::artefactchooser_element((isset($configdata['artefactid'])) ? $configdata['artefactid'] : null, $istemplate);
$elements[] = self::artefactchooser_element((isset($configdata['artefactid'])) ? $configdata['artefactid'] : null);
if ($istemplate) {
$elements[] = PluginArtefactBlog::block_advanced_options_element($configdata, 'blogpost');
};
......@@ -157,11 +157,6 @@ class PluginBlocktypeBlogpost extends PluginBlocktype {
'extracols' => '1 - {artefact_blog_blogpost}.published AS draft',
'template' => 'artefact:blog:artefactchooser-element.tpl',
);
if (!$istemplate) {
$element['rules'] = array(
'required' => true,
);
}
return $element;
}
......
......@@ -78,16 +78,13 @@ class PluginBlocktypeRecentposts extends PluginBlocktype {
}
public static function instance_config_form($instance, $istemplate) {
if ($istemplate) {
// No configuration when this block is in a template
return array();
}
safe_require('artefact', 'blog');
$configdata = $instance->get('configdata');
return array(
self::artefactchooser_element((isset($configdata['artefactids'])) ? $configdata['artefactids'] : null, $istemplate),
PluginArtefactBlog::block_advanced_options_element($configdata, 'blog'),
);
$elements = array(self::artefactchooser_element((isset($configdata['artefactids'])) ? $configdata['artefactids'] : null));
if ($istemplate) {
$elements[] = PluginArtefactBlog::block_advanced_options_element($configdata, 'blog');
}
return $elements;
}
public static function artefactchooser_element($default=null, $istemplate=false) {
......
......@@ -108,7 +108,7 @@ class PluginBlocktypeFiledownload extends PluginBlocktype {
}
public static function artefactchooser_element($default=null, $istemplate=false) {
$element = array(
return array(
'name' => 'artefactids',
'type' => 'artefactchooser',
'title' => get_string('Files', 'blocktype.file/filedownload'),
......@@ -119,13 +119,6 @@ class PluginBlocktypeFiledownload extends PluginBlocktype {
'artefacttypes' => array('file', 'image', 'profileicon'),
'template' => 'artefact:file:artefactchooser-element.tpl',
);
if (!$istemplate) {
// You don't have to choose a file if this view is a template
$element['rules'] = array(
'required' => true,
);
}
return $element;
}
/**
......
......@@ -81,12 +81,12 @@ class PluginBlocktypeFolder extends PluginBlocktype {
public static function instance_config_form($instance, $istemplate) {
$configdata = $instance->get('configdata');
return array(
self::artefactchooser_element((isset($configdata['artefactid'])) ? $configdata['artefactid'] : null, $istemplate),
self::artefactchooser_element((isset($configdata['artefactid'])) ? $configdata['artefactid'] : null),
);
}
public static function artefactchooser_element($default=null, $istemplate=false) {
$element = array(
return array(
'name' => 'artefactid',
'type' => 'artefactchooser',
'title' => get_string('folder', 'artefact.file'),
......@@ -96,13 +96,6 @@ class PluginBlocktypeFolder extends PluginBlocktype {
'artefacttypes' => array('folder'),
'template' => 'artefact:file:artefactchooser-element.tpl',
);
if (!$istemplate) {
// You don't have to choose a folder if this view is a template
$element['rules'] = array(
'required' => true,
);
}
return $element;
}
/**
......
......@@ -96,7 +96,7 @@ class PluginBlocktypeHtml extends PluginBlocktype {
$extraselect = 'filetype IN (' . join(',', array_map('db_quote', self::get_allowed_mimetypes())) . ')';
$extrajoin = ' JOIN {artefact_file_files} ON {artefact_file_files}.artefact = a.id ';
$element = array(
return array(
'name' => 'artefactid',
'type' => 'artefactchooser',
'title' => get_string('file', 'artefact.file'),
......@@ -107,12 +107,6 @@ class PluginBlocktypeHtml extends PluginBlocktype {
'template' => 'artefact:file:artefactchooser-element.tpl',
'extraselect' => $extraselect,
);
if (!$istemplate) {
$element['rules'] = array(
'required' => true,
);
}
return $element;
}
public static function default_copy_type() {
......
......@@ -120,7 +120,7 @@ class PluginBlocktypeImage extends PluginBlocktype {
}
public static function artefactchooser_element($default=null, $istemplate=false) {
$element = array(
return array(
'name' => 'artefactid',
'type' => 'artefactchooser',
'title' => get_string('image'),
......@@ -130,13 +130,6 @@ class PluginBlocktypeImage extends PluginBlocktype {
'artefacttypes' => array('image', 'profileicon'),
'template' => 'artefact:file:artefactchooser-element.tpl',
);
if (!$istemplate) {
// You don't have to choose a file if this view is a template
$element['rules'] = array(
'required' => true,
);
}
return $element;
}
/**
......
......@@ -126,13 +126,6 @@ class PluginBlocktypeInternalmedia extends PluginBlocktype {
'extrajoin' => $extrajoin,
'template' => 'artefact:file:artefactchooser-element.tpl',
);
if (!$istemplate) {
// You don't have to choose a file if this view is a template
$element['rules'] = array(
'required' => true,
);
}
return $element;
}
public static function artefactchooser_get_element_data($artefact) {
......
......@@ -83,11 +83,6 @@ class PluginBlocktypeContactinfo extends PluginBlocktype {
}
public static function instance_config_form($instance, $istemplate) {
if ($istemplate) {
// Don't offer any configuration. Profile data needs to be reworked
// so it's not artefacts before this will work
return array();
}
$configdata = $instance->get('configdata');
$form = array();
......@@ -120,7 +115,7 @@ class PluginBlocktypeContactinfo extends PluginBlocktype {
);
// Which fields does the user want
$form[] = self::artefactchooser_element((isset($configdata['artefactids'])) ? $configdata['artefactids'] : null, $istemplate);
$form[] = self::artefactchooser_element((isset($configdata['artefactids'])) ? $configdata['artefactids'] : null);
return $form;
}
......
......@@ -117,17 +117,12 @@ class PluginBlocktypeProfileinfo extends PluginBlocktype {
}
public static function instance_config_form($instance, $istemplate) {
if ($istemplate) {
// Don't offer any configuration. Profile data needs to be reworked
// so it's not artefacts before this will work
return array();
}
$configdata = $instance->get('configdata');
$form = array();
// Which fields does the user want
$form[] = self::artefactchooser_element((isset($configdata['artefactids'])) ? $configdata['artefactids'] : null, $istemplate);
$form[] = self::artefactchooser_element((isset($configdata['artefactids'])) ? $configdata['artefactids'] : null);
// Profile icon
if (!$result = get_records_sql_array('SELECT a.id, a.artefacttype, a.title, a.note
......
......@@ -80,15 +80,12 @@ class PluginBlocktypeResumefield extends PluginBlocktype {
}
public static function instance_config_form($instance, $istemplate) {
if ($istemplate) {
return array();
}
$configdata = $instance->get('configdata');
$form = array();
// Which resume field does the user want
$form[] = self::artefactchooser_element((isset($configdata['artefactid'])) ? $configdata['artefactid'] : null, $istemplate);
$form[] = self::artefactchooser_element((isset($configdata['artefactid'])) ? $configdata['artefactid'] : null);
$form['message'] = array(
'type' => 'html',
'value' => get_string('filloutyourresume', 'blocktype.resume/resumefield', '<a href="' . get_config('wwwroot') . 'artefact/resume/">', '</a>'),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment