diff --git a/app/assets/stylesheets/themes/default/components/_tabs.scss b/app/assets/stylesheets/themes/default/components/_tabs.scss
index e1f5542..17a0660 100644
--- a/app/assets/stylesheets/themes/default/components/_tabs.scss
+++ b/app/assets/stylesheets/themes/default/components/_tabs.scss
@@ -5,7 +5,7 @@
.tabbed {
$tabs-border-width: 1px;
$tabs-border-colour: $light-blue;
- $tabs-padding-horizontal: 16px;
+ $tabs-padding-horizontal: 13px;
$tabs-height: 35px;
ul.tabs {
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index 3fb04c9..c3563e9 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -2,7 +2,7 @@ class IssuesController < ApplicationController
before_filter :get_issue, only: [:show, :edit, :update, :destroy]
def index
- raise AccessError unless cuser and cuser.admin?
+ raise AccessError unless cuser and (cuser.admin? or cuser.moderator?)
sort = case params['sort']
when "title" then "title"
@@ -12,9 +12,13 @@ class IssuesController < ApplicationController
else "created_at DESC"
end
- @open = Issue.with_status(Issue::STATUS_OPEN).all order: sort
- @solved = Issue.with_status(Issue::STATUS_SOLVED).all order: sort
- @rejected = Issue.with_status(Issue::STATUS_REJECTED).all order: sort
+ allowed = Issue::allowed_categories cuser
+ qstring = 'category_id IN (?)'
+ qstring += ' OR category_id IS NULL' if cuser.admin?
+
+ @open = Issue.where(qstring, allowed).with_status(Issue::STATUS_OPEN).all order: sort
+ @solved = Issue.where(qstring, allowed).with_status(Issue::STATUS_SOLVED).all order: sort
+ @rejected = Issue.where(qstring, allowed).with_status(Issue::STATUS_REJECTED).all order: sort
end
def show
@@ -49,7 +53,7 @@ class IssuesController < ApplicationController
end
def update
- raise AccessError unless @issue.can_update? cuser
+ raise AccessError unless @issue.can_update?(cuser, params[:issue])
if @issue.update_attributes(params[:issue])
flash[:notice] = t(:issues_update)
redirect_to(@issue)
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 6550c67..e156a57 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -3,7 +3,11 @@ class UsersController < ApplicationController
respond_to :html, :js
def index
- @users = User.search(params[:search]).paginate(per_page: 40, page: params[:page])
+ if params[:filter] == 'lately'
+ @users = User.search(params[:search]).lately.paginate(per_page: 40, page: params[:page])
+ else
+ @users = User.search(params[:search]).paginate(per_page: 40, page: params[:page])
+ end
end
def show
diff --git a/app/models/concerns/extra.rb b/app/models/concerns/extra.rb
index 97189c3..6b46adb 100644
--- a/app/models/concerns/extra.rb
+++ b/app/models/concerns/extra.rb
@@ -26,7 +26,7 @@ module Extra
end
def bbcode_to_html(text)
- Sanitize.clean(text.to_s).bbcode_to_html.gsub(/\r/, "
").html_safe
+ Sanitize.clean(text.to_s).bbcode_to_html.gsub(/\n|\r\n/, "
").html_safe
end
def move_up(scope, column = "position")
diff --git a/app/models/group.rb b/app/models/group.rb
index 367185d..f7d61ec 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -22,6 +22,7 @@ class Group < ActiveRecord::Base
PREDICTORS = 8
STAFF = 10
GATHER_MODERATORS = 14
+ COMP_MOD_COUNCIL = 16
attr_protected :id, :updated_at, :created_at, :founder_id
validates_length_of :name, :maximum => 20
@@ -86,4 +87,20 @@ class Group < ActiveRecord::Base
end
casters
end
+
+ def self.gathermods
+ gathermods = []
+ (find(GATHER_MODERATORS).groupers).each do |g|
+ gathermods << g unless gathermods.include? g
+ end
+ gathermods
+ end
+
+ def self.compmodcouncil
+ compmodcouncil = []
+ (find(COMP_MOD_COUNCIL).groupers).each do |g|
+ compmodcouncil << g unless compmodcouncil.include? g
+ end
+ compmodcouncil
+ end
end
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 594ddb0..0bf039b 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -24,6 +24,11 @@ class Issue < ActiveRecord::Base
STATUS_SOLVED = 1
STATUS_REJECTED = 2
+ CATEGORY_WEBSITE = 17
+ CATEGORY_NSLPLUGIN = 20
+ CATEGORY_LEAGUE = 22
+ CATEGORY_GATHER = 54
+
attr_accessor :assigned_name
attr_protected :id, :created_at, :updated_at
@@ -96,18 +101,38 @@ class Issue < ActiveRecord::Base
end
def can_show? cuser
- cuser and !cuser.nil? and ((author == cuser) or cuser.admin?)
+ return false unless cuser
+ return true if cuser.admin?
+
+ ((author == cuser) or (Issue::allowed_categories(cuser).include?(self.category_id)))
+
end
def can_create? cuser
true
end
- def can_update? cuser
- cuser and cuser.admin?
+ def can_update?(cuser, params = {})
+ return false unless cuser
+ return true if cuser.admin?
+ return false unless Issue::allowed_categories(cuser).include?(self.category_id)
+ !(params.member?(:category_id) && (self.category_id.to_s != params[:category_id]))
end
def can_destroy? cuser
cuser and cuser.admin?
end
+
+ # STATIC METHODS
+
+ def self.allowed_categories cuser
+ allowed = []
+ allowed << CATEGORY_GATHER if cuser.admin? || cuser.gather_moderator? # gather
+ allowed << CATEGORY_WEBSITE if cuser.admin? # website
+ allowed << CATEGORY_LEAGUE if cuser.admin? # league
+ allowed << CATEGORY_NSLPLUGIN if cuser.admin? # ensl plugin
+ allowed
+ end
+
+
end
diff --git a/app/models/user.rb b/app/models/user.rb
index db83fea..cbc97b9 100755
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -99,6 +99,8 @@ class User < ActiveRecord::Base
:conditions => "bans.id IS NOT NULL"
scope :idle,
:conditions => ["lastvisit < ?", 30.minutes.ago.utc]
+ scope :lately,
+ :conditions => ["lastvisit > ?", 30.days.ago.utc]
before_validation :update_password
@@ -190,11 +192,15 @@ class User < ActiveRecord::Base
end
def admin?
- groups.exists? :id => Group::ADMINS
+ groups.exists? id: Group::ADMINS
end
def ref?
- groups.exists? :id => Group::REFEREES
+ groups.exists? id: Group::REFEREES
+ end
+
+ def staff?
+ groups.exists? id: Group::STAFF
end
def staff?
@@ -202,7 +208,20 @@ class User < ActiveRecord::Base
end
def caster?
- groups.exists? :id => Group::CASTERS
+ groups.exists? id: Group::CASTERS
+ end
+
+ # might seem redundant but allows for later extensions like forum moderators
+ def moderator?
+ groups.exists? id: Group::GATHER_MODERATORS
+ end
+
+ def gather_moderator?
+ groups.exists? id: Group::GATHER_MODERATORS
+ end
+
+ def allowed_to_ban?
+ admin? or moderator?
end
def gather_moderator?
diff --git a/app/views/about/staff.html.erb b/app/views/about/staff.html.erb
index ae75282..02c441a 100644
--- a/app/views/about/staff.html.erb
+++ b/app/views/about/staff.html.erb
@@ -6,7 +6,7 @@
To contact us:
+ | Username | +Task | +Age | +|
---|---|---|---|---|
<%= flag grouper.user.country %> | +<%= namelink grouper.user %> | +<%= h grouper.user.email_s %> | ++ <% if grouper.task %> + <%= h grouper.task %> + <% else %> + <%= h grouper.group.name.singularize %> + <% end %> + | +<%= h grouper.user.age %> | +
+ | Username | +Task | +Age | +|
---|---|---|---|---|
<%= flag grouper.user.country %> | +<%= namelink grouper.user %> | +<%= h grouper.user.email_s %> | ++ <% if grouper.task %> + <%= h grouper.task %> + <% else %> + <%= h grouper.group.name.singularize %> + <% end %> + | +<%= h grouper.user.age %> | +