Changeset 2847
- Timestamp:
- 07/28/08 03:33:20 (4 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/feature-revision-histories/lib/MT/Entry.pm
r2790 r2847 31 31 type => 'smallint', 32 32 not_null => 1, 33 label => 'Status' 33 label => 'Status', 34 revisioned => 1 34 35 }, 35 36 'author_id' => { 36 37 type => 'integer', 37 38 not_null => 1, 38 label => 'Author' 39 label => 'Author', 40 revisioned => 1 39 41 }, 40 42 'allow_comments' => { 41 43 type => 'boolean', 42 label => 'Accept Comments' 44 label => 'Accept Comments', 45 revisioned => 1 43 46 }, 44 47 'title' => { … … 73 76 'allow_pings' => { 74 77 type => 'boolean', 75 label => 'Accept Trackbacks' 78 label => 'Accept Trackbacks', 79 revisioned => 1 76 80 }, 77 81 'keywords' => { branches/feature-revision-histories/lib/MT/Revisable.pm
r2831 r2847 10 10 11 11 use strict; 12 13 our $MAX_REVISIONS = 20; 12 14 13 15 sub install_properties { … … 24 26 $class->install_column('current_revision'); 25 27 $props->{defaults}{current_revision} = 0; 28 29 # To track how many revisions to store for each object, add 30 # a meta column in MT::Blog 31 # my $blog_class = MT->model('blog'); 32 # $blog_class->install_meta({ column_defs => { 33 # "max_${datasource}_revision" => 'integer' 34 # }}); 26 35 27 36 # Callbacks: clean list of changed columns to only … … 141 150 $obj->gather_changed_cols($orig); 142 151 152 # Collision Checking 153 my $changed_cols = $obj->{changed_revisioned_cols}; 154 my $modified_by = $orig->author; 155 156 if(scalar @$changed_cols) { 157 if($app->isa('MT::App::CMS') 158 && $app->param('current_revision') != $orig->current_revision) { 159 my %param = ( 160 collision => 1, 161 return_args => $app->param('return_args'), 162 modified_by_nickname => $modified_by->nickname 163 ); 164 return $app->forward( "view", \%param ); 165 } 166 } 167 143 168 $obj->increment_revision($orig); # Added here for consistency 144 169 } … … 174 199 sub pack_revision { 175 200 my $obj = shift; 176 my $values;177 201 my $values = $obj->column_values; 178 202 … … 292 316 } 293 317 318 sub diff_object { 319 my $obj_a = shift; 320 my ($obj_b, $diff_args) = @_; 321 322 return $obj_a->error(MT->translate("There aren't the same types of objects, expecting two [_1]", 323 lc $obj_a->class_label_plural)) 324 if ref $obj_a ne ref $obj_b; 325 326 my %diff; 327 my $cols = $obj_a->revisioned_columns(); 328 foreach my $col (@$cols) { 329 $diff{$col} = _diff_string($obj_a->$col, $obj_b->$col, $diff_args); 330 } 331 332 return \%diff; 333 } 334 294 335 sub diff_revision { 295 336 my $obj = shift; … … 310 351 311 352 return $obj->error(MT->translate("Did not get two [_1]", lc $obj->class_label_plural)) 312 if ref $obj_a ne 'MT::Entry' || ref $obj_b ne 'MT::Entry';353 if ref $obj_a ne ref $obj || ref $obj_b ne ref $obj; 313 354 314 355 my %diff; … … 337 378 push @result, { 338 379 flag => $diff->[0], 339 value=> ($diff->[0] eq '+') ? $diff->[2] : $diff->[1]380 text => ($diff->[0] eq '+') ? $diff->[2] : $diff->[1] 340 381 }; 341 382 } else { 342 383 push @result, { 343 384 flag => '-', 344 value=> $diff->[1]385 text => $diff->[1] 345 386 }; 346 387 push @result, { 347 388 flag => '+', 348 value=> $diff->[2]389 text => $diff->[2] 349 390 }; 350 391 }
