Commit 5232d0ab authored by Penny Leach's avatar Penny Leach
Browse files

fixing bugs in the coverletter & interests artefact types (resume)

and reorganising a bit to make more sense
parent 7b7d8b16
......@@ -77,7 +77,7 @@ $form = array(
'type' => 'wysiwyg',
'cols' => 70,
'rows' => 10,
'defaultvalue' => ((!empty($coverletter)) ? $coverletter->get('title') : null),
'defaultvalue' => ((!empty($coverletter)) ? $coverletter->get('description') : null),
),
)
),
......@@ -89,7 +89,7 @@ $form = array(
'elements' => array(
'interest' => array(
'type' => 'wysiwyg',
'defaultvalue' => ((!empty($interest)) ? $interest->get('title') : null),
'defaultvalue' => ((!empty($interest)) ? $interest->get('description') : null),
'cols' => 70,
'rows' => 10,
),
......@@ -294,19 +294,42 @@ function resumemainform_submit(Pieform $form, $values) {
if (empty($coverletter) && !empty($values['coverletter'])) {
$coverletter = new ArtefactTypeCoverletter(0, array(
'owner' => $userid,
'title' => $values['coverletter']
'description' => $values['coverletter']
));
$coverletter->commit();
}
else if (!empty($coverletter)) {
else if (!empty($coverletter) && !empty($values['coverletter'])) {
$coverletter->set('description', $values['coverletter']);
$coverletter->commit();
}
else if (!empty($coverletter) && empty($values['coverletter'])) {
$coverletter->delete();
}
}
catch (Exception $e) {
$errors['coverletter'] = true;
}
try {
if (empty($interest) && !empty($values['interest'])) {
$interest = new ArtefactTypeInterest(0, array(
'owner' => $userid,
'description' => $values['interest']
));
$interest->commit();
}
else if (!empty($interest) && !empty($values['interest'])) {
$interest->set('description', $values['interest']);
$interest->commit();
}
else if (!empty($interest) && empty($values['interest'])) {
$interest->delete();
}
}
catch (Exception $e) {
$errors['interest'] = true;
}
try {
if (empty($personalinformation)) {
$personalinformation = new ArtefactTypePersonalinformation(0, array(
......@@ -323,23 +346,6 @@ function resumemainform_submit(Pieform $form, $values) {
$errors['personalinformation'] = true;
}
try {
if (empty($interest) && !empty($values['interest'])) {
$interest = new ArtefactTypeInterest(0, array(
'owner' => $userid,
'title' => $values['interest']
));
$interest->commit();
}
else if (!empty($interest)) {
$interest->set('description', $values['interest']);
$interest->commit();
}
}
catch (Exception $e) {
$errors['interest'] = true;
}
if (empty($errors)) {
$form->json_reply(PIEFORM_OK, get_string('resumesaved','artefact.resume'));
}
......
......@@ -83,6 +83,13 @@ class PluginArtefactResume extends Plugin {
class ArtefactTypeResume extends ArtefactType {
public function get_icon() {}
public function __construct($id=0, $data=array()) {
if (empty($id)) {
$data['title'] = get_string($this->get_artefact_type(), 'artefact.resume');
}
parent::__construct($id, $data);
}
public static function is_singular() {
return false;
......@@ -110,6 +117,13 @@ class ArtefactTypeCoverletter extends ArtefactTypeResume {
return true;
}
public function __construct($id=0, $data=array()) {
if (empty($id)) {
$data['title'] = get_string($this->get_artefact_type(), 'artefact.resume');
}
parent::__construct($id, $data);
}
public static function get_render_list() {
return array(
FORMAT_ARTEFACT_LISTSELF,
......@@ -127,6 +141,29 @@ class ArtefactTypeCoverletter extends ArtefactTypeResume {
}
}
class ArtefactTypeInterest extends ArtefactTypeResume {
public static function is_singular() {
return true;
}
public static function get_render_list() {
return array(
FORMAT_ARTEFACT_LISTSELF,
FORMAT_ARTEFACT_RENDERFULL,
FORMAT_ARTEFACT_RENDERMETADATA,
);
}
public function listself($options) {
return array('html' => get_string('interest', 'artefact.resume'));
}
public function render_full($options) {
return array('html' => $this->title);
}
}
class ArtefactTypeContactinformation extends ArtefactTypeResume {
public function get_html($editing=true) {
......@@ -306,28 +343,6 @@ class ArtefactTypePersonalinformation extends ArtefactTypeResume {
}
class ArtefactTypeInterest extends ArtefactTypeResume {
public static function is_singular() {
return true;
}
public static function get_render_list() {
return array(
FORMAT_ARTEFACT_LISTSELF,
FORMAT_ARTEFACT_RENDERFULL,
FORMAT_ARTEFACT_RENDERMETADATA,
);
}
public function listself($options) {
return array('html' => get_string('interest', 'artefact.resume'));
}
public function render_full($options) {
return array('html' => $this->title);
}
}
abstract class ArtefactTypeResumeComposite extends ArtefactTypeResume {
......
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