  def team_organize
    Log.add_info(request, params.inspect)

    team_id = params[:team_id]
    unless team_id.blank?
      begin
        @team = Team.find(team_id)
      rescue
        @team = nil
      ensure
        if @team.nil?
          flash[:notice] = t('msg.already_deleted', :name => Team.model_name.human)
          return
        end
      end

      users = @team.get_users_a
    end 

    team_members = params[:team_members]

    created = false
    modified = false

    if team_members.nil? or team_members.empty?

      unless team_id.blank?
        # @team must not be nil.
        @team.save if modified = @team.clear_users
      end

    else

      if team_members != users

        if team_id.blank?

          item = Item.find(params[:id])

          created = true
          @team = Team.new
          @team.name = item.title
          @team.item_id = params[:id]
          @team.status = Team::STATUS_STANDBY

        else

          @team.clear_users
        end

        @team.add_users team_members
        @team.save
        @team.remove_application team_members

        modified = true 
      end
     end

    if created
      @team.create_team_folder
    end

    @item = @team.item

    if modified
      flash[:notice] = t('msg.register_success')
    end
    render(:partial => 'ajax_team_info', :layout => false)

  rescue => evar
    Log.add_error(request, evar)
    render(:partial => 'ajax_team_info', :layout => false)
  end
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.