Commit ee2cb42c authored by Nigel McNie's avatar Nigel McNie
Browse files

Merge branch 'master' of git+ssh://git.catalyst.net.nz/git/public/mahara

Conflicts:

	htdocs/lib/view.php
parents 442ffc6f fb8b15e0
......@@ -32,7 +32,7 @@ define('TITLE', get_string('pluginadmin', 'admin'));
require_once('pieforms/pieform.php');
$plugintype = param_alpha('plugintype');
$pluginname = param_alpha('pluginname');
$pluginname = param_variable('pluginname');
define('SECTION_PLUGINTYPE', $plugintype);
define('SECTION_PLUGINNAME', $pluginname);
......
......@@ -121,7 +121,7 @@ class PluginBlocktypeProfileinfo extends PluginBlocktype {
// Profile icon
if (!$result = get_records_sql_array('SELECT a.id, a.artefacttype, a.title, a.note
FROM {artefact} a
WHERE artefacttype = \'profileicon\' OR artefacttype = \'email\'
WHERE (artefacttype = \'profileicon\' OR artefacttype = \'email\')
AND a.owner = (
SELECT owner
FROM {view}
......
......@@ -44,6 +44,9 @@ define('BYTESERVING_BOUNDARY', 'm1i2k3e40516'); //unique string constant
* @param string $filename The name of the file as the browser should use to
* serve it.
* @param array $options Any options to use when serving the file. Currently
* lifetime = 0 for no cache
* forcedownload - force application rather than inline
* overridecontenttype - send this instead of the mimetype
* there are none.
*/
function serve_file($path, $filename, $options=array()) {
......@@ -81,7 +84,7 @@ function serve_file($path, $filename, $options=array()) {
// @todo possibly need addslashes on the filename, but I'm unsure on exactly
// how the browsers will handle it.
if ($mimetype == 'application/forcedownload') {
if ($mimetype == 'application/forcedownload' || isset($options['forcedownload'])) {
header('Content-Disposition: attachment; filename="' . $filename . '"');
}
else {
......@@ -154,7 +157,12 @@ function serve_file($path, $filename, $options=array()) {
header('Content-Type: Text/plain; charset=utf-8');
}
else {
header('Content-Type: ' . $mimetype);
if (isset($options['overridecontenttype'])) {
header('Content-Type: ' . $options['overridecontenttype']);
}
else {
header('Content-Type: ' . $mimetype);
}
}
header('Content-Length: ' . $filesize);
while (@ob_end_flush()); //flush the buffers - save memory and disable sid rewrite
......
......@@ -1175,6 +1175,7 @@ class View {
$value = $data['defaultvalue'];
$elementname = $data['name'];
$template = $data['template'];
$extraselect = (isset($data['extraselect']) ? ' AND ' . $data['extraselect'] : '');
$offset -= $offset % $limit;
......@@ -1185,10 +1186,14 @@ class View {
if (!empty($artefacttypes)) {
$select .= ' AND artefacttype IN(' . implode(',', array_map('db_quote', $artefacttypes)) . ')';
}
if ($search != '') {
$search = db_quote('%' . str_replace('%', '%%', $search) . '%');
$select .= 'AND (title ILIKE(' . $search . ') OR description ILIKE(' . $search . ') )';
}
$select .= $extraselect;
$sortorder = 'title';
if (method_exists($blocktypeclass, 'artefactchooser_get_sort_order')) {
$sortorder = call_static_method($blocktypeclass, 'artefactchooser_get_sort_order');
......@@ -1197,37 +1202,39 @@ class View {
$totalartefacts = count_records_select('artefact', $select);
$result = '';
foreach ($artefacts as &$artefact) {
safe_require('artefact', get_field('artefact_installed_type', 'plugin', 'name', $artefact->artefacttype));
if ($artefacts) {
foreach ($artefacts as &$artefact) {
safe_require('artefact', get_field('artefact_installed_type', 'plugin', 'name', $artefact->artefacttype));
if (method_exists($blocktypeclass, 'artefactchooser_get_element_data')) {
$artefact = call_static_method($blocktypeclass, 'artefactchooser_get_element_data', $artefact);
}
if (method_exists($blocktypeclass, 'artefactchooser_get_element_data')) {
$artefact = call_static_method($blocktypeclass, 'artefactchooser_get_element_data', $artefact);
}
// Build the radio button or checkbox for the artefact
$formcontrols = '';
if ($selectone) {
$formcontrols .= '<input type="radio" class="radio" id="' . hsc($elementname . '_' . $artefact->id)
. '" name="' . hsc($elementname) . '" value="' . hsc($artefact->id) . '"';
if ($value == $artefact->id) {
$formcontrols .= ' checked="checked"';
// Build the radio button or checkbox for the artefact
$formcontrols = '';
if ($selectone) {
$formcontrols .= '<input type="radio" class="radio" id="' . hsc($elementname . '_' . $artefact->id)
. '" name="' . hsc($elementname) . '" value="' . hsc($artefact->id) . '"';
if ($value == $artefact->id) {
$formcontrols .= ' checked="checked"';
}
$formcontrols .= '>';
}
$formcontrols .= '>';
}
else {
$formcontrols .= '<input type="checkbox" id="' . hsc($elementname . '_' . $artefact->id) . '" name="' . hsc($elementname) . '[' . hsc($artefact->id) . ']"';
if ($value && in_array($artefact->id, $value)) {
$formcontrols .= ' checked="checked"';
else {
$formcontrols .= '<input type="checkbox" id="' . hsc($elementname . '_' . $artefact->id) . '" name="' . hsc($elementname) . '[' . hsc($artefact->id) . ']"';
if ($value && in_array($artefact->id, $value)) {
$formcontrols .= ' checked="checked"';
}
$formcontrols .= '>';
$formcontrols .= '<input type="hidden" name="' . hsc($elementname) . '_onpage[]" value="' . hsc($artefact->id) . '">';
}
$formcontrols .= '>';
$formcontrols .= '<input type="hidden" name="' . hsc($elementname) . '_onpage[]" value="' . hsc($artefact->id) . '">';
}
$smarty = smarty_core();
$smarty->assign('artefact', $artefact);
$smarty->assign('elementname', $elementname);
$smarty->assign('formcontrols', $formcontrols);
$result .= $smarty->fetch($template) . "\n";
$smarty = smarty_core();
$smarty->assign('artefact', $artefact);
$smarty->assign('elementname', $elementname);
$smarty->assign('formcontrols', $formcontrols);
$result .= $smarty->fetch($template) . "\n";
}
}
$smarty = smarty_core();
......
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