indexes => {
unique_letter => {
columns => [ 'letter_identifier', 'entry_id', 'template_id' ],
+ unique => 1,
}
},
default => {
},
datasource => 'love_letter',
primary_key => 'id',
+
+ child_of => [ 'MT::Entry', 'MT::Template' ],
});
sub mail_param {
$param;
}
+sub backup_terms_args {
+ my $class = shift;
+ my ($blog_ids) = @_;
+
+ if (defined($blog_ids) && scalar(@$blog_ids)) {
+ my $entry_ids = [ map($_->id, MT::Entry->load(
+ { 'blog_id' => $blog_ids, },
+ {
+ 'join' => Lovers::LoveLetter->join_on(
+ 'entry_id', undef, undef
+ ),
+ 'fetchonly' => ['id'],
+ }
+ )) ];
+ my $template_ids = [ map($_->id, MT::Template->load(
+ { 'blog_id' => $blog_ids, },
+ {
+ 'join' => Lovers::LoveLetter->join_on(
+ 'template_id', undef, undef
+ ),
+ 'fetchonly' => ['id'],
+ }
+ )) ];
+ return {
+ terms => [
+ [
+ { 'entry_id' => @$entry_ids ? $entry_ids : 0 },
+ '-and',
+ { 'template_id' => 0 },
+ ],
+ '-or',
+ [
+ { 'template_id' => @$template_ids ? $template_ids : 0 },
+ '-and',
+ { 'entry_id' => 0 },
+ ],
+ ],
+ args => undef
+ };
+ }
+ else {
+ return { terms => undef, args => undef };
+ }
+}
+
+sub parents {
+ my $obj = shift;
+ {
+ entry_id => MT->model('entry'),
+ template_id => MT->model('template'),
+ };
+}
+
1;