11 Commits

18 changed files with 209 additions and 90 deletions

View File

@@ -69,7 +69,7 @@ class BlogpostsController < ApplicationController
end end
def auth def auth
unless mod? unless mod? && current_user.confirmed?
flash[:alert] = "You are not allowed to edit posts!" flash[:alert] = "You are not allowed to edit posts!"
redirect_to @post ? @post : blogposts_path redirect_to @post ? @post : blogposts_path
end end

View File

@@ -17,7 +17,7 @@ class ForumgroupsController < ApplicationController
end end
def update def update
if admin? if admin? && current_user.confirmed?
@group = Forumgroup.find(params[:id]) @group = Forumgroup.find(params[:id])
if @group.update_attributes(group_params) if @group.update_attributes(group_params)
flash[:notice] = "Forum group updated" flash[:notice] = "Forum group updated"
@@ -41,7 +41,7 @@ class ForumgroupsController < ApplicationController
end end
def create def create
if admin? if admin? && current_user.confirmed?
@group = Forumgroup.new(group_params) @group = Forumgroup.new(group_params)
if @group.save if @group.save
flash[:notice] = "Forum group created." flash[:notice] = "Forum group created."
@@ -57,7 +57,7 @@ class ForumgroupsController < ApplicationController
end end
def destroy def destroy
if admin? if admin? && current_user.confirmed?
@group = Forumgroup.find(params[:id]) @group = Forumgroup.find(params[:id])
if @group.destroy if @group.destroy
flash[:notice] = "forum group deleted." flash[:notice] = "forum group deleted."

View File

@@ -34,7 +34,7 @@ class ForumsController < ApplicationController
end end
def update def update
if admin? if admin? && current_user.confirmed?
if @forum.update_attributes(forum_params) if @forum.update_attributes(forum_params)
flash[:notice] = "Forum updated" flash[:notice] = "Forum updated"
redirect_to @forum redirect_to @forum
@@ -48,7 +48,7 @@ class ForumsController < ApplicationController
end end
def create def create
if admin? if admin? && current_user.confirmed?
@forum = Forum.new(forum_params([:forumgroup_id])) @forum = Forum.new(forum_params([:forumgroup_id]))
if @forum.save if @forum.save
flash[:notice] = "Forum created." flash[:notice] = "Forum created."
@@ -64,7 +64,7 @@ class ForumsController < ApplicationController
end end
def destroy def destroy
if admin? if admin? && current_user.confirmed?
if @forum.destroy if @forum.destroy
flash[:notice] = "Forum deleted." flash[:notice] = "Forum deleted."
else else

View File

@@ -22,9 +22,9 @@ class InfoController < ApplicationController
def create def create
@info = Info.new(info_params) @info = Info.new(info_params)
if @info.save if @info.save
redirect_to @info, notice: 'Info has been created.' redirect_to @info, notice: 'The info page has been created!'
else else
flash[:alert] = "Error creating info" flash[:alert] = "An error occured while creating the info page."
render action: "new" render action: "new"
end end
end end
@@ -32,18 +32,18 @@ class InfoController < ApplicationController
def update def update
@info.attributes = info_params() @info.attributes = info_params()
if @info.save if @info.save
redirect_to @info, notice: 'Info has been updated.' redirect_to @info, notice: 'The info page has been updated!'
else else
flash[:alert] = "There was a problem while updating the info" flash[:alert] = "An error occured while updating the info page."
render action: "edit" render action: "edit"
end end
end end
def destroy def destroy
if @info.destroy if @info.destroy
flash[:notice] = "Info deleted!" flash[:notice] = "The info page has been deleted!"
else else
flash[:alert] = "There was a problem while deleting this info" flash[:alert] = "An error occured while deleting the info page."
end end
redirect_to info_index_path redirect_to info_index_path
end end
@@ -62,9 +62,9 @@ class InfoController < ApplicationController
end end
def auth def auth
unless mod? unless mod? && current_user.confirmed?
flash[:alert] = "You are not allowed to edit info!" flash[:alert] = "You are not allowed to edit info pages!"
redirect_to @info ? @info : info_index_path redirect_to @info ? @info : info_index_path
end end
end end
end end

View File

@@ -19,7 +19,11 @@ class UsersController < ApplicationController
begin begin
@ban_json = JSON.parse(File.read("/etc/minecraft/redstoner/banned-players.json")).detect {|u| u["uuid"].tr("-", "") == @user.uuid} @ban_json = JSON.parse(File.read("/etc/minecraft/redstoner/banned-players.json")).detect {|u| u["uuid"].tr("-", "") == @user.uuid}
rescue rescue
flash.now[:alert] = "An error occured while checking if this user is banned from the server!" if @user.is?(current_user)
flash.now[:alert] = "An error occured while checking if you are banned from the server!"
else
flash.now[:alert] = "An error occured while checking if this user is banned from the server!"
end
@ban_json = nil @ban_json = nil
end end
end end
@@ -131,7 +135,7 @@ class UsersController < ApplicationController
end end
def resend_mail def resend_mail
if (@user.is?(current_user) || mod?) && !@user.confirmed? if (@user.is?(current_user) || (mod? && current_user.confirmed?)) && !@user.confirmed?
RedstonerMailer.register_mail(@user, false).deliver_now RedstonerMailer.register_mail(@user, false).deliver_now
flash[:notice] = "Check your inbox for the confirmation mail." flash[:notice] = "Check your inbox for the confirmation mail."
else else
@@ -141,7 +145,7 @@ class UsersController < ApplicationController
end end
def update def update
if (mod? && current_user.role >= @user.role ) || (@user.is?(current_user) && confirmed?) if (mod? && current_user.role >= @user.role && current_user.confirmed?) || (@user.is?(current_user) && confirmed?)
if mod? if mod?
userdata = user_params([:name, :skype, :youtube, :twitter, :about, :role, :badge, :confirmed, :header_scroll, :utc_time, :dark]) userdata = user_params([:name, :skype, :youtube, :twitter, :about, :role, :badge, :confirmed, :header_scroll, :utc_time, :dark])
else else
@@ -184,7 +188,7 @@ class UsersController < ApplicationController
end end
def ban def ban
if mod? && current_user.role >= @user.role if mod? && current_user.role >= @user.role && current_user.confirmed?
@user.role = Role.get :banned @user.role = Role.get :banned
flash[:notice] = "'#{@user.name}' has been banned!" flash[:notice] = "'#{@user.name}' has been banned!"
else else
@@ -194,7 +198,7 @@ class UsersController < ApplicationController
end end
def unban def unban
if mod? && current_user.role >= @user.role if mod? && current_user.role >= @user.role && current_user.confirmed?
@user.role = Role.get :normal @user.role = Role.get :normal
flash[:notice] = "\"#{@user.name}\" has been unbanned!" flash[:notice] = "\"#{@user.name}\" has been unbanned!"
else else
@@ -204,7 +208,7 @@ class UsersController < ApplicationController
end end
def destroy def destroy
if superadmin? if superadmin? && current_user.confirmed?
if @user.destroy if @user.destroy
flash[:notice] = "User deleted forever." flash[:notice] = "User deleted forever."
redirect_to users_url redirect_to users_url
@@ -219,28 +223,28 @@ class UsersController < ApplicationController
end end
def edit_notifications def edit_notifications
unless @user.is?(current_user) || admin? && current_user.role > @user.role || superadmin? unless @user.is?(current_user) || (admin? && current_user.role > @user.role) || superadmin?
flash[:alert] = "You are not allowed to edit this user's notification settings!" flash[:alert] = "You are not allowed to edit this user's notification settings!"
redirect_to @user redirect_to @user
end end
end end
def edit_login def edit_login
unless @user.is?(current_user) || admin? && current_user.role > @user.role || superadmin? unless @user.is?(current_user) || (admin? && current_user.role > @user.role) || superadmin?
flash[:alert] = "You are not allowed to edit this user's login details!" flash[:alert] = "You are not allowed to edit this user's login details!"
redirect_to @user redirect_to @user
end end
end end
def edit_website_settings def edit_website_settings
unless @user.is?(current_user) || admin? && current_user.role > @user.role || superadmin? unless @user.is?(current_user) || (admin? && current_user.role > @user.role) || superadmin?
flash[:alert] = "You are not allowed to edit this user's website settings!" flash[:alert] = "You are not allowed to edit this user's website settings!"
redirect_to @user redirect_to @user
end end
end end
def update_login def update_login
if @user.is?(current_user) || admin? && current_user.role > @user.role || superadmin? if @user.is?(current_user) || (admin? && current_user.role > @user.role && current_user.confirmed?) || (superadmin? && current_user.confirmed?)
authenticated = !@user.is?(current_user) || @user.authenticate(params[:current_password]) authenticated = !@user.is?(current_user) || @user.authenticate(params[:current_password])
if params[:user][:password].present? if params[:user][:password].present?
@user.password = params[:user][:password] @user.password = params[:user][:password]

View File

@@ -1,10 +1,20 @@
<% title "Edit News: #{@post.title}" %> <% title "Edit News: #{@post.title}" %>
<%
def can_edit?
mod? && current_user.confirmed?
end
%>
<h1>Edit post</h1> <h1>Edit post</h1>
<%= form_for @post do |f|%> <%= form_for @post do |f|%>
<%= f.text_field :title %> <%= f.text_field :title, disabled: !can_edit? %>
<%= render partial: "md_editor", locals: {name: "blogpost[content]", content: @post.content} %> <%= render partial: "md_editor", locals: {name: "blogpost[content]", content: @post.content, options: {disabled: !can_edit?}} %>
<p><%= f.submit "Update Post", class: "btn blue left" %></p> <p><%= f.submit "Update Post", class: "btn blue left", disabled: !can_edit? %></p>
<% end %>
<p><%= button_to "Delete post", @post, method: "delete", data: {confirm: "Delete post & comments forever?"}, class: "btn red right", disabled: !can_edit? %></p>
<div class="clear"></div>
<% if !current_user.confirmed? %>
<span class='red-alert'>You must confirm your email before you can edit blog posts.</span>
<% end %> <% end %>
<p><%= button_to "Delete post", @post, method: "delete", data: {confirm: "Delete post & comments forever?"}, class: "btn red right" %></p>
<div class="clear"></div>

View File

@@ -1,9 +1,19 @@
<% title "New Blog Post" %> <% title "New Blog Post" %>
<%
def can_create?
admin? && current_user.confirmed?
end
%>
<h1>New Post</h1> <h1>New Post</h1>
<%= form_for @post do |f|%> <%= form_for @post do |f|%>
<%= f.text_field :title, placeholder: "Title" %> <%= f.text_field :title, placeholder: "Title", disabled: !can_create? %>
<%= render partial: "md_editor", locals: {name: "blogpost[content]", content: @post.content} %> <%= render partial: "md_editor", locals: {name: "blogpost[content]", content: @post.content, options: {disabled: !can_create?}} %>
<p><%= f.submit "Create Post", class: "btn blue left" %></p> <p><%= f.submit "Create Post", class: "btn blue left", disabled: !can_create? %></p>
<div class="clear"></div> <div class="clear"></div>
<% if !current_user.confirmed? %>
<span class='red-alert'>You must confirm your email before you can create new blog posts.</span>
<% end %>
<% end %> <% end %>

View File

@@ -1,5 +1,11 @@
<% title "Manage Forums" %> <% title "Manage Forums" %>
<%
def can_edit?
admin? && current_user.confirmed?
end
%>
<h1>Manage Forums</h1> <h1>Manage Forums</h1>
<div class="item-group"> <div class="item-group">
<div class="header"> <div class="header">
@@ -19,22 +25,26 @@
<table> <table>
<tr> <tr>
<td><%= f.label :name %></td> <td><%= f.label :name %></td>
<td><%= f.text_field :name, placeholder: "Name" %></td> <td><%= f.text_field :name, placeholder: "Name", disabled: !can_edit? %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :position %></td> <td><%= f.label :position %></td>
<td><%= f.number_field :position, placeholder: "Position" %></td> <td><%= f.number_field :position, placeholder: "Position", disabled: !can_edit? %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :role_read_id, "Min. read role" %></td> <td><%= f.label :role_read_id, "Min. read role" %></td>
<td><%= f.select :role_read_id, role_selection, include_blank: "None" %></td> <td><%= f.select :role_read_id, role_selection, { include_blank: "None" }, { disabled: !can_edit? } %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :role_write_id, "Min. write role" %></td> <td><%= f.label :role_write_id, "Min. write role" %></td>
<td><%= f.select :role_write_id, role_selection, include_blank: false %></td> <td><%= f.select :role_write_id, role_selection, { include_blank: false }, { disabled: !can_edit? } %></td>
</tr> </tr>
</table> </table>
<p><%= f.submit "Update group", class: "btn blue left" %></p> <p><%= f.submit "Update group", class: "btn blue left", disabled: !can_edit? %></p>
<% end %>
<p><%= button_to "Delete group", @group, :method => "delete", data: {confirm: "Delete group?\nForums + Threads will not be accessible!"}, class: "btn red right", disabled: !can_edit? %></p>
<div class="clear"></div>
<% if !current_user.confirmed? %>
<span class='red-alert'>You must confirm your email before you can edit forum groups.</span>
<% end %> <% end %>
<p><%= button_to "Delete group", @group, :method => "delete", data: {confirm: "Delete group?\nForums + Threads will not be accessible!"}, class: "btn red right" %></p>
<div class="clear"></div>

View File

@@ -1,26 +1,36 @@
<% title "New Forum: #{@group.name}" %> <% title "New Forum: #{@group.name}" %>
<%
def can_create?
admin? && current_user.confirmed?
end
%>
<h1>New forum group</h1> <h1>New forum group</h1>
<% role_selection = Role.all_from_to(:normal, :admin).collect{|p|[p.name, p.id]} %> <% role_selection = Role.all_from_to(:normal, :admin).collect{|p|[p.name, p.id]} %>
<%= form_for @group do |f|%> <%= form_for @group do |f|%>
<table> <table>
<tr> <tr>
<td><%= f.label :name %></td> <td><%= f.label :name %></td>
<td><%= f.text_field :name, placeholder: "Name" %></td> <td><%= f.text_field :name, placeholder: "Name", disabled: !can_create? %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :position %></td> <td><%= f.label :position %></td>
<td><%= f.number_field :position, placeholder: "Position" %></td> <td><%= f.number_field :position, placeholder: "Position", disabled: !can_create? %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :role_read_id, "Min. read role" %></td> <td><%= f.label :role_read_id, "Min. read role" %></td>
<td><%= f.select :role_read_id, role_selection, include_blank: "None" %></td> <td><%= f.select :role_read_id, role_selection, { include_blank: "None" }, { disabled: !can_create? } %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :role_write_id, "Min. write role" %></td> <td><%= f.label :role_write_id, "Min. write role" %></td>
<td><%= f.select :role_write_id, role_selection, include_blank: false %></td> <td><%= f.select :role_write_id, role_selection, { include_blank: false }, { disabled: !can_create? } %></td>
</tr> </tr>
</table> </table>
<p><%= f.submit "Create group", class: "btn blue left" %></p> <p><%= f.submit "Create group", class: "btn blue left", disabled: !can_create? %></p>
<div class="clear"></div> <div class="clear"></div>
<% end %>
<% if !current_user.confirmed? %>
<span class='red-alert'>You must confirm your email before you can create new forum groups.</span>
<% end %>
<% end %>

View File

@@ -1,5 +1,11 @@
<% title "Edit Forum: #{@forum.name}" %> <% title "Edit Forum: #{@forum.name}" %>
<%
def can_edit?
admin? && current_user.confirmed?
end
%>
<%= link_to "(Edit) #{@forum.group.name}", edit_forumgroup_path(@forum.group) %> → <%= @forum.name %> <%= link_to "(Edit) #{@forum.group.name}", edit_forumgroup_path(@forum.group) %> → <%= @forum.name %>
<h1>Edit Forum</h1> <h1>Edit Forum</h1>
<% role_selection = Role.all_from_to(:normal, :admin).collect{|p|[p.name, p.id]} %> <% role_selection = Role.all_from_to(:normal, :admin).collect{|p|[p.name, p.id]} %>
@@ -7,26 +13,30 @@
<table> <table>
<tr> <tr>
<td><%= f.label :name %></td> <td><%= f.label :name %></td>
<td><%= f.text_field :name, placeholder: "Name" %></td> <td><%= f.text_field :name, placeholder: "Name", disabled: !can_edit? %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :position %></td> <td><%= f.label :position %></td>
<td><%= f.number_field :position, placeholder: "Position" %></td> <td><%= f.number_field :position, placeholder: "Position", disabled: !can_edit? %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :role_read_id, "Min. read role" %></td> <td><%= f.label :role_read_id, "Min. read role" %></td>
<td><%= f.select :role_read_id, role_selection, include_blank: "None" %></td> <td><%= f.select :role_read_id, role_selection, { include_blank: "None" }, { disabled: !can_edit? } %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :role_write_id, "Min. write role" %></td> <td><%= f.label :role_write_id, "Min. write role" %></td>
<td><%= f.select :role_write_id, role_selection, include_blank: false %></td> <td><%= f.select :role_write_id, role_selection, { include_blank: false }, { disabled: !can_edit? } %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :necro_length, "Necropost warning delay (in days)" %></td> <td><%= f.label :necro_length, "Necropost warning delay (in days)" %></td>
<td><%= f.number_field :necro_length, placeholder: "Warning Delay (leave blank for no warning)" %></td> <td><%= f.number_field :necro_length, placeholder: "Warning Delay (leave blank for no warning)", disabled: !can_edit? %></td>
</tr> </tr>
</table> </table>
<p><%= f.submit "Update forum", class: "btn blue left" %></p> <p><%= f.submit "Update forum", class: "btn blue left", disabled: !can_edit? %></p>
<% end %> <% end %>
<p><%= button_to "Delete forum", @forum, method: "delete", data: {confirm: "Delete forum forever?\nThreads won't be accessible!"}, class: "btn red right" %></p> <p><%= button_to "Delete forum", @forum, method: "delete", data: {confirm: "Delete forum forever?\nThreads won't be accessible!"}, class: "btn red right", disabled: !can_edit? %></p>
<div class="clear"></div> <div class="clear"></div>
<% if !current_user.confirmed? %>
<span class='red-alert'>You must confirm your email before you can edit forums.</span>
<% end %>

View File

@@ -56,6 +56,4 @@
<% if admin? %> <% if admin? %>
<%= link_to "New group", new_forumgroup_path, class: "btn blue" %> <%= link_to "New group", new_forumgroup_path, class: "btn blue" %>
<% elsif mod? %>
<%= link_to "New group", "#", class: "btn blue", disabled: true %>
<% end %> <% end %>

View File

@@ -1,5 +1,11 @@
<% title "New Forum: #{@forum.group.name}" %> <% title "New Forum: #{@forum.group.name}" %>
<%
def can_create?
admin? && current_user.confirmed?
end
%>
<%= link_to @forum.group, forumgroup_path(@forum.group) %> → New forum <%= link_to @forum.group, forumgroup_path(@forum.group) %> → New forum
<h1>New Forum</h1> <h1>New Forum</h1>
<% role_selection = Role.all_from_to(:normal, :admin).collect{|p|[p.name, p.id]} %> <% role_selection = Role.all_from_to(:normal, :admin).collect{|p|[p.name, p.id]} %>
@@ -7,26 +13,30 @@
<table> <table>
<tr> <tr>
<td><%= f.label :name %></td> <td><%= f.label :name %></td>
<td><%= f.text_field :name, placeholder: "Name" %></td> <td><%= f.text_field :name, placeholder: "Name", disabled: !can_create? %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :position %></td> <td><%= f.label :position %></td>
<td><%= f.number_field :position, placeholder: "Position" %></td> <td><%= f.number_field :position, placeholder: "Position", disabled: !can_create? %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :role_read_id, "Min. read role" %></td> <td><%= f.label :role_read_id, "Min. read role" %></td>
<td><%= f.select :role_read_id, role_selection, include_blank: "None" %></td> <td><%= f.select :role_read_id, role_selection, { include_blank: "None"}, { disabled: !can_create? } %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :role_write_id, "Min. write role" %></td> <td><%= f.label :role_write_id, "Min. write role" %></td>
<td><%= f.select :role_write_id, role_selection, include_blank: false %></td> <td><%= f.select :role_write_id, role_selection, { include_blank: false }, { disabled: !can_create? } %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :necro_length, "Necropost warning delay (in days)" %></td> <td><%= f.label :necro_length, "Necropost warning delay (in days)" %></td>
<td><%= f.number_field :necro_length, placeholder: "Warning Delay (leave blank for no warning)" %></td> <td><%= f.number_field :necro_length, placeholder: "Warning Delay (leave blank for no warning)", disabled: !can_create? %></td>
</tr> </tr>
</table> </table>
<%= f.hidden_field :forumgroup_id %> <%= f.hidden_field :forumgroup_id %>
<p><%= f.submit "Create forum", class: "btn blue left" %></p> <p><%= f.submit "Create forum", class: "btn blue left", disabled: !can_create? %></p>
<div class="clear"></div> <div class="clear"></div>
<% if !current_user.confirmed? %>
<span class='red-alert'>You must confirm your email before you can create new forums.</span>
<% end %>
<% end %> <% end %>

View File

@@ -1,10 +1,20 @@
<% title "Edit Info: #{@info.title}" %> <% title "Edit Info: #{@info.title}" %>
<%
def can_edit?
mod? && current_user.confirmed?
end
%>
<h1>Edit Info</h1> <h1>Edit Info</h1>
<%= form_for @info do |f|%> <%= form_for @info do |f|%>
<%= f.text_field :title%> <%= f.text_field :title, disabled: !can_edit? %>
<%= render partial: "md_editor", locals: {name: "info[content]", content: @info.content} %> <%= render partial: "md_editor", locals: {name: "info[content]", content: @info.content, options: {disabled: !can_edit?}} %>
<p><%= f.submit "Update Info", class: "btn blue left" %></p> <p><%= f.submit "Update Info", class: "btn blue left", disabled: !can_edit? %></p>
<% end %>
<p><%= button_to "Delete Info", @info, method: "delete", data: {confirm: "Are you sure you want to delete this info page?"}, class: "btn red right", disabled: !can_edit? %></p>
<div class="clear"></div>
<% if !current_user.confirmed? %>
<span class='red-alert'>You must confirm your email before you can edit info pages.</span>
<% end %> <% end %>
<p><%= button_to "Delete Info", @info, method: "delete", data: {confirm: "Delete Info forever?"}, class: "btn red right" %></p>
<div class="clear"></div>

View File

@@ -1,9 +1,19 @@
<% title "New Info" %> <% title "New Info" %>
<%
def can_create?
mod? && current_user.confirmed?
end
%>
<h1>New Info</h1> <h1>New Info</h1>
<%= form_for @info, url: info_index_path do |f|%> <%= form_for @info, url: info_index_path do |f|%>
<%= f.text_field :title, placeholder: "Title" %> <%= f.text_field :title, placeholder: "Title", disabled: !can_create? %>
<%= render partial: "md_editor", locals: {name: "info[content]", content: @info.content} %> <%= render partial: "md_editor", locals: {name: "info[content]", content: @info.content, options: {disabled: !can_create?}} %>
<p><%= f.submit "Create Info", class: "btn blue left" %></p> <p><%= f.submit "Create Info", class: "btn blue left", disabled: !can_create? %></p>
<div class="clear"></div> <div class="clear"></div>
<% if !current_user.confirmed? %>
<span class='red-alert'>You must confirm your email before you can create new info pages.</span>
<% end %>
<% end %> <% end %>

View File

@@ -2,7 +2,7 @@
<% <%
def can_edit? def can_edit?
(@user.is?(current_user) && confirmed?) || (mod? && current_user.role >= @user.role) (@user.is?(current_user) && confirmed?) || (mod? && current_user.role >= @user.role && current_user.confirmed?)
end end
%> %>
@@ -23,7 +23,7 @@
<td>Role</td> <td>Role</td>
<td> <td>
<% if current_user.role >= @user.role %> <% if current_user.role >= @user.role %>
<%= f.select :role, Role.all_to(current_user.role) %> <%= f.select :role, Role.all_to(current_user.role), {}, { disabled: !can_edit? } %>
<% end %> <% end %>
</td> </td>
</tr> </tr>
@@ -31,7 +31,7 @@
<td>Badge</td> <td>Badge</td>
<td> <td>
<% if current_user.role >= Role.get(:mod) %> <% if current_user.role >= Role.get(:mod) %>
<%= f.select :badge, Badge.all %> <%= f.select :badge, Badge.all, {}, { disabled: !can_edit? } %>
<% end %> <% end %>
</td> </td>
</tr> </tr>
@@ -57,7 +57,7 @@
<tr> <tr>
<td>Twitter username</td> <td>Twitter username</td>
<td> <td>
<%= f.text_field :twitter, placeholder: "Twitter username", disabled: !(@user.is?(current_user) && confirmed? || (mod? && current_user.role >= @user.role)) %> <%= f.text_field :twitter, placeholder: "Twitter username", disabled: !can_edit? %>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -69,7 +69,7 @@
</tbody> </tbody>
</table> </table>
<p><%= f.submit "Save profile", class: "btn variable-size left", disabled: (!@user.confirmed? && @user.is?(current_user)) %></p> <p><%= f.submit "Save profile", class: "btn variable-size left", disabled: !can_edit? %></p>
<p> <p>
<%= link_to "Edit login details", edit_login_user_path(@user), class: "btn variable-size right" %> <%= link_to "Edit login details", edit_login_user_path(@user), class: "btn variable-size right" %>
<%= link_to "Notification settings", edit_notifications_user_path(@user), class: "btn variable-size right" %> <%= link_to "Notification settings", edit_notifications_user_path(@user), class: "btn variable-size right" %>
@@ -77,7 +77,9 @@
</p> </p>
<div class="clear"></div> <div class="clear"></div>
<% if !@user.confirmed? %> <% if !@user.is?(current_user) && !current_user.confirmed? %>
<span class='red-alert'>You must confirm your own email before you can edit other profiles.</span>
<% elsif !@user.confirmed? %>
<% if @user.is?(current_user) %> <% if @user.is?(current_user) %>
<span class='red-alert'>Please confirm your email address first!</span> <span class='red-alert'>Please confirm your email address first!</span>
<% else %> <% else %>

View File

@@ -1,5 +1,11 @@
<% title "Edit Notification Settings: #{@user.name}" %> <% title "Edit Notification Settings: #{@user.name}" %>
<%
def can_edit?
(@user.is?(current_user) && confirmed?) || (mod? && current_user.role >= @user.role && current_user.confirmed?)
end
%>
<%= link_to @user.name, @user %> → Edit Notification Settings <%= link_to @user.name, @user %> → Edit Notification Settings
<h1>Edit Notification Settings</h1> <h1>Edit Notification Settings</h1>
@@ -11,13 +17,13 @@
<tr> <tr>
<td>replies to my thread</td> <td>replies to my thread</td>
<td> <td>
<%= f.check_box :mail_own_thread_reply %> <%= f.check_box :mail_own_thread_reply, disabled: !can_edit? %>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>replies to a thread I already replied to</td> <td>replies to a thread I already replied to</td>
<td> <td>
<%= f.check_box :mail_other_thread_reply %> <%= f.check_box :mail_other_thread_reply, disabled: !can_edit? %>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -26,13 +32,13 @@
<i>(Currently used for staff only)</i> <i>(Currently used for staff only)</i>
</td> </td>
<td> <td>
<%= f.check_box :mail_own_blogpost_comment %> <%= f.check_box :mail_own_blogpost_comment, disabled: !can_edit? %>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>comments a blog post I already commented</td> <td>comments a blog post I already commented</td>
<td> <td>
<%= f.check_box :mail_other_blogpost_comment %> <%= f.check_box :mail_other_blogpost_comment, disabled: !can_edit? %>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -40,14 +46,20 @@
mentions me in a thread or comment mentions me in a thread or comment
</td> </td>
<td> <td>
<%= f.check_box :mail_mention %> <%= f.check_box :mail_mention, disabled: !can_edit? %>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<h3>Public Key</h1> <h3>Public Key</h1>
<p>All notification emails will be encrypted with this key if you supply it.</p> <p>All notification emails will be encrypted with this key if you supply it.</p>
<%= f.text_area :public_key, placeholder: "-----BEGIN PGP PUBLIC KEY BLOCK-----" %> <%= f.text_area :public_key, placeholder: "-----BEGIN PGP PUBLIC KEY BLOCK-----", disabled: !can_edit? %>
<p><%= f.submit "Save changes", class: "btn blue left" %></p> <p><%= f.submit "Save changes", class: "btn blue left", disabled: !can_edit? %></p>
<div class="clear"></div> <div class="clear"></div>
<% if !@user.is?(current_user) && !current_user.confirmed? %>
<span class='red-alert'>You must confirm your own email before you can edit other user's notification settings.</span>
<% elsif !@user.confirmed? && @user.is?(current_user) %>
<span class='red-alert'>You need to confirm your email before you can edit your notification settings.</span>
<% end %>
<% end %> <% end %>

View File

@@ -1,5 +1,11 @@
<% title "Edit Website Settings: #{@user.name}" %> <% title "Edit Website Settings: #{@user.name}" %>
<%
def can_edit?
(@user.is?(current_user) && confirmed?) || (mod? && current_user.role >= @user.role && current_user.confirmed?)
end
%>
<%= link_to @user.name, @user %> → Edit Website Settings <%= link_to @user.name, @user %> → Edit Website Settings
<h1>Edit Website Settings</h1> <h1>Edit Website Settings</h1>
@@ -10,25 +16,31 @@
<tr> <tr>
<td>Header moves with scrolling (Experimental - do not report bugs)</td> <td>Header moves with scrolling (Experimental - do not report bugs)</td>
<td> <td>
<%= f.check_box :header_scroll %> <%= f.check_box :header_scroll, disabled: !can_edit? %>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Show exact UTC times</td> <td>Show exact UTC times</td>
<td> <td>
<%= f.check_box :utc_time %> <%= f.check_box :utc_time, disabled: !can_edit? %>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Dark theme*</td> <td>Dark theme*</td>
<td> <td>
<%= f.check_box :dark %> <%= f.check_box :dark, disabled: !can_edit? %>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<p><%= f.submit "Save changes", class: "btn blue left" %></p> <p><%= f.submit "Save changes", class: "btn blue left", disabled: !can_edit? %></p>
<div class="clear"></div> <div class="clear"></div>
<% if !@user.is?(current_user) && !current_user.confirmed? %>
<span class='red-alert'>You must confirm your own email before you can edit other user's website settings.</span>
<% elsif !@user.confirmed? && @user.is?(current_user) %>
<span class='red-alert'>You need to confirm your email before you can edit your website settings.</span>
<% end %>
<% end %> <% end %>
<br><br><br> <br><br><br>
*Warning: If as a result to enabling this style your eyes get infected with a severe case of eye cancer, we are not reliable for any damage. Please contact your doctor in advance to ensure that in case of infection you will be treated accordingly. Quality theme brought to you by Redempt™. *Warning: If as a result to enabling this style your eyes get infected with a severe case of eye cancer, we are not reliable for any damage. Please contact your doctor in advance to ensure that in case of infection you will be treated accordingly. Quality theme brought to you by Redempt™.

View File

@@ -16,16 +16,27 @@
<div class="clear"></div> <div class="clear"></div>
<% if @ban_json && (@ban_json["expires"] == "forever" || !(DateTime.parse(@ban_json["expires"]) <= DateTime.now)) %> <% if @ban_json && (@ban_json["expires"] == "forever" || !(DateTime.parse(@ban_json["expires"]) <= DateTime.now)) %>
<span class="user-banned">This user is banned on the server for "<%=@ban_json["reason"]%>"<%=" until #{@ban_json["expires"]}" unless @ban_json["expires"] == "forever"%></span> <% if @user.is?(current_user) %>
<span class="user-banned">You are banned on the server for "<%=@ban_json["reason"]%>"<%=" until #{@ban_json["expires"]}" unless @ban_json["expires"] == "forever"%></span>
<% else %>
<span class="user-banned">This user is banned on the server for "<%=@ban_json["reason"]%>"<%=" until #{@ban_json["expires"]}" unless @ban_json["expires"] == "forever"%></span>
<% end %>
<% end %> <% end %>
<% if @user.banned? %> <% if @user.banned? %>
<% if @user.is?(current_user) %>
<span class="user-banned">You are banned on the website!</span>
<% else %>
<span class="user-banned">This user is banned on the website!</span> <span class="user-banned">This user is banned on the website!</span>
<% end %>
<% end %> <% end %>
<br> <br>
<% if !@user.confirmed? %> <% if !@user.confirmed? %>
<% if @user.is?(current_user) || mod? %> <% if @user.is?(current_user) %>
<span class="user-unconfirmed">Please confirm your email <u><%= @user.email %></u> !</span> <span class="user-unconfirmed">You haven't confirmed your email "<u><%= @user.email %></u>" yet!</span>
<%= button_to "Resend the confirmation mail", resend_mail_user_path, class: "btn dark", form_class: "inline-block", data: {confirm: "Did you check your spam folder?"} %> <%= button_to "Resend the confirmation mail", resend_mail_user_path, class: "btn dark", form_class: "inline-block", data: {confirm: "Did you check your spam folder?"} %>
<% elsif mod? %>
<span class="user-unconfirmed">This user hasn't confirmed their email "<u><%= @user.email %></u>" yet!</span>
<%= button_to "Resend the confirmation mail", resend_mail_user_path, class: "btn dark", form_class: "inline-block" %>
<% else %> <% else %>
<span class="user-unconfirmed">This user hasn't confirmed their email yet!</span> <span class="user-unconfirmed">This user hasn't confirmed their email yet!</span>
<% end %> <% end %>