boxroom 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
|
2
|
+
class SearchController < Boxroom::ApplicationController
|
|
3
|
+
include Boxroom::BaseController
|
|
4
|
+
|
|
5
|
+
def show
|
|
6
|
+
@folder = get_folder_or_redirect(params[:folder_id])
|
|
7
|
+
@term = params[:term]
|
|
8
|
+
result = Search::FilesAndFolders.(params: {term: @term, folder_id: @folder.id})
|
|
9
|
+
if result.success?
|
|
10
|
+
@folders = result['folders']
|
|
11
|
+
@files = result['files']
|
|
12
|
+
else
|
|
13
|
+
@folders = []
|
|
14
|
+
@files = []
|
|
15
|
+
if result['contract.default'].errors.present?
|
|
16
|
+
flash[:alert] = result['contract.default'].errors.full_messages.uniq.join(', ')
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module Boxroom
|
|
2
|
+
class SessionsController < Boxroom::ApplicationController
|
|
3
|
+
include Boxroom::BaseController
|
|
4
|
+
|
|
5
|
+
skip_before_action :require_login
|
|
6
|
+
|
|
7
|
+
def new
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def create
|
|
11
|
+
user = User.authenticate(params[:username], params[:password])
|
|
12
|
+
|
|
13
|
+
unless user.nil?
|
|
14
|
+
if params[:remember_me] == 'true'
|
|
15
|
+
user.refresh_remember_token
|
|
16
|
+
cookies[:auth_token] = {:value => user.remember_token, :expires => 2.weeks.from_now}
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
session[:user_id] = user.id
|
|
20
|
+
redirect_url = session.delete(:return_to) || folders_url
|
|
21
|
+
redirect_to redirect_url, :only_path => true
|
|
22
|
+
else
|
|
23
|
+
log_failed_sign_in_attempt(Time.now, params[:username], request.remote_ip)
|
|
24
|
+
redirect_to new_session_url, :alert => t(:credentials_incorrect)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def destroy
|
|
29
|
+
current_user.forget_me
|
|
30
|
+
cookies.delete :auth_token
|
|
31
|
+
reset_session
|
|
32
|
+
session[:user_id] = nil
|
|
33
|
+
redirect_to Boxroom.configuration.sign_out_path ? Boxroom.configuration.sign_out_path : new_session_url
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
def log_failed_sign_in_attempt(date, username, ip)
|
|
39
|
+
Rails.logger.error(
|
|
40
|
+
"\nFAILED SIGN IN ATTEMPT:\n" +
|
|
41
|
+
"=======================\n" +
|
|
42
|
+
" Date: #{date}\n" +
|
|
43
|
+
" Username: #{username}\n" +
|
|
44
|
+
" IP address: #{ip}\n\n"
|
|
45
|
+
)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
module Boxroom
|
|
2
|
+
class ShareLinksController < Boxroom::ApplicationController
|
|
3
|
+
include Boxroom::BaseController
|
|
4
|
+
|
|
5
|
+
before_action :require_admin, :only => [:index, :destroy]
|
|
6
|
+
before_action :require_existing_file, :except => [:index, :destroy]
|
|
7
|
+
before_action :require_existing_share_link, :only => :destroy
|
|
8
|
+
before_action :require_read_permission, :only => [:new, :create]
|
|
9
|
+
skip_before_action :require_login, :only => :show
|
|
10
|
+
|
|
11
|
+
rescue_from ActiveRecord::RecordNotFound, NoMethodError, RuntimeError, :with => :redirect_to_root_or_signin_and_show_alert
|
|
12
|
+
|
|
13
|
+
def index
|
|
14
|
+
@share_links = ShareLink.active_share_links
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Note: @file is set in require_existing_file
|
|
18
|
+
def show
|
|
19
|
+
send_file @file.attachment.path, :filename => @file.attachment_file_name unless @file.nil?
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Note: @file is set in require_existing_file
|
|
23
|
+
def new
|
|
24
|
+
@share_link = @file.share_links.build
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Note: @file and @folder are set in require_existing_file
|
|
28
|
+
def create
|
|
29
|
+
@share_link = @file.share_links.build(permitted_params.share_link)
|
|
30
|
+
@share_link.user = current_user
|
|
31
|
+
|
|
32
|
+
if @share_link.save
|
|
33
|
+
UserMailer.share_link_email(@share_link).deliver_now
|
|
34
|
+
redirect_to @folder, :notice => t(:shared_successfully)
|
|
35
|
+
else
|
|
36
|
+
render :action => 'new'
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Note: @share_link is set in require_existing_share_link
|
|
41
|
+
def destroy
|
|
42
|
+
@share_link.destroy
|
|
43
|
+
redirect_to share_links_url
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
private
|
|
47
|
+
|
|
48
|
+
def require_existing_file
|
|
49
|
+
@file = params[:file_id].blank? ? ShareLink.file_for_token(params[:id]) : UserFile.find(params[:file_id])
|
|
50
|
+
@folder = @file.folder
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def require_existing_share_link
|
|
54
|
+
@share_link = ShareLink.find(params[:id])
|
|
55
|
+
rescue ActiveRecord::RecordNotFound
|
|
56
|
+
redirect_to share_links_url, :alert => t(:already_deleted, :type => t(:this_share_link))
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def redirect_to_root_or_signin_and_show_alert
|
|
60
|
+
if signed_in?
|
|
61
|
+
redirect_to Folder.root, :alert => t(:already_deleted, :type => t(:this_file))
|
|
62
|
+
else
|
|
63
|
+
redirect_to signin_url, :alert => t(:already_deleted, :type => t(:this_file))
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Boxroom
|
|
2
|
+
class SignupController < Boxroom::ApplicationController
|
|
3
|
+
include Boxroom::BaseController
|
|
4
|
+
|
|
5
|
+
before_action :require_valid_token, :only => [:edit, :update]
|
|
6
|
+
skip_before_action :require_login
|
|
7
|
+
|
|
8
|
+
# Note: @user is set in require_valid_token
|
|
9
|
+
def edit
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Note: @user is set in require_valid_token
|
|
13
|
+
def update
|
|
14
|
+
if @user.update_attributes(permitted_params.user.merge({:password_required => true}))
|
|
15
|
+
redirect_to new_session_url, :notice => t(:signed_up_successfully)
|
|
16
|
+
else
|
|
17
|
+
render :action => 'edit'
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def require_valid_token
|
|
24
|
+
@user = User.find_by_signup_token(params[:id])
|
|
25
|
+
|
|
26
|
+
if @user.nil? || @user.signup_token_expires_at < Time.now
|
|
27
|
+
redirect_to new_session_url, :alert => t(:sign_url_expired)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
module Boxroom
|
|
2
|
+
class UsersController < Boxroom::ApplicationController
|
|
3
|
+
include Boxroom::BaseController
|
|
4
|
+
|
|
5
|
+
before_action :require_admin, :except => [:edit, :update]
|
|
6
|
+
before_action :require_existing_user, :only => [:edit, :update, :destroy, :extend]
|
|
7
|
+
before_action :require_deleted_user_isnt_admin, :only => :destroy
|
|
8
|
+
|
|
9
|
+
def index
|
|
10
|
+
@users = User.where.not(:name => nil).order('name')
|
|
11
|
+
@new_users = User.where(:name => nil).order('email')
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def new
|
|
15
|
+
@user = User.new
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def create
|
|
19
|
+
@user = User.new(permitted_params.user)
|
|
20
|
+
|
|
21
|
+
if @user.save
|
|
22
|
+
UserMailer.signup_email(@user).deliver_now
|
|
23
|
+
redirect_to users_url
|
|
24
|
+
else
|
|
25
|
+
render :action => 'new'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Note: @user is set in require_existing_user
|
|
30
|
+
def edit
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Note: @user is set in require_existing_user
|
|
34
|
+
def update
|
|
35
|
+
if @user.update_attributes(permitted_params.user.merge({:password_required => false}))
|
|
36
|
+
redirect_to edit_user_url(@user), :notice => t(:your_changes_were_saved)
|
|
37
|
+
else
|
|
38
|
+
render :action => 'edit'
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Note: @user is set in require_existing_user
|
|
43
|
+
def extend
|
|
44
|
+
@user.signup_token_expires_at = @user.signup_token_expires_at + 2.weeks
|
|
45
|
+
@user.save(:validate => false)
|
|
46
|
+
redirect_to users_url
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Note: @user is set in require_existing_user
|
|
50
|
+
def destroy
|
|
51
|
+
@user.destroy
|
|
52
|
+
redirect_to users_url
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
def require_existing_user
|
|
58
|
+
if current_user.member_of_admins? && params[:id] != current_user.id.to_s
|
|
59
|
+
@title = t(:edit_user)
|
|
60
|
+
@user = User.find(params[:id])
|
|
61
|
+
else
|
|
62
|
+
@title = t(:account_settings)
|
|
63
|
+
@user = current_user
|
|
64
|
+
end
|
|
65
|
+
rescue ActiveRecord::RecordNotFound
|
|
66
|
+
redirect_to users_url, :alert => t(:user_already_deleted)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def require_deleted_user_isnt_admin
|
|
70
|
+
if @user.is_admin
|
|
71
|
+
redirect_to users_url, :alert => t(:admin_user_cannot_be_deleted)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
module Boxroom
|
|
2
|
+
module BaseController
|
|
3
|
+
extend ActiveSupport::Concern
|
|
4
|
+
|
|
5
|
+
included do
|
|
6
|
+
before_action :require_admin_in_system
|
|
7
|
+
before_action :require_login
|
|
8
|
+
|
|
9
|
+
helper_method :clipboard, :current_user, :signed_in?, :permitted_params
|
|
10
|
+
|
|
11
|
+
%w{read update delete}.each do |method|
|
|
12
|
+
define_method "require_#{method}_permission" do
|
|
13
|
+
unless (method == 'read' && @folder.is_root?) || current_user.send("can_#{method}", @folder)
|
|
14
|
+
redirect_folder = @folder.parent.nil? ? Folder.root : @folder.parent
|
|
15
|
+
redirect_to redirect_folder, :alert => t(:no_permissions_for_this_type, :method => t(:create), :type => t(:this_folder))
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
protected
|
|
22
|
+
|
|
23
|
+
def clipboard
|
|
24
|
+
cl = session[:clipboard]
|
|
25
|
+
cl = Clipboard.new if cl.nil?
|
|
26
|
+
if cl.kind_of? Hash # Init clipboard from Hash
|
|
27
|
+
new_cl = Clipboard.new
|
|
28
|
+
cl['folders'].each do |folder_id|
|
|
29
|
+
new_cl.add(Folder.find(folder_id))
|
|
30
|
+
end
|
|
31
|
+
cl['files'].each do |file_id|
|
|
32
|
+
new_cl.add(UserFile.find(file_id))
|
|
33
|
+
end
|
|
34
|
+
cl = new_cl
|
|
35
|
+
end
|
|
36
|
+
cl
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def current_user
|
|
40
|
+
@current_user ||= User.find_by_id(session[:user_id])
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def signed_in?
|
|
44
|
+
!!current_user
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def permitted_params
|
|
48
|
+
@permitted_params ||= PermittedParams.new(params, current_user)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def require_admin_in_system
|
|
52
|
+
redirect_to new_admin_url if User.no_admin_yet?
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def require_admin
|
|
56
|
+
redirect_to :root unless current_user.member_of_admins?
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def require_login
|
|
60
|
+
if current_user.nil?
|
|
61
|
+
user = User.find_by_remember_token(cookies[:auth_token]) unless cookies[:auth_token].blank?
|
|
62
|
+
|
|
63
|
+
if user.nil?
|
|
64
|
+
reset_session
|
|
65
|
+
session[:user_id] = nil
|
|
66
|
+
session[:return_to] = request.fullpath
|
|
67
|
+
redirect_to new_session_url
|
|
68
|
+
else
|
|
69
|
+
user.refresh_remember_token
|
|
70
|
+
session[:user_id] = user.id
|
|
71
|
+
cookies[:auth_token] = user.remember_token
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def require_existing_target_folder
|
|
77
|
+
@target_folder = get_folder_or_redirect(params[:folder_id])
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def require_create_permission
|
|
81
|
+
unless current_user.can_create(@target_folder)
|
|
82
|
+
redirect_to @target_folder, :alert => t(:no_permissions_for_this_type, :method => t(:create), :type => t(:this_folder))
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def get_folder_or_redirect(id)
|
|
87
|
+
Folder.find(id)
|
|
88
|
+
rescue ActiveRecord::RecordNotFound
|
|
89
|
+
redirect_to Folder.root, :alert => t(:already_deleted, :type => t(:this_folder))
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Boxroom
|
|
2
|
+
module FoldersHelper
|
|
3
|
+
def breadcrumbs(folder, breadcrumbs = '')
|
|
4
|
+
breadcrumbs = "<li>#{link_to(folder.parent.name, folder.parent)}</li> #{breadcrumbs}"
|
|
5
|
+
breadcrumbs = breadcrumbs(folder.parent, breadcrumbs) unless folder.parent == Folder.root
|
|
6
|
+
breadcrumbs.html_safe
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def file_icon(extension)
|
|
10
|
+
if extension && FileTest.exists?(Rails.root.join('app', 'assets', 'images', 'fileicons', "#{extension.downcase}.png"))
|
|
11
|
+
"boxroom/fileicons/#{extension.downcase}.png"
|
|
12
|
+
else
|
|
13
|
+
'boxroom/file.png'
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Boxroom
|
|
2
|
+
class UserMailer < ActionMailer::Base
|
|
3
|
+
def signup_email(user)
|
|
4
|
+
@user = user
|
|
5
|
+
mail(:to => user.email, :subject => t(:signup_email_subject))
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def reset_password_email(user)
|
|
9
|
+
@user = user
|
|
10
|
+
mail(:to => user.email, :subject => t(:reset_password_email_subject))
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def share_link_email(share_link)
|
|
14
|
+
@share_link = share_link
|
|
15
|
+
mail(:to => share_link.user.email, :reply_to => share_link.user.email, :bcc => share_link.emails, :subject => t(:share_link_email_subject, :email => share_link.user.email))
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module Boxroom
|
|
2
|
+
class Clipboard
|
|
3
|
+
def initialize
|
|
4
|
+
setup
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def folders
|
|
8
|
+
Folder.where(:id => @folders)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def files
|
|
12
|
+
UserFile.where(:id => @files)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def add(item)
|
|
16
|
+
if item.class == Folder
|
|
17
|
+
@folders << item.id unless @folders.include?(item.id)
|
|
18
|
+
else
|
|
19
|
+
@files << item.id unless @files.include?(item.id)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def remove(item)
|
|
24
|
+
if item.class == Folder
|
|
25
|
+
@folders.delete(item.id)
|
|
26
|
+
else
|
|
27
|
+
@files.delete(item.id)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def empty?
|
|
32
|
+
(@folders.empty? || folders.empty?) && (@files.empty? || files.empty?)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def reset
|
|
36
|
+
setup
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def setup
|
|
42
|
+
@folders, @files = [], []
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|