app/models/members/project_member.rb
# Add users to project teams with passed access option
#
# access can be an integer representing a access code
# or symbol like :master representing role
#
# Ex.
#   add_users_into_projects(
#     project_ids,
#     user_ids,
#     ProjectMember::MASTER
#   )
#
#   add_users_into_projects(
#     project_ids,
#     user_ids,
#     :master
#   )
#
Add users to project teams with passed access option
access can be an integer representing a access code
or symbol like :master representing role

Ex.


Add users to project teams with passed access option access can be an integer representing a access code or symbol like : master representing role Ex .
def add_users_into_projects(project_ids, user_ids, access, current_user = nil)
      access_level = if roles_hash.has_key?(access)
                       roles_hash[access]
                     elsif roles_hash.values.include?(access.to_i)
                       access
                     else
                       raise "Non valid access"
                     end
      users = user_ids.map { |user_id| Member.user_for_id(user_id) }
      ProjectMember.transaction do
        project_ids.each do |project_id|
          project = Project.find(project_id)
          users.each do |user|
            Member.add_user(project.project_members, user, access_level, current_user)
          end
        end
      end
      true
    rescue
      false
    end
def add_users_into_projects ( project_ids , user_ids , access , current_user = nil ) access_level = if roles_hash . has_key? ( access ) roles_hash [ access ] elsif roles_hash . values . include? ( access . to_i ) access else raise "Non valid access" end users = user_ids . map { | user_id | Member . user_for_id ( user_id ) } ProjectMember . transaction do project_ids . each do | project_id | project = Project . find ( project_id ) users . each do | user | Member . add_user ( project . project_members , user , access_level , current_user ) end end end true rescue false end
Add users to project teams with passed access option
access can be an integer representing a access code
or symbol like :master representing role
Add users to project teams with passed access option access can be an integer representing a access code or symbol like : master representing role
project_ids
user_ids
access
current_user