molten-trunk/molten5/app/helpers/cases_helper.rb
# Creates a button and link to subscribe or unsubscribe to the
# +current_user+'s account cases.
Creates a button and link to subscribe or unsubscribe to the
+current_user+'s account cases.
Creates a button and link to subscribe or unsubscribe to the + current_user + ' s account cases .
def link_to_subscribe_to_cases
   html = if current_contact.share_cases?(current_contact.company)
            link_to image_tag('buttons/share_cases.gif'),
                    :controller => 'case_watchers',
                    :action => 'account',
                    :id => current_contact.company   
     elsif SfcaseWatcher.find_for_contact_and_account(current_contact)
            link_to_remote image_tag('buttons/unsubscribe.gif'), 
                     {:url => {:controller => 'case_watchers',
                              :action => 'unsubscribe',
                              :account => current_contact.company.id,
                              :from => controller.action_name},
                      :loading => "Element.toggle('sub_indicator');Element.hide('subscribe_link')"
                     },
                     {:id => 'subscribe_link'}
   else
      link_to_remote image_tag('buttons/subscribe.gif'), 
                     {:url => {:controller => 'case_watchers',
                              :action => 'subscribe',
                              :account => current_contact.company.id,
                              :from => controller.action_name},
                      :loading => "Element.toggle('sub_indicator');Element.hide('subscribe_link')"
                     },
                     {:id => 'subscribe_link'}
    end
    html += sub_indicator
    html
  rescue  ActiveRecord::StatementInvalid
    "connection error"
  end
def link_to_subscribe_to_cases html = if current_contact . share_cases? ( current_contact . company ) link_to image_tag ( 'buttons/share_cases.gif' ) , :controller => 'case_watchers' , :action => 'account' , :id => current_contact . company elsif SfcaseWatcher . find_for_contact_and_account ( current_contact ) link_to_remote image_tag ( 'buttons/unsubscribe.gif' ) , { :url => { :controller => 'case_watchers' , :action => 'unsubscribe' , :account => current_contact . company . id , :from => controller . action_name } , :loading => "Element.toggle('sub_indicator');Element.hide('subscribe_link')" } , { :id => 'subscribe_link' } else link_to_remote image_tag ( 'buttons/subscribe.gif' ) , { :url => { :controller => 'case_watchers' , :action => 'subscribe' , :account => current_contact . company . id , :from => controller . action_name } , :loading => "Element.toggle('sub_indicator');Element.hide('subscribe_link')" } , { :id => 'subscribe_link' } end html += sub_indicator html rescue ActiveRecord :: StatementInvalid "connection error" end
Creates a button and link to subscribe or unsubscribe to the
+current_user+'s account cases.
Creates a button and link to subscribe or unsubscribe to the + current_user + ' s account cases .