Commit 7617b275 authored by Gregor Anzelj's avatar Gregor Anzelj Committed by Robert Lyon

Support for linking to electronic publications (Bug #547386)

Change-Id: I48866b92bd3a54fe41dd72781d193de7ccecad12
Signed-off-by: default avatarGregor Anzelj <gregor.anzelj@gmail.com>
parent cd08104c
......@@ -76,6 +76,7 @@
<FIELD NAME="title" TYPE="text" NOTNULL="true" />
<FIELD NAME="contribution" TYPE="text" NOTNULL="true" />
<FIELD NAME="description" TYPE="text" NOTNULL="false" />
<FIELD NAME="url" TYPE="text" NOTNULL="false" />
<FIELD NAME="displayorder" TYPE="int" LENGTH="10" NOTNULL="true" />
</FIELDS>
<KEYS>
......
......@@ -28,7 +28,7 @@
defined('INTERNAL') || die();
function xmldb_artefact_resume_upgrade($oldversion=0) {
$status = true;
if ($oldversion < 2008012200) {
......@@ -43,8 +43,8 @@ function xmldb_artefact_resume_upgrade($oldversion=0) {
'artefact_resume_educationhistory',
'artefact_resume_membership') as $table) {
$records = get_records_array($table, '', '', 'startdate DESC', 'id,startdate,enddate');
// Sigh. table_column is screwed beyond belief. We let it do its
// work (in the case of start and stopdate at least because it does
// Sigh. table_column is screwed beyond belief. We let it do its
// work (in the case of start and stopdate at least because it does
// cast the columns OK), then fix its bugs
execute_sql('ALTER TABLE {' . $table . '} ADD displayorder ' . $inttype);
table_column($table, 'startdate', 'startdate', 'text', null, null, '', 'not null');
......@@ -64,10 +64,10 @@ function xmldb_artefact_resume_upgrade($oldversion=0) {
if (!empty($records)) {
foreach ($records as $k => $r) {
set_field($table, 'displayorder', $k, 'id', $r->id);
set_field($table, 'startdate',
set_field($table, 'startdate',
format_date(strtotime($r->startdate), 'strftimedate', 'current', 'artefact.resume'),
'id', $r->id);
set_field($table, 'enddate',
set_field($table, 'enddate',
format_date(strtotime($r->enddate), 'strftimedate', 'current', 'artefact.resume'),
'id', $r->id);
}
......@@ -93,7 +93,7 @@ function xmldb_artefact_resume_upgrade($oldversion=0) {
if (!empty($records)) {
foreach ($records as $k => $r) {
set_field($table, 'displayorder', $k, 'id', $r->id);
set_field($table, 'date',
set_field($table, 'date',
format_date(strtotime($r->date), 'strftimedate', 'current', 'artefact.resume'),
'id', $r->id);
}
......@@ -132,5 +132,12 @@ function xmldb_artefact_resume_upgrade($oldversion=0) {
change_field_notnull($table, $field);
}
if ($oldversion < 2013071300) {
$table = new XMLDBTable('artefact_resume_book');
$field = new XMLDBField('url');
$field->setAttributes(XMLDB_TYPE_TEXT);
add_field($table, $field);
}
return $status;
}
......@@ -54,7 +54,7 @@ $elements = call_static_method(generate_artefact_class_name($type), 'get_addform
$elements['submit'] = array(
'type' => 'submitcancel',
'value' => array(get_string('save'), get_string('cancel')),
'goto' => get_config('wwwroot') . '/artefact/resume/' . $tabs[$type] . '.php',
'goto' => get_config('wwwroot') . 'artefact/resume/' . $tabs[$type] . '.php',
);
$elements['compositetype'] = array(
'type' => 'hidden',
......
......@@ -67,6 +67,8 @@ $string['position'] = 'Position';
$string['qualification'] = 'Qualification';
$string['title'] = 'Title';
$string['description'] = 'Description';
$string['bookurl'] = 'URL';
$string['notvalidurl'] = 'Not a valid URL';
$string['employer'] = 'Employer';
$string['jobtitle'] = 'Job title';
$string['jobdescription'] = 'Position description';
......
<h3>URL</h3>
<p>URL for the book or publication details.</p>
<h3>URL</h3>
<p>URL for the book or publication details.</p>
......@@ -688,6 +688,7 @@ function compositeSaveCallback(form, data) {
element.value = '';
}
});
formSuccess(form, data);
}
function deleteComposite(type, id, artefact) {
......@@ -1137,7 +1138,7 @@ class ArtefactTypeBook extends ArtefactTypeResumeComposite {
}
public static function get_tablerenderer_body_js_string() {
return "r.description";
return "TD(r.description, DIV({'id':'composite-book-url'}, A({'href':r.url, 'target':'_blank'}, r.url)))";
}
public static function get_addform_elements() {
......@@ -1174,6 +1175,12 @@ class ArtefactTypeBook extends ArtefactTypeResumeComposite {
'resizable' => false,
'title' => get_string('detailsofyourcontribution', 'artefact.resume'),
),
'url' => array(
'type' => 'text',
'title' => get_string('bookurl', 'artefact.resume'),
'size' => 70,
'help' => true,
),
);
}
......@@ -1259,6 +1266,25 @@ class ArtefactTypePersonalskill extends ArtefactTypeResumeGoalAndSkill { }
class ArtefactTypeAcademicskill extends ArtefactTypeResumeGoalAndSkill { }
class ArtefactTypeWorkskill extends ArtefactTypeResumeGoalAndSkill { }
function book_validate(Pieform $form, $values) {
// Check if string enter by user is valid URL
if (array_key_exists('url', $values) && !empty($values['url'])) {
if (filter_var($values['url'], FILTER_VALIDATE_URL) === false) {
$form->set_error('url', get_string('notvalidurl', 'artefact.resume'));
}
}
}
function addbook_validate(Pieform $form, $values) {
// Check if string enter by user is valid URL
if (array_key_exists('url', $values) && !empty($values['url'])) {
if (filter_var($values['url'], FILTER_VALIDATE_URL) === false) {
$form->set_error('url', get_string('notvalidurl', 'artefact.resume'));
}
}
}
function compositeform_submit(Pieform $form, $values) {
try {
call_static_method(generate_artefact_class_name($values['compositetype']),
......@@ -1274,7 +1300,7 @@ function compositeformedit_submit(Pieform $form, $values) {
global $SESSION;
$tabs = PluginArtefactResume::composite_tabs();
$goto = get_config('wwwroot') . '/artefact/resume/';
$goto = get_config('wwwroot') . 'artefact/resume/';
if (isset($tabs[$values['compositetype']])) {
$goto .= $tabs[$values['compositetype']] . '.php';
}
......
......@@ -17,7 +17,7 @@
<tr class="{cycle values='r0,r0,r1,r1'} expandable-head">
{if $controls}<td class="buttonscell"></td>{/if}
<td class="toggle">{$row->date}</td>
<td>{$row->title}</td>
<td>{if $row->url}<a href="{$row->url}" target="_blank">{$row->title}</a>{else}{$row->title}{/if}</td>
{if $controls}<td class="buttonscell"></td>{/if}
</tr>
<tr class="{cycle values='r0,r0,r1,r1'} expandable-body">
......
......@@ -28,5 +28,5 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2010020300;
$config->release = '1.0.1';
$config->version = 2013071300;
$config->release = '1.0.2';
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