Changeset 1776
- Timestamp:
- 04/04/08 22:48:02 (5 months ago)
- Files:
-
- branches/release-33/lib/MT/CMS/Blog.pm (modified) (3 diffs)
- branches/release-33/lib/MT/FileInfo.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/release-33/lib/MT/CMS/Blog.pm
r1753 r1776 1371 1371 } 1372 1372 1373 sub _update_finfos { 1374 my ($app, $new_virtual, $where) = @_; 1375 my $finfo_class = MT->model('fileinfo'); 1376 my $driver = $finfo_class->driver; 1377 my $dbd = $driver->dbd; 1378 1379 my $stmt = MT::ObjectDriver::SQL->new; 1380 1381 if ($where) { 1382 my $new_where = {}; 1383 while (my ($key, $val) = each %$where) { 1384 my $new_key = $dbd->db_column_name($finfo_class->datasource, $key); 1385 $new_where->{$new_key} = $val; 1386 } 1387 $stmt->add_complex_where([ $new_where ]); 1388 } 1389 my $virtual_col = $dbd->db_column_name($finfo_class->datasource, 'virtual'); 1390 $stmt->add_complex_where([ { $virtual_col => { op => '!=', value => $new_virtual } } ]); 1391 1392 my $sql = join q{ }, 'UPDATE', $driver->table_for($finfo_class), 'SET', 1393 $virtual_col, '= ?', $stmt->as_sql_where(); 1394 1395 my $dbh = $driver->rw_handle; 1396 $dbh->do($sql, {}, $new_virtual, @{ $stmt->{bind} }) 1397 or return $app->error($dbh->errstr || $DBI::errstr); 1398 1; 1399 } 1400 1373 1401 sub post_save { 1374 1402 my $eh = shift; … … 1416 1444 } 1417 1445 1446 if (!$dcty_changed || $dcty eq 'custom') { 1447 # do nothing 1448 } 1449 elsif ($dcty eq 'none') { 1450 _update_finfos($app, 0); 1451 } 1452 elsif ($dcty eq 'all') { 1453 _update_finfos($app, 1); 1454 } 1455 elsif ($dcty eq 'archives') { 1456 # Only archives have template maps. 1457 _update_finfos($app, 1, { templatemap_id => \'is not null' }); 1458 _update_finfos($app, 0, { templatemap_id => \'is null' }); 1459 } 1460 1418 1461 # If either of the publishing paths changed, rebuild the fileinfos. 1419 1462 my $path_changed = 0; … … 1422 1465 && $app->param($path_field) ne $original->$path_field(); 1423 1466 } 1424 if ($dcty ne 'none' && ($dcty_changed || $path_changed)) { 1467 1468 if ($path_changed) { 1425 1469 $app->rebuild( BlogID => $obj->id, NoStatic => 1 ) 1426 1470 or return $app->publish_error(); branches/release-33/lib/MT/FileInfo.pm
r1495 r1776 38 38 datasource => 'fileinfo', 39 39 primary_key => 'id', 40 cacheable => 0, 40 41 }); 41 42
