zen 0.1a
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +19 -0
- data/MANIFEST +337 -0
- data/README.textile +42 -0
- data/Rakefile +6 -0
- data/bin/zen +9 -0
- data/doc/Categories.html +93 -0
- data/doc/Categories/Controllers.html +93 -0
- data/doc/Categories/Controllers/Categories.html +995 -0
- data/doc/Categories/Controllers/CategoryGroups.html +878 -0
- data/doc/Categories/Models.html +97 -0
- data/doc/Categories/Models/Category.html +269 -0
- data/doc/Categories/Models/CategoryGroup.html +231 -0
- data/doc/Comments.html +93 -0
- data/doc/Comments/Controllers.html +93 -0
- data/doc/Comments/Controllers/Comments.html +797 -0
- data/doc/Comments/Controllers/CommentsForm.html +487 -0
- data/doc/Comments/Liquid.html +93 -0
- data/doc/Comments/Liquid/CommentForm.html +522 -0
- data/doc/Comments/Liquid/Comments.html +543 -0
- data/doc/Comments/Models.html +95 -0
- data/doc/Comments/Models/Comment.html +260 -0
- data/doc/CustomFields.html +93 -0
- data/doc/CustomFields/Controllers.html +93 -0
- data/doc/CustomFields/Controllers/CustomFieldGroups.html +902 -0
- data/doc/CustomFields/Controllers/CustomFields.html +974 -0
- data/doc/CustomFields/Models.html +97 -0
- data/doc/CustomFields/Models/CustomField.html +272 -0
- data/doc/CustomFields/Models/CustomFieldGroup.html +259 -0
- data/doc/CustomFields/Models/CustomFieldValue.html +154 -0
- data/doc/Ramaze.html +93 -0
- data/doc/Ramaze/Helper.html +93 -0
- data/doc/Ramaze/Helper/ACL.html +531 -0
- data/doc/Ramaze/Helper/Asset.html +617 -0
- data/doc/Ramaze/Helper/Breadcrumb.html +411 -0
- data/doc/Ramaze/Helper/Common.html +738 -0
- data/doc/Sections.html +93 -0
- data/doc/Sections/Controllers.html +93 -0
- data/doc/Sections/Controllers/SectionEntries.html +1100 -0
- data/doc/Sections/Controllers/Sections.html +953 -0
- data/doc/Sections/Liquid.html +93 -0
- data/doc/Sections/Liquid/SectionEntries.html +674 -0
- data/doc/Sections/Liquid/Sections.html +494 -0
- data/doc/Sections/Models.html +97 -0
- data/doc/Sections/Models/Section.html +272 -0
- data/doc/Sections/Models/SectionEntry.html +264 -0
- data/doc/Sequel.html +91 -0
- data/doc/Sequel/Model.html +243 -0
- data/doc/Settings.html +93 -0
- data/doc/Settings/Controllers.html +91 -0
- data/doc/Settings/Controllers/Settings.html +565 -0
- data/doc/Settings/Liquid.html +91 -0
- data/doc/Settings/Liquid/Setting.html +426 -0
- data/doc/Settings/Models.html +95 -0
- data/doc/Settings/Models/Setting.html +293 -0
- data/doc/Users.html +93 -0
- data/doc/Users/Controllers.html +93 -0
- data/doc/Users/Controllers/AccessRules.html +904 -0
- data/doc/Users/Controllers/UserGroups.html +879 -0
- data/doc/Users/Controllers/Users.html +1124 -0
- data/doc/Users/Liquid.html +93 -0
- data/doc/Users/Liquid/User.html +480 -0
- data/doc/Users/Liquid/Users.html +495 -0
- data/doc/Users/Models.html +97 -0
- data/doc/Users/Models/AccessRule.html +257 -0
- data/doc/Users/Models/User.html +649 -0
- data/doc/Users/Models/UserGroup.html +267 -0
- data/doc/Zen.html +391 -0
- data/doc/Zen/Bin.html +113 -0
- data/doc/Zen/Bin/Base.html +727 -0
- data/doc/Zen/Controllers.html +115 -0
- data/doc/Zen/Controllers/AdminController.html +298 -0
- data/doc/Zen/Controllers/BaseController.html +272 -0
- data/doc/Zen/Controllers/FrontendController.html +164 -0
- data/doc/Zen/Controllers/MainController.html +421 -0
- data/doc/Zen/Database.html +498 -0
- data/doc/Zen/Language.html +660 -0
- data/doc/Zen/Liquid.html +117 -0
- data/doc/Zen/Liquid/ControllerBehavior.html +448 -0
- data/doc/Zen/Liquid/General.html +444 -0
- data/doc/Zen/Liquid/Redirect.html +435 -0
- data/doc/Zen/Liquid/Strip.html +447 -0
- data/doc/Zen/Logger.html +393 -0
- data/doc/Zen/Package.html +909 -0
- data/doc/_index.html +724 -0
- data/doc/class_list.html +36 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +53 -0
- data/doc/css/style.css +310 -0
- data/doc/file.README.html +86 -0
- data/doc/file_list.html +38 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +86 -0
- data/doc/js/app.js +203 -0
- data/doc/js/full_list.js +149 -0
- data/doc/js/jquery.js +154 -0
- data/doc/method_list.html +1139 -0
- data/doc/top-level-namespace.html +88 -0
- data/lib/zen.rb +77 -0
- data/lib/zen/base/database.rb +105 -0
- data/lib/zen/base/language.rb +132 -0
- data/lib/zen/base/logger.rb +54 -0
- data/lib/zen/base/package.rb +233 -0
- data/lib/zen/base/version.rb +11 -0
- data/lib/zen/bin/zen_binary.rb +173 -0
- data/lib/zen/controller/admin_controller.rb +60 -0
- data/lib/zen/controller/base_controller.rb +39 -0
- data/lib/zen/controller/frontend_controller.rb +16 -0
- data/lib/zen/controller/main_controller.rb +93 -0
- data/lib/zen/helper/acl.rb +124 -0
- data/lib/zen/helper/asset.rb +104 -0
- data/lib/zen/helper/breadcrumb.rb +71 -0
- data/lib/zen/helper/common.rb +157 -0
- data/lib/zen/language/en/zen_general.rb +21 -0
- data/lib/zen/language/en/zen_models.rb +39 -0
- data/lib/zen/layout/admin.xhtml +72 -0
- data/lib/zen/layout/login.xhtml +44 -0
- data/lib/zen/liquid/controller_behavior.rb +55 -0
- data/lib/zen/liquid/general.rb +69 -0
- data/lib/zen/liquid/redirect.rb +47 -0
- data/lib/zen/liquid/strip.rb +58 -0
- data/lib/zen/model/methods.rb +26 -0
- data/lib/zen/model/settings.rb +27 -0
- data/lib/zen/packages/categories/LICENSE +19 -0
- data/lib/zen/packages/categories/README.textile +0 -0
- data/lib/zen/packages/categories/lib/categories.rb +24 -0
- data/lib/zen/packages/categories/lib/categories/controller/categories.rb +202 -0
- data/lib/zen/packages/categories/lib/categories/controller/category_groups.rb +173 -0
- data/lib/zen/packages/categories/lib/categories/language/en/categories.rb +38 -0
- data/lib/zen/packages/categories/lib/categories/language/en/category_groups.rb +37 -0
- data/lib/zen/packages/categories/lib/categories/model/category.rb +42 -0
- data/lib/zen/packages/categories/lib/categories/model/category_group.rb +29 -0
- data/lib/zen/packages/categories/lib/categories/view/admin/categories/edit.xhtml +7 -0
- data/lib/zen/packages/categories/lib/categories/view/admin/categories/form.xhtml +36 -0
- data/lib/zen/packages/categories/lib/categories/view/admin/categories/index.xhtml +70 -0
- data/lib/zen/packages/categories/lib/categories/view/admin/categories/new.xhtml +7 -0
- data/lib/zen/packages/categories/lib/categories/view/admin/category_groups/edit.xhtml +7 -0
- data/lib/zen/packages/categories/lib/categories/view/admin/category_groups/form.xhtml +18 -0
- data/lib/zen/packages/categories/lib/categories/view/admin/category_groups/index.xhtml +72 -0
- data/lib/zen/packages/categories/lib/categories/view/admin/category_groups/new.xhtml +7 -0
- data/lib/zen/packages/categories/migrations/.gitkeep +0 -0
- data/lib/zen/packages/categories/migrations/1295282303_create_schema.rb +40 -0
- data/lib/zen/packages/comments/LICENSE +19 -0
- data/lib/zen/packages/comments/README.textile +0 -0
- data/lib/zen/packages/comments/lib/comments.rb +26 -0
- data/lib/zen/packages/comments/lib/comments/controller/comments.rb +157 -0
- data/lib/zen/packages/comments/lib/comments/controller/comments_form.rb +135 -0
- data/lib/zen/packages/comments/lib/comments/language/en/comments.rb +52 -0
- data/lib/zen/packages/comments/lib/comments/liquid/comment_form.rb +97 -0
- data/lib/zen/packages/comments/lib/comments/liquid/comments.rb +115 -0
- data/lib/zen/packages/comments/lib/comments/model/comment.rb +34 -0
- data/lib/zen/packages/comments/lib/comments/view/admin/comments/edit.xhtml +7 -0
- data/lib/zen/packages/comments/lib/comments/view/admin/comments/form.xhtml +31 -0
- data/lib/zen/packages/comments/lib/comments/view/admin/comments/index.xhtml +74 -0
- data/lib/zen/packages/comments/migrations/.gitkeep +0 -0
- data/lib/zen/packages/comments/migrations/1295282202_create_schema.rb +24 -0
- data/lib/zen/packages/comments/migrations/1296949631_add_defensio_signature.rb +11 -0
- data/lib/zen/packages/custom_fields/LICENSE +19 -0
- data/lib/zen/packages/custom_fields/README.textile +0 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields.rb +24 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/controller/custom_field_groups.rb +179 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/controller/custom_fields.rb +194 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/language/en/custom_field_groups.rb +45 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/language/en/custom_fields.rb +64 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/model/custom_field.rb +41 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/model/custom_field_group.rb +32 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/model/custom_field_value.rb +20 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/view/admin/custom_field_groups/edit.xhtml +7 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/view/admin/custom_field_groups/form.xhtml +18 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/view/admin/custom_field_groups/index.xhtml +88 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/view/admin/custom_field_groups/new.xhtml +7 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/view/admin/custom_fields/edit.xhtml +7 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/view/admin/custom_fields/form.xhtml +50 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/view/admin/custom_fields/index.xhtml +75 -0
- data/lib/zen/packages/custom_fields/lib/custom_fields/view/admin/custom_fields/new.xhtml +7 -0
- data/lib/zen/packages/custom_fields/migrations/.gitkeep +0 -0
- data/lib/zen/packages/custom_fields/migrations/1295255665_create_schema.rb +53 -0
- data/lib/zen/packages/sections/LICENSE +19 -0
- data/lib/zen/packages/sections/README.textile +43 -0
- data/lib/zen/packages/sections/lib/sections.rb +33 -0
- data/lib/zen/packages/sections/lib/sections/controller/section_entries.rb +251 -0
- data/lib/zen/packages/sections/lib/sections/controller/sections.rb +205 -0
- data/lib/zen/packages/sections/lib/sections/language/en/section_entries.rb +58 -0
- data/lib/zen/packages/sections/lib/sections/language/en/sections.rb +63 -0
- data/lib/zen/packages/sections/lib/sections/liquid/section_entries.rb +209 -0
- data/lib/zen/packages/sections/lib/sections/liquid/sections.rb +76 -0
- data/lib/zen/packages/sections/lib/sections/model/section.rb +43 -0
- data/lib/zen/packages/sections/lib/sections/model/section_entry.rb +43 -0
- data/lib/zen/packages/sections/lib/sections/view/admin/edit.xhtml +7 -0
- data/lib/zen/packages/sections/lib/sections/view/admin/form.xhtml +54 -0
- data/lib/zen/packages/sections/lib/sections/view/admin/index.xhtml +77 -0
- data/lib/zen/packages/sections/lib/sections/view/admin/new.xhtml +7 -0
- data/lib/zen/packages/sections/lib/sections/view/admin/section_entries/edit.xhtml +7 -0
- data/lib/zen/packages/sections/lib/sections/view/admin/section_entries/form.xhtml +147 -0
- data/lib/zen/packages/sections/lib/sections/view/admin/section_entries/index.xhtml +74 -0
- data/lib/zen/packages/sections/lib/sections/view/admin/section_entries/new.xhtml +7 -0
- data/lib/zen/packages/sections/migrations/.gitkeep +0 -0
- data/lib/zen/packages/sections/migrations/1295251836_create_schema.rb +35 -0
- data/lib/zen/packages/sections/migrations/1296335671_userdata_section_entries.rb +18 -0
- data/lib/zen/packages/sections/migrations/1296936110_drop_comment_antispam.rb +11 -0
- data/lib/zen/packages/settings/LICENSE +0 -0
- data/lib/zen/packages/settings/README.textile +0 -0
- data/lib/zen/packages/settings/lib/settings.rb +22 -0
- data/lib/zen/packages/settings/lib/settings/controller/settings.rb +113 -0
- data/lib/zen/packages/settings/lib/settings/language/en/settings.rb +56 -0
- data/lib/zen/packages/settings/lib/settings/liquid/setting.rb +56 -0
- data/lib/zen/packages/settings/lib/settings/model/setting.rb +38 -0
- data/lib/zen/packages/settings/lib/settings/view/admin/settings/index.xhtml +79 -0
- data/lib/zen/packages/settings/migrations/.gitkeep +0 -0
- data/lib/zen/packages/settings/migrations/1295597111_create_schema.rb +31 -0
- data/lib/zen/packages/users/LICENSE +19 -0
- data/lib/zen/packages/users/README.textile +0 -0
- data/lib/zen/packages/users/lib/users.rb +35 -0
- data/lib/zen/packages/users/lib/users/controller/access_rules.rb +186 -0
- data/lib/zen/packages/users/lib/users/controller/user_groups.rb +171 -0
- data/lib/zen/packages/users/lib/users/controller/users.rb +240 -0
- data/lib/zen/packages/users/lib/users/language/en/access_rules.rb +49 -0
- data/lib/zen/packages/users/lib/users/language/en/user_groups.rb +42 -0
- data/lib/zen/packages/users/lib/users/language/en/users.rb +63 -0
- data/lib/zen/packages/users/lib/users/liquid/user.rb +75 -0
- data/lib/zen/packages/users/lib/users/liquid/users.rb +80 -0
- data/lib/zen/packages/users/lib/users/model/access_rule.rb +29 -0
- data/lib/zen/packages/users/lib/users/model/user.rb +96 -0
- data/lib/zen/packages/users/lib/users/model/user_group.rb +38 -0
- data/lib/zen/packages/users/lib/users/public/admin/js/users/access_rules.js +43 -0
- data/lib/zen/packages/users/lib/users/view/admin/access_rules/edit.xhtml +7 -0
- data/lib/zen/packages/users/lib/users/view/admin/access_rules/form.xhtml +68 -0
- data/lib/zen/packages/users/lib/users/view/admin/access_rules/index.xhtml +85 -0
- data/lib/zen/packages/users/lib/users/view/admin/access_rules/new.xhtml +7 -0
- data/lib/zen/packages/users/lib/users/view/admin/user_groups/edit.xhtml +7 -0
- data/lib/zen/packages/users/lib/users/view/admin/user_groups/form.xhtml +19 -0
- data/lib/zen/packages/users/lib/users/view/admin/user_groups/index.xhtml +69 -0
- data/lib/zen/packages/users/lib/users/view/admin/user_groups/new.xhtml +7 -0
- data/lib/zen/packages/users/lib/users/view/admin/users/edit.xhtml +7 -0
- data/lib/zen/packages/users/lib/users/view/admin/users/form.xhtml +25 -0
- data/lib/zen/packages/users/lib/users/view/admin/users/index.xhtml +73 -0
- data/lib/zen/packages/users/lib/users/view/admin/users/login.xhtml +22 -0
- data/lib/zen/packages/users/lib/users/view/admin/users/new.xhtml +7 -0
- data/lib/zen/packages/users/migrations/.gitkeep +0 -0
- data/lib/zen/packages/users/migrations/1295281013_create_schema.rb +54 -0
- data/lib/zen/public/admin/css/boilerplate.css +174 -0
- data/lib/zen/public/admin/css/general.css +485 -0
- data/lib/zen/public/admin/css/grid.css +119 -0
- data/lib/zen/public/admin/css/layout.css +111 -0
- data/lib/zen/public/admin/images/general/noise.jpg +0 -0
- data/lib/zen/public/admin/images/icons/accept.png +0 -0
- data/lib/zen/public/admin/images/icons/add.png +0 -0
- data/lib/zen/public/admin/images/icons/back.png +0 -0
- data/lib/zen/public/admin/images/icons/bold.png +0 -0
- data/lib/zen/public/admin/images/icons/close.png +0 -0
- data/lib/zen/public/admin/images/icons/delete.png +0 -0
- data/lib/zen/public/admin/images/icons/edit.png +0 -0
- data/lib/zen/public/admin/images/icons/error.png +0 -0
- data/lib/zen/public/admin/images/icons/help.png +0 -0
- data/lib/zen/public/admin/images/icons/info.png +0 -0
- data/lib/zen/public/admin/images/icons/italic.png +0 -0
- data/lib/zen/public/admin/images/icons/large/error.png +0 -0
- data/lib/zen/public/admin/images/icons/large/notice.png +0 -0
- data/lib/zen/public/admin/images/icons/large/success.png +0 -0
- data/lib/zen/public/admin/images/icons/link.png +0 -0
- data/lib/zen/public/admin/images/icons/logout.png +0 -0
- data/lib/zen/public/admin/images/icons/ol.png +0 -0
- data/lib/zen/public/admin/images/icons/pdf.png +0 -0
- data/lib/zen/public/admin/images/icons/ul.png +0 -0
- data/lib/zen/public/admin/images/icons/user.png +0 -0
- data/lib/zen/public/admin/images/icons/view.png +0 -0
- data/lib/zen/public/admin/js/mootools/core.js +436 -0
- data/lib/zen/public/admin/js/mootools/more.js +288 -0
- data/lib/zen/public/admin/js/zen/editor/base.js +265 -0
- data/lib/zen/public/admin/js/zen/editor/drivers/html.js +104 -0
- data/lib/zen/public/admin/js/zen/editor/drivers/markdown.js +102 -0
- data/lib/zen/public/admin/js/zen/editor/drivers/textile.js +102 -0
- data/lib/zen/public/admin/js/zen/init.js +57 -0
- data/lib/zen/public/admin/js/zen/modal.js +159 -0
- data/lib/zen/public/admin/js/zen/notification.js +213 -0
- data/lib/zen/public/admin/js/zen/tabs.js +263 -0
- data/lib/zen/tasks.rb +6 -0
- data/pkg/.gitkeep +0 -0
- data/proto/app/Rakefile +2 -0
- data/proto/app/app.rb +20 -0
- data/proto/app/config.ru +18 -0
- data/proto/app/config/config.rb +17 -0
- data/proto/app/config/database.rb +18 -0
- data/proto/app/config/middlewares.rb +23 -0
- data/proto/app/config/requires.rb +8 -0
- data/proto/app/logs/.gitkeep +0 -0
- data/proto/app/public/.gitkeep +0 -0
- data/proto/app/start.rb +22 -0
- data/proto/app/vendor/.gitkeep +0 -0
- data/proto/app/vendor/themes/.gitkeep +0 -0
- data/proto/migration.rb +11 -0
- data/proto/module/LICENSE +0 -0
- data/proto/module/README.textile +0 -0
- data/proto/module/lib/module.rb +15 -0
- data/proto/module/lib/module/controller/controllers.rb +86 -0
- data/proto/module/lib/module/language/en/languages.rb +3 -0
- data/proto/module/lib/module/model/model.rb +12 -0
- data/proto/module/lib/module/view/admin/edit.xhtml +0 -0
- data/proto/module/lib/module/view/admin/form.xhtml +0 -0
- data/proto/module/lib/module/view/admin/index.xhtml +0 -0
- data/proto/module/lib/module/view/admin/new.xhtml +0 -0
- data/proto/module/migrations/.gitkeep +0 -0
- data/spec/javascript/css/base.css +177 -0
- data/spec/javascript/css/style.css +204 -0
- data/spec/javascript/css/typography.css +70 -0
- data/spec/javascript/editor/index.html +65 -0
- data/spec/javascript/images/close.png +0 -0
- data/spec/javascript/images/info.png +0 -0
- data/spec/javascript/js/editor.js +16 -0
- data/spec/javascript/js/modal.js +12 -0
- data/spec/javascript/js/namespace.js +2 -0
- data/spec/javascript/js/notification.js +43 -0
- data/spec/javascript/js/tabs.js +8 -0
- data/spec/javascript/modal/index.html +45 -0
- data/spec/javascript/notification/index.html +48 -0
- data/spec/javascript/tabs/index.html +73 -0
- data/spec/javascript/tabs/tab_1.html +1 -0
- data/spec/javascript/tabs/tab_2.html +1 -0
- data/spec/zen/base/language.rb +31 -0
- data/spec/zen/base/logger.rb +34 -0
- data/spec/zen/base/package.rb +47 -0
- data/spec/zen/config/database.rb +8 -0
- data/spec/zen/helper/asset.rb +26 -0
- data/spec/zen/helper/breadcrumb.rb +24 -0
- data/spec/zen/language/en/general.rb +4 -0
- data/spec/zen/language/nl/general.rb +4 -0
- data/spec/zen/liquid/general.rb +42 -0
- data/spec/zen/logs/.gitkeep +0 -0
- data/spec/zen/spec.rb +9 -0
- data/spec/zen/spec_database.db +0 -0
- data/tasks/bacon.rake +99 -0
- data/tasks/build.rake +72 -0
- data/tasks/clean.rake +18 -0
- data/tasks/db.rake +81 -0
- data/tasks/doc.rake +5 -0
- data/tasks/extension.rake +65 -0
- data/tasks/proto.rake +37 -0
- data/tasks/theme.rake +63 -0
- metadata +512 -0
@@ -0,0 +1,240 @@
|
|
1
|
+
module Users
|
2
|
+
module Controllers
|
3
|
+
##
|
4
|
+
# Controller for managing users. Users in this case are people
|
5
|
+
# that have access to the backend. However, users might be able
|
6
|
+
# to access the backend but that doesn't mean they can actuall use it.
|
7
|
+
# The permission system will block anybody that don't have the correct
|
8
|
+
# permissions for each module. In case of a module like a forum it's
|
9
|
+
# probably better to add some additional checks to ensure people
|
10
|
+
# can't mess around with your system.
|
11
|
+
#
|
12
|
+
# @author Yorick Peterse
|
13
|
+
# @since 0.1
|
14
|
+
#
|
15
|
+
class Users < Zen::Controllers::AdminController
|
16
|
+
map '/admin/users'
|
17
|
+
|
18
|
+
trait :extension_identifier => 'com.zen.users'
|
19
|
+
include ::Users::Models
|
20
|
+
|
21
|
+
before_all do
|
22
|
+
csrf_protection :save, :delete do
|
23
|
+
respond(@zen_general_lang.errors[:csrf], 401)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Every action should use the admin layout except the "login" method,
|
28
|
+
# that one will use a trimmed down version of the admin layout.
|
29
|
+
layout do |path, format|
|
30
|
+
if path == 'login'
|
31
|
+
:login
|
32
|
+
else
|
33
|
+
:admin
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
##
|
38
|
+
# Load our language packs, set the form URLs and define our page title.
|
39
|
+
#
|
40
|
+
# @author Yorick Peterse
|
41
|
+
# @since 0.1
|
42
|
+
#
|
43
|
+
def initialize
|
44
|
+
super
|
45
|
+
|
46
|
+
@form_save_url = '/admin/users/save'
|
47
|
+
@form_delete_url = '/admin/users/delete'
|
48
|
+
@form_login_url = '/admin/users/login'
|
49
|
+
@users_lang = Zen::Language.load 'users'
|
50
|
+
|
51
|
+
# Set the page title
|
52
|
+
if !action.method.nil?
|
53
|
+
method = action.method.to_sym
|
54
|
+
|
55
|
+
if @users_lang.titles.key? method
|
56
|
+
@page_title = @users_lang.titles[method]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
##
|
62
|
+
# Show an overview of all users and allow the current user
|
63
|
+
# to manage these users.
|
64
|
+
#
|
65
|
+
# @author Yorick Peterse
|
66
|
+
# @since 0.1
|
67
|
+
#
|
68
|
+
def index
|
69
|
+
if !user_authorized?([:read])
|
70
|
+
respond(@zen_general_lang.errors[:not_authorized], 403)
|
71
|
+
end
|
72
|
+
|
73
|
+
set_breadcrumbs @users_lang.titles[:index]
|
74
|
+
|
75
|
+
@users = User.all
|
76
|
+
end
|
77
|
+
|
78
|
+
##
|
79
|
+
# Edit an existing user based on the ID.
|
80
|
+
#
|
81
|
+
# @author Yorick Peterse
|
82
|
+
# @since 0.1
|
83
|
+
#
|
84
|
+
def edit id
|
85
|
+
if !user_authorized?([:read, :update])
|
86
|
+
respond(@zen_general_lang.errors[:not_authorized], 403)
|
87
|
+
end
|
88
|
+
|
89
|
+
set_breadcrumbs anchor_to(@users_lang.titles[:index], "admin/users"), @users_lang.titles[:edit]
|
90
|
+
|
91
|
+
@user = User[id]
|
92
|
+
@user_group_pks = UserGroup.pk_hash(:name)
|
93
|
+
end
|
94
|
+
|
95
|
+
##
|
96
|
+
# Create a new user.
|
97
|
+
#
|
98
|
+
# @author Yorick Peterse
|
99
|
+
# @since 0.1
|
100
|
+
#
|
101
|
+
def new
|
102
|
+
if !user_authorized?([:read, :create])
|
103
|
+
respond(@zen_general_lang.errors[:not_authorized], 403)
|
104
|
+
end
|
105
|
+
|
106
|
+
set_breadcrumbs anchor_to(@users_lang.titles[:index], "admin/users"), @users_lang.titles[:new]
|
107
|
+
|
108
|
+
@user = User.new
|
109
|
+
@user_group_pks = UserGroup.pk_hash(:name)
|
110
|
+
end
|
111
|
+
|
112
|
+
##
|
113
|
+
# Show a form that allows a user to log in.
|
114
|
+
#
|
115
|
+
# @author Yorick Peterse
|
116
|
+
# @since 0.1
|
117
|
+
#
|
118
|
+
def login
|
119
|
+
if request.post?
|
120
|
+
# Let's see if we can authenticate
|
121
|
+
if user_login(request.subset(:email, :password))
|
122
|
+
# Update the last time the user logged in
|
123
|
+
User[:email => request.params['email']].update(:last_login => Time.new)
|
124
|
+
|
125
|
+
notification :success, @users_lang.titles[:index], @users_lang.success[:login]
|
126
|
+
redirect "admin"
|
127
|
+
else
|
128
|
+
notification :error, @users_lang.titles[:index], @users_lang.errors[:login]
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
##
|
134
|
+
# Logout and destroy the user's session.
|
135
|
+
#
|
136
|
+
# @author Yorick Peterse
|
137
|
+
# @since 0.1
|
138
|
+
#
|
139
|
+
def logout
|
140
|
+
user_logout
|
141
|
+
|
142
|
+
notification :success, @users_lang.titles[:index], @users_lang.success[:logout]
|
143
|
+
redirect "admin/users/login"
|
144
|
+
end
|
145
|
+
|
146
|
+
##
|
147
|
+
# Saves or creates a new user based on the POST data and a field named "id".
|
148
|
+
#
|
149
|
+
# @author Yorick Peterse
|
150
|
+
# @since 0.1
|
151
|
+
#
|
152
|
+
def save
|
153
|
+
if !user_authorized?([:update, :create])
|
154
|
+
respond(@zen_general_lang.errors[:not_authorized], 403)
|
155
|
+
end
|
156
|
+
|
157
|
+
post = request.params.dup
|
158
|
+
|
159
|
+
post.each do |key, value|
|
160
|
+
post.delete(key) if value.empty?
|
161
|
+
end
|
162
|
+
|
163
|
+
if post["id"] and !post["id"].empty?
|
164
|
+
@user = User[post["id"]]
|
165
|
+
save_action = :save
|
166
|
+
else
|
167
|
+
@user = User.new
|
168
|
+
save_action = :new
|
169
|
+
end
|
170
|
+
|
171
|
+
if !post['new_password'].nil? and !post['new_password'].empty?
|
172
|
+
if post['new_password'] != post['confirm_password']
|
173
|
+
notification :error, @users_lang.titles[:index], @users_lang.errors[:no_password_match]
|
174
|
+
redirect_referrer
|
175
|
+
else
|
176
|
+
post['password'] = post['new_password']
|
177
|
+
|
178
|
+
post.delete 'new_password'
|
179
|
+
post.delete 'confirm_password'
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
# User group pks have to be integers
|
184
|
+
if !post["user_group_pks"].nil?
|
185
|
+
post["user_group_pks"].map! { |value| value.to_i }
|
186
|
+
else
|
187
|
+
post["user_group_pks"] = []
|
188
|
+
end
|
189
|
+
|
190
|
+
flash_success = @users_lang.success[save_action]
|
191
|
+
flash_error = @users_lang.errors[save_action]
|
192
|
+
|
193
|
+
begin
|
194
|
+
@user.update(post)
|
195
|
+
notification(:success, @users_lang.titles[:index], flash_success)
|
196
|
+
rescue
|
197
|
+
notification(:error, @users_lang.titles[:index], flash_error)
|
198
|
+
|
199
|
+
flash[:form_errors] = @user.errors
|
200
|
+
end
|
201
|
+
|
202
|
+
if @user.id
|
203
|
+
redirect "/admin/users/edit/#{@user.id}"
|
204
|
+
else
|
205
|
+
redirect_referrer
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
##
|
210
|
+
# Delete all specified users.
|
211
|
+
#
|
212
|
+
# @author Yorick Peterse
|
213
|
+
# @since 0.1
|
214
|
+
#
|
215
|
+
def delete
|
216
|
+
if !user_authorized?([:delete])
|
217
|
+
respond(@zen_general_lang.errors[:not_authorized], 403)
|
218
|
+
end
|
219
|
+
|
220
|
+
if !request.params["user_ids"] or request.params["user_ids"].empty?
|
221
|
+
notification(:error, @users_lang.titles[:index], @users_lang.errors[:no_delete])
|
222
|
+
redirect_referrer
|
223
|
+
end
|
224
|
+
|
225
|
+
request.params["user_ids"].each do |id|
|
226
|
+
@user = User[id]
|
227
|
+
|
228
|
+
begin
|
229
|
+
@user.delete
|
230
|
+
notification(:success, @users_lang.titles[:index], @users_lang.success[:delete] % id)
|
231
|
+
rescue
|
232
|
+
notification(:error, @users_lang.titles[:index], @users_lang.errors[:delete] % id)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
redirect_referrer
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
Zen::Language.translation 'access_rules' do |item|
|
2
|
+
|
3
|
+
item.titles = {
|
4
|
+
:index => 'Access Rules',
|
5
|
+
:edit => 'Edit Access Rule',
|
6
|
+
:new => 'Add Access Rule'
|
7
|
+
}
|
8
|
+
|
9
|
+
item.labels = {
|
10
|
+
:id => '#',
|
11
|
+
:extension => 'Extension',
|
12
|
+
:rule_applies => 'Rule applies to',
|
13
|
+
:create => 'Create',
|
14
|
+
:read => 'Read',
|
15
|
+
:update => 'Update',
|
16
|
+
:delete => 'Delete',
|
17
|
+
:user => 'User',
|
18
|
+
:user_group => 'User group'
|
19
|
+
}
|
20
|
+
|
21
|
+
item.special = {
|
22
|
+
:boolean_hash => {true => "Yes", false => "No"},
|
23
|
+
:rule_applies_hash => {"Users" => "div_user_id", "User groups" => "div_user_group_id"}
|
24
|
+
}
|
25
|
+
|
26
|
+
item.messages = {
|
27
|
+
:no_rules => 'No access rules have been added yet'
|
28
|
+
}
|
29
|
+
|
30
|
+
item.errors = {
|
31
|
+
:new => "Failed to create a new access rule.",
|
32
|
+
:save => "Failed to save the access rule.",
|
33
|
+
:delete => "Failed to delete the access rule with ID #%s",
|
34
|
+
:no_delete => "You haven't specified any access rules to delete."
|
35
|
+
}
|
36
|
+
|
37
|
+
item.success = {
|
38
|
+
:new => "The new access rule has been created.",
|
39
|
+
:save => "The access rule has been modified.",
|
40
|
+
:delete => "The access rule with ID #%s has been deleted."
|
41
|
+
}
|
42
|
+
|
43
|
+
item.buttons = {
|
44
|
+
:new => 'New rule',
|
45
|
+
:delete => 'Delete selected rules',
|
46
|
+
:save => 'Save rule'
|
47
|
+
}
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
Zen::Language.translation 'user_groups' do |item|
|
2
|
+
item.titles = {
|
3
|
+
:index => 'User Groups',
|
4
|
+
:edit => 'Edit User Group',
|
5
|
+
:new => 'Add User Group'
|
6
|
+
}
|
7
|
+
|
8
|
+
item.labels = {
|
9
|
+
:id => '#',
|
10
|
+
:name => 'Name',
|
11
|
+
:slug => 'Slug',
|
12
|
+
:description => 'Description',
|
13
|
+
:super_group => 'Super group'
|
14
|
+
}
|
15
|
+
|
16
|
+
item.special = {
|
17
|
+
:boolean_hash => {true => "Yes", false => "No"}
|
18
|
+
}
|
19
|
+
|
20
|
+
item.messages = {
|
21
|
+
:no_user_groups => 'No user groups have been added yet'
|
22
|
+
}
|
23
|
+
|
24
|
+
item.errors = {
|
25
|
+
:new => "Failed to create a new user group.",
|
26
|
+
:save => "Failed to save the user group.",
|
27
|
+
:delete => "Failed to delete the user group with ID #%s",
|
28
|
+
:no_delete => "You haven't specified any user groups to delete."
|
29
|
+
}
|
30
|
+
|
31
|
+
item.success = {
|
32
|
+
:new => "The new user group has been created.",
|
33
|
+
:save => "The user group has been modified.",
|
34
|
+
:delete => "The user group with ID #%s has been deleted."
|
35
|
+
}
|
36
|
+
|
37
|
+
item.buttons = {
|
38
|
+
:new_group => 'New group',
|
39
|
+
:delete_groups => 'Delete selected groups',
|
40
|
+
:save_group => 'Save group'
|
41
|
+
}
|
42
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
Zen::Language.translation 'users' do |item|
|
2
|
+
# Page titles
|
3
|
+
item.titles = {
|
4
|
+
:index => 'Users',
|
5
|
+
:edit => 'Edit User',
|
6
|
+
:new => 'Add User',
|
7
|
+
:login => 'Login'
|
8
|
+
}
|
9
|
+
|
10
|
+
# Labels
|
11
|
+
item.labels = {
|
12
|
+
:id => '#',
|
13
|
+
:email => 'Email',
|
14
|
+
:name => 'Name',
|
15
|
+
:website => 'Website',
|
16
|
+
:password => 'Password',
|
17
|
+
:new_password => 'New password',
|
18
|
+
:confirm_password => 'Confirm password',
|
19
|
+
:status => 'Status',
|
20
|
+
:created_at => 'Created',
|
21
|
+
:updated_at => 'Updated',
|
22
|
+
:last_login => 'Last login',
|
23
|
+
:user_groups => 'User groups'
|
24
|
+
}
|
25
|
+
|
26
|
+
# Special items such as sub hashes and such
|
27
|
+
item.special = {
|
28
|
+
:status_hash => {'open' => 'Open', 'closed' => 'Closed'}
|
29
|
+
}
|
30
|
+
|
31
|
+
# General messages
|
32
|
+
item.messages = {
|
33
|
+
:no_users => 'No users have been added yet'
|
34
|
+
}
|
35
|
+
|
36
|
+
# Error specific messages
|
37
|
+
item.errors = {
|
38
|
+
:new => "Failed to create a new users.",
|
39
|
+
:save => "Failed to save the user.",
|
40
|
+
:delete => "Failed to delete the user with ID #%s",
|
41
|
+
:no_delete => "You haven't specified any users to delete.",
|
42
|
+
:no_password_match => 'The specified passwords didn\'t match.',
|
43
|
+
:login => "Failed to login with the specified details",
|
44
|
+
:logout => "Failed to log out, what the hell is going on?"
|
45
|
+
}
|
46
|
+
|
47
|
+
# Success messages
|
48
|
+
item.success = {
|
49
|
+
:new => "The new user has been created.",
|
50
|
+
:save => "The user has been modified.",
|
51
|
+
:delete => "The user with ID #%s has been deleted.",
|
52
|
+
:login => "You've been successfully logged in.",
|
53
|
+
:logout => "You've been successfully logged out."
|
54
|
+
}
|
55
|
+
|
56
|
+
# Buttons
|
57
|
+
item.buttons = {
|
58
|
+
:login => 'Login',
|
59
|
+
:new_user => 'New user',
|
60
|
+
:delete_users => 'Delete selected users',
|
61
|
+
:save_user => 'Save user'
|
62
|
+
}
|
63
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module Users
|
2
|
+
module Liquid
|
3
|
+
##
|
4
|
+
# Tag that can be used to retrieve details about a single user. When using this
|
5
|
+
# tag you can use the database table's column names as the keys, multiple keys
|
6
|
+
# will result in multiple WHERE/AND clauses. In order to retrieve a user with
|
7
|
+
# the Email address "me@awesome.com" you'd do the following:
|
8
|
+
#
|
9
|
+
# bc. {% user email="me@awesome.com" %}
|
10
|
+
# {{name}}
|
11
|
+
# {% enduser %}
|
12
|
+
#
|
13
|
+
# If you want to add an extra condition simply do the following:
|
14
|
+
#
|
15
|
+
# bc. {% user email="me@awesome.com" status="open" %}
|
16
|
+
# {{name}}
|
17
|
+
# {% enduser %}
|
18
|
+
#
|
19
|
+
# Note that this class is a Liquid block, not a tag. This means that you'll have to
|
20
|
+
# specify the closing tag. The reason for this is that there are multiple columns
|
21
|
+
# for the user table and using a tag in combination of a variable would result in
|
22
|
+
# more code.
|
23
|
+
#
|
24
|
+
# @author Yorick Peterse
|
25
|
+
# @since 0.1
|
26
|
+
#
|
27
|
+
class User < ::Liquid::Block
|
28
|
+
include ::Zen::Liquid::General
|
29
|
+
|
30
|
+
##
|
31
|
+
# Initializes the class, parses the tag and retrieves the user for the specified tag.
|
32
|
+
#
|
33
|
+
# @author Yorick Peterse
|
34
|
+
# @param [String] tag_name The name of the tag that was called.
|
35
|
+
# @param [String] arguments All additional arguments passed as a string.
|
36
|
+
# @param [String] html The HTML inside the block.
|
37
|
+
# @since 0.1
|
38
|
+
#
|
39
|
+
def initialize tag_name, arguments, markup
|
40
|
+
super
|
41
|
+
|
42
|
+
@arguments = {}
|
43
|
+
arguments = parse_key_values(arguments)
|
44
|
+
|
45
|
+
arguments.each do |k, v|
|
46
|
+
@arguments[k.to_sym] = v
|
47
|
+
end
|
48
|
+
|
49
|
+
@user = {}
|
50
|
+
user = ::Users::Models::User[@arguments]
|
51
|
+
|
52
|
+
if !user.nil?
|
53
|
+
user.values.each do |k, v|
|
54
|
+
@user[k.to_s] = v
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
##
|
60
|
+
# Renders the tag
|
61
|
+
#
|
62
|
+
# @author Yorick Peterse
|
63
|
+
# @param [Object] context The Liquid context for the current tag.
|
64
|
+
# @return [Array]
|
65
|
+
#
|
66
|
+
def render context
|
67
|
+
@user.each do |k, v|
|
68
|
+
context[k] = v
|
69
|
+
end
|
70
|
+
|
71
|
+
render_all(@nodelist, context)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|