Changeset 1205

Show
Ignore:
Timestamp:
07/11/08 14:34:03 (6 months ago)
Author:
kovit
Message:

fix 'portal_controller.rb at line 137-190'

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/app/controllers/portal_controller.rb

    r881 r1205  
    135135  end 
    136136 
     137 # journal 
     138 #  
     139  def my_recent_journal 
     140    if @user 
     141       if @used_by_owner 
     142         # show public, protected, & private items 
     143         @journals = JournalEntry.paginate_by_user_id(@owner.id, :order => "created_at DESC", :page => params[:page], :per_page => $ITEMS_PER_PAGE) 
     144        else 
     145          # show public & protected items 
     146          # don't use visibility <= 3 because it won't utilize a proper index. 
     147          @journals = JournalEntry.paginate(:all, 
     148                                          :conditions => ['(visibility = ? OR visibility = ?) AND user_id=?', JournalEntry.public, JournalEntry.protected, @owner.id], 
     149                                          :order => "created_at DESC", :page => params[:page], :per_page => $ITEMS_PER_PAGE) 
     150        end 
     151    else 
     152      # show only public items 
     153      @journals = JournalEntry.paginate(:all, :conditions => ['visibility = ? AND user_id=?', JournalEntry.public, @owner.id], 
     154                                        :order => "created_at DESC", :page => params[:page], :per_page => $ITEMS_PER_PAGE) 
     155    end 
     156      render :layout => false, :partial => "journals/journal_browser", :locals => { 
     157      :journal_entries => @journals, 
     158      :div_id => 'my_recent_journal', 
     159      :latest_url => portal_my_recent_journal_url(:username => @owner.username), 
     160      :prev_url => portal_my_recent_journal_url(:username => @owner.username, :page => @page - 1), 
     161      :next_url => portal_my_recent_journal_url(:username => @owner.username, :page => @page + 1), 
     162    } 
     163  end 
     164 
     165  def my_journal_monitor 
     166 
     167    if @user 
     168      @journals = JournalEntry.paginate(:all, 
     169                                       :conditions => ['(visibility = ? OR visibility = ?) AND (user_id in (?)) OR ((user_id=?) AND (visibility = ?)) OR ((user_id=?) AND (visibility = ?)) ', JournalEntry.public, JournalEntry.protected, get_following, @owner.id, JournalEntry.public, @owner.id, JournalEntry.protected], 
     170                                        :order => "created_at DESC", :page => params[:page], :per_page => $ITEMS_PER_PAGE) 
     171    else 
     172     @journals = JournalEntry.paginate(:conditions => ["visibility = ? AND (user_id in (?)) OR ((user_id=?) AND (visibility = ?))", JournalEntry.public, get_following, @owner.id, JournalEntry.public], 
     173                                        :order => "created_at DESC", :page => params[:page], :per_page => $ITEMS_PER_PAGE) 
     174    end 
     175    render :layout => false, :partial => "journals/journal_browser", :locals => { 
     176      :journal_entries => @journals, 
     177      :div_id => 'my_journal_monitor', 
     178      :latest_url => portal_my_journal_monitor_url(:username => @owner.username), 
     179      :prev_url => portal_my_journal_monitor_url(:username => @owner.username, :page => @page - 1), 
     180      :next_url => portal_my_journal_monitor_url(:username => @owner.username, :page => @page + 1), 
     181    } 
     182  end 
     183 
     184  def get_following 
     185    l = [] 
     186    if (jfriends = JournalFollowing.find_all_by_follower_id(@owner.id)) 
     187      jfriends.each { |f| l << f.owner_id } 
     188    end 
     189    l 
     190  end 
     191 
    137192  private # ---------------------------------------------------------- 
    138193 
  • trunk/app/views/portal/user.html.erb

    r916 r1205  
    217217</div> 
    218218 
     219<div class="main_title"><%= _("Journal") %></div> 
     220 
     221  <div id="Journal" style="display: none;"> 
     222    <div class="box"> 
     223      <div class="title"><%= _("Recent Journal Entries") -%></div> 
     224      <div id="my_recent_journal"> 
     225        <div class="short_item"> 
     226          <span class="more"> 
     227            <%= link_to_remote(_("View") + ' &raquo;', 
     228                               :update => 'my_recent_journal', 
     229                               :url => portal_my_recent_journal_url(:username => @owner.username), 
     230                               :loaded => "Effect.FlashAppear('my_recent_journal');" 
     231                               ) %> 
     232          </span> 
     233        </div> 
     234      </div> 
     235    </div> 
     236 
     237    <div class="box"> 
     238      <div class="title"><%= _("Recent Journal Entries of Others") -%></div> 
     239      <div id="my_journal_monitor"> 
     240        <div class="short_item"> 
     241          <span class="more"> 
     242            <%= link_to_remote(_("View") + ' &raquo;', 
     243                               :update => 'my_journal_monitor', 
     244                               :url => portal_my_journal_monitor_url(:username => @owner.username), 
     245                               :loaded => "Effect.FlashAppear('my_journal_monitor');" 
     246                               ) %> 
     247          </span> 
     248        </div> 
     249      </div> 
     250    </div> 
     251 </div> 
     252 
     253 <div class="box" id="Journal_show"> 
     254    <span class="more"> 
     255      <%= link_to _("Show") + ' &raquo;', '#', 
     256          :onclick => "Effect.FlashAppear('Journal'); Element.hide('Journal_show'); Element.show('Journal_hide'); return false;" 
     257          %> 
     258    </span> 
     259  </div> 
     260 
     261  <div class="box right" id="Journal_hide" style="display: none;"> 
     262    <span class="more"> 
     263      <%= link_to '&laquo; ' + _("Hide"), '#', 
     264          :onclick => "Element.hide('Journal'); Element.hide('Journal_hide'); Element.show('Journal_show'); return false;" 
     265          %> 
     266    </span> 
     267  </div> 
     268 
    219269<div id="sidebar2"> 
    220270  <%= render :partial => "shared/common_sidebars", :locals => {:owner => @owner} %>