Changeset 1873
- Timestamp:
- 04/13/08 04:41:46 (15 months ago)
- Location:
- branches/release-34/lib/MT
- Files:
-
- 17 modified
-
App.pm (modified) (1 diff)
-
App/Comments.pm (modified) (1 diff)
-
App/Trackback.pm (modified) (2 diffs)
-
AtomServer.pm (modified) (1 diff)
-
BackupRestore/BackupFileHandler.pm (modified) (1 diff)
-
Blocklist.pm (modified) (1 diff)
-
CMS/Entry.pm (modified) (2 diffs)
-
CMS/Tag.pm (modified) (2 diffs)
-
CMS/Template.pm (modified) (3 diffs)
-
Object.pm (modified) (1 diff)
-
ObjectDriver/Driver/DBI.pm (modified) (1 diff)
-
Tag.pm (modified) (3 diffs)
-
Template/ContextHandlers.pm (modified) (2 diffs)
-
TemplateMap.pm (modified) (1 diff)
-
Upgrade.pm (modified) (6 diffs)
-
Util.pm (modified) (3 diffs)
-
XMLRPCServer.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/release-34/lib/MT/App.pm
r1823 r1873 1649 1649 } 1650 1650 1651 my $existing = MT::Author-> count( { name => $name } );1651 my $existing = MT::Author->exist( { name => $name } ); 1652 1652 return $app->error($app->translate("A user with the same name already exists.")) 1653 1653 if $existing; -
branches/release-34/lib/MT/App/Comments.pm
r1823 r1873 680 680 681 681 if ( 682 MT::Comment-> count(682 MT::Comment->exist( 683 683 { 684 684 ip => $user_ip, -
branches/release-34/lib/MT/App/Trackback.pm
r1866 r1873 560 560 } 561 561 elsif ( my $cid = $tb->category_id ) { 562 my $ count = $app->model('entry')->count(562 my $exist = $app->model('entry')->exist( 563 563 { status => MT::Entry::RELEASE() }, 564 564 { … … 569 569 return $app->_response( 570 570 Error => $app->translate( "Invalid TrackBack ID '[_1]'", $tb_id ) ) 571 if $count <= 0;571 unless $exist; 572 572 } 573 573 my $rss = _generate_rss($tb); -
branches/release-34/lib/MT/AtomServer.pm
r1825 r1873 342 342 if (my $basename = $app->get_header('Slug')) { 343 343 my $entry_class = ref $entry; 344 my $basename_uses = $entry_class-> count({344 my $basename_uses = $entry_class->exist({ 345 345 blog_id => $entry->blog_id, 346 346 basename => $basename, -
branches/release-34/lib/MT/BackupRestore/BackupFileHandler.pm
r1711 r1873 256 256 } 257 257 elsif ('permission' eq $name) { 258 my $perm = $class-> count( {258 my $perm = $class->exist( { 259 259 author_id => $obj->author_id, 260 260 blog_id => $obj->blog_id -
branches/release-34/lib/MT/Blocklist.pm
r1495 r1873 32 32 my ($blog_id, $action, @urls) = @_; 33 33 foreach my $url (@urls) { 34 next if $class-> count({blog_id => $blog_id, text => $url});34 next if $class->exist({blog_id => $blog_id, text => $url}); 35 35 my $this = $class->new(); 36 36 $this->set_values({blog_id => $blog_id, text => $url, -
branches/release-34/lib/MT/CMS/Entry.pm
r1823 r1873 81 81 $param->{can_send_notifications} = 1; 82 82 $param->{has_subscribers} = 83 $not_class-> count( { blog_id => $blog_id } );83 $not_class->exist( { blog_id => $blog_id } ); 84 84 } 85 85 … … 1151 1151 && $type eq 'entry' ) 1152 1152 { 1153 my $ cnt =1154 $class-> count( { blog_id => $blog_id, basename => $basename } );1155 if ($ cnt) {1153 my $exist = 1154 $class->exist( { blog_id => $blog_id, basename => $basename } ); 1155 if ($exist) { 1156 1156 $obj->basename( MT::Util::make_unique_basename($obj) ); 1157 1157 } -
branches/release-34/lib/MT/CMS/Tag.pm
r1823 r1873 110 110 if ( $tag && $blog_id ) { 111 111 my $ot_class = $app->model('objecttag'); 112 my $ count = $ot_class->count(112 my $exist = $ot_class->exist( 113 113 { 114 114 object_datasource => $class->datasource, … … 117 117 } 118 118 ); 119 undef $tag unless $ count;119 undef $tag unless $exist; 120 120 } 121 121 return $app->json_result( { exists => $tag ? 'true' : 'false' } ); -
branches/release-34/lib/MT/CMS/Template.pm
r1872 r1873 1126 1126 my $blog_id = $q->param('blog_id'); 1127 1127 my $at = $q->param('new_archive_type'); 1128 my $ count = MT::TemplateMap->count(1128 my $exist = MT::TemplateMap->exist( 1129 1129 { 1130 1130 blog_id => $blog_id, … … 1133 1133 ); 1134 1134 my $map = MT::TemplateMap->new; 1135 $map->is_preferred( $ count ? 0 : 1 );1135 $map->is_preferred( $exist ? 0 : 1 ); 1136 1136 $map->template_id( scalar $q->param('template_id') ); 1137 1137 $map->blog_id($blog_id); … … 1835 1835 my $new_name = $new_basename; 1836 1836 my $i = 0; 1837 while (MT::Template-> count({ name => $new_name, blog_id => $tmpl->blog_id })) {1837 while (MT::Template->exist({ name => $new_name, blog_id => $tmpl->blog_id })) { 1838 1838 $new_name = $new_basename . ' (' . ++$i . ')'; 1839 1839 } -
branches/release-34/lib/MT/Object.pm
r1846 r1873 543 543 ## Drivers. 544 544 545 # Note: Removed methods: set_driver546 547 545 sub count { shift->_proxy('count', @_) } 546 sub exist { shift->_proxy('exist', @_) } 548 547 sub count_group_by { shift->_proxy('count_group_by', @_) } 549 548 sub sum_group_by { shift->_proxy('sum_group_by', @_) } -
branches/release-34/lib/MT/ObjectDriver/Driver/DBI.pm
r1502 r1873 59 59 order => '', 60 60 limit => undef, 61 offset => undef, 62 }, 63 ); 64 } 65 66 sub exist { 67 my $driver = shift; 68 my($class, $terms, $args) = @_; 69 70 return $driver->_select_aggregate( 71 select => '1', 72 class => $class, 73 terms => $terms, 74 args => $args, 75 override => { 76 order => '', 77 limit => 1, 61 78 offset => undef, 62 79 }, -
branches/release-34/lib/MT/Tag.pm
r1657 r1873 95 95 if (!$tag->n8d_id) { 96 96 # normalized tag! we can't delete if others reference us 97 my $child_tags = MT::Tag-> count({n8d_id => $tag->id});97 my $child_tags = MT::Tag->exist({n8d_id => $tag->id}); 98 98 return $tag->error(MT->translate("This tag is referenced by others.")) 99 99 if $child_tags; … … 108 108 if ($n8d_tag) { 109 109 # Normalized tag, no longer referenced by other tags... 110 if (!MT::Tag-> count({n8d_id => $n8d_tag->id})) {110 if (!MT::Tag->exist({n8d_id => $n8d_tag->id})) { 111 111 # Noramlized tag that no longer has any object tag associations 112 112 require MT::ObjectTag; 113 if (!MT::ObjectTag-> count({tag_id => $n8d_tag->id})) {113 if (!MT::ObjectTag->exist({tag_id => $n8d_tag->id})) { 114 114 $n8d_tag->remove 115 115 or return $tag->error($n8d_tag->errstr); … … 412 412 my $this_tag_id = $otag->tag_id; 413 413 $otag->remove; 414 if (! MT::ObjectTag-> count({tag_id => $this_tag_id})) {414 if (! MT::ObjectTag->exist({tag_id => $this_tag_id})) { 415 415 # no more references to this tag... just delete it now 416 416 if (my $tag = MT::Tag->load($this_tag_id)) { -
branches/release-34/lib/MT/Template/ContextHandlers.pm
r1862 r1873 3043 3043 3044 3044 my $class = MT->model('entry'); 3045 $class-> count( \%terms );3045 $class->exist( \%terms ); 3046 3046 } 3047 3047 … … 3058 3058 3059 3059 my $class = MT->model('page'); 3060 $class-> count( \%terms );3060 $class->exist( \%terms ); 3061 3061 } 3062 3062 -
branches/release-34/lib/MT/TemplateMap.pm
r1823 r1873 108 108 $blog->save; 109 109 for my $at ( @{ $ats{ $blog->id } } ) { 110 unless ( __PACKAGE__-> count({110 unless ( __PACKAGE__->exist({ 111 111 blog_id => $blog->id, archive_type => $at, is_preferred => 1 112 112 }) ) { -
branches/release-34/lib/MT/Upgrade.pm
r1866 r1873 368 368 updater => { 369 369 type => 'blog', 370 condition => sub { !(MT::Permission-> count({370 condition => sub { !(MT::Permission->exist({ 371 371 blog_id => $_[0]->id, author_id => 0 })) }, 372 372 code => sub { … … 1480 1480 1481 1481 require MT::Author; 1482 return undef if MT::Author-> count;1482 return undef if MT::Author->exist; 1483 1483 1484 1484 $self->progress($self->translate_escape("Creating initial blog and user records...")); … … 1606 1606 1607 1607 require MT::Role; 1608 return if MT::Role-> count();1608 return if MT::Role->exist(); 1609 1609 1610 1610 foreach my $r (@default_roles) { … … 1673 1673 $terms->{blog_id} = $blog_id; 1674 1674 1675 return 1 if MT::Template-> count( $terms );1675 return 1 if MT::Template->exist( $terms ); 1676 1676 1677 1677 $self->progress($self->translate_escape("Creating new template: '[_1]'.", $val->{name})); … … 1984 1984 require MT::Template; 1985 1985 my $dyn_error_template = 1986 MT::Template-> count({type => 'dynamic_error'});1986 MT::Template->exist({type => 'dynamic_error'}); 1987 1987 if ($dyn_error_template) { 1988 1988 return 3.1; … … 1990 1990 1991 1991 my $comment_pending_template = 1992 MT::Template-> count({type => 'comment_pending'});1992 MT::Template->exist({type => 'comment_pending'}); 1993 1993 if ($comment_pending_template) { 1994 1994 return 3.0; -
branches/release-34/lib/MT/Util.pm
r1823 r1873 936 936 937 937 my $class = ref $entry; 938 while ($class-> count({ blog_id => $blog->id,938 while ($class->exist({ blog_id => $blog->id, 939 939 basename => $base })) { 940 940 $base = $base_copy . '_' . $i++; … … 962 962 963 963 my $cat_class = ref $cat; 964 while ($cat_class-> count({ blog_id => $cat->blog_id,964 while ($cat_class->exist({ blog_id => $cat->blog_id, 965 965 basename => $base })) { 966 966 $base = $base_copy . '_' . $i++; … … 982 982 983 983 my $author_class = ref $author; 984 while ($author_class-> count({ basename => $base })) {984 while ($author_class->exist({ basename => $base })) { 985 985 $base = $base_copy . '_' . $i++; 986 986 } -
branches/release-34/lib/MT/XMLRPCServer.pm
r1823 r1873 184 184 # Ensure this basename is unique. 185 185 my $entry_class = ref $entry; 186 my $basename_uses = $entry_class-> count({186 my $basename_uses = $entry_class->exist({ 187 187 blog_id => $entry->blog_id, 188 188 basename => $basename,
