1 class IssuesController < ApplicationController
4 before_action :authorize_web
5 before_action :set_locale
6 before_action :require_user
7 before_action :check_permission
8 before_action :find_issue, :only => [:show, :resolve, :reopen, :ignore]
14 @issue_types.concat %w[Note] if current_user.moderator?
15 @issue_types.concat %w[DiaryEntry DiaryComment User] if current_user.administrator?
17 @users = User.joins(:roles).where(:user_roles => { :role => current_user.roles.map(&:role) }).distinct
18 @issues = Issue.visible_to(current_user)
21 if params[:search_by_user]&.present?
22 @find_user = User.find_by(:display_name => params[:search_by_user])
24 @issues = @issues.where(:reported_user_id => @find_user.id)
26 @issues = @issues.none
27 flash.now[:warning] = t(".user_not_found")
31 @issues = @issues.where(:status => params[:status]) if params[:status]&.present?
33 @issues = @issues.where(:reportable_type => params[:issue_type]) if params[:issue_type]&.present?
35 if params[:last_updated_by]&.present?
36 last_updated_by = params[:last_updated_by].to_s == "nil" ? nil : params[:last_updated_by].to_i
37 @issues = @issues.where(:updated_by => last_updated_by)
42 @read_reports = @issue.read_reports
43 @unread_reports = @issue.unread_reports
44 @comments = @issue.comments
45 @related_issues = @issue.reported_user.issues.where(:assigned_role => current_user.roles.map(&:role)) if @issue.reported_user
46 @new_comment = IssueComment.new(:issue => @issue)
53 redirect_to @issue, :notice => t(".resolved")
61 @issue.updated_by = current_user.id
63 redirect_to @issue, :notice => t(".ignored")
71 @issue.updated_by = current_user.id
73 redirect_to @issue, :notice => t(".reopened")
82 @issue = Issue.find(params[:id])
86 unless current_user.administrator? || current_user.moderator?
87 flash[:error] = t("application.require_moderator_or_admin.not_a_moderator_or_admin")