phcscriptcdn 48.0.0 → 49.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -2
  3. data/app/assets/javascripts/phcscriptcdn/application.js +2 -2
  4. data/app/assets/stylesheets/phcscriptcdn/application.scss +2 -2
  5. data/app/controllers/phcscriptcdn/application_controller.rb +20 -10
  6. data/app/controllers/phcscriptcdn/script/authors_controller.rb +19 -8
  7. data/app/controllers/phcscriptcdn/script/extensions_controller.rb +17 -6
  8. data/app/controllers/phcscriptcdn/script/licences_controller.rb +16 -5
  9. data/app/controllers/phcscriptcdn/script/listings_controller.rb +15 -6
  10. data/app/controllers/phcscriptcdn/script/urls_controller.rb +13 -4
  11. data/app/controllers/phcscriptcdn/script/versions_controller.rb +15 -4
  12. data/app/helpers/phcscriptcdn/application_helper.rb +0 -10
  13. data/app/helpers/phcscriptcdn/script/authors_helper.rb +4 -0
  14. data/app/helpers/phcscriptcdn/script/extensions_helper.rb +4 -0
  15. data/app/helpers/phcscriptcdn/script/licences_helper.rb +4 -0
  16. data/app/helpers/phcscriptcdn/script/listings_helper.rb +4 -0
  17. data/app/helpers/phcscriptcdn/script/urls_helper.rb +4 -0
  18. data/app/helpers/phcscriptcdn/script/versions_helper.rb +4 -0
  19. data/app/jobs/phcscriptcdn/application_job.rb +2 -2
  20. data/app/mailers/phcscriptcdn/application_mailer.rb +6 -0
  21. data/app/models/phcscriptcdn/application_record.rb +5 -3
  22. data/app/models/phcscriptcdn/script.rb +7 -5
  23. data/app/models/phcscriptcdn/script/author.rb +0 -7
  24. data/app/models/phcscriptcdn/script/listing.rb +3 -13
  25. data/app/models/phcscriptcdn/script/url.rb +2 -2
  26. data/app/models/phcscriptcdn/script/version.rb +1 -1
  27. data/app/views/layouts/phcscriptcdn/application.html.erb +64 -41
  28. data/app/views/layouts/phcscriptcdn/components/backend/footer/_footer.html.erb +9 -4
  29. data/app/views/layouts/phcscriptcdn/components/backend/navigation/_top_menu.html.erb +78 -0
  30. data/app/views/layouts/phcscriptcdn/components/backend/sidebars/_side_menu.html.erb +154 -0
  31. data/app/views/phcscriptcdn/script/authors/_form.html.erb +15 -20
  32. data/app/views/phcscriptcdn/script/authors/edit.html.erb +32 -32
  33. data/app/views/phcscriptcdn/script/authors/index.html.erb +50 -60
  34. data/app/views/phcscriptcdn/script/authors/new.html.erb +33 -32
  35. data/app/views/phcscriptcdn/script/authors/show.html.erb +42 -32
  36. data/app/views/phcscriptcdn/script/extensions/_form.html.erb +13 -14
  37. data/app/views/phcscriptcdn/script/extensions/edit.html.erb +32 -31
  38. data/app/views/phcscriptcdn/script/extensions/index.html.erb +45 -52
  39. data/app/views/phcscriptcdn/script/extensions/new.html.erb +31 -30
  40. data/app/views/phcscriptcdn/script/extensions/show.html.erb +41 -31
  41. data/app/views/phcscriptcdn/script/licences/_form.html.erb +21 -21
  42. data/app/views/phcscriptcdn/script/licences/edit.html.erb +31 -31
  43. data/app/views/phcscriptcdn/script/licences/index.html.erb +55 -62
  44. data/app/views/phcscriptcdn/script/licences/new.html.erb +31 -31
  45. data/app/views/phcscriptcdn/script/licences/show.html.erb +41 -31
  46. data/app/views/phcscriptcdn/script/listings/_form.html.erb +27 -28
  47. data/app/views/phcscriptcdn/script/listings/edit.html.erb +29 -30
  48. data/app/views/phcscriptcdn/script/listings/index.html.erb +45 -54
  49. data/app/views/phcscriptcdn/script/listings/new.html.erb +28 -30
  50. data/app/views/phcscriptcdn/script/listings/show.html.erb +38 -28
  51. data/app/views/phcscriptcdn/script/urls/_form.html.erb +13 -14
  52. data/app/views/phcscriptcdn/script/urls/edit.html.erb +17 -30
  53. data/app/views/phcscriptcdn/script/urls/index.html.erb +47 -54
  54. data/app/views/phcscriptcdn/script/urls/new.html.erb +31 -31
  55. data/app/views/phcscriptcdn/script/urls/show.html.erb +41 -30
  56. data/app/views/phcscriptcdn/script/versions/_form.html.erb +9 -10
  57. data/app/views/phcscriptcdn/script/versions/edit.html.erb +31 -31
  58. data/app/views/phcscriptcdn/script/versions/index.html.erb +43 -50
  59. data/app/views/phcscriptcdn/script/versions/new.html.erb +31 -31
  60. data/app/views/phcscriptcdn/script/versions/show.html.erb +41 -31
  61. data/config/routes.rb +19 -22
  62. data/db/migrate/{20160731205917_create_phcscriptcdn_script_listings.rb → 20160821183652_create_phcscriptcdn_script_listings.rb} +5 -6
  63. data/db/migrate/{20160731210723_create_phcscriptcdn_script_authors.rb → 20160821183714_create_phcscriptcdn_script_authors.rb} +1 -2
  64. data/db/migrate/{20160731205205_create_phcscriptcdn_script_extensions.rb → 20160821183735_create_phcscriptcdn_script_extensions.rb} +1 -1
  65. data/db/migrate/{20160801032225_create_phcscriptcdn_script_licences.rb → 20160821183805_create_phcscriptcdn_script_licences.rb} +1 -1
  66. data/db/migrate/{20160731210626_create_phcscriptcdn_script_urls.rb → 20160821183830_create_phcscriptcdn_script_urls.rb} +5 -5
  67. data/db/migrate/{20160731205954_create_phcscriptcdn_script_versions.rb → 20160821183946_create_phcscriptcdn_script_versions.rb} +1 -1
  68. data/db/migrate/20170517064049_create_phcscriptcdn_listing_versions.rb +1 -0
  69. data/db/migrate/20170517064114_create_phcscriptcdn_scriptversion_versions.rb +1 -0
  70. data/db/migrate/20170517064150_create_phcscriptcdn_url_versions.rb +17 -16
  71. data/db/migrate/20170517064208_create_phcscriptcdn_author_versions.rb +1 -0
  72. data/db/migrate/20170517064427_create_phcscriptcdn_licence_versions.rb +1 -0
  73. data/lib/phcscriptcdn/engine.rb +6 -1
  74. data/lib/phcscriptcdn/version.rb +1 -1
  75. metadata +100 -116
  76. data/app/assets/javascripts/phcscriptcdn/frontend/listings.js +0 -2
  77. data/app/assets/stylesheets/phcscriptcdn/frontend/listings.scss +0 -3
  78. data/app/controllers/phcscriptcdn/frontend/listings_controller.rb +0 -20
  79. data/app/helpers/phcscriptcdn/frontend/listings_helper.rb +0 -4
  80. data/app/models/phcscriptcdn/frontend/listing.rb +0 -8
  81. data/app/views/layouts/phcscriptcdn/components/backend/navigation/_navigation.html.erb +0 -56
  82. data/app/views/layouts/phcscriptcdn/components/backend/topbar/_topbar.html.erb +0 -5
  83. data/app/views/layouts/phcscriptcdn/components/backend/topbar/_topbar_links.html.erb +0 -0
  84. data/app/views/layouts/phcscriptcdn/frontend.html.erb +0 -22
  85. data/app/views/phcscriptcdn/frontend/listings/index.html.erb +0 -46
  86. data/app/views/phcscriptcdn/frontend/listings/show.html.erb +0 -59
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 440dc15290c206b27c165d6f58e25d1ef1a74d61e60ee678efa3078bcd5e0492
4
- data.tar.gz: ef1754391b153ab5947f0dd3739ada2b549fd07a308cb8d2a0a7d0ddc1353052
3
+ metadata.gz: 544e9ea892cf2ef14ea1f76468ab26ef0cbc1a079a861938eb02bf2e1929703e
4
+ data.tar.gz: 244aa5773babb504ca06cd021b099f433145ed1e6a0517aa80c8d97b9f70c105
5
5
  SHA512:
6
- metadata.gz: 473ffe394b57921305bd6fa8146aee1f1273419413edd00349da5d246e6e152bbdaa720634df67eda030afaa1494cc204795cfd73e12c49a53378c5e140465ee
7
- data.tar.gz: 62770878dd0beeadf2d1fe7c92f714c191f9bda991082676cea38732b0c7aecedaa9adbbd8baa9035a9dce97fc8098ffa73b020d8b10969aeeea56b3b5b45896
6
+ metadata.gz: 506b7f7513c1affee5923575a1638a74659a125e72391e96d86284c65fdbaa3b94b05eea640d1c2ff0d26bdbede20a7717d98e100a5f920aaa633576e9dcfcc6
7
+ data.tar.gz: b610b14f4f130654ed6c6b457374a71a19a18856d458fa01c783bafcc445e577d206598f35c9a4dea78390700d5bb54a15094b3fcd9e62f02ee0c1b6b1d61510
data/README.md CHANGED
@@ -31,5 +31,3 @@ To properly function re-compile your application's assets to copy over required
31
31
  All PHCScriptCDN views and layouts can be overwritten by copying files to your application.
32
32
 
33
33
  rails generate phcscriptcdn:views
34
-
35
- #### Additional Information
@@ -1,2 +1,2 @@
1
- // Load PHCAdmin3 Javascript
2
- //= require phc_admins_main_three
1
+ // Load Admin Theme
2
+ //= require phc_admin_theme_scripts_four
@@ -1,2 +1,2 @@
1
- // Load PHCAdmin3 Styles
2
- @import "phc_admins_style_three";
1
+ // Load Admin Theme
2
+ @import "phc_admin_theme_styles_four";
@@ -1,12 +1,22 @@
1
1
  module Phcscriptcdn
2
- class ApplicationController < ActionController::Base
3
-
4
- # Security
5
- protect_from_forgery with: :exception
6
-
7
- # Load Helpers
8
- helper Phctitleseo::Engine.helpers
9
- helper Phcnotifi::Engine.helpers
10
-
11
- end
2
+ class ApplicationController < ActionController::Base
3
+
4
+ # Security Filters
5
+ protect_from_forgery with: :exception
6
+
7
+ # Load Requried Helper Files
8
+ helper Phccorehelpers::Engine.helpers
9
+ helper Phcmenus::Engine.helpers
10
+ helper Phctitleseo::Engine.helpers
11
+ helper Phcnotifi::Engine.helpers
12
+ helper Phcaccounts::Engine.helpers
13
+
14
+ # Papertrail Whodunnit Username
15
+ def user_for_paper_trail
16
+ current_user ? current_user.username : 'Public user'
17
+ end
18
+
19
+ private
20
+
21
+ end
12
22
  end
@@ -3,21 +3,28 @@ require_dependency "phcscriptcdn/application_controller"
3
3
  module Phcscriptcdn
4
4
  class Script::AuthorsController < ApplicationController
5
5
 
6
- # Filters & Security
6
+ # Include Core Helpers, Security & Action Filters
7
+ include Phccorehelpers::PhcpluginsproHelper
8
+ before_action :authenticate_user!
9
+ before_action :set_paper_trail_whodunnit
7
10
  before_action :set_script_author, only: [:show, :edit, :update, :destroy]
8
11
 
9
12
  # INDEX - Script Author
10
13
  def index
11
- @script_authors = Script::Author.all
14
+ @script_authors = Script::Author.where(org_id: current_user.org_id)
12
15
  end
13
16
 
14
17
  # DETAILS - Script Author
15
18
  def show
19
+ @script_authors = Script::Author.friendly.find(params[:id])
20
+ @versions = Phcscriptcdn::AuthorVersions.where(item_id: params[:id], item_type: 'Phcscriptcdn::Script::Author')
16
21
  end
17
22
 
18
23
  # NEW - Script Author
19
24
  def new
20
25
  @script_author = Script::Author.new
26
+ @script_author.user_id = current_user.id
27
+ @script_author.org_id = current_user.org_id
21
28
  end
22
29
 
23
30
  # EDIT - Script Author
@@ -27,19 +34,23 @@ module Phcscriptcdn
27
34
  # CREATE - Script Author
28
35
  def create
29
36
  @script_author = Script::Author.new(script_author_params)
37
+ @script_author.user_id = current_user.id
38
+ @script_author.org_id = current_user.org_id
30
39
  if @script_author.save
31
40
  redirect_to script_authors_url, notice: 'Author was successfully created.'
32
41
  else
33
- render :new
42
+ render :new
34
43
  end
35
44
  end
36
45
 
37
46
  # PATCH/PUT - Script Author
38
47
  def update
48
+ @script_author.user_id = current_user.id
49
+ @script_author.org_id = current_user.org_id
39
50
  if @script_author.update(script_author_params)
40
- redirect_to script_authors_url, notice: 'Author was successfully updated.'
41
- else
42
- render :edit
51
+ redirect_to script_authors_url, notice: 'Author was successfully updated.'
52
+ else
53
+ render :edit
43
54
  end
44
55
  end
45
56
 
@@ -53,12 +64,12 @@ module Phcscriptcdn
53
64
 
54
65
  # Common Callbacks
55
66
  def set_script_author
56
- @script_author = Script::Author.find(params[:id])
67
+ @script_author = Script::Author.friendly.find(params[:id])
57
68
  end
58
69
 
59
70
  # Whitelist
60
71
  def script_author_params
61
- params.require(:script_author).permit(:authorfirstname, :authorlastname, :authorwebsite, :authorgithub, :authortwitter, :slug, :user_id, :user_name)
72
+ params.require(:script_author).permit(:authorfirstname, :authorlastname, :authorwebsite, :authorgithub, :slug, :user_id, :org_id, :listing_id)
62
73
  end
63
74
 
64
75
  end
@@ -3,21 +3,28 @@ require_dependency "phcscriptcdn/application_controller"
3
3
  module Phcscriptcdn
4
4
  class Script::ExtensionsController < ApplicationController
5
5
 
6
- # Filters & Security
6
+ # Include Core Helpers, Security & Action Filters
7
+ include Phccorehelpers::PhcpluginsproHelper
8
+ before_action :authenticate_user!
9
+ before_action :set_paper_trail_whodunnit
7
10
  before_action :set_script_extension, only: [:show, :edit, :update, :destroy]
8
11
 
9
12
  # INDEX - Script Extension
10
13
  def index
11
- @script_extensions = Script::Extension.all
14
+ @script_extensions = Script::Extension.where(org_id: current_user.org_id)
12
15
  end
13
16
 
14
17
  # DETAILS - Script Extension
15
18
  def show
19
+ @script_extensions = Script::Extension.friendly.find(params[:id])
20
+ @versions = Phcscriptcdn::ExtensionVersions.where(item_id: params[:id], item_type: 'Phcscriptcdn::Script::Extension')
16
21
  end
17
22
 
18
23
  # NEW - Script Extension
19
24
  def new
20
25
  @script_extension = Script::Extension.new
26
+ @script_extension.user_id = current_user.id
27
+ @script_extension.org_id = current_user.org_id
21
28
  end
22
29
 
23
30
  # EDIT - Script Extension
@@ -27,15 +34,19 @@ module Phcscriptcdn
27
34
  # CREATE - Script Extension
28
35
  def create
29
36
  @script_extension = Script::Extension.new(script_extension_params)
37
+ @script_extension.user_id = current_user.id
38
+ @script_extension.org_id = current_user.org_id
30
39
  if @script_extension.save
31
40
  redirect_to script_extensions_url, notice: 'Extension was successfully created.'
32
41
  else
33
- render :new
42
+ render :new
34
43
  end
35
44
  end
36
45
 
37
46
  # PATCH/PUT - Script Extension
38
47
  def update
48
+ @script_extension.user_id = current_user.id
49
+ @script_extension.org_id = current_user.org_id
39
50
  if @script_extension.update(script_extension_params)
40
51
  redirect_to script_extensions_url, notice: 'Extension was successfully updated.'
41
52
  else
@@ -45,7 +56,7 @@ module Phcscriptcdn
45
56
 
46
57
  # DELETE - Script Extension
47
58
  def destroy
48
- @script_extension.destroy
59
+ @script_extension.destroy
49
60
  redirect_to script_extensions_url, notice: 'Extension was successfully destroyed.'
50
61
  end
51
62
 
@@ -53,12 +64,12 @@ module Phcscriptcdn
53
64
 
54
65
  # Common Callbacks
55
66
  def set_script_extension
56
- @script_extension = Script::Extension.find(params[:id])
67
+ @script_extension = Script::Extension.friendly.find(params[:id])
57
68
  end
58
69
 
59
70
  # Whitelists
60
71
  def script_extension_params
61
- params.require(:script_extension).permit(:scriptextensionname, :scriptextensiondes, :scriptextension, :slug, :user_id, :user_name)
72
+ params.require(:script_extension).permit(:scriptextensionname, :scriptextensiondes, :scriptextension, :slug, :user_id, :org_id, :listing_id)
62
73
  end
63
74
 
64
75
  end
@@ -3,21 +3,28 @@ require_dependency "phcscriptcdn/application_controller"
3
3
  module Phcscriptcdn
4
4
  class Script::LicencesController < ApplicationController
5
5
 
6
- # Filters & Security
6
+ # Include Core Helpers, Security & Action Filters
7
+ include Phccorehelpers::PhcpluginsproHelper
8
+ before_action :authenticate_user!
9
+ before_action :set_paper_trail_whodunnit
7
10
  before_action :set_script_licence, only: [:show, :edit, :update, :destroy]
8
11
 
9
12
  # INDEX - Script Licences
10
13
  def index
11
- @script_licences = Script::Licence.all
14
+ @script_licences = Script::Licence.where(org_id: current_user.org_id)
12
15
  end
13
16
 
14
17
  # DETAILS - Script Licences
15
18
  def show
19
+ @script_licences = Script::Licence.friendly.find(params[:id])
20
+ @versions = Phcscriptcdn::LicenceVersions.where(item_id: params[:id], item_type: 'Phcscriptcdn::Script::Licence')
16
21
  end
17
22
 
18
23
  # NEW - Script Licences
19
24
  def new
20
25
  @script_licence = Script::Licence.new
26
+ @script_licence.user_id = current_user.id
27
+ @script_licence.org_id = current_user.org_id
21
28
  end
22
29
 
23
30
  # EDIT - Script Licences
@@ -27,15 +34,19 @@ module Phcscriptcdn
27
34
  # POST - Script Licences
28
35
  def create
29
36
  @script_licence = Script::Licence.new(script_licence_params)
37
+ @script_licence.user_id = current_user.id
38
+ @script_licence.org_id = current_user.org_id
30
39
  if @script_licence.save
31
40
  redirect_to script_licences_url, notice: 'Licence was successfully created.'
32
41
  else
33
- render :new
42
+ render :new
34
43
  end
35
44
  end
36
45
 
37
46
  # PATCH/PUT - Script Licences
38
47
  def update
48
+ @script_licence.user_id = current_user.id
49
+ @script_licence.org_id = current_user.org_id
39
50
  if @script_licence.update(script_licence_params)
40
51
  redirect_to script_licences_url, notice: 'Licence was successfully updated.'
41
52
  else
@@ -53,12 +64,12 @@ module Phcscriptcdn
53
64
 
54
65
  # Common Callbacks
55
66
  def set_script_licence
56
- @script_licence = Script::Licence.find(params[:id])
67
+ @script_licence = Script::Licence.friendly.find(params[:id])
57
68
  end
58
69
 
59
70
  # Whitelists
60
71
  def script_licence_params
61
- params.require(:script_licence).permit(:lcncname, :lcncdescription, :lcncdescript, :lcnccomgpl, :lcncarvlfsf, :lcncarvlosi, :lcncarvlcopyfree, :lcncarvldebian, :lcncarvlfedora, :slug, :user_id, :user_name)
72
+ params.require(:script_licence).permit(:lcncname, :lcncdescription, :lcncdescript, :lcnccomgpl, :lcncarvlfsf, :lcncarvlosi, :lcncarvlcopyfree, :lcncarvldebian, :lcncarvlfedora, :slug, :user_id, :org_id, :listing_id)
62
73
  end
63
74
 
64
75
  end
@@ -3,16 +3,21 @@ require_dependency "phcscriptcdn/application_controller"
3
3
  module Phcscriptcdn
4
4
  class Script::ListingsController < ApplicationController
5
5
 
6
- # Filters & Security
6
+ # Include Core Helpers, Security & Action Filters
7
+ include Phccorehelpers::PhcpluginsproHelper
8
+ before_action :authenticate_user!
9
+ before_action :set_paper_trail_whodunnit
7
10
  before_action :set_script_listing, only: [:show, :edit, :update, :destroy]
8
11
 
9
12
  # INDEX - Script Listings
10
13
  def index
11
- @script_listings = Script::Listing.all
14
+ @script_listings = Script::Listing.where(org_id: current_user.org_id)
12
15
  end
13
16
 
14
17
  # DETAILS - Script Listings
15
18
  def show
19
+ @script_listings = Script::Listing.friendly.find(params[:id])
20
+ @versions = Phcscriptcdn::ListingVersions.where(item_id: params[:id], item_type: 'Phcscriptcdn::Script::Listing')
16
21
  end
17
22
 
18
23
  # NEW - Script Listings
@@ -27,6 +32,8 @@ module Phcscriptcdn
27
32
  # POST - Script Listings
28
33
  def create
29
34
  @script_listing = Script::Listing.new(script_listing_params)
35
+ @script_listing.user_id = current_user.id
36
+ @script_listing.org_id = current_user.org_id
30
37
  if @script_listing.save
31
38
  redirect_to script_listings_path, notice: 'Listing was successfully created.'
32
39
  else
@@ -36,10 +43,12 @@ module Phcscriptcdn
36
43
 
37
44
  # PATCH/PUT - Script Listings
38
45
  def update
46
+ @script_listing.user_id = current_user.id
47
+ @script_listing.org_id = current_user.org_id
39
48
  if @script_listing.update(script_listing_params)
40
49
  redirect_to script_listings_path, notice: 'Listing was successfully updated.'
41
- else
42
- render :edit
50
+ else
51
+ render :edit
43
52
  end
44
53
  end
45
54
 
@@ -53,12 +62,12 @@ module Phcscriptcdn
53
62
 
54
63
  # Common Callbacks
55
64
  def set_script_listing
56
- @script_listing = Script::Listing.find(params[:id])
65
+ @script_listing = Script::Listing.friendly.find(params[:id])
57
66
  end
58
67
 
59
68
  # Whitelist
60
69
  def script_listing_params
61
- params.require(:script_listing).permit(:scripttitle, :scriptdescription, :descriptionsource, :scriptwebsite, :scripttwitter, :scriptgithub, :scriptinitialrelease, :scriptlastestrelease, :scriptbetarelease, :scriptstatus, :slug, :user_id, :user_name, :version_id, :author_id, :licence_id)
70
+ params.require(:script_listing).permit(:scripttitle, :scriptdescription, :descriptionsource, :scriptwebsite, :scriptgithub, :scriptinitialrelease, :scriptlastestrelease, :scriptbetarelease, :scriptlastestreleasecdn, :scriptstatus, :slug, :user_id, :org_id, :version_id, :author_id, :licence_id)
62
71
  end
63
72
 
64
73
  end
@@ -3,7 +3,10 @@ require_dependency "phcscriptcdn/application_controller"
3
3
  module Phcscriptcdn
4
4
  class Script::UrlsController < ApplicationController
5
5
 
6
- # Filters & Security
6
+ # Include Core Helpers, Security & Action Filters
7
+ include Phccorehelpers::PhcpluginsproHelper
8
+ before_action :authenticate_user!
9
+ before_action :set_paper_trail_whodunnit
7
10
  before_action :set_script_url, only: [:show, :edit, :update, :destroy]
8
11
 
9
12
  # INDEX - Script Authors
@@ -15,13 +18,15 @@ module Phcscriptcdn
15
18
  # DETAILED PROFILE - Script Authors
16
19
  def show
17
20
  script_listing = Script::Listing.find(params[:listing_id])
18
- @script_url = script_listing.urls.find(params[:id])
21
+ @script_url = script_listing.urls.friendly.find(params[:id])
19
22
  end
20
23
 
21
24
  # NEW - Script Athors
22
25
  def new
23
26
  script_listing = Script::Listing.find(params[:listing_id])
24
27
  @script_url = script_listing.urls.build
28
+ @script_url.user_id = current_user.id
29
+ @script_url.org_id = current_user.org_id
25
30
  end
26
31
 
27
32
  # EDIT - Script Athors
@@ -34,6 +39,8 @@ module Phcscriptcdn
34
39
  def create
35
40
  @script_listing = Script::Listing.find(params[:listing_id])
36
41
  @script_url = @script_listing.urls.create(script_url_params)
42
+ @script_url.user_id = current_user.id
43
+ @script_url.org_id = current_user.org_id
37
44
  if @script_url.save
38
45
  redirect_to script_listing_urls_path, notice: 'Author was successfully created.'
39
46
  else
@@ -43,6 +50,8 @@ module Phcscriptcdn
43
50
 
44
51
  # PATCH/PUT - Script Athors
45
52
  def update
53
+ @script_url.user_id = current_user.id
54
+ @script_url.org_id = current_user.org_id
46
55
  if @script_url.update(script_url_params)
47
56
  redirect_to script_listing_urls_path, notice: 'Author was successfully updated.'
48
57
  else
@@ -62,12 +71,12 @@ module Phcscriptcdn
62
71
 
63
72
  # Common Callbacks
64
73
  def set_script_url
65
- @script_url = Script::Url.find(params[:id])
74
+ @script_url = Script::Url.friendly.find(params[:id])
66
75
  end
67
76
 
68
77
  # Whitelists
69
78
  def script_url_params
70
- params.require(:script_url).permit(:scripturl, :scripturlrelease, :scripturlcdnupdate, :slug, :user_id, :user_name, :listing_id, :version_id, :extension_id)
79
+ params.require(:script_url).permit(:scripturl, :scripturlrelease, :scripturlcdnupdate, :slug, :user_id, :org_id, :listing_id, :version_id, :extension_id)
71
80
  end
72
81
 
73
82
  end
@@ -3,21 +3,28 @@ require_dependency "phcscriptcdn/application_controller"
3
3
  module Phcscriptcdn
4
4
  class Script::VersionsController < ApplicationController
5
5
 
6
- # Filters & Security
6
+ # Include Core Helpers, Security & Action Filters
7
+ include Phccorehelpers::PhcpluginsproHelper
8
+ before_action :authenticate_user!
9
+ before_action :set_paper_trail_whodunnit
7
10
  before_action :set_script_version, only: [:show, :edit, :update, :destroy]
8
11
 
9
12
  # INDEX - Script Versions
10
13
  def index
11
- @script_versions = Script::Version.all
14
+ @script_versions = Script::Version.where(org_id: current_user.org_id)
12
15
  end
13
16
 
14
17
  # DETAILS - Script Versions
15
18
  def show
19
+ @script_versions = Script::Version.friendly.find(params[:id])
20
+ @versions = Phcscriptcdn::ScriptversionVersions.where(item_id: params[:id], item_type: 'Phcscriptcdn::Script::Version')
16
21
  end
17
22
 
18
23
  # NEW - Script Versions
19
24
  def new
20
25
  @script_version = Script::Version.new
26
+ @script_version.user_id = current_user.id
27
+ @script_version.org_id = current_user.org_id
21
28
  end
22
29
 
23
30
  # EDIT - Script Versions
@@ -27,6 +34,8 @@ module Phcscriptcdn
27
34
  # POST - Script Versions
28
35
  def create
29
36
  @script_version = Script::Version.new(script_version_params)
37
+ @script_version.user_id = current_user.id
38
+ @script_version.org_id = current_user.org_id
30
39
  if @script_version.save
31
40
  redirect_to script_versions_url, notice: 'Version was successfully created.'
32
41
  else
@@ -36,6 +45,8 @@ module Phcscriptcdn
36
45
 
37
46
  # PATCH/PUT - Script Versions
38
47
  def update
48
+ @script_version.user_id = current_user.id
49
+ @script_version.org_id = current_user.org_id
39
50
  if @script_version.update(script_version_params)
40
51
  redirect_to script_versions_url, notice: 'Version was successfully updated.'
41
52
  else
@@ -53,12 +64,12 @@ module Phcscriptcdn
53
64
 
54
65
  # Common Callbacks
55
66
  def set_script_version
56
- @script_version = Script::Version.find(params[:id])
67
+ @script_version = Script::Version.friendly.find(params[:id])
57
68
  end
58
69
 
59
70
  # Only allow a trusted parameter "white list" through.
60
71
  def script_version_params
61
- params.require(:script_version).permit(:scriptversion, :slug, :user_id, :user_name)
72
+ params.require(:script_version).permit(:scriptversion, :slug, :user_id, :org_id, :listing_id)
62
73
  end
63
74
 
64
75
  end