<commit_before># This file is part of Mconf-Web, a web application that provides access
# to the Mconf webconferencing system. Copyright (C) 2010-2015 Mconf.
#
# This file is licensed under the Affero General Public License version
# 3 or later. See the LICENSE file.

module SpacesHelper

  # Stores the current tab in the menu for spaces
  def spaces_menu_at(tab)
    @spaces_menu_tab = tab
  end

  # Selects the tab if it is the current tab in the menu for spaces
  def spaces_menu_select_if(tab, options={})
    old_class = options[:class] || ''
    @spaces_menu_tab == tab ?
      options.update({ :class => "#{old_class} active" }) :
      options
  end

  # Returns whether the selected menu is `tab`
  def spaces_menu_is(tab)
    @spaces_menu_tab == tab
  end

  # Returns a link to join the space depending on the status of the
  # current user. Possible cases:
  # * If there's no current user, returns a button to register.
  # * If the user has already requested to join the space, shows a disabled button
  #   informing him of that.
  # * If the user was already invited to join the space, shows a button that
  #   goes to the page to accept/decline the invitation.
  # * If the user is already a member of the space, returns nil.
  def space_join_button(space, options={})
    options[:class] = "#{options[:class]} btn btn-large btn-block"

    # no user logged, renders a register button
    if !user_signed_in?
      options[:class] = "#{options[:class]} btn-success"
      if Site.current.registration_enabled?
        link_to t('_other.register'), register_path, options
      else
        link_to t('_other.login'), login_path, options
      end

    # the user already requested to join the space
    elsif space.pending_join_request_for?(current_user)
      request = space.pending_join_request_for(current_user)

      options[:class] = "#{options[:class]} btn-danger btn-sm tooltipped"
      options[:data] = { confirm: t('spaces.space_join_button.cancel_confirm') }
      options[:method] = :post
      options[:title] = t("spaces.space_join_button.cancel_tooltip", message: request.comment)
      button = link_to t("spaces.space_join_button.cancel"), decline_space_join_request_path(space, request), options

      button

    # the user was already invited to join the space
    elsif space.pending_invitation_for?(current_user)
      invitation = space.pending_invitation_for(current_user)
      options[:class] = "#{options[:class]} btn-success"
      icon = content_tag :i, "", :class => "icon-exclamation-sign"<commit_msg>Show always the sign in btn when anonymous users access spaces/show<commit_after># This file is part of Mconf-Web, a web application that provides access
# to the Mconf webconferencing system. Copyright (C) 2010-2015 Mconf.
#
# This file is licensed under the Affero General Public License version
# 3 or later. See the LICENSE file.

module SpacesHelper

  # Stores the current tab in the menu for spaces
  def spaces_menu_at(tab)
    @spaces_menu_tab = tab
  end

  # Selects the tab if it is the current tab in the menu for spaces
  def spaces_menu_select_if(tab, options={})
    old_class = options[:class] || ''
    @spaces_menu_tab == tab ?
      options.update({ :class => "#{old_class} active" }) :
      options
  end

  # Returns whether the selected menu is `tab`
  def spaces_menu_is(tab)
    @spaces_menu_tab == tab
  end

  # Returns a link to join the space depending on the status of the
  # current user. Possible cases:
  # * If there's no current user, returns a button to register.
  # * If the user has already requested to join the space, shows a disabled button
  #   informing him of that.
  # * If the user was already invited to join the space, shows a button that
  #   goes to the page to accept/decline the invitation.
  # * If the user is already a member of the space, returns nil.
  def space_join_button(space, options={})
    options[:class] = "#{options[:class]} btn btn-large btn-block"

    # no user logged, renders a register button
    if !user_signed_in?
      options[:class] = "#{options[:class]} btn-success"
      link_to t('_other.login'), login_path, options

    # the user already requested to join the space
    elsif space.pending_join_request_for?(current_user)
      request = space.pending_join_request_for(current_user)

      options[:class] = "#{options[:class]} btn-danger btn-sm tooltipped"
      options[:data] = { confirm: t('spaces.space_join_button.cancel_confirm') }
      options[:method] = :post
      options[:title] = t("spaces.space_join_button.cancel_tooltip", message: request.comment)
      button = link_to t("spaces.space_join_button.cancel"), decline_space_join_request_path(space, request), options

      button

    # the user was already invited to join the space
    elsif space.pending_invitation_for?(current_user)
      invitation = space.pending_invitation_for(current_user)
      options[:class] = "#{options[:class]} btn-success"
      icon = content_tag :i, "", :class => "icon-exclamation-sign"
{'fraction_non_alphanumeric': 0.0942834458118301, 'fraction_numerical': 0.003572846367606193, 'mean_word_length': 3.713751169317119, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6931716', 'n_tokens_mistral': 1508, 'n_tokens_neox': 1454, 'n_words': 521}