Commit 5dc631e3 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Implement bulk_delete for non-file artefacts


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 2c5d560f
......@@ -493,6 +493,20 @@ class ArtefactTypeBlogPost extends ArtefactType {
db_commit();
}
public static function bulk_delete($artefactids) {
if (empty($artefactids)) {
return;
}
$idstr = join(',', array_map('intval', $artefactids));
db_begin();
delete_records_select('artefact_blog_blogpost', 'blogpost IN (' . $idstr . ')');
parent::bulk_delete($artefactids);
db_commit();
}
/**
* Checks that the person viewing this blog is the owner. If not, throws an
* AccessDeniedException. Used in the blog section to ensure only the
......
......@@ -573,6 +573,19 @@ class ArtefactTypeEmail extends ArtefactTypeProfileField {
parent::delete();
}
public static function bulk_delete($artefactids) {
if (empty($artefactids)) {
return;
}
$idstr = join(',', array_map('intval', $artefactids));
db_begin();
delete_records_select('artefact_internal_profile_email', 'artefact IN (' . $idstr . ')');
parent::bulk_delete($artefactids);
db_commit();
}
public function render_self($options) {
if (array_key_exists('link', $options) && $options['link'] == true) {
$html = '<a href="mailto:' . hsc($this->title) . '">' . hsc($this->title) . '</a>';
......
......@@ -378,6 +378,20 @@ class ArtefactTypeTask extends ArtefactType {
db_commit();
}
public static function bulk_delete($artefactids) {
if (empty($artefactids)) {
return;
}
$idstr = join(',', array_map('intval', $artefactids));
db_begin();
delete_records_select('artefact_plans_task', 'artefact IN (' . $idstr . ')');
parent::bulk_delete($artefactids);
db_commit();
}
/**
* Gets the new/edit tasks pieform
*
......
......@@ -373,6 +373,19 @@ class ArtefactTypePersonalinformation extends ArtefactTypeResume {
db_commit();
}
public static function bulk_delete($artefactids) {
if (empty($artefactids)) {
return;
}
$idstr = join(',', array_map('intval', $artefactids));
db_begin();
delete_records_select('artefact_resume_personal_information', 'artefact IN (' . $idstr . ')');
parent::bulk_delete($artefactids);
db_commit();
}
}
......@@ -479,6 +492,19 @@ abstract class ArtefactTypeResumeComposite extends ArtefactTypeResume {
db_commit();
}
public static function bulk_delete_composite($artefactids, $compositetype) {
$table = 'artefact_resume_' . $compositetype;
if (empty($artefactids)) {
return;
}
$idstr = join(',', array_map('intval', $artefactids));
db_begin();
delete_records_select($table, 'artefact IN (' . $idstr . ')');
parent::bulk_delete($artefactids);
db_commit();
}
/**
* Takes a pieform that's been set up by all the
......@@ -859,6 +885,10 @@ class ArtefactTypeEmploymenthistory extends ArtefactTypeResumeComposite {
),
);
}
public static function bulk_delete($artefactids) {
ArtefactTypeResumeComposite::bulk_delete_composite($artefactids, 'employmenthistory');
}
}
class ArtefactTypeEducationhistory extends ArtefactTypeResumeComposite {
......@@ -974,6 +1004,10 @@ function formatQualification(name, type, institution) {
}
EOF;
}
public static function bulk_delete($artefactids) {
ArtefactTypeResumeComposite::bulk_delete_composite($artefactids, 'educationhistory');
}
}
class ArtefactTypeCertification extends ArtefactTypeResumeComposite {
......@@ -1026,6 +1060,10 @@ class ArtefactTypeCertification extends ArtefactTypeResumeComposite {
),
);
}
public static function bulk_delete($artefactids) {
ArtefactTypeResumeComposite::bulk_delete_composite($artefactids, 'certification');
}
}
class ArtefactTypeBook extends ArtefactTypeResumeComposite {
......@@ -1087,6 +1125,10 @@ class ArtefactTypeBook extends ArtefactTypeResumeComposite {
),
);
}
public static function bulk_delete($artefactids) {
ArtefactTypeResumeComposite::bulk_delete_composite($artefactids, 'book');
}
}
class ArtefactTypeMembership extends ArtefactTypeResumeComposite {
......@@ -1146,6 +1188,10 @@ class ArtefactTypeMembership extends ArtefactTypeResumeComposite {
),
);
}
public static function bulk_delete($artefactids) {
ArtefactTypeResumeComposite::bulk_delete_composite($artefactids, 'membership');
}
}
class ArtefactTypeResumeGoalAndSkill 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