zen 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +15 -0
- data/.mailmap +2 -0
- data/.rvmrc +2 -0
- data/.travis.yml +8 -3
- data/AUTHORS +1 -2
- data/CHANGELOG.md +48 -17
- data/README.md +44 -39
- data/Rakefile +4 -0
- data/bin/zen +5 -30
- data/lib/zen.rb +13 -19
- data/lib/zen/asset.rb +99 -64
- data/lib/zen/bin/create.rb +94 -0
- data/lib/zen/bin/runner.rb +118 -0
- data/lib/zen/controller/admin_controller.rb +52 -36
- data/lib/zen/controller/base_controller.rb +5 -5
- data/lib/zen/controller/frontend_controller.rb +7 -7
- data/lib/zen/controller/main_controller.rb +12 -10
- data/lib/zen/controller/preview.rb +15 -11
- data/lib/zen/helper/acl.rb +73 -53
- data/lib/zen/helper/blue_form_vendor.rb +689 -0
- data/lib/zen/helper/breadcrumb.rb +23 -19
- data/lib/zen/helper/message.rb +3 -3
- data/lib/zen/helper/theme.rb +18 -13
- data/lib/zen/language.rb +62 -58
- data/lib/zen/language/en/zen_general.yml +2 -4
- data/lib/zen/language/nl/zen_general.yml +2 -4
- data/lib/zen/layout/admin.xhtml +3 -12
- data/lib/zen/layout/login.xhtml +1 -6
- data/lib/zen/model/methods.rb +6 -6
- data/lib/zen/model/settings.rb +5 -4
- data/lib/zen/package.rb +47 -38
- data/lib/zen/package/all.rb +3 -5
- data/lib/zen/package/base.rb +7 -7
- data/lib/zen/package/categories/lib/categories.rb +8 -3
- data/lib/zen/package/categories/lib/categories/controller/categories.rb +81 -55
- data/lib/zen/package/categories/lib/categories/controller/category_groups.rb +45 -44
- data/lib/zen/package/categories/lib/categories/helper/category.rb +88 -0
- data/lib/zen/package/categories/lib/categories/language/en/categories.yml +5 -4
- data/lib/zen/package/categories/lib/categories/language/en/category_groups.yml +5 -4
- data/lib/zen/package/categories/lib/categories/language/nl/categories.yml +5 -4
- data/lib/zen/package/categories/lib/categories/language/nl/category_groups.yml +5 -4
- data/lib/zen/package/categories/lib/categories/model/category.rb +15 -13
- data/lib/zen/package/categories/lib/categories/model/category_group.rb +3 -3
- data/lib/zen/package/categories/lib/categories/plugin/categories.rb +36 -25
- data/lib/zen/package/categories/lib/categories/view/admin/categories/form.xhtml +49 -56
- data/lib/zen/package/categories/lib/categories/view/admin/categories/index.xhtml +48 -35
- data/lib/zen/package/categories/lib/categories/view/admin/category-groups/form.xhtml +36 -29
- data/lib/zen/package/categories/lib/categories/view/admin/category-groups/index.xhtml +42 -37
- data/lib/zen/package/comments/lib/comments.rb +4 -1
- data/lib/zen/package/comments/lib/comments/controller/comments.rb +39 -32
- data/lib/zen/package/comments/lib/comments/controller/comments_form.rb +45 -26
- data/lib/zen/package/comments/lib/comments/helper/comment.rb +35 -0
- data/lib/zen/package/comments/lib/comments/language/en/comments.yml +9 -7
- data/lib/zen/package/comments/lib/comments/language/nl/comments.yml +10 -8
- data/lib/zen/package/comments/lib/comments/model/comment.rb +31 -17
- data/lib/zen/package/comments/lib/comments/model/comment_status.rb +15 -0
- data/lib/zen/package/comments/lib/comments/plugin/anti_spam.rb +27 -18
- data/lib/zen/package/comments/lib/comments/plugin/comments.rb +25 -20
- data/lib/zen/package/comments/lib/comments/view/admin/comments/form.xhtml +61 -54
- data/lib/zen/package/comments/lib/comments/view/admin/comments/index.xhtml +38 -23
- data/lib/zen/package/comments/migrations/1308774099_comment_status.rb +60 -0
- data/lib/zen/package/custom_fields/lib/custom_fields.rb +33 -7
- data/lib/zen/package/custom_fields/lib/custom_fields/blue_form_parameters.rb +209 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_groups.rb +50 -47
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_types.rb +215 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_fields.rb +111 -73
- data/lib/zen/package/custom_fields/lib/custom_fields/helper/custom_field.rb +79 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_field_groups.yml +20 -19
- data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_field_types.yml +40 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_fields.yml +34 -32
- data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_field_groups.yml +5 -4
- data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_field_types.yml +40 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_fields.yml +18 -16
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field.rb +31 -11
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_method.rb +15 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_type.rb +50 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb +28 -7
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/form.xhtml +33 -28
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/index.xhtml +48 -46
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-types/form.xhtml +61 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-types/index.xhtml +93 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/form.xhtml +105 -99
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/index.xhtml +43 -39
- data/lib/zen/package/custom_fields/migrations/1295255665_create_schema.rb +47 -16
- data/lib/zen/package/custom_fields/migrations/1310659580_custom_field_types.rb +148 -0
- data/lib/zen/package/custom_fields/migrations/1311694920_rename_css_class.rb +11 -0
- data/lib/zen/package/menus/lib/menus/controller/menu_items.rb +40 -35
- data/lib/zen/package/menus/lib/menus/controller/menus.rb +47 -43
- data/lib/zen/package/menus/lib/menus/helper/{menu_item.rb → menu.rb} +42 -15
- data/lib/zen/package/menus/lib/menus/language/en/menu_items.yml +5 -5
- data/lib/zen/package/menus/lib/menus/language/en/menus.yml +9 -8
- data/lib/zen/package/menus/lib/menus/language/nl/menu_items.yml +8 -8
- data/lib/zen/package/menus/lib/menus/language/nl/menus.yml +11 -10
- data/lib/zen/package/menus/lib/menus/model/menu.rb +5 -5
- data/lib/zen/package/menus/lib/menus/model/menu_item.rb +6 -5
- data/lib/zen/package/menus/lib/menus/plugin/menus.rb +41 -43
- data/lib/zen/package/menus/lib/menus/view/admin/menu-items/form.xhtml +59 -63
- data/lib/zen/package/menus/lib/menus/view/admin/menu-items/index.xhtml +35 -30
- data/lib/zen/package/menus/lib/menus/view/admin/menus/form.xhtml +46 -37
- data/lib/zen/package/menus/lib/menus/view/admin/menus/index.xhtml +37 -37
- data/lib/zen/package/menus/migrations/1297184342_create_schema.rb +5 -5
- data/lib/zen/package/menus/migrations/1308671733_rename_order_column.rb +11 -0
- data/lib/zen/package/menus/migrations/1311695030_rename_css_class.rb +17 -0
- data/lib/zen/package/sections/lib/sections.rb +18 -11
- data/lib/zen/package/sections/lib/sections/controller/section_entries.rb +115 -109
- data/lib/zen/package/sections/lib/sections/controller/sections.rb +72 -50
- data/lib/zen/package/sections/lib/sections/helper/section.rb +53 -0
- data/lib/zen/package/sections/lib/sections/language/en/section_entries.yml +5 -4
- data/lib/zen/package/sections/lib/sections/language/en/sections.yml +5 -4
- data/lib/zen/package/sections/lib/sections/language/nl/section_entries.yml +5 -4
- data/lib/zen/package/sections/lib/sections/language/nl/sections.yml +5 -4
- data/lib/zen/package/sections/lib/sections/model/section.rb +17 -9
- data/lib/zen/package/sections/lib/sections/model/section_entry.rb +192 -13
- data/lib/zen/package/sections/lib/sections/model/section_entry_status.rb +13 -0
- data/lib/zen/package/sections/lib/sections/plugin/section_entries.rb +60 -39
- data/lib/zen/package/sections/lib/sections/plugin/sections.rb +14 -11
- data/lib/zen/package/sections/lib/sections/view/admin/form.xhtml +100 -97
- data/lib/zen/package/sections/lib/sections/view/admin/index.xhtml +41 -39
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/form.xhtml +95 -215
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/index.xhtml +48 -40
- data/lib/zen/package/sections/migrations/1308672298_use_id_for_default_section.rb +40 -0
- data/lib/zen/package/sections/migrations/1308813320_section_entry_statuses.rb +58 -0
- data/lib/zen/package/settings/lib/settings/controller/settings.rb +5 -8
- data/lib/zen/package/settings/lib/settings/model/setting.rb +2 -37
- data/lib/zen/package/settings/lib/settings/plugin/setting_base.rb +18 -1
- data/lib/zen/package/settings/lib/settings/plugin/settings.rb +13 -7
- data/lib/zen/package/settings/lib/settings/view/admin/settings/index.xhtml +2 -1
- data/lib/zen/package/users/lib/users.rb +3 -1
- data/lib/zen/package/users/lib/users/controller/access_rules.rb +77 -60
- data/lib/zen/package/users/lib/users/controller/user_groups.rb +41 -36
- data/lib/zen/package/users/lib/users/controller/users.rb +48 -42
- data/lib/zen/package/users/lib/users/helper/users.rb +72 -0
- data/lib/zen/package/users/lib/users/language/en/access_rules.yml +6 -5
- data/lib/zen/package/users/lib/users/language/en/user_groups.yml +5 -4
- data/lib/zen/package/users/lib/users/language/en/users.yml +1 -0
- data/lib/zen/package/users/lib/users/language/nl/access_rules.yml +5 -4
- data/lib/zen/package/users/lib/users/language/nl/user_groups.yml +5 -4
- data/lib/zen/package/users/lib/users/language/nl/users.yml +1 -0
- data/lib/zen/package/users/lib/users/model/access_rule.rb +5 -1
- data/lib/zen/package/users/lib/users/model/user.rb +17 -10
- data/lib/zen/package/users/lib/users/public/admin/js/users/access_rules.js +10 -37
- data/lib/zen/package/users/lib/users/public/admin/js/users/lib/access_rules.js +49 -0
- data/lib/zen/package/users/lib/users/view/admin/access-rules/form.xhtml +105 -96
- data/lib/zen/package/users/lib/users/view/admin/access-rules/index.xhtml +48 -41
- data/lib/zen/package/users/lib/users/view/admin/user-groups/form.xhtml +42 -32
- data/lib/zen/package/users/lib/users/view/admin/user-groups/index.xhtml +43 -38
- data/lib/zen/package/users/lib/users/view/admin/users/form.xhtml +76 -67
- data/lib/zen/package/users/lib/users/view/admin/users/index.xhtml +43 -41
- data/lib/zen/package/users/lib/users/view/admin/users/login.xhtml +12 -9
- data/lib/zen/package/users/migrations/1295281013_create_schema.rb +2 -2
- data/lib/zen/plugin.rb +56 -50
- data/lib/zen/plugin/markup/lib/markup/markup.rb +33 -21
- data/lib/zen/public/admin/css/zen/buttons.css +11 -7
- data/lib/zen/public/admin/css/zen/datepicker.css +6 -6
- data/lib/zen/public/admin/css/zen/forms.css +2 -1
- data/lib/zen/public/admin/css/zen/general.css +15 -10
- data/lib/zen/public/admin/css/zen/layout.css +51 -20
- data/lib/zen/public/admin/css/zen/tables.css +39 -11
- data/lib/zen/public/admin/css/zen/tabs.css +6 -4
- data/lib/zen/public/admin/css/zen/window.css +11 -11
- data/lib/zen/public/{favicon.ico → admin/favicon.ico} +0 -0
- data/lib/zen/public/admin/images/zen/icons/asc.png +0 -0
- data/lib/zen/public/admin/images/zen/icons/desc.png +0 -0
- data/lib/zen/public/admin/js/vendor/datepicker.js +0 -11
- data/lib/zen/public/admin/js/{mootools → vendor/mootools}/core.js +0 -1
- data/lib/zen/public/admin/js/{mootools → vendor/mootools}/more.js +100 -29
- data/lib/zen/public/admin/js/zen/index.js +48 -0
- data/lib/zen/public/admin/js/zen/lib/asset.js +111 -0
- data/lib/zen/public/admin/js/zen/{editor.js → lib/editor.js} +107 -127
- data/lib/zen/public/admin/js/zen/{editor → lib/editor}/markdown.js +7 -9
- data/lib/zen/public/admin/js/zen/{editor → lib/editor}/textile.js +7 -9
- data/lib/zen/public/admin/js/zen/lib/html_table.js +143 -0
- data/lib/zen/public/admin/js/zen/{tabs.js → lib/tabs.js} +40 -37
- data/lib/zen/public/admin/js/zen/{window.js → lib/window.js} +24 -20
- data/lib/zen/spec/bacon/color_output.rb +39 -0
- data/lib/zen/spec/helper.rb +152 -0
- data/lib/zen/spec/simplecov.rb +22 -0
- data/lib/zen/task/build.rake +20 -43
- data/lib/zen/task/clean.rake +2 -6
- data/lib/zen/task/db.rake +8 -12
- data/lib/zen/task/package.rake +4 -10
- data/lib/zen/task/plugin.rake +3 -9
- data/lib/zen/task/proto.rake +0 -62
- data/lib/zen/task/test.rake +6 -3
- data/lib/zen/task/theme.rake +4 -11
- data/lib/zen/theme.rb +22 -24
- data/lib/zen/validation.rb +34 -27
- data/lib/zen/version.rb +2 -8
- data/lib/zen/view/head.xhtml +7 -0
- data/lib/zen/view/main.xhtml +7 -22
- data/{proto/package/migrations → pkg}/.gitkeep +0 -0
- data/proto/app/app.rb +1 -0
- data/proto/app/config/config.rb +5 -4
- data/proto/app/config/database.rb +19 -41
- data/proto/app/config/middlewares.rb +32 -29
- data/proto/{package/lib/package/view/admin/package/index.xhtml → app/log/database/dev/.gitkeep} +0 -0
- data/proto/app/log/database/live/.gitkeep +0 -0
- data/spec/Rakefile +26 -0
- data/spec/fixtures/zen/asset.rb +18 -0
- data/spec/fixtures/zen/helper/acl.rb +39 -0
- data/spec/fixtures/zen/helper/message.rb +19 -0
- data/spec/fixtures/zen/language/en/spec.yml +10 -0
- data/spec/fixtures/zen/language/nl/spec.yml +7 -0
- data/spec/fixtures/zen/package.rb +17 -0
- data/spec/fixtures/zen/package/comments/controller/comments_form.rb +27 -0
- data/spec/fixtures/zen/package/settings/plugin/settings.rb +20 -0
- data/spec/fixtures/zen/plugin.rb +7 -0
- data/spec/fixtures/zen/theme/404.xhtml +1 -0
- data/spec/fixtures/zen/theme/default-section/index.xhtml +1 -0
- data/spec/fixtures/zen/theme/helper/404.xhtml +1 -0
- data/spec/fixtures/zen/theme/helper/partial.xhtml +1 -0
- data/spec/fixtures/zen/theme/helper/wrong_partial.xhtml +1 -0
- data/spec/fixtures/zen/theme/partials/partial.xhtml +1 -0
- data/spec/fixtures/zen/theme/theme.rb +11 -0
- data/spec/fixtures/zen/validation.rb +22 -0
- data/spec/helper.rb +41 -0
- data/spec/zen/all.rb +5 -0
- data/spec/zen/asset.rb +97 -0
- data/spec/zen/bin/create.rb +89 -0
- data/spec/zen/bin/runner.rb +47 -0
- data/spec/zen/controller/admin_controller.rb +26 -0
- data/spec/zen/controller/main_controller.rb +81 -0
- data/spec/zen/controller/preview.rb +33 -0
- data/spec/zen/helper/acl.rb +149 -0
- data/spec/zen/helper/breadcrumb.rb +38 -0
- data/spec/zen/helper/message.rb +31 -0
- data/spec/zen/helper/theme.rb +58 -0
- data/spec/zen/language.rb +55 -0
- data/spec/zen/package.rb +23 -0
- data/spec/zen/package/categories/controller/categories.rb +123 -0
- data/spec/zen/package/categories/controller/category_groups.rb +108 -0
- data/spec/zen/package/categories/helper/category.rb +75 -0
- data/spec/zen/package/categories/plugin/categories.rb +92 -0
- data/spec/zen/package/comments/controller/comments.rb +134 -0
- data/spec/zen/package/comments/controller/comments_form.rb +343 -0
- data/spec/zen/package/comments/helper/comment.rb +47 -0
- data/spec/zen/package/comments/plugin/anti_spam.rb +59 -0
- data/spec/zen/package/comments/plugin/comments.rb +107 -0
- data/spec/zen/package/custom_fields/blue_form_parameters.rb +183 -0
- data/spec/zen/package/custom_fields/controller/custom_field_groups.rb +120 -0
- data/spec/zen/package/custom_fields/controller/custom_field_types.rb +169 -0
- data/spec/zen/package/custom_fields/controller/custom_fields.rb +158 -0
- data/spec/zen/package/custom_fields/helper/custom_field.rb +86 -0
- data/spec/zen/package/menus/controller/menu_items.rb +110 -0
- data/spec/zen/package/menus/controller/menus.rb +110 -0
- data/spec/zen/package/menus/helper/menu.rb +75 -0
- data/spec/zen/package/menus/plugin/menus.rb +120 -0
- data/spec/zen/package/sections/controller/section_entries.rb +201 -0
- data/spec/zen/package/sections/controller/sections.rb +116 -0
- data/spec/zen/package/sections/helper/section.rb +74 -0
- data/spec/zen/package/sections/plugin/section_entries.rb +161 -0
- data/spec/zen/package/sections/plugin/sections.rb +75 -0
- data/spec/zen/package/settings/controller/settings.rb +36 -0
- data/spec/zen/package/settings/plugin/settings.rb +33 -0
- data/spec/zen/package/users/controller/access_rules.rb +90 -0
- data/spec/zen/package/users/controller/user_groups.rb +101 -0
- data/spec/zen/package/users/controller/users.rb +130 -0
- data/spec/zen/package/users/helper/users.rb +97 -0
- data/spec/zen/plugin.rb +64 -0
- data/spec/zen/plugin/helper.rb +11 -0
- data/spec/zen/plugin/markup.rb +44 -0
- data/spec/zen/theme.rb +41 -0
- data/spec/zen/validation.rb +63 -0
- data/zen.gemspec +36 -0
- metadata +159 -113
- data/MANIFEST +0 -266
- data/lib/zen/bin/app.rb +0 -40
- data/lib/zen/ext/string.rb +0 -185
- data/lib/zen/helper/common.rb +0 -106
- data/lib/zen/package/categories/lib/categories/view/admin/categories/edit.xhtml +0 -7
- data/lib/zen/package/categories/lib/categories/view/admin/categories/new.xhtml +0 -7
- data/lib/zen/package/categories/lib/categories/view/admin/category-groups/edit.xhtml +0 -7
- data/lib/zen/package/categories/lib/categories/view/admin/category-groups/new.xhtml +0 -7
- data/lib/zen/package/comments/lib/comments/view/admin/comments/edit.xhtml +0 -7
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/edit.xhtml +0 -7
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/new.xhtml +0 -7
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/edit.xhtml +0 -7
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/new.xhtml +0 -7
- data/lib/zen/package/menus/lib/menus/view/admin/menu-items/edit.xhtml +0 -7
- data/lib/zen/package/menus/lib/menus/view/admin/menu-items/new.xhtml +0 -7
- data/lib/zen/package/menus/lib/menus/view/admin/menus/edit.xhtml +0 -7
- data/lib/zen/package/menus/lib/menus/view/admin/menus/new.xhtml +0 -7
- data/lib/zen/package/sections/lib/sections/view/admin/edit.xhtml +0 -7
- data/lib/zen/package/sections/lib/sections/view/admin/new.xhtml +0 -7
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/edit.xhtml +0 -7
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/new.xhtml +0 -7
- data/lib/zen/package/users/lib/users/view/admin/access-rules/edit.xhtml +0 -7
- data/lib/zen/package/users/lib/users/view/admin/access-rules/new.xhtml +0 -7
- data/lib/zen/package/users/lib/users/view/admin/user-groups/edit.xhtml +0 -7
- data/lib/zen/package/users/lib/users/view/admin/user-groups/new.xhtml +0 -7
- data/lib/zen/package/users/lib/users/view/admin/users/edit.xhtml +0 -7
- data/lib/zen/package/users/lib/users/view/admin/users/new.xhtml +0 -7
- data/lib/zen/plugin/controller.rb +0 -59
- data/lib/zen/public/admin/css/zen/notifications.css +0 -84
- data/lib/zen/public/admin/images/zen/icons/large/error.png +0 -0
- data/lib/zen/public/admin/images/zen/icons/large/notice.png +0 -0
- data/lib/zen/public/admin/images/zen/icons/large/success.png +0 -0
- data/lib/zen/public/admin/js/zen/core.js +0 -73
- data/lib/zen/public/admin/js/zen/init.js +0 -80
- data/proto/package/lib/package.rb +0 -21
- data/proto/package/lib/package/controller/controllers.rb +0 -50
- data/proto/package/lib/package/language/en/languages.yml +0 -4
- data/proto/package/lib/package/model/model.rb +0 -12
@@ -3,9 +3,9 @@ module Users
|
|
3
3
|
#:nodoc:
|
4
4
|
module Controller
|
5
5
|
##
|
6
|
-
# Controller for managing all user groups. It's not required to add a user
|
7
|
-
# but it can certainly make it easier when adding custom
|
8
|
-
# user full access to the backend.
|
6
|
+
# Controller for managing all user groups. It's not required to add a user
|
7
|
+
# to a group but it can certainly make it easier when adding custom
|
8
|
+
# permissions or granting a user full access to the backend.
|
9
9
|
#
|
10
10
|
# @author Yorick Peterse
|
11
11
|
# @since 0.1
|
@@ -13,7 +13,8 @@ module Users
|
|
13
13
|
class UserGroups < Zen::Controller::AdminController
|
14
14
|
include ::Users::Model
|
15
15
|
|
16
|
-
|
16
|
+
helper :users
|
17
|
+
map '/admin/user-groups'
|
17
18
|
|
18
19
|
before_all do
|
19
20
|
csrf_protection(:save, :delete) do
|
@@ -34,9 +35,6 @@ module Users
|
|
34
35
|
def initialize
|
35
36
|
super
|
36
37
|
|
37
|
-
@form_save_url = UserGroups.r(:save)
|
38
|
-
@form_delete_url = UserGroups.r(:delete)
|
39
|
-
|
40
38
|
Zen::Language.load('user_groups')
|
41
39
|
|
42
40
|
# Set the page title
|
@@ -44,6 +42,11 @@ module Users
|
|
44
42
|
method = action.method.to_sym
|
45
43
|
@page_title = lang("user_groups.titles.#{method}") rescue nil
|
46
44
|
end
|
45
|
+
|
46
|
+
@boolean_hash = {
|
47
|
+
true => lang('zen_general.special.boolean_hash.true'),
|
48
|
+
false => lang('zen_general.special.boolean_hash.false')
|
49
|
+
}
|
47
50
|
end
|
48
51
|
|
49
52
|
##
|
@@ -58,13 +61,11 @@ module Users
|
|
58
61
|
# @since 0.1
|
59
62
|
#
|
60
63
|
def index
|
61
|
-
|
62
|
-
respond(lang('zen_general.errors.not_authorized'), 403)
|
63
|
-
end
|
64
|
+
require_permissions(:read)
|
64
65
|
|
65
66
|
set_breadcrumbs(lang('user_groups.titles.index'))
|
66
67
|
|
67
|
-
@user_groups = UserGroup
|
68
|
+
@user_groups = paginate(UserGroup)
|
68
69
|
end
|
69
70
|
|
70
71
|
##
|
@@ -80,20 +81,20 @@ module Users
|
|
80
81
|
# @since 0.1
|
81
82
|
#
|
82
83
|
def edit(id)
|
83
|
-
|
84
|
-
respond(lang('zen_general.errors.not_authorized'), 403)
|
85
|
-
end
|
84
|
+
require_permissions(:read, :update)
|
86
85
|
|
87
86
|
set_breadcrumbs(
|
88
|
-
|
87
|
+
UserGroups.a(lang('user_groups.titles.index'), :index),
|
89
88
|
lang('user_groups.titles.edit')
|
90
89
|
)
|
91
90
|
|
92
91
|
if flash[:form_data]
|
93
92
|
@user_group = flash[:form_data]
|
94
93
|
else
|
95
|
-
@user_group =
|
94
|
+
@user_group = validate_user_group(id)
|
96
95
|
end
|
96
|
+
|
97
|
+
render_view(:form)
|
97
98
|
end
|
98
99
|
|
99
100
|
##
|
@@ -108,20 +109,21 @@ module Users
|
|
108
109
|
# @since 0.1
|
109
110
|
#
|
110
111
|
def new
|
111
|
-
|
112
|
-
respond(lang('zen_general.errors.not_authorized'), 403)
|
113
|
-
end
|
112
|
+
require_permissions(:read, :create)
|
114
113
|
|
115
114
|
set_breadcrumbs(
|
116
|
-
|
115
|
+
UserGroups.a(lang('user_groups.titles.index'), :index),
|
117
116
|
lang('user_groups.titles.new')
|
118
117
|
)
|
119
118
|
|
120
119
|
@user_group = UserGroup.new
|
120
|
+
|
121
|
+
render_view(:form)
|
121
122
|
end
|
122
123
|
|
123
124
|
##
|
124
|
-
# Saves or creates a new user group based on the POST data and a field
|
125
|
+
# Saves or creates a new user group based on the POST data and a field
|
126
|
+
# named 'id'.
|
125
127
|
#
|
126
128
|
# This method requires the following permissions:
|
127
129
|
#
|
@@ -132,17 +134,17 @@ module Users
|
|
132
134
|
# @since 0.1
|
133
135
|
#
|
134
136
|
def save
|
135
|
-
if !user_authorized?([:create, :update])
|
136
|
-
respond(lang('zen_general.errors.not_authorized'), 403)
|
137
|
-
end
|
138
|
-
|
139
137
|
post = request.subset(:id, :name, :slug, :description, :super_group)
|
140
138
|
|
141
139
|
if post['id'] and !post['id'].empty?
|
142
|
-
|
140
|
+
require_permissions(:update)
|
141
|
+
|
142
|
+
user_group = validate_user_group(post['id'])
|
143
143
|
save_action = :save
|
144
144
|
else
|
145
|
-
|
145
|
+
require_permissions(:create)
|
146
|
+
|
147
|
+
user_group = UserGroup.new
|
146
148
|
save_action = :new
|
147
149
|
|
148
150
|
post.delete('slug') if post['slug'].empty?
|
@@ -154,18 +156,20 @@ module Users
|
|
154
156
|
flash_error = lang("user_groups.errors.#{save_action}")
|
155
157
|
|
156
158
|
begin
|
157
|
-
|
159
|
+
user_group.update(post)
|
158
160
|
message(:success, flash_success)
|
159
161
|
rescue => e
|
160
162
|
Ramaze::Log.error(e.inspect)
|
161
163
|
message(:error, flash_error)
|
162
164
|
|
163
|
-
flash[:form_data] =
|
164
|
-
flash[:form_errors] =
|
165
|
+
flash[:form_data] = user_group
|
166
|
+
flash[:form_errors] = user_group.errors
|
167
|
+
|
168
|
+
redirect_referrer
|
165
169
|
end
|
166
170
|
|
167
|
-
if
|
168
|
-
redirect(UserGroups.r(:edit,
|
171
|
+
if user_group.id
|
172
|
+
redirect(UserGroups.r(:edit, user_group.id))
|
169
173
|
else
|
170
174
|
redirect_referrer
|
171
175
|
end
|
@@ -182,11 +186,10 @@ module Users
|
|
182
186
|
# @since 0.1
|
183
187
|
#
|
184
188
|
def delete
|
185
|
-
|
186
|
-
respond(lang('zen_general.errors.not_authorized'), 403)
|
187
|
-
end
|
189
|
+
require_permissions(:delete)
|
188
190
|
|
189
|
-
if !request.params['user_group_ids']
|
191
|
+
if !request.params['user_group_ids'] \
|
192
|
+
or request.params['user_group_ids'].empty?
|
190
193
|
message(:error, lang('user_groups.errors.no_delete'))
|
191
194
|
redirect_referrer
|
192
195
|
end
|
@@ -198,6 +201,8 @@ module Users
|
|
198
201
|
rescue => e
|
199
202
|
Ramaze::Log.error(e.inspect)
|
200
203
|
message(:error, lang('user_groups.errors.delete') % id)
|
204
|
+
|
205
|
+
redirect_referrer
|
201
206
|
end
|
202
207
|
end
|
203
208
|
|
@@ -3,13 +3,12 @@ module Users
|
|
3
3
|
#:nodoc:
|
4
4
|
module Controller
|
5
5
|
##
|
6
|
-
# Controller for managing users. Users in this case are people
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
# can't mess around with your system.
|
6
|
+
# Controller for managing users. Users in this case are people that have
|
7
|
+
# access to the backend. However, users might be able to access the backend
|
8
|
+
# but that doesn't mean they can actuall use it. The permission system will
|
9
|
+
# block anybody that don't have the correct permissions for each module. In
|
10
|
+
# case of a module like a forum it's probably better to add some additional
|
11
|
+
# checks to ensure people can't mess around with your system.
|
13
12
|
#
|
14
13
|
# @author Yorick Peterse
|
15
14
|
# @since 0.1
|
@@ -17,7 +16,8 @@ module Users
|
|
17
16
|
class Users < Zen::Controller::AdminController
|
18
17
|
include ::Users::Model
|
19
18
|
|
20
|
-
|
19
|
+
helper :users
|
20
|
+
map '/admin/users'
|
21
21
|
|
22
22
|
before_all do
|
23
23
|
csrf_protection(:save, :delete) do
|
@@ -48,10 +48,6 @@ module Users
|
|
48
48
|
def initialize
|
49
49
|
super
|
50
50
|
|
51
|
-
@form_save_url = Users.r(:save)
|
52
|
-
@form_delete_url = Users.r(:delete)
|
53
|
-
@form_login_url = Users.r(:login)
|
54
|
-
|
55
51
|
Zen::Language.load('users')
|
56
52
|
|
57
53
|
# Set the page title
|
@@ -78,13 +74,11 @@ module Users
|
|
78
74
|
# @since 0.1
|
79
75
|
#
|
80
76
|
def index
|
81
|
-
|
82
|
-
respond(lang('zen_general.errors.not_authorized'), 403)
|
83
|
-
end
|
77
|
+
require_permissions(:read)
|
84
78
|
|
85
79
|
set_breadcrumbs(lang('users.titles.index'))
|
86
80
|
|
87
|
-
@users = User
|
81
|
+
@users = paginate(User)
|
88
82
|
end
|
89
83
|
|
90
84
|
##
|
@@ -100,22 +94,22 @@ module Users
|
|
100
94
|
# @since 0.1
|
101
95
|
#
|
102
96
|
def edit(id)
|
103
|
-
|
104
|
-
respond(lang('zen_general.errors.not_authorized'), 403)
|
105
|
-
end
|
97
|
+
require_permissions(:read, :update)
|
106
98
|
|
107
99
|
set_breadcrumbs(
|
108
|
-
|
100
|
+
Users.a(lang('users.titles.index'), :index),
|
109
101
|
lang('users.titles.edit')
|
110
102
|
)
|
111
103
|
|
112
104
|
if flash[:form_data]
|
113
105
|
@user = flash[:form_data]
|
114
106
|
else
|
115
|
-
@user =
|
107
|
+
@user = validate_user(id)
|
116
108
|
end
|
117
109
|
|
118
110
|
@user_group_pks = UserGroup.pk_hash(:name)
|
111
|
+
|
112
|
+
render_view(:form)
|
119
113
|
end
|
120
114
|
|
121
115
|
##
|
@@ -130,17 +124,17 @@ module Users
|
|
130
124
|
# @since 0.1
|
131
125
|
#
|
132
126
|
def new
|
133
|
-
|
134
|
-
respond(lang('zen_general.errors.not_authorized'), 403)
|
135
|
-
end
|
127
|
+
require_permissions(:read, :create)
|
136
128
|
|
137
129
|
set_breadcrumbs(
|
138
|
-
|
130
|
+
Users.a(lang('users.titles.index'), :index),
|
139
131
|
lang('users.titles.new')
|
140
132
|
)
|
141
133
|
|
142
134
|
@user = User.new
|
143
135
|
@user_group_pks = UserGroup.pk_hash(:name)
|
136
|
+
|
137
|
+
render_view(:form)
|
144
138
|
end
|
145
139
|
|
146
140
|
##
|
@@ -154,7 +148,8 @@ module Users
|
|
154
148
|
# Let's see if we can authenticate
|
155
149
|
if user_login(request.subset(:email, :password))
|
156
150
|
# Update the last time the user logged in
|
157
|
-
User[:email => request.params['email']]
|
151
|
+
User[:email => request.params['email']] \
|
152
|
+
.update(:last_login => Time.new)
|
158
153
|
|
159
154
|
message(:success, lang('users.success.login'))
|
160
155
|
redirect(::Sections::Controller::Sections.r(:index))
|
@@ -190,20 +185,29 @@ module Users
|
|
190
185
|
# @since 0.1
|
191
186
|
#
|
192
187
|
def save
|
193
|
-
if !user_authorized?([:update, :create])
|
194
|
-
respond(lang('zen_general.errors.not_authorized'), 403)
|
195
|
-
end
|
196
|
-
|
197
188
|
post = request.subset(
|
198
|
-
:id,
|
199
|
-
:
|
189
|
+
:id,
|
190
|
+
:email,
|
191
|
+
:name,
|
192
|
+
:website,
|
193
|
+
:new_password,
|
194
|
+
:confirm_password,
|
195
|
+
:status,
|
196
|
+
:language,
|
197
|
+
:frontend_language,
|
198
|
+
:date_format,
|
199
|
+
:user_group_pks
|
200
200
|
)
|
201
201
|
|
202
202
|
if post['id'] and !post['id'].empty?
|
203
|
-
|
203
|
+
require_permissions(:update)
|
204
|
+
|
205
|
+
user = validate_user(post['id'])
|
204
206
|
save_action = :save
|
205
207
|
else
|
206
|
-
|
208
|
+
require_permissions(:create)
|
209
|
+
|
210
|
+
user = User.new
|
207
211
|
save_action = :new
|
208
212
|
end
|
209
213
|
|
@@ -228,18 +232,20 @@ module Users
|
|
228
232
|
flash_error = lang("users.errors.#{save_action}")
|
229
233
|
|
230
234
|
begin
|
231
|
-
|
235
|
+
user.update(post)
|
232
236
|
message(:success, flash_success)
|
233
237
|
rescue => e
|
234
238
|
Ramaze::Log.error(e.inspect)
|
235
239
|
message(:error, flash_error)
|
236
240
|
|
237
|
-
flash[:form_data] =
|
238
|
-
flash[:form_errors] =
|
241
|
+
flash[:form_data] = user
|
242
|
+
flash[:form_errors] = user.errors
|
243
|
+
|
244
|
+
redirect_referrer
|
239
245
|
end
|
240
246
|
|
241
|
-
if
|
242
|
-
redirect(Users.r(:edit,
|
247
|
+
if user.id
|
248
|
+
redirect(Users.r(:edit, user.id))
|
243
249
|
else
|
244
250
|
redirect_referrer
|
245
251
|
end
|
@@ -256,9 +262,7 @@ module Users
|
|
256
262
|
# @since 0.1
|
257
263
|
#
|
258
264
|
def delete
|
259
|
-
|
260
|
-
respond(lang('zen_general.errors.not_authorized'), 403)
|
261
|
-
end
|
265
|
+
require_permissions(:delete)
|
262
266
|
|
263
267
|
if !request.params['user_ids'] or request.params['user_ids'].empty?
|
264
268
|
message(:error, lang('users.errors.no_delete'))
|
@@ -272,6 +276,8 @@ module Users
|
|
272
276
|
rescue => e
|
273
277
|
Ramaze::Log.error(e.inspect)
|
274
278
|
message(:error,lang('users.errors.delete') % id)
|
279
|
+
|
280
|
+
redirect_referrer
|
275
281
|
end
|
276
282
|
end
|
277
283
|
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#:nodoc:
|
2
|
+
module Ramaze
|
3
|
+
#:nodoc:
|
4
|
+
module Helper
|
5
|
+
##
|
6
|
+
# Helper for the users package. Note that this helper is called "Users"
|
7
|
+
# rather than "User" as otherwise Ramaze could get confused and load the
|
8
|
+
# incorrect helper (as it already comes with a helper named "User").
|
9
|
+
#
|
10
|
+
# @author Yorick Peterse
|
11
|
+
# @since 0.2.8
|
12
|
+
#
|
13
|
+
module Users
|
14
|
+
##
|
15
|
+
# Checks if an access rule is valid and returns it if ithis is the case.
|
16
|
+
#
|
17
|
+
# @author Yorick Peterse
|
18
|
+
# @since 0.2.8
|
19
|
+
# @param [Fixnum] access_rule_id The ID of the access rule to validate.
|
20
|
+
# @return [Users::Model::AccessRule]
|
21
|
+
#
|
22
|
+
def validate_access_rule(access_rule_id)
|
23
|
+
rule = ::Users::Model::AccessRule[access_rule_id]
|
24
|
+
|
25
|
+
if rule.nil?
|
26
|
+
message(:error, lang('access_rules.errors.invalid_rule'))
|
27
|
+
redirect(::Users::Controller::AccessRules.r(:index))
|
28
|
+
else
|
29
|
+
return rule
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
##
|
34
|
+
# Checks if a user group is valid and returns it if this is the case.
|
35
|
+
#
|
36
|
+
# @author Yorick Peterse
|
37
|
+
# @since 0.2.8
|
38
|
+
# @param [Fixnum] user_group_id The ID of the user group to validate.
|
39
|
+
# @return [Users::Model::UserGroup]
|
40
|
+
#
|
41
|
+
def validate_user_group(user_group_id)
|
42
|
+
group = ::Users::Model::UserGroup[user_group_id]
|
43
|
+
|
44
|
+
if group.nil?
|
45
|
+
message(:error, lang('user_groups.errors.invalid_group'))
|
46
|
+
redirect(::Users::Controller::UserGroups.r(:index))
|
47
|
+
else
|
48
|
+
return group
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
##
|
53
|
+
# Validates a user and returns the object if it's a valid user.
|
54
|
+
#
|
55
|
+
# @author Yorick Peterse
|
56
|
+
# @since 0.2.8
|
57
|
+
# @param [Fixnum] user_id The ID of the user to validate.
|
58
|
+
# @return [Users::Model::User]
|
59
|
+
#
|
60
|
+
def validate_user(user_id)
|
61
|
+
user = ::Users::Model::User[user_id]
|
62
|
+
|
63
|
+
if user.nil?
|
64
|
+
message(:error, lang('users.errors.invalid_user'))
|
65
|
+
redirect(::Users::Controller::Users.r(:index))
|
66
|
+
else
|
67
|
+
return user
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end # Users
|
71
|
+
end # Helper
|
72
|
+
end # Ramaze
|