 
       modal = new KDModalView modalOptions
 
-  cancelMembershipPolicyChange:(policy, membershipPolicyView, modal)->
-    membershipPolicyView.enableInvitations.setValue policy.invitationsEnabled
-
-  updateMembershipPolicy:(group, policy, formData, membershipPolicyView, callback)->
-    group.modifyMembershipPolicy formData, (err)->
-      unless err
-        policy.emit 'MembershipPolicyChangeSaved'
-        new KDNotificationView {title:"Membership policy has been updated."}
-      KD.showError err
 
   editPermissions:(group)->
     group.getData().fetchPermissions (err, permissionSet)->

      if pageInfo.topLevel
      then router.handleRoute "#{pageInfo.path}"
      else router.handleRoute "#{pageInfo.path}", {entryPoint}

    @groups = {}
    @currentGroupData = new GroupData

  getCurrentGroup:->
    throw 'FIXME: array should never be passed'  if Array.isArray @currentGroupData.data
    return @currentGroupData.data

  openGroupChannel:(group, callback=->)->
    @groupChannel = KD.remote.subscribe "group.#{group.slug}",
      serviceType : 'group'
      group       : group.slug
      isExclusive : yes

    @forwardEvent @groupChannel, "MemberJoinedGroup"
    @forwardEvent @groupChannel, "FollowHappened"

    @groupChannel.once 'setSecretNames', callback

  changeGroup:(groupName='', callback=->)->

    groupName or= 'koding' # KD.defaultSlug
    return callback()  if @currentGroupName is groupName

    oldGroupName        = @currentGroupName
    @currentGroupName   = groupName

    unless groupName is oldGroupName
      KD.remote.cacheable groupName, (err, models)=>
        if err then callback err
        else if models?
          [group] = models
          if group.bongo_.constructorName isnt 'JGroup'
            @isReady = yes
          else
            @setGroup groupName
            @currentGroupData.setGroup group
            @isReady = yes
            callback null, groupName, group
            @emit 'GroupChanged', groupName, group
            @openGroupChannel group, => @emit 'GroupChannelReady'

  getUserArea:->
    @userArea ? group:
      if KD.config.entryPoint?.type is 'group'
      then KD.config.entryPoint.slug
      else (KD.getSingleton 'groupsController').currentGroupName

  setUserArea:(userArea)->
    @userArea = userArea

  getGroupSlug:-> @currentGroupName

  setGroup:(groupName)->
    @currentGroupName = groupName
    @setUserArea {
      group: groupName, user: KD.whoami().profile.nickname
    }

  onboardingText =
    everything : """

              modal.destroy()
              callback null

  openPrivateGroup:(group)->
    group.canOpenGroup (err, hasPermission)=>
      if err
