molten-trunk/molten5_withgrid/app/controllers/case_watchers_controller.rb
def update_subscriptions_from_account  
    contacts = params[:contacts]
    contacts_subscribing = params[:subscribers].is_a?(Hash) ? params[:subscribers].keys : []
    contacts_unsubscribing = params[:contacts] - contacts_subscribing
    
    # subscribe these contacts
    contacts_subscribing.each do |c_id|
      begin
        Case_Watcher.create_subscription!(Contact.find(c_id), 
                                        :account => Sfaccount.find(params[:id]).synced_record )
      rescue  ActiveRecord::RecordNotFound
        logger.info("Couldn't create subscription for contact w/id: #{c_id}. Contact doesn't exist.")
      end
    end

    # unsubscribe these contacts
    contacts_unsubscribing.each do |c_id|
      begin
        Case_Watcher.remove_subscription!(Contact.find(c_id), 
                                        :account => Sfaccount.find(params[:id]).synced_record )
      rescue  ActiveRecord::RecordNotFound
        logger.info("Couldn't remove subscription for contact w/id: #{c_id}. Contact doesn't exist.")
      end
    end
    
    redirect_to :action => 'account', :id => @account, :notice => "Account subscriptions updated."
  end
# Updates subscriptions for an account, subscribing and unsubscribing contacts.
Updates subscriptions for an account, subscribing and unsubscribing contacts.
Updates subscriptions for an account subscribing and unsubscribing contacts .
def update_subscriptions_from_account  
    contacts = params[:contacts]
    contacts_subscribing = params[:subscribers].is_a?(Hash) ? params[:subscribers].keys : []
    contacts_unsubscribing = params[:contacts] - contacts_subscribing
    contacts_subscribing.each do |c_id|
      begin
        Case_Watcher.create_subscription!(Contact.find(c_id), 
                                        :account => Sfaccount.find(params[:id]).synced_record )
      rescue  ActiveRecord::RecordNotFound
        logger.info("Couldn't create subscription for contact w/id: #{c_id}. Contact doesn't exist.")
      end
    end
    contacts_unsubscribing.each do |c_id|
      begin
        Case_Watcher.remove_subscription!(Contact.find(c_id), 
                                        :account => Sfaccount.find(params[:id]).synced_record )
      rescue  ActiveRecord::RecordNotFound
        logger.info("Couldn't remove subscription for contact w/id: #{c_id}. Contact doesn't exist.")
      end
    end
    redirect_to :action => 'account', :id => @account, :notice => "Account subscriptions updated."
  end
def update_subscriptions_from_account contacts = params [ :contacts ] contacts_subscribing = params [ :subscribers ] . is_a? ( Hash ) ? params [ :subscribers ] . keys : [ ] contacts_unsubscribing = params [ :contacts ] - contacts_subscribing contacts_subscribing . each do | c_id | begin Case_Watcher . create_subscription! ( Contact . find ( c_id ) , :account => Sfaccount . find ( params [ :id ] ) . synced_record ) rescue ActiveRecord :: RecordNotFound logger . info ( "Couldn't create subscription for contact w/id: #{c_id}. Contact doesn't exist." ) end end contacts_unsubscribing . each do | c_id | begin Case_Watcher . remove_subscription! ( Contact . find ( c_id ) , :account => Sfaccount . find ( params [ :id ] ) . synced_record ) rescue ActiveRecord :: RecordNotFound logger . info ( "Couldn't remove subscription for contact w/id: #{c_id}. Contact doesn't exist." ) end end redirect_to :action => 'account' , :id => @account , :notice => "Account subscriptions updated." end
Updates subscriptions for an account, subscribing and unsubscribing contacts.
Updates subscriptions for an account subscribing and unsubscribing contacts .
# subscribe these contacts # unsubscribe these contacts