Changeset 1128

Show
Ignore:
Timestamp:
09/23/08 16:15:26 (14 months ago)
Author:
mpaschal
Message:

Add 'Collect Now' button to profile listing
Split first_update flag into synchronous scan and 'hide events without timestamps' flags
BugzID: 80151

Location:
trunk/ActionStreams/plugins/ActionStreams
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/ActionStreams/plugins/ActionStreams/config.yaml

    r1126 r1128  
    2323            add_other_profile:       $ActionStreams::ActionStreams::Plugin::add_other_profile 
    2424            remove_other_profile:    $ActionStreams::ActionStreams::Plugin::remove_other_profile 
     25            itemset_update_profiles: $ActionStreams::ActionStreams::Plugin::itemset_update_profiles 
    2526            itemset_hide_events:     $ActionStreams::ActionStreams::Plugin::itemset_hide_events 
    2627            itemset_show_events:     $ActionStreams::ActionStreams::Plugin::itemset_show_events 
  • trunk/ActionStreams/plugins/ActionStreams/lib/ActionStreams/Event.pm

    r1111 r1128  
    99use ActionStreams::Scraper; 
    1010 
    11 our $first_update = 0; 
     11our $hide_timeless = 0; 
    1212 
    1313__PACKAGE__->install_properties({ 
     
    5454    my %profile = @_; 
    5555 
     56    # Keep this option out of band so we don't have to count on 
     57    # implementations of update_events() passing it through. 
     58    local $hide_timeless = delete $profile{hide_timeless} ? 1 : 0; 
     59 
    5660    my $warn = $SIG{__WARN__} || sub { print STDERR $_[0] }; 
    5761    local $SIG{__WARN__} = sub { 
     
    356360        }); 
    357361        $event->tags(@$tags) if $tags; 
    358         if ($first_update && !$event->created_on) { 
     362        if ($hide_timeless && !$event->created_on) { 
    359363            $event->visible(0); 
    360364        } 
  • trunk/ActionStreams/plugins/ActionStreams/lib/ActionStreams/Plugin.pm

    r1114 r1128  
    366366        added          => $app->param('added')   ? 1 : 0, 
    367367        removed        => $app->param('removed') ? 1 : 0, 
     368        updated        => $app->param('updated') ? 1 : 0, 
    368369        _build_service_data( 
    369370            networks => $app->registry('profile_services'), 
     
    482483} 
    483484 
     485sub itemset_update_profiles { 
     486    my $app = shift; 
     487 
     488    my %users; 
     489    my $page_author_id; 
     490    PROFILE: for my $profile ($app->param('id')) { 
     491        my ($author_id, $type, $ident) = split /:/, $profile, 3; 
     492 
     493        my $user = ($users{$author_id} ||= MT->model('author')->load($author_id)) 
     494            or next PROFILE; 
     495        next PROFILE 
     496            if $app->user->id != $author_id && !$app->user->is_superuser(); 
     497 
     498        my $profiles = $user->other_profiles($type); 
     499        if (!$profiles) { 
     500            next PROFILE; 
     501        } 
     502        my @profiles = grep { $_->{ident} eq $ident } @$profiles; 
     503        for my $author_profile (@profiles) { 
     504            update_events_for_profile($user, $author_profile, 
     505                synchronous => 1); 
     506        } 
     507 
     508        $page_author_id = 1; 
     509    } 
     510 
     511    return $app->redirect($app->uri( 
     512        mode => 'other_profiles', 
     513        args => { id => ($page_author_id || $app->user->id), updated => 1 }, 
     514    )); 
     515} 
     516 
    484517sub first_profile_update { 
    485518    my ($cb, $app, $user, $profile) = @_; 
    486     require ActionStreams::Event; 
    487     local $ActionStreams::Event::first_update = 1; 
    488     update_events_for_profile($user, $profile); 
     519    update_events_for_profile($user, $profile, 
     520        synchronous => 1, hide_timeless => 1); 
    489521} 
    490522 
     
    9791011 
    9801012sub update_events { 
    981     require ActionStreams::Event; 
    9821013    my $mt = MT->app; 
    983  
    9841014    $mt->run_callbacks('pre_action_streams_task', $mt); 
    9851015 
     
    10001030 
    10011031sub update_events_for_profile { 
    1002     my ($author, $profile) = @_; 
     1032    my ($author, $profile, %param) = @_; 
    10031033    my $type = $profile->{type}; 
    10041034    my $streams = $profile->{streams}; 
    10051035    return if !$streams || !%$streams; 
    10061036 
     1037    require ActionStreams::Event; 
    10071038    my @event_classes = ActionStreams::Event->classes_for_type($type) 
    10081039      or return; 
     
    10141045        next EVENTCLASS if !$streams->{$event_class->class_type}; 
    10151046 
    1016         if ($ActionStreams::Event::first_update) { 
    1017             # Do the first update synchronously. 
     1047        if ($param{synchronous}) { 
    10181048            $event_class->update_events_safely( 
    1019                 author => $author, 
     1049                author        => $author, 
     1050                hide_timeless => $param{hide_timeless} ? 1 : 0, 
    10201051                %$profile, 
    10211052            ); 
  • trunk/ActionStreams/plugins/ActionStreams/tmpl/other_profiles.tmpl

    r471 r1128  
    5656        </mtapp:statusmsg> 
    5757    </mt:if> 
     58    <mt:if name="updated"> 
     59        <mtapp:statusmsg 
     60            id="updated" 
     61            class="success"> 
     62            <__trans phrase="The selected profiles were scanned for updates."> 
     63        </mtapp:statusmsg> 
     64    </mt:if> 
    5865</mt:setvarblock> 
    5966 
     
    7683        title="<__trans phrase="Delete selected profiles (x)">" 
    7784        ><__trans phrase="Delete"></a> 
     85    <a href="javascript:void(0)" 
     86        onclick="doForMarkedInThisWindow(getByID('profile-listing-form'), '<__trans phrase="profile">', '<__trans phrase="profiles">', 'id', 'itemset_update_profiles'); return false" 
     87        title="<__trans phrase="Scan now for new actions">" 
     88        ><__trans phrase="Update Now"></a> 
    7889</mt:setvarblock> 
    7990<mt:var name="position_actions_top" value="1">