In-Portal Issue Tracker

Welcome to the In-Portal Open Source CMS Issue Tracker! This is a central management / tracking tool for all types of tasks / issues / bugs for the In-Portal Project. Before reporting any issues, please make sure to read the Guide into Issue Tracker and How to Properly Test and Report Bugs!

Viewing Issue Simple Details Jump to Notes ] Wiki ]  Related Changesets ] View Advanced ] Issue History ] Print ]
ID Category Type Reproducibility Date Submitted Last Update
0000271 [In-Portal CMS] Data Management feature request N/A 2009-09-04 15:28 2012-07-25 05:32
Reporter alex View Status public Project Name In-Portal CMS
Assigned To alex Developer
Priority normal Resolution fixed Fixed in Version 5.2.0-B1
Status closed Product Version 5.1.0 Target Version 5.2.0
Time EstimateNo estimate
Summary 0000271: Redesign "Data Validation" Engine
Description Here is form data processing cycle from user to database:

1. user opens editing template and inputs form data into form fields;
2. user presses save button to place it's changes to database;
3. form data is passed to kDBItem (or it's descendant) class for processing;
4. class kDBItem (or it's descendant) uses kDBItem::Validate method to validate data before saving to database;
5. internally validation is performed using options defined for each field in it's declaration (all fields are validated, no matter what fields were submitted from form);
6. based on validation results user is either returned to form with validation errors displayed or editing window is successfully closed.

This approach has several not obvious weaknesses:
1. all fields are validated, instead of submitted only fields - this takes time, when not all possible fields are displayed on form;
2. validation rules are defined directly in field declaration in unit config - this doesn't allow form-based validation rules on base level (but can be done inside event handler as usual).

Idea is to move all validation-related field options to form declaration (see task 0000270) and submit used form name along with form fields to kDBItem class, that will use it to perform form-based validation.

How to do this:
1. create kValidator class (with one public method named ValidateField) and move all validation-related code to it from kDBItem class;
2. add $form_name parameter to kDBItem::Validate and to kDBItem::ValidateField methods;
3. when $form_name parameter is not passed, then create (and cache) instance of kValidator class and use validation-related options from field declaration in unit config;
4. when $form_name parameter is passed, then create (and cache) instance of validator class, specified in form declaration and use validation-related options for given field from form declaration;
5. validate form fields using appropriate validator class and validation-related options.
4. create ValidatorClass unit config option (like ListClass option), that will allow to define custom validator class for given unit config and use it later in forms declared inside that unit config.

This way compatibility with unit configs, that don't use forms, layouts will be preserved. Also side effect is, that less memory will be used, when data from several tables in displayed on same screen (front-end mostly).
Additional Information Form Usage:
===========
You can define as many forms as you need in 'Forms' unit config option, e.g.

'Forms' => Array (
    'front_registration' => Array (
        'Fields' => Array (
            'FirstName' => Array ('required' => 1, 'default' => ''),
        )
    ),
),

In this example new form called 'front_registration' is created. Database field called 'FirstName' is made required on this form. If form called 'default' is also defined, then it is always applied first.


You can override following unit config options from form declaration:
- ItemSQLs
- ListSQLs
- Fields
- CustomFields
- VirtualFields
- CalculatedFields
- AggregatedCalculatedFields


1. to set form name in template use this tag <inp2:prefix.special_FormName name="front_registration"/> before any other tag of this prefix.special.

2. to pass form-name to next template after form submit place this hidden field on a form:
<input type="hidden" name="forms[prefix.special]" value="<inp2:prefix.special_FormName/>"/>

3. to use custom validator class do this:
- add 'ValidatorClass' => 'CustomValidator' to unit config
- register class in factory
Tags No tags attached.
Reference https://groups.google.com/d/topic/in-portal-dev/cfhRH6VUxaE/discussion
Change Log Message
Estimate Points 3
Attached Files patch file icon forms_core.patch [^] (262,481 bytes) 2011-09-29 10:43
patch file icon forms_modules.patch [^] (65,519 bytes) 2011-09-29 10:43 [Show Content]
patch file icon forms_themes.patch [^] (30,462 bytes) 2011-09-29 10:43 [Show Content]
patch file icon session_expiration_used_validatelogin_field.patch [^] (2,343 bytes) 2011-09-29 14:57 [Show Content]
patch file icon user_autologin_after_registration_fix.patch [^] (784 bytes) 2012-01-03 10:53 [Show Content]

- Relationships Relation Graph ] Dependency Graph ]
related to 0000951closed (5.1.3)alex User isn't automatically logged-in, when "Immediate" user registration mode is used 
related to 0000270active (Icebox) "Form Configuration" for Add/Edit in Admin Console 
related to 0000269active (Icebox) "Form Layout" Configurator for Add/Edit Templates in Admin 
related to 0001095closed (5.1.3)alex Error messages are displayed on unrelated forms 
related to 0000351active (Icebox) Remove "kDBEventHandler::RemoveRequiredFields" method 

-  Notes
User avatar (0003642)
alex (manager)
2011-07-27 05:52
edited on: 2011-07-27 10:46

Several problems found during implementation of this:
1. direct assignment of 'required' field option to unit config (from OnAfterConfigRead and it's hooks)
2. validation options must be stored in kDBItem class and then put into kValidator object for validation
3. in some places direct read of validation options occurs from field options array
4. formatters create virtual fields, like "CreatedOn_date" and copy required marks from Fields array into them. This way virtual fields, like 'CreatedOn_date' won't in validationOptions array to be properly validated


Due mentioned above problems I wasn't able to store validation options separately in kDBItem object and was force to merge them into kDBItem::Fields property during object initial configuration. Because of it it's impossible to change form name for already existing object.

However you can pass 'form_name' => 'form name here' in additional options during object configuration.

User avatar (0003755)
alex (manager)
2011-09-17 05:07
edited on: 2011-09-28 12:11

Affiliate processing changes TODO:
----------------------------------
1. make "affil.user" object load affiliate record associated with current logged-in record
2. use 2 prefixes on user registration form: "u.register" and "affil.register"
3. in UsersEventHandler::itemChanged check, that form_name is "form_registration" and then:
- recall affil.register object with skip_autoload
- set fields from request and call Validate
- if affiliate record not valid, then set $user->SetError on some fake user's field
4. in UsersEventHandler::afterItemChanged try to create affiliate object that was set before (and place user id insite it)

In forms, where affiliate record can be edited directly use "affil.user" without intermediate user object at all.

User avatar (0003935)
alex (manager)
2011-09-29 10:43

Done.
User avatar (0003936)
alex (manager)
2011-09-29 10:44

Will test later all together.
User avatar (0003937)
alex (manager)
2011-09-29 10:46

Fix committed to 5.2.x branch. Commit Message:

Fixes 0000271: Redesign "Data Validation" Engine
User avatar (0005006)
alex (manager)
2012-07-25 05:32

Since 5.2.0 version was released.

- Related Changesets
In-Portal CMS: 5.2.x r14971
Timestamp: 2012-01-03 10:55:03
Author: alex
Details ] Diff ]
Bug 0000271: Redesign "Data Validation" Engine
1. auto-login of user after instant registration fails
mod - /in-portal/branches/5.2.x/core/units/users/users_event_handler.php Diff ] File ]
In-Portal CMS: 5.2.x r14599
Timestamp: 2011-09-29 14:58:55
Author: alex
Details ] Diff ]
Bug 0000271: Redesign "Data Validation" Engine
1. session expiration code used ValidateLogin field, that was replaced by UserLogin and "login" form name wasn't used
mod - /in-portal/branches/5.2.x/admin/system_presets/simple/users_u.php Diff ] File ]
mod - /in-portal/branches/5.2.x/core/kernel/application.php Diff ] File ]
mod - /in-portal/branches/5.2.x/core/kernel/kbase.php Diff ] File ]
In-Portal CMS: 5.2.x r14596
Timestamp: 2011-09-29 10:46:43
Author: alex
Details ] Diff ]
Fixes 0000271: Redesign "Data Validation" Engine
mod - /in-portal/branches/5.2.x/core/admin_templates/login.tpl Diff ] File ]
mod - /in-portal/branches/5.2.x/core/kernel/application.php Diff ] File ]
mod - /in-portal/branches/5.2.x/core/kernel/db/cat_dbitem.php Diff ] File ]
mod - /in-portal/branches/5.2.x/core/kernel/db/db_event_handler.php Diff ] File ]
mod - /in-portal/branches/5.2.x/core/kernel/db/db_tag_processor.php Diff ] File ]
mod - /in-portal/branches/5.2.x/core/kernel/db/dbitem.php Diff ] File ]
mod - /in-portal/branches/5.2.x/core/kernel/kbase.php Diff ] File ]
mod - /in-portal/branches/5.2.x/core/kernel/utility/formatters/date_formatter.php Diff ] File ]
mod - /in-portal/branches/5.2.x/core/kernel/utility/formatters/formatter.php Diff ] File ]
mod - /in-portal/branches/5.2.x/core/kernel/utility/formatters/multilang_formatter.php Diff ] File ]
mod - /in-portal/branches/5.2.x/core/kernel/utility/formatters/serialized_formatter.php Diff ] File ]
mod - /in-portal/branches/5.2.x/core/kernel/utility/formatters/unit_formatter.php Diff ] File ]
add - /in-portal/branches/5.2.x/core/kernel/utility/validator.php File ]
mod - /in-portal/branches/5.2.x/core/units/configuration/configuration_tag_processor.php Diff ] File ]
mod - /in-portal/branches/5.2.x/core/units/forms/forms/forms_eh.php Diff ] File ]
mod - /in-portal/branches/5.2.x/core/units/helpers/cat_dbitem_export_helper.php Diff ] File ]
mod - /in-portal/branches/5.2.x/core/units/mailing_lists/mailing_list_eh.php Diff ] File ]
mod - /in-portal/branches/5.2.x/core/units/phrases/phrases_event_handler.php Diff ] File ]
mod - /in-portal/branches/5.2.x/core/units/users/users_config.php Diff ] File ]
mod - /in-portal/branches/5.2.x/core/units/users/users_event_handler.php Diff ] File ]
mod - /in-portal/branches/5.2.x/core/units/users/users_item.php Diff ] File ]
mod - /in-portal/branches/5.2.x/core/units/users/users_tag_processor.php Diff ] File ]
Modules :: In-Link: 5.2.x r14595
Timestamp: 2011-09-29 10:45:59
Author: alex
Details ] Diff ]
Bug 0000271: Redesign "Data Validation" Engine
mod - /modules/in-link/branches/5.2.x/units/listing_types/listing_types_event_handler.php Diff ] File ]
Modules :: In-Commerce: 5.2.x r14594
Timestamp: 2011-09-29 10:45:36
Author: alex
Details ] Diff ]
Bug 0000271: Redesign "Data Validation" Engine
mod - /w/in-commerce/branches/5.2.x/units/affiliate_payment_types/affiliate_payment_types_config.php Diff ] File ]
add - /w/in-commerce/branches/5.2.x/units/affiliate_payment_types/affiliate_payment_types_tp.php File ]
mod - /w/in-commerce/branches/5.2.x/units/affiliates/affiliates_config.php Diff ] File ]
mod - /w/in-commerce/branches/5.2.x/units/affiliates/affiliates_event_handler.php Diff ] File ]
mod - /w/in-commerce/branches/5.2.x/units/files/files_config.php Diff ] File ]
mod - /w/in-commerce/branches/5.2.x/units/files/files_event_handler.php Diff ] File ]
mod - /w/in-commerce/branches/5.2.x/units/gift_certificates/gift_certificates_eh.php Diff ] File ]
add - /w/in-commerce/branches/5.2.x/units/orders/order_validator.php File ]
mod - /w/in-commerce/branches/5.2.x/units/orders/orders_config.php Diff ] File ]
mod - /w/in-commerce/branches/5.2.x/units/orders/orders_event_handler.php Diff ] File ]
mod - /w/in-commerce/branches/5.2.x/units/orders/orders_item.php Diff ] File ]
Themes :: Advanced: 1.2.x r14593
Timestamp: 2011-09-29 10:44:31
Author: alex
Details ] Diff ]
Bug 0000271: Redesign "Data Validation" Engine
mod - /themes/advanced/branches/1.2.x/in-commerce/elements/forms.elm.tpl Diff ] File ]
mod - /themes/advanced/branches/1.2.x/in-commerce/elements/registration_fields.elm.tpl Diff ] File ]
mod - /themes/advanced/branches/1.2.x/in-commerce/my_account/affiliate/affiliate.tpl Diff ] File ]
mod - /themes/advanced/branches/1.2.x/in-commerce/my_account/affiliate/affiliate_materials.tpl Diff ] File ]
mod - /themes/advanced/branches/1.2.x/in-commerce/my_account/affiliate/affiliate_payment_type.tpl Diff ] File ]
mod - /themes/advanced/branches/1.2.x/in-commerce/my_account/affiliate/affiliate_payments.tpl Diff ] File ]
mod - /themes/advanced/branches/1.2.x/platform/elements/side_boxes/login.elm.tpl Diff ] File ]
mod - /themes/advanced/branches/1.2.x/platform/elements/side_boxes/mailing_list.elm.tpl Diff ] File ]
mod - /themes/advanced/branches/1.2.x/platform/elements/side_boxes/recommend_site.elm.tpl Diff ] File ]
mod - /themes/advanced/branches/1.2.x/platform/login/forgot_password.tpl Diff ] File ]
mod - /themes/advanced/branches/1.2.x/platform/login/register.tpl Diff ] File ]
mod - /themes/advanced/branches/1.2.x/platform/mailing_list/subscribe.tpl Diff ] File ]
mod - /themes/advanced/branches/1.2.x/platform/mailing_list/unsubscribe.tpl Diff ] File ]

- Issue History
Date Modified Username Field Change
2012-07-25 05:32 alex Note Added: 0005006
2012-07-25 05:32 alex Status resolved => closed
2012-01-03 10:55 alex Changeset attached 5.2.x r14971
2012-01-03 10:53 alex File Added: user_autologin_after_registration_fix.patch
2011-10-22 05:36 alex Estimate Points => 3
2011-09-29 14:58 alex Changeset attached 5.2.x r14599
2011-09-29 14:57 alex File Added: session_expiration_used_validatelogin_field.patch
2011-09-29 10:46 alex Note Added: 0003937
2011-09-29 10:46 alex Status reviewed and tested => resolved
2011-09-29 10:46 alex Fixed in Version => 5.2.0-B1
2011-09-29 10:46 alex Resolution open => fixed
2011-09-29 10:46 alex Assigned To !COMMUNITY => alex
2011-09-29 10:46 alex Changeset attached 5.2.x r14596
2011-09-29 10:45 alex Changeset attached 5.2.x r14595
2011-09-29 10:45 alex Changeset attached 5.2.x r14594
2011-09-29 10:44 alex Changeset attached 1.2.x r14593
2011-09-29 10:44 alex Note Added: 0003936
2011-09-29 10:44 alex Status needs testing => reviewed and tested
2011-09-29 10:43 alex Time Estimate Removed 1 =>
2011-09-29 10:43 alex Note Added: 0003935
2011-09-29 10:43 alex Assigned To => !COMMUNITY
2011-09-29 10:43 alex Developer => alex
2011-09-29 10:43 alex Status active => needs testing
2011-09-29 10:43 alex File Added: forms_themes.patch
2011-09-29 10:43 alex File Added: forms_modules.patch
2011-09-29 10:43 alex File Added: forms_core.patch
2011-09-28 12:11 alex Note Edited: 0003755 View Revisions
2011-09-27 06:27 alex Time Estimate Added 1
2011-09-25 09:32 alex Relationship added related to 0000351
2011-09-17 05:07 alex Note Added: 0003755
2011-08-13 07:49 alex Additional Information Updated View Revisions
2011-08-10 05:08 alex Relationship added related to 0001095
2011-08-04 10:18 alex Relationship replaced related to 0000951
2011-08-04 10:18 alex Relationship added parent of 0000951
2011-07-28 04:02 alex Additional Information Updated View Revisions
2011-07-27 10:46 alex Note Edited: 0003642 View Revisions
2011-07-27 06:41 alex Note Edited: 0003642 View Revisions
2011-07-27 05:52 alex Note Added: 0003642
2011-07-08 10:58 alex Target Version Icebox => 5.2.0
2011-07-05 15:39 Dmitry Reference => https://groups.google.com/d/topic/in-portal-dev/cfhRH6VUxaE/discussion
2010-08-31 14:26 alex version => 5.1.0
2009-09-05 09:15 alex Summary Redesign "Data Dalidation" Engine => Redesign "Data Validation" Engine
2009-09-04 17:14 Dmitry Fixed in Version Icebox =>
2009-09-04 17:14 Dmitry Target Version => Icebox
2009-09-04 17:13 Dmitry Category Admin Interfaces => Data Management
2009-09-04 17:13 Dmitry Fixed in Version => Icebox
2009-09-04 17:13 Dmitry Summary Data validation engine redesign => Redesign "Data Dalidation" Engine
2009-09-04 17:13 Dmitry Description Updated View Revisions
2009-09-04 15:30 alex Relationship added related to 0000269
2009-09-04 15:30 alex Relationship added related to 0000270
2009-09-04 15:28 alex New Issue



Web Development by Intechnic
In-Portal Open Source CMS
In-Portal Open Source CMS
Copyright © 2000 - 2009 MantisBT Group

Powered by Mantis Bugtracker