Commit 87bc4be3 authored by Penny Leach's avatar Penny Leach
Browse files

Fixing up view based rendering issues for the resume plugin (fixes [#666])

parent a9e38bea
......@@ -32,6 +32,7 @@ require(dirname(dirname(dirname(__FILE__))) . '/init.php');
$limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);
$type = param_alpha('type');
$view = param_integer('view', 0);
$data = array();
$count = 0;
......@@ -39,14 +40,29 @@ $count = 0;
$prefix = get_config('dbprefix');
$othertable = 'artefact_resume_' . $type;
$owner = $USER->get('id');
$sql = 'SELECT ar.*, a.owner
FROM ' . $prefix . 'artefact a
JOIN ' . $prefix . $othertable . ' ar ON ar.artefact = a.id
WHERE a.owner = ? AND a.artefacttype = ?
LIMIT ' . $limit . ' OFFSET ' . $offset;
if (!$data = get_records_sql_array($sql, array($USER->get('id'), $type))) {
if (!empty($view)) {
if (!can_view_view($view)) {
throw new AccessDeniedException();
}
require_once('view.php');
$v = new View($view);
$owner = $v->get('owner');
}
if (!$data = get_records_sql_array($sql, array($owner, $type))) {
$data = array();
}
$count = count_records('artefact', 'owner', $owner, 'artefacttype', $type);
foreach ($data as &$row) {
foreach (array('date', 'startdate', 'enddate') as $key) {
if (array_key_exists($key, $row)) {
......@@ -54,7 +70,6 @@ foreach ($data as &$row) {
}
}
}
$count = count_records('artefact', 'owner', $USER->get('id'), 'artefacttype', $type);
echo json_encode(array(
'data' => $data,
'limit' => $limit,
......
......@@ -133,7 +133,7 @@ class ArtefactTypeCoverletter extends ArtefactTypeResume {
}
public function render_full($options) {
return array('html' => $this->title);
return array('html' => $this->description);
}
}
......@@ -505,6 +505,12 @@ abstract class ArtefactTypeResumeComposite extends ArtefactTypeResume {
{$type}list.type = '{$type}';
{$type}list.statevars.push('type');
" .
(( array_key_exists('viewid', $options))
? "{$type}list.view = " . $options['viewid'] . ";
{$type}list.statevars.push('view');"
: ""
) . "
{$type}list.updateOnLoad();
");
return $content;
......
Supports Markdown
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