From 19861ba8c6564e5b4e7f8876025896761ade4875 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 14 Apr 2016 12:30:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B6=85=E7=BA=A7=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E7=9A=84=E7=BB=84=E7=BB=87=E5=8F=AF=E5=85=B3=E8=81=94=E6=89=80?= =?UTF-8?q?=E6=9C=89=E5=85=AC=E5=BC=80=E8=AF=BE=E7=A8=8B=E5=92=8C=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 16 +++++++++++++--- .../organizations/_join_course_menu.html.erb | 2 +- .../organizations/_join_project_menu.html.erb | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 4fa7659c9..457b3bfa1 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -352,8 +352,13 @@ class OrganizationsController < ApplicationController if !params[:name].nil? condition = "%#{params[:name].strip}%".gsub(" ","") end - sql = "select courses.* from courses inner join members on courses.id = members.course_id where members.user_id = #{User.current.id} and courses.is_public = 1 and courses.name like '#{condition}'"+ - "and courses.id not in (select distinct org_courses.course_id from org_courses where org_courses.organization_id = #{@organization.id}) and courses.is_delete=0" + if User.current.admin? + sql = "select courses.* from courses where courses.is_public = 1 and courses.name like '#{condition}'"+ + "and courses.id not in (select distinct org_courses.course_id from org_courses where org_courses.organization_id = #{@organization.id}) and courses.is_delete=0" + else + sql = "select courses.* from courses inner join members on courses.id = members.course_id where members.user_id = #{User.current.id} and courses.is_public = 1 and courses.name like '#{condition}'"+ + "and courses.id not in (select distinct org_courses.course_id from org_courses where org_courses.organization_id = #{@organization.id}) and courses.is_delete=0" + end #user_courses = Course.find_by_sql(sql) @courses = Course.find_by_sql(sql) # @added_course_ids = @organization.courses.map(&:id) @@ -396,8 +401,13 @@ class OrganizationsController < ApplicationController if !params[:name].nil? condition = "%#{params[:name].strip}%".gsub(" ","") end - sql = "select projects.* from projects inner join members on projects.id = members.project_id where members.user_id = #{User.current.id} and projects.status != 9 and projects.is_public = 1 and projects.name like '#{condition}'" + + if User.current.admin? + sql = "select projects.* from projects where projects.status != 9 and projects.is_public = 1 and projects.name like '#{condition}'" + " and projects.id not in (select org_projects.project_id from org_projects where organization_id = #{@organization.id}) and status=1" + else + sql = "select projects.* from projects inner join members on projects.id = members.project_id where members.user_id = #{User.current.id} and projects.status != 9 and projects.is_public = 1 and projects.name like '#{condition}'" + + " and projects.id not in (select org_projects.project_id from org_projects where organization_id = #{@organization.id}) and status=1" + end #user_projects = Course.find_by_sql(sql) @projects = Course.find_by_sql(sql) # @added_course_ids = @organization.projects.map(&:id) diff --git a/app/views/organizations/_join_course_menu.html.erb b/app/views/organizations/_join_course_menu.html.erb index c480e851c..b21e52d2f 100644 --- a/app/views/organizations/_join_course_menu.html.erb +++ b/app/views/organizations/_join_course_menu.html.erb @@ -29,7 +29,7 @@
<%=form_tag url_for(:controller => 'organizations', :action => 'join_courses', :organization_id => organization_id),:method => 'post', :id => 'join_courses_form', :remote => true,:class=>"resourcesSearchBox" do %> -
+
diff --git a/app/views/organizations/_join_project_menu.html.erb b/app/views/organizations/_join_project_menu.html.erb index 6040408bb..c9bd48610 100644 --- a/app/views/organizations/_join_project_menu.html.erb +++ b/app/views/organizations/_join_project_menu.html.erb @@ -29,7 +29,7 @@
<%=form_tag url_for(:controller => 'organizations', :action => 'join_projects', :organization_id => organization_id),:method => 'post', :id => 'join_projects_form', :remote => true,:class=>"resourcesSearchBox" do %> -
+