app/models/membership.rb
# Make a pending membership request.
Make a pending membership request.
Make a pending membership request .
def request(user, group, send_mail = nil)
      if send_mail.nil?
        send_mail = global_prefs.email_notifications? &&
                    group.owner.connection_notifications?
      end
      if user.groups.include?(group) or Membership.exists?(user, group)
        nil
      else
        if group.public? or group.private?
          transaction do
            create(:user => user, :group => group, :status => PENDING)
            if send_mail
              membership = user.memberships.find(:first, :conditions => ['group_id = ?',group])
              Notifier.deliver_membership_request(membership)
            end
          end
          if group.public?
            membership = user.memberships.find(:first, :conditions => ['group_id = ?',group])
            membership.accept
            if send_mail
              Notifier.deliver_membership_public_group(membership)
            end
          end
        end
        true
      end
    end
def request ( user , group , send_mail = nil ) if send_mail . nil? send_mail = global_prefs . email_notifications? && group . owner . connection_notifications? end if user . groups . include? ( group ) or Membership . exists? ( user , group ) nil else if group . public? or group . private? transaction do create ( :user => user , :group => group , :status => PENDING ) if send_mail membership = user . memberships . find ( :first , :conditions => [ 'group_id = ?' , group ] ) Notifier . deliver_membership_request ( membership ) end end if group . public? membership = user . memberships . find ( :first , :conditions => [ 'group_id = ?' , group ] ) membership . accept if send_mail Notifier . deliver_membership_public_group ( membership ) end end end true end end
Make a pending membership request.
Make a pending membership request .
user
<not_specific>
group
<not_specific>
send_mail
<not_specific>