boxroom 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +50 -0
- data/Rakefile +36 -0
- data/app/assets/config/boxroom_manifest.js +2 -0
- data/app/assets/images/boxroom/clipboard.png +0 -0
- data/app/assets/images/boxroom/clipboard_add.png +0 -0
- data/app/assets/images/boxroom/copy.png +0 -0
- data/app/assets/images/boxroom/delete.png +0 -0
- data/app/assets/images/boxroom/edit.png +0 -0
- data/app/assets/images/boxroom/exclamation.png +0 -0
- data/app/assets/images/boxroom/extend.png +0 -0
- data/app/assets/images/boxroom/failed.png +0 -0
- data/app/assets/images/boxroom/file.png +0 -0
- data/app/assets/images/boxroom/file_add.png +0 -0
- data/app/assets/images/boxroom/fileicons/7z.png +0 -0
- data/app/assets/images/boxroom/fileicons/ai.png +0 -0
- data/app/assets/images/boxroom/fileicons/aif.png +0 -0
- data/app/assets/images/boxroom/fileicons/aiff.png +0 -0
- data/app/assets/images/boxroom/fileicons/audio.png +0 -0
- data/app/assets/images/boxroom/fileicons/bz2.png +0 -0
- data/app/assets/images/boxroom/fileicons/c.png +0 -0
- data/app/assets/images/boxroom/fileicons/conf.png +0 -0
- data/app/assets/images/boxroom/fileicons/cpp.png +0 -0
- data/app/assets/images/boxroom/fileicons/cs.png +0 -0
- data/app/assets/images/boxroom/fileicons/css.png +0 -0
- data/app/assets/images/boxroom/fileicons/csv.png +0 -0
- data/app/assets/images/boxroom/fileicons/divx.png +0 -0
- data/app/assets/images/boxroom/fileicons/doc.png +0 -0
- data/app/assets/images/boxroom/fileicons/docx.png +0 -0
- data/app/assets/images/boxroom/fileicons/dot.png +0 -0
- data/app/assets/images/boxroom/fileicons/fla.png +0 -0
- data/app/assets/images/boxroom/fileicons/gif.png +0 -0
- data/app/assets/images/boxroom/fileicons/gz.png +0 -0
- data/app/assets/images/boxroom/fileicons/htm.png +0 -0
- data/app/assets/images/boxroom/fileicons/html.png +0 -0
- data/app/assets/images/boxroom/fileicons/image.png +0 -0
- data/app/assets/images/boxroom/fileicons/java.png +0 -0
- data/app/assets/images/boxroom/fileicons/jpeg.png +0 -0
- data/app/assets/images/boxroom/fileicons/jpg.png +0 -0
- data/app/assets/images/boxroom/fileicons/js.png +0 -0
- data/app/assets/images/boxroom/fileicons/mdb.png +0 -0
- data/app/assets/images/boxroom/fileicons/mdbx.png +0 -0
- data/app/assets/images/boxroom/fileicons/mov.png +0 -0
- data/app/assets/images/boxroom/fileicons/mp3.png +0 -0
- data/app/assets/images/boxroom/fileicons/mpg.png +0 -0
- data/app/assets/images/boxroom/fileicons/ogg.png +0 -0
- data/app/assets/images/boxroom/fileicons/pdf.png +0 -0
- data/app/assets/images/boxroom/fileicons/php.png +0 -0
- data/app/assets/images/boxroom/fileicons/pl.png +0 -0
- data/app/assets/images/boxroom/fileicons/png.png +0 -0
- data/app/assets/images/boxroom/fileicons/ppt.png +0 -0
- data/app/assets/images/boxroom/fileicons/pptx.png +0 -0
- data/app/assets/images/boxroom/fileicons/ps.png +0 -0
- data/app/assets/images/boxroom/fileicons/py.png +0 -0
- data/app/assets/images/boxroom/fileicons/ram.png +0 -0
- data/app/assets/images/boxroom/fileicons/rar.png +0 -0
- data/app/assets/images/boxroom/fileicons/rb.png +0 -0
- data/app/assets/images/boxroom/fileicons/rm.png +0 -0
- data/app/assets/images/boxroom/fileicons/rtf.png +0 -0
- data/app/assets/images/boxroom/fileicons/sql.png +0 -0
- data/app/assets/images/boxroom/fileicons/swf.png +0 -0
- data/app/assets/images/boxroom/fileicons/tar.png +0 -0
- data/app/assets/images/boxroom/fileicons/tgz.png +0 -0
- data/app/assets/images/boxroom/fileicons/txt.png +0 -0
- data/app/assets/images/boxroom/fileicons/video.png +0 -0
- data/app/assets/images/boxroom/fileicons/wav.png +0 -0
- data/app/assets/images/boxroom/fileicons/wma.png +0 -0
- data/app/assets/images/boxroom/fileicons/wmv.png +0 -0
- data/app/assets/images/boxroom/fileicons/xls.png +0 -0
- data/app/assets/images/boxroom/fileicons/xlsx.png +0 -0
- data/app/assets/images/boxroom/fileicons/xml.png +0 -0
- data/app/assets/images/boxroom/fileicons/xvid.png +0 -0
- data/app/assets/images/boxroom/fileicons/zip.png +0 -0
- data/app/assets/images/boxroom/folder.png +0 -0
- data/app/assets/images/boxroom/folder_add.png +0 -0
- data/app/assets/images/boxroom/group.png +0 -0
- data/app/assets/images/boxroom/group_add.png +0 -0
- data/app/assets/images/boxroom/group_grey.png +0 -0
- data/app/assets/images/boxroom/information.png +0 -0
- data/app/assets/images/boxroom/logo.png +0 -0
- data/app/assets/images/boxroom/move.png +0 -0
- data/app/assets/images/boxroom/permissions.png +0 -0
- data/app/assets/images/boxroom/share.png +0 -0
- data/app/assets/images/boxroom/spinner.gif +0 -0
- data/app/assets/images/boxroom/tick.png +0 -0
- data/app/assets/images/boxroom/user.png +0 -0
- data/app/assets/images/boxroom/user_add.png +0 -0
- data/app/assets/javascripts/boxroom/application.js.coffee +51 -0
- data/app/assets/javascripts/boxroom/files.js.coffee +33 -0
- data/app/assets/stylesheets/boxroom/application.scss +7 -0
- data/app/concepts/boxroom/base_cell.rb +7 -0
- data/app/concepts/boxroom/folder/cell/show.rb +25 -0
- data/app/concepts/boxroom/folder/view/show.erb +69 -0
- data/app/concepts/boxroom/search/contract/files_and_folders.rb +9 -0
- data/app/concepts/boxroom/search/operations/files_and_folders.rb +21 -0
- data/app/controllers/boxroom/admins_controller.rb +30 -0
- data/app/controllers/boxroom/application_controller.rb +5 -0
- data/app/controllers/boxroom/clipboard_controller.rb +87 -0
- data/app/controllers/boxroom/files_controller.rb +78 -0
- data/app/controllers/boxroom/folders_controller.rb +91 -0
- data/app/controllers/boxroom/groups_controller.rb +60 -0
- data/app/controllers/boxroom/permissions_controller.rb +19 -0
- data/app/controllers/boxroom/reset_password_controller.rb +45 -0
- data/app/controllers/boxroom/search_controller.rb +21 -0
- data/app/controllers/boxroom/sessions_controller.rb +48 -0
- data/app/controllers/boxroom/share_links_controller.rb +67 -0
- data/app/controllers/boxroom/signup_controller.rb +31 -0
- data/app/controllers/boxroom/users_controller.rb +75 -0
- data/app/controllers/concerns/boxroom/base_controller.rb +92 -0
- data/app/helpers/boxroom/application_helper.rb +4 -0
- data/app/helpers/boxroom/folders_helper.rb +17 -0
- data/app/jobs/boxroom/application_job.rb +4 -0
- data/app/mailers/boxroom/application_mailer.rb +6 -0
- data/app/mailers/boxroom/user_mailer.rb +18 -0
- data/app/models/boxroom/application_record.rb +5 -0
- data/app/models/boxroom/clipboard.rb +45 -0
- data/app/models/boxroom/folder.rb +113 -0
- data/app/models/boxroom/group.rb +57 -0
- data/app/models/boxroom/permission.rb +6 -0
- data/app/models/boxroom/permitted_params.rb +33 -0
- data/app/models/boxroom/share_link.rb +40 -0
- data/app/models/boxroom/user.rb +113 -0
- data/app/models/boxroom/user_file.rb +35 -0
- data/app/views/boxroom/admins/new.html.erb +42 -0
- data/app/views/boxroom/clipboard/_clipboard_empty.de.html.erb +2 -0
- data/app/views/boxroom/clipboard/_clipboard_empty.en.html.erb +2 -0
- data/app/views/boxroom/clipboard/_clipboard_empty.es.html.erb +2 -0
- data/app/views/boxroom/clipboard/_clipboard_empty.fr.html.erb +2 -0
- data/app/views/boxroom/clipboard/_clipboard_empty.it.html.erb +2 -0
- data/app/views/boxroom/clipboard/_clipboard_empty.nl.html.erb +2 -0
- data/app/views/boxroom/clipboard/_clipboard_empty.zh-CN.html.erb +2 -0
- data/app/views/boxroom/clipboard/_show.html.erb +72 -0
- data/app/views/boxroom/files/edit.html.erb +24 -0
- data/app/views/boxroom/files/new.html.erb +45 -0
- data/app/views/boxroom/folders/_form.html.erb +19 -0
- data/app/views/boxroom/folders/edit.html.erb +6 -0
- data/app/views/boxroom/folders/new.html.erb +6 -0
- data/app/views/boxroom/folders/show.html.erb +69 -0
- data/app/views/boxroom/groups/_form.html.erb +21 -0
- data/app/views/boxroom/groups/edit.html.erb +4 -0
- data/app/views/boxroom/groups/index.html.erb +42 -0
- data/app/views/boxroom/groups/new.html.erb +4 -0
- data/app/views/boxroom/permissions/_form.html.erb +46 -0
- data/app/views/boxroom/reset_password/_message.de.html.erb +2 -0
- data/app/views/boxroom/reset_password/_message.en.html.erb +2 -0
- data/app/views/boxroom/reset_password/_message.es.html.erb +2 -0
- data/app/views/boxroom/reset_password/_message.fr.html.erb +2 -0
- data/app/views/boxroom/reset_password/_message.it.html.erb +2 -0
- data/app/views/boxroom/reset_password/_message.nl.html.erb +2 -0
- data/app/views/boxroom/reset_password/_message.zh-CN.html.erb +2 -0
- data/app/views/boxroom/reset_password/edit.html.erb +30 -0
- data/app/views/boxroom/reset_password/new.html.erb +22 -0
- data/app/views/boxroom/search/show.html.erb +15 -0
- data/app/views/boxroom/sessions/new.html.erb +31 -0
- data/app/views/boxroom/share_links/index.html.erb +24 -0
- data/app/views/boxroom/share_links/new.html.erb +49 -0
- data/app/views/boxroom/shared/_footer.html.erb +9 -0
- data/app/views/boxroom/shared/_header.html.erb +45 -0
- data/app/views/boxroom/signup/edit.html.erb +42 -0
- data/app/views/boxroom/user_mailer/reset_password_email.de.text.erb +18 -0
- data/app/views/boxroom/user_mailer/reset_password_email.en.text.erb +17 -0
- data/app/views/boxroom/user_mailer/reset_password_email.es.text.erb +17 -0
- data/app/views/boxroom/user_mailer/reset_password_email.fr.text.erb +17 -0
- data/app/views/boxroom/user_mailer/reset_password_email.it.text.erb +17 -0
- data/app/views/boxroom/user_mailer/reset_password_email.nl.text.erb +17 -0
- data/app/views/boxroom/user_mailer/reset_password_email.zh-CN.text.erb +16 -0
- data/app/views/boxroom/user_mailer/share_link_email.de.text.erb +20 -0
- data/app/views/boxroom/user_mailer/share_link_email.en.text.erb +20 -0
- data/app/views/boxroom/user_mailer/share_link_email.es.text.erb +20 -0
- data/app/views/boxroom/user_mailer/share_link_email.fr.text.erb +20 -0
- data/app/views/boxroom/user_mailer/share_link_email.it.text.erb +20 -0
- data/app/views/boxroom/user_mailer/share_link_email.nl.text.erb +20 -0
- data/app/views/boxroom/user_mailer/share_link_email.zh-CN.text.erb +20 -0
- data/app/views/boxroom/user_mailer/signup_email.de.text.erb +9 -0
- data/app/views/boxroom/user_mailer/signup_email.en.text.erb +9 -0
- data/app/views/boxroom/user_mailer/signup_email.es.text.erb +9 -0
- data/app/views/boxroom/user_mailer/signup_email.fr.text.erb +9 -0
- data/app/views/boxroom/user_mailer/signup_email.it.text.erb +9 -0
- data/app/views/boxroom/user_mailer/signup_email.nl.text.erb +10 -0
- data/app/views/boxroom/user_mailer/signup_email.zh-CN.text.erb +8 -0
- data/app/views/boxroom/users/_form.html.erb +63 -0
- data/app/views/boxroom/users/edit.html.erb +4 -0
- data/app/views/boxroom/users/index.html.erb +68 -0
- data/app/views/boxroom/users/new.html.erb +4 -0
- data/app/views/layouts/boxroom/application.html.erb +37 -0
- data/config/locales/de.yml +414 -0
- data/config/locales/en.yml +407 -0
- data/config/locales/es.yml +403 -0
- data/config/locales/fr.yml +403 -0
- data/config/locales/it.yml +414 -0
- data/config/locales/nl.yml +408 -0
- data/config/locales/zh-CN.yml +406 -0
- data/config/routes.rb +44 -0
- data/db/migrate/20100930062939_boxroom_create_users.rb +20 -0
- data/db/migrate/20100930091426_boxroom_create_folders.rb +14 -0
- data/db/migrate/20100930091451_boxroom_create_groups.rb +12 -0
- data/db/migrate/20101002122244_boxroom_create_user_files.rb +17 -0
- data/db/migrate/20101005071402_boxroom_create_permissions.rb +16 -0
- data/db/migrate/20101005071508_boxroom_create_groups_users.rb +12 -0
- data/db/migrate/20110106045148_boxroom_drop_column_user_id_from_folders.rb +9 -0
- data/db/migrate/20110106045414_boxroom_drop_column_user_id_from_user_files.rb +9 -0
- data/db/migrate/20110529123402_boxroom_drop_column_access_key_from_users.rb +9 -0
- data/db/migrate/20110616215033_boxroom_create_share_links.rb +15 -0
- data/db/migrate/20120411075110_boxroom_add_column_signup_token_to_users.rb +8 -0
- data/db/migrate/20120411081345_boxroom_add_column_signup_token_expires_at_to_users.rb +7 -0
- data/db/migrate/20130626210927_boxroom_add_columns_message_user_id_to_share_links.rb +6 -0
- data/db/migrate/20130628082245_boxroom_populate_user_id_in_share_links.rb +9 -0
- data/lib/boxroom.rb +35 -0
- data/lib/boxroom/configuration.rb +18 -0
- data/lib/boxroom/engine.rb +9 -0
- data/lib/boxroom/version.rb +3 -0
- data/lib/paperclip/spoof_detector.rb +7 -0
- data/lib/tasks/boxroom_tasks.rake +4 -0
- metadata +481 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
module Boxroom::Search
|
2
|
+
class FilesAndFolders < ::Trailblazer::Operation
|
3
|
+
step Trailblazer::Operation::Contract::Build(constant: Boxroom::Search::Contract::FilesAndFolders)
|
4
|
+
step Trailblazer::Operation::Contract::Validate()
|
5
|
+
step :search_tree
|
6
|
+
|
7
|
+
def search_tree(options, params:, **)
|
8
|
+
options['files'], options['folders'] = [], []
|
9
|
+
folder = Boxroom::Folder.find(params[:folder_id])
|
10
|
+
search_folder(params[:term], folder, options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def search_folder(term, folder, options)
|
14
|
+
options['folders'] << folder if folder.name.downcase.include? term.downcase
|
15
|
+
options['files'] += folder.user_files.where("lower(attachment_file_name) LIKE ?", "%#{term.downcase}%").all.to_a
|
16
|
+
folder.children.each do |f|
|
17
|
+
search_folder(term, f, options)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Boxroom
|
2
|
+
class AdminsController < Boxroom::ApplicationController
|
3
|
+
include Boxroom::BaseController
|
4
|
+
|
5
|
+
skip_before_action :require_admin_in_system, :require_login
|
6
|
+
before_action :require_no_admin
|
7
|
+
|
8
|
+
def new
|
9
|
+
@user = User.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def create
|
13
|
+
@user = User.new(permitted_params.user)
|
14
|
+
@user.password_required = true
|
15
|
+
@user.is_admin = true
|
16
|
+
|
17
|
+
if @user.save
|
18
|
+
redirect_to new_session_url, :notice => t(:admin_user_created_successfully)
|
19
|
+
else
|
20
|
+
render :action => 'new'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def require_no_admin
|
27
|
+
redirect_to new_session_url unless User.no_admin_yet?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module Boxroom
|
2
|
+
class ClipboardController < Boxroom::ApplicationController
|
3
|
+
include Boxroom::BaseController
|
4
|
+
|
5
|
+
before_action :require_existing_item, :except => :reset
|
6
|
+
before_action :require_existing_target_folder, :only => [:copy, :move]
|
7
|
+
before_action :require_target_is_not_child, :only => :move
|
8
|
+
before_action :require_create_permission, :only => [:copy, :move]
|
9
|
+
before_action :require_read_permission, :only => [:create, :copy, :move]
|
10
|
+
before_action :require_delete_permission, :only => :move
|
11
|
+
|
12
|
+
# @item is set in require_existing_item
|
13
|
+
def create
|
14
|
+
cl = clipboard
|
15
|
+
cl.add(@item)
|
16
|
+
session[:clipboard] = cl
|
17
|
+
redirect_to folder_url(params[:folder_id]), :notice => t(:added_to_clipboard)
|
18
|
+
end
|
19
|
+
|
20
|
+
# @item is set in require_existing_item
|
21
|
+
def destroy
|
22
|
+
cl = clipboard
|
23
|
+
cl.remove(@item)
|
24
|
+
session[:clipboard] = cl
|
25
|
+
redirect_to folder_url(params[:folder_id])
|
26
|
+
end
|
27
|
+
|
28
|
+
def reset
|
29
|
+
cl = clipboard
|
30
|
+
cl.reset
|
31
|
+
session[:clipboard] = cl
|
32
|
+
redirect_to folder_url(params[:folder_id])
|
33
|
+
end
|
34
|
+
|
35
|
+
def copy
|
36
|
+
paste :copy
|
37
|
+
end
|
38
|
+
|
39
|
+
def move
|
40
|
+
paste :move
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
# @item is set in require_existing_item
|
46
|
+
# @target_folder is set in require_existing_target_folder
|
47
|
+
def paste(action)
|
48
|
+
@item.send(action, @target_folder)
|
49
|
+
cl = clipboard
|
50
|
+
cl.remove(@item)
|
51
|
+
session[:clipboard] = cl
|
52
|
+
redirect_to folder_url(params[:folder_id])
|
53
|
+
rescue ActiveRecord::RecordInvalid
|
54
|
+
redirect_to folder_url(params[:folder_id]), :alert => t("could_not_#{action}", :type => t(params[:type]))
|
55
|
+
end
|
56
|
+
|
57
|
+
def require_existing_item
|
58
|
+
if params[:type] == 'folder'
|
59
|
+
@item = @folder = Folder.find(params[:id])
|
60
|
+
else
|
61
|
+
@item = UserFile.find(params[:id])
|
62
|
+
@folder = @item.folder
|
63
|
+
end
|
64
|
+
rescue ActiveRecord::RecordNotFound
|
65
|
+
redirect_to folder_url(params[:folder_id]), :alert => t(:already_deleted, :type => t("this_#{params[:type]}"))
|
66
|
+
end
|
67
|
+
|
68
|
+
def require_target_is_not_child
|
69
|
+
if params[:type] == 'folder'
|
70
|
+
if @folder == @target_folder || @folder.parent_of?(@target_folder)
|
71
|
+
redirect_to folder_url(params[:folder_id]), :alert => t(:cannot_move_to_own_subfolder)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Overrides require_#{method}_permission in ApplicationController.
|
77
|
+
# Check if @folder can be read or deleted and redirects to the
|
78
|
+
# current folder (identified by params[:folder_id]) if not.
|
79
|
+
%w{read delete}.each do |method|
|
80
|
+
define_method "require_#{method}_permission" do
|
81
|
+
unless current_user.send("can_#{method}", @folder)
|
82
|
+
redirect_to folder_url(params[:folder_id]), :alert => t(:no_permissions_for_this_type, :method => t(method), :type => t("this_#{params[:type]}"))
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module Boxroom
|
2
|
+
class FilesController < Boxroom::ApplicationController
|
3
|
+
include Boxroom::BaseController
|
4
|
+
|
5
|
+
before_action :require_existing_file, :only => [:show, :edit, :update, :destroy]
|
6
|
+
before_action :require_existing_target_folder, :only => [:new, :create]
|
7
|
+
|
8
|
+
before_action :require_create_permission, :only => [:new, :create]
|
9
|
+
before_action :require_read_permission, :only => :show
|
10
|
+
before_action :require_update_permission, :only => [:edit, :update]
|
11
|
+
before_action :require_delete_permission, :only => :destroy
|
12
|
+
|
13
|
+
# @file and @folder are set in require_existing_file
|
14
|
+
def show
|
15
|
+
send_file @file.attachment.path, :filename => @file.attachment_file_name
|
16
|
+
end
|
17
|
+
|
18
|
+
# @target_folder is set in require_existing_target_folder
|
19
|
+
def new
|
20
|
+
@file = @target_folder.user_files.build
|
21
|
+
end
|
22
|
+
|
23
|
+
# @target_folder is set in require_existing_target_folder
|
24
|
+
def create
|
25
|
+
existing_file = UserFile.where(
|
26
|
+
attachment_file_name: permitted_params.user_file["attachment"].original_filename,
|
27
|
+
attachment_content_type: permitted_params.user_file["attachment"].content_type,
|
28
|
+
folder_id: params[:target_folder_id]
|
29
|
+
).first
|
30
|
+
|
31
|
+
if existing_file # Resume upload
|
32
|
+
existing_file.update_attribute(:attachment_file_size, existing_file.attachment_file_size + permitted_params.user_file["attachment"].size)
|
33
|
+
File.open("#{Rails.root}/#{Boxroom.configuration.uploads_path}/#{Rails.env}/#{existing_file.id}/original/#{existing_file.id}", "ab") {|f| f.write(permitted_params.user_file["attachment"].read)}
|
34
|
+
else
|
35
|
+
@file = @target_folder.user_files.create(permitted_params.user_file)
|
36
|
+
end
|
37
|
+
|
38
|
+
head :ok
|
39
|
+
end
|
40
|
+
|
41
|
+
# @file and @folder are set in require_existing_file
|
42
|
+
def edit
|
43
|
+
end
|
44
|
+
|
45
|
+
# @file and @folder are set in require_existing_file
|
46
|
+
def update
|
47
|
+
if @file.update_attributes(permitted_params.user_file)
|
48
|
+
redirect_to edit_file_url(@file), :notice => t(:your_changes_were_saved)
|
49
|
+
else
|
50
|
+
render :action => 'edit'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# @file and @folder are set in require_existing_file
|
55
|
+
def destroy
|
56
|
+
@file.destroy
|
57
|
+
redirect_to @folder
|
58
|
+
end
|
59
|
+
|
60
|
+
def exists
|
61
|
+
@folder = Folder.find(params[:folder])
|
62
|
+
|
63
|
+
if current_user.can_read(@folder) || current_user.can_write(@folder)
|
64
|
+
@file = @folder.user_files.build(:attachment_file_name => params[:name].gsub(Boxroom::RESTRICTED_CHARACTERS, '_'))
|
65
|
+
render :json => !@file.valid?
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def require_existing_file
|
72
|
+
@file = UserFile.find(params[:id])
|
73
|
+
@folder = @file.folder
|
74
|
+
rescue ActiveRecord::RecordNotFound
|
75
|
+
redirect_to Folder.root, :alert => t(:already_deleted, :type => t(:this_file))
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module Boxroom
|
2
|
+
class FoldersController < Boxroom::ApplicationController
|
3
|
+
include Boxroom::BaseController
|
4
|
+
|
5
|
+
before_action :require_existing_folder, :only => [:show, :edit, :update, :destroy]
|
6
|
+
before_action :require_existing_target_folder, :only => [:new, :create]
|
7
|
+
before_action :require_folder_isnt_root_folder, :only => [:edit, :update, :destroy]
|
8
|
+
|
9
|
+
before_action :require_create_permission, :only => [:new, :create]
|
10
|
+
before_action :require_read_permission, :only => :show
|
11
|
+
before_action :require_update_permission, :only => [:edit, :update]
|
12
|
+
before_action :require_delete_permission, :only => :destroy
|
13
|
+
|
14
|
+
def index
|
15
|
+
redirect_to Folder.root
|
16
|
+
end
|
17
|
+
|
18
|
+
# Note: @folder is set in require_existing_folder
|
19
|
+
def show
|
20
|
+
end
|
21
|
+
|
22
|
+
# Note: @target_folder is set in require_existing_target_folder
|
23
|
+
def new
|
24
|
+
@folder = @target_folder.children.build
|
25
|
+
end
|
26
|
+
|
27
|
+
# Note: @target_folder is set in require_existing_target_folder
|
28
|
+
def create
|
29
|
+
@folder = @target_folder.children.build(permitted_params.folder)
|
30
|
+
|
31
|
+
if @folder.save
|
32
|
+
redirect_to @target_folder
|
33
|
+
else
|
34
|
+
render :action => 'new'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Note: @folder is set in require_existing_folder
|
39
|
+
def edit
|
40
|
+
end
|
41
|
+
|
42
|
+
# Note: @folder is set in require_existing_folder
|
43
|
+
def update
|
44
|
+
if @folder.update_attributes(permitted_params.folder)
|
45
|
+
redirect_to edit_folder_url(@folder), :notice => t(:your_changes_were_saved)
|
46
|
+
else
|
47
|
+
render :action => 'edit'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Note: @folder is set in require_existing_folder
|
52
|
+
def destroy
|
53
|
+
target_folder = @folder.parent
|
54
|
+
@folder.destroy
|
55
|
+
redirect_to target_folder
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
# get_folder_or_redirect is defined in ApplicationController
|
61
|
+
def require_existing_folder
|
62
|
+
@folder = get_folder_or_redirect(params[:id])
|
63
|
+
end
|
64
|
+
|
65
|
+
def require_folder_isnt_root_folder
|
66
|
+
if @folder.is_root?
|
67
|
+
redirect_to Folder.root, :alert => t(:cannot_delete_root_folder)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# Overrides require_delete_permission in ApplicationController
|
72
|
+
def require_delete_permission
|
73
|
+
unless @folder.is_root? || current_user.can_delete(@folder)
|
74
|
+
redirect_to @folder.parent, :alert => t(:no_permissions_for_this_type, :method => t(:delete), :type => t(:this_folder))
|
75
|
+
else
|
76
|
+
require_delete_permissions_for(@folder.children)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def require_delete_permissions_for(folders)
|
81
|
+
folders.each do |folder|
|
82
|
+
unless current_user.can_delete(folder)
|
83
|
+
redirect_to @folder.parent, :alert => t(:no_delete_permissions_for_subfolder)
|
84
|
+
else
|
85
|
+
# Recursive...
|
86
|
+
require_delete_permissions_for(folder.children)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Boxroom
|
2
|
+
class GroupsController < Boxroom::ApplicationController
|
3
|
+
include Boxroom::BaseController
|
4
|
+
|
5
|
+
before_action :require_admin
|
6
|
+
before_action :require_existing_group, :only => [:edit, :update, :destroy]
|
7
|
+
before_action :require_group_isnt_admins_group, :only => [:edit, :update, :destroy]
|
8
|
+
|
9
|
+
def index
|
10
|
+
@groups = Group.order(:name)
|
11
|
+
end
|
12
|
+
|
13
|
+
def new
|
14
|
+
@group = Group.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def create
|
18
|
+
@group = Group.new(permitted_params.group)
|
19
|
+
|
20
|
+
if @group.save
|
21
|
+
redirect_to groups_url
|
22
|
+
else
|
23
|
+
render :action => 'new'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Note: @group is set in require_existing_group
|
28
|
+
def edit
|
29
|
+
end
|
30
|
+
|
31
|
+
# Note: @group is set in require_existing_group
|
32
|
+
def update
|
33
|
+
if @group.update_attributes(permitted_params.group)
|
34
|
+
redirect_to edit_group_url(@group), :notice => t(:your_changes_were_saved)
|
35
|
+
else
|
36
|
+
render :action => 'edit'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Note: @group is set in require_existing_group
|
41
|
+
def destroy
|
42
|
+
@group.destroy
|
43
|
+
redirect_to groups_url
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def require_existing_group
|
49
|
+
@group = Group.find(params[:id])
|
50
|
+
rescue ActiveRecord::RecordNotFound
|
51
|
+
redirect_to groups_url, :alert => t(:group_already_deleted)
|
52
|
+
end
|
53
|
+
|
54
|
+
def require_group_isnt_admins_group
|
55
|
+
if @group.admins_group?
|
56
|
+
redirect_to groups_url, :alert => t(:admins_group_cannot_be_deleted)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Boxroom
|
2
|
+
class PermissionsController < Boxroom::ApplicationController
|
3
|
+
include Boxroom::BaseController
|
4
|
+
|
5
|
+
before_action :require_admin
|
6
|
+
|
7
|
+
def update_multiple
|
8
|
+
if params[:permissions]
|
9
|
+
permissions = Permission.update(params[:permissions].keys, params[:permissions].values)
|
10
|
+
folder = permissions.first.folder
|
11
|
+
folder.copy_permissions_to_children(permissions) if params[:recursive] && folder.has_children?
|
12
|
+
end
|
13
|
+
|
14
|
+
redirect_back fallback_location: root_path
|
15
|
+
rescue ActiveRecord::RecordNotFound # Folder was deleted, so permissions are gone too
|
16
|
+
redirect_to Folder.root, :alert => t(:already_deleted, :type => t(:this_folder))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Boxroom
|
2
|
+
class ResetPasswordController < Boxroom::ApplicationController
|
3
|
+
include Boxroom::BaseController
|
4
|
+
|
5
|
+
before_action :require_valid_token, :only => [:edit, :update]
|
6
|
+
skip_before_action :require_login
|
7
|
+
|
8
|
+
def new
|
9
|
+
end
|
10
|
+
|
11
|
+
def create
|
12
|
+
user = User.find_by_email(params[:email])
|
13
|
+
|
14
|
+
unless user.nil?
|
15
|
+
user.refresh_reset_password_token
|
16
|
+
UserMailer.reset_password_email(user).deliver_now
|
17
|
+
end
|
18
|
+
|
19
|
+
redirect_to new_reset_password_url, :notice => t(:instruction_email_sent, :email => params[:email])
|
20
|
+
end
|
21
|
+
|
22
|
+
# Note: @user is set in require_valid_token
|
23
|
+
def edit
|
24
|
+
end
|
25
|
+
|
26
|
+
# Note: @user is set in require_valid_token
|
27
|
+
def update
|
28
|
+
if @user.update_attributes(permitted_params.user.merge({:password_required => true}))
|
29
|
+
redirect_to new_session_url, :notice => t(:password_reset_successfully)
|
30
|
+
else
|
31
|
+
render :action => 'edit'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def require_valid_token
|
38
|
+
@user = User.find_by_reset_password_token(params[:id])
|
39
|
+
|
40
|
+
if @user.nil? || @user.reset_password_token_expires_at < Time.now
|
41
|
+
redirect_to new_reset_password_url, :alert => t(:reset_url_expired)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|