Index: branches/5.2.x/core/admin_templates/user_selector.tpl
===================================================================
diff -u -N -r14726 -r15563
--- branches/5.2.x/core/admin_templates/user_selector.tpl (.../user_selector.tpl) (revision 14726)
+++ branches/5.2.x/core/admin_templates/user_selector.tpl (.../user_selector.tpl) (revision 15563)
@@ -49,7 +49,7 @@
Index: branches/5.2.x/core/units/structure/structure_config.php
===================================================================
diff -u -N -r15390 -r15563
--- branches/5.2.x/core/units/structure/structure_config.php (.../structure_config.php) (revision 15390)
+++ branches/5.2.x/core/units/structure/structure_config.php (.../structure_config.php) (revision 15563)
@@ -1,6 +1,6 @@
Array('type' => 'string', 'default' => null),
'CachedDescendantCatsQty' => Array('type' => 'int', 'not_null' => 1, 'default' => 0),
'CachedNavbar' => Array('type' => 'string', 'formatter' => 'kMultiLanguage', 'default' => null),
- 'CreatedById' => Array('type' => 'int', 'formatter' => 'kLEFTFormatter', 'options' => Array(USER_ROOT => 'root', USER_GUEST => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'Users WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Username', 'default' => NULL),
+ 'CreatedById' => Array('type' => 'int', 'formatter' => 'kLEFTFormatter', 'options' => Array(USER_ROOT => 'root', USER_GUEST => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'Users WHERE %s', 'left_key_field' => 'PortalUserId', 'left_title_field' => USER_TITLE_FIELD, 'default' => NULL),
'ResourceId' => Array('type' => 'int', 'default' => null),
'ParentPath' => Array('type' => 'string', 'default' => null),
'TreeLeft' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
@@ -153,7 +153,7 @@
'NewItem' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 2),
'PopItem' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 2),
'Modified' => Array('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#'),
- 'ModifiedById' => Array('type' => 'int', 'formatter' => 'kLEFTFormatter', 'options' => Array(USER_ROOT => 'root', USER_GUEST => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'Users WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Username', 'default' => NULL),
+ 'ModifiedById' => Array('type' => 'int', 'formatter' => 'kLEFTFormatter', 'options' => Array(USER_ROOT => 'root', USER_GUEST => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'Users WHERE %s', 'left_key_field' => 'PortalUserId', 'left_title_field' => USER_TITLE_FIELD, 'default' => NULL),
'CachedTemplate' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
'CachedTemplateHash' => Array ('type' => 'string', 'not_null' => 1, 'default' => 0),
Index: branches/5.2.x/core/units/mailing_lists/mailing_lists_config.php
===================================================================
diff -u -N -r15461 -r15563
--- branches/5.2.x/core/units/mailing_lists/mailing_lists_config.php (.../mailing_lists_config.php) (revision 15461)
+++ branches/5.2.x/core/units/mailing_lists/mailing_lists_config.php (.../mailing_lists_config.php) (revision 15563)
@@ -1,6 +1,6 @@
'int',
'formatter' => 'kLEFTFormatter',
'options' => Array (USER_ROOT => 'root'),
- 'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Users WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Username',
+ 'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Users WHERE %s',
+ 'left_key_field' => 'PortalUserId', 'left_title_field' => USER_TITLE_FIELD,
'required' => 1, 'not_null' => 1, 'default' => USER_ROOT,
),
Index: branches/5.2.x/core/units/users/users_tag_processor.php
===================================================================
diff -u -N -r15517 -r15563
--- branches/5.2.x/core/units/users/users_tag_processor.php (.../users_tag_processor.php) (revision 15517)
+++ branches/5.2.x/core/units/users/users_tag_processor.php (.../users_tag_processor.php) (revision 15563)
@@ -1,6 +1,6 @@
loginUserById( $login_user->GetID() );
}
}
+
+ /**
+ * Returns user selector title
+ *
+ * @param Array $params
+ * @return string
+ * @access protected
+ */
+ protected function UserSelectorTitle($params)
+ {
+ $object = $this->getObject($params);
+ /* @var $object kDBItem */
+
+ return $object->GetDBField('Email') ? $object->GetDBField('Email') : $object->GetDBField('Username');
+ }
}
\ No newline at end of file
Index: branches/5.2.x/core/units/system_event_subscriptions/system_event_subscriptions_config.php
===================================================================
diff -u -N -r15290 -r15563
--- branches/5.2.x/core/units/system_event_subscriptions/system_event_subscriptions_config.php (.../system_event_subscriptions_config.php) (revision 15290)
+++ branches/5.2.x/core/units/system_event_subscriptions/system_event_subscriptions_config.php (.../system_event_subscriptions_config.php) (revision 15563)
@@ -1,6 +1,6 @@
Array (
'BindToSystemEvent' => 'ee.BindToSystemEvent',
'EmailEventName' => 'ee.Event',
- 'Username' => 'CASE %1$s.UserId WHEN ' . USER_ROOT . ' THEN "root" WHEN ' . USER_GUEST . ' THEN "Guest" ELSE IF(CONCAT(u.FirstName, u.LastName) <> "", CONCAT(u.FirstName, " ", u.LastName), IF(%1$s.UserId IS NULL, "Guest", u.Username)) END',
+ 'Username' => 'CASE %1$s.UserId WHEN ' . USER_ROOT . ' THEN "root" WHEN ' . USER_GUEST . ' THEN "Guest" ELSE IF(CONCAT(u.FirstName, u.LastName) <> "", CONCAT(u.FirstName, " ", u.LastName), IF(%1$s.UserId IS NULL, "Guest", IF(u.Username = "", u.Email, u.Username))) END',
'CategoryName' => 'c.l%2$s_Name',
'ItemName' => '%1$s.ItemId',
'ParentItemName' => '%1$s.ParentItemId',
@@ -101,7 +101,7 @@
'required' => 1, 'default' => NULL
),
'SubscriberEmail' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
- 'UserId' => Array ('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array (USER_ROOT => 'root', USER_GUEST => 'Guest'), 'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Users WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Username', 'default' => NULL),
+ 'UserId' => Array ('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array (USER_ROOT => 'root', USER_GUEST => 'Guest'), 'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Users WHERE %s', 'left_key_field' => 'PortalUserId', 'left_title_field' => USER_TITLE_FIELD, 'default' => NULL),
'CategoryId' => Array ('type' => 'int', 'default' => NULL),
'IncludeSublevels' => Array (
'type' => 'int',
Index: branches/5.2.x/core/units/page_revisions/page_revisions_config.php
===================================================================
diff -u -N -r15165 -r15563
--- branches/5.2.x/core/units/page_revisions/page_revisions_config.php (.../page_revisions_config.php) (revision 15165)
+++ branches/5.2.x/core/units/page_revisions/page_revisions_config.php (.../page_revisions_config.php) (revision 15563)
@@ -1,6 +1,6 @@
Array (
'' => Array (
- 'CreatedBy' => 'created_by.Username',
+ 'CreatedBy' => 'IF(created_by.Username = "", created_by.Email, created_by.Username)',
'IsLive' => 'IF(%1$s.RevisionNumber = c.LiveRevisionNumber, 1, 0)',
),
),
@@ -74,7 +74,7 @@
'FromRevisionId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'CreatedById' => Array (
'type' => 'int',
- 'formatter' => 'kLEFTFormatter', 'options' => Array (USER_ROOT => 'root', USER_GUEST => 'Guest'), 'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Users WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Username', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'sample_value' => 'Guest', 'required' => 1,
+ 'formatter' => 'kLEFTFormatter', 'options' => Array (USER_ROOT => 'root', USER_GUEST => 'Guest'), 'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Users WHERE %s', 'left_key_field' => 'PortalUserId', 'left_title_field' => USER_TITLE_FIELD, 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'sample_value' => 'Guest', 'required' => 1,
'default' => NULL
),
'CreatedOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#'),
Index: branches/5.2.x/core/units/spam_reports/spam_reports_config.php
===================================================================
diff -u -N -r15165 -r15563
--- branches/5.2.x/core/units/spam_reports/spam_reports_config.php (.../spam_reports_config.php) (revision 15165)
+++ branches/5.2.x/core/units/spam_reports/spam_reports_config.php (.../spam_reports_config.php) (revision 15563)
@@ -64,7 +64,7 @@
'CalculatedFields' => Array (
'' => Array (
'ItemName' => 'IF(%1$s.ItemPrefix LIKE "%rev", review.ReviewText, "")',
- 'ReportedBy' => 'reported_by.Username',
+ 'ReportedBy' => 'IF(reported_by.Username = "", reported_by.Email, reported_by.Username)',
),
),
@@ -86,7 +86,7 @@
'ReportedOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#'),
'ReportedById' => Array (
'type' => 'int',
- 'formatter' => 'kLEFTFormatter', 'options' => Array (USER_ROOT => 'root', USER_GUEST => 'Guest'), 'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Users WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Username', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'sample_value' => 'Guest',
+ 'formatter' => 'kLEFTFormatter', 'options' => Array (USER_ROOT => 'root', USER_GUEST => 'Guest'), 'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Users WHERE %s', 'left_key_field' => 'PortalUserId', 'left_title_field' => USER_TITLE_FIELD, 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'sample_value' => 'Guest',
'default' => NULL
)
),
Index: branches/5.2.x/core/units/visits/visits_config.php
===================================================================
diff -u -N -r15012 -r15563
--- branches/5.2.x/core/units/visits/visits_config.php (.../visits_config.php) (revision 15012)
+++ branches/5.2.x/core/units/visits/visits_config.php (.../visits_config.php) (revision 15563)
@@ -1,6 +1,6 @@
Array (
'' => Array (
- 'UserName' => 'IF( ISNULL(u.Username), IF (%1$s.PortalUserId = ' . USER_ROOT . ', \'root\', IF (%1$s.PortalUserId = ' . USER_GUEST . ', \'Guest\', \'n/a\')), u.Username)',
+ 'UserName' => 'IF( ISNULL(u.Username), IF (%1$s.PortalUserId = ' . USER_ROOT . ', \'root\', IF (%1$s.PortalUserId = ' . USER_GUEST . ', \'Guest\', \'n/a\')), IF(u.Username = "", u.Email, u.Username))',
),
'incommerce' => Array (
- 'UserName' => 'IF( ISNULL(u.Username), IF (%1$s.PortalUserId = ' . USER_ROOT . ', \'root\', IF (%1$s.PortalUserId = ' . USER_GUEST . ', \'Guest\', \'n/a\')), u.Username)',
- 'AffiliateUser' => 'IF( LENGTH(au.Username),au.Username,\'!la_None!\')',
+ 'UserName' => 'IF( ISNULL(u.Username), IF (%1$s.PortalUserId = ' . USER_ROOT . ', \'root\', IF (%1$s.PortalUserId = ' . USER_GUEST . ', \'Guest\', \'n/a\')), IF(u.Username = "", u.Email, u.Username))',
+ 'AffiliateUser' => 'IF(au.PortalUserId IS NULL, "!la_None!", IF(au.Username = "", au.Email, au.Username))',
'AffiliatePortalUserId' => 'af.PortalUserId',
'OrderTotalAmount' => 'IF(ord.Status = 4, ord.SubTotal+ord.ShippingCost+ord.VAT, 0)',
'OrderAffiliateCommission' => 'IF(ord.Status = 4, ord.AffiliateCommission, 0)',
@@ -133,7 +133,7 @@
'VisitDate' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'custom_filter' => 'date_range', 'default' => NULL),
'Referer' => Array ('type' => 'string','not_null' => '1','default' => ''),
'IPAddress' => Array ('type' => 'string','not_null' => '1','default' => ''),
- 'AffiliateId' => Array ('type' => 'int','formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array (0 => 'lu_None'), 'left_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'Affiliates af LEFT JOIN '.TABLE_PREFIX.'Users pu ON pu.PortalUserId = af.PortalUserId WHERE `%s` = \'%s\'','left_key_field' => 'AffiliateId','left_title_field' => 'Username','not_null'=>1,'default'=>0),
+ 'AffiliateId' => Array ('type' => 'int','formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array (0 => 'lu_None'), 'left_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'Affiliates af LEFT JOIN '.TABLE_PREFIX.'Users u ON u.PortalUserId = af.PortalUserId WHERE %s','left_key_field' => 'AffiliateId','left_title_field' => 'IF(u.Email = "", u.Username, u.Email)','not_null'=>1,'default'=>0),
'PortalUserId' => Array ('type' => 'int','not_null' => '1','default' => USER_GUEST),
),
Index: branches/5.2.x/core/units/categories/categories_config.php
===================================================================
diff -u -N -r15471 -r15563
--- branches/5.2.x/core/units/categories/categories_config.php (.../categories_config.php) (revision 15471)
+++ branches/5.2.x/core/units/categories/categories_config.php (.../categories_config.php) (revision 15563)
@@ -1,6 +1,6 @@
Array ('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => null),
'CachedDescendantCatsQty' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'CachedNavbar' => Array ('type' => 'string', 'formatter' => 'kMultiLanguage', 'default' => null),
- 'CreatedById' => Array ('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array (USER_ROOT => 'root', USER_GUEST => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'Users WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Username', 'default' => NULL),
+ 'CreatedById' => Array ('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array (USER_ROOT => 'root', USER_GUEST => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'Users WHERE %s', 'left_key_field' => 'PortalUserId', 'left_title_field' => USER_TITLE_FIELD, 'default' => NULL),
'ResourceId' => Array ('type' => 'int', 'default' => null),
'ParentPath' => Array ('type' => 'string', 'default' => null),
'TreeLeft' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
@@ -339,7 +339,7 @@
'NewItem' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 2),
'PopItem' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 2),
'Modified' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#'),
- 'ModifiedById' => Array ('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array (USER_ROOT => 'root', USER_GUEST => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'Users WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Username', 'default' => NULL),
+ 'ModifiedById' => Array ('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array (USER_ROOT => 'root', USER_GUEST => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'Users WHERE %s', 'left_key_field' => 'PortalUserId', 'left_title_field' => USER_TITLE_FIELD, 'default' => NULL),
'CachedTemplate' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''),
'CachedTemplateHash' => Array ('type' => 'string', 'not_null' => 1, 'default' => 0),
Index: branches/5.2.x/core/units/logs/system_logs/system_logs_config.php
===================================================================
diff -u -N -r15552 -r15563
--- branches/5.2.x/core/units/logs/system_logs/system_logs_config.php (.../system_logs_config.php) (revision 15552)
+++ branches/5.2.x/core/units/logs/system_logs/system_logs_config.php (.../system_logs_config.php) (revision 15563)
@@ -1,6 +1,6 @@
Array (
'' => Array (
- 'Username' => 'CASE %1$s.LogUserId WHEN ' . USER_ROOT . ' THEN "root" WHEN ' . USER_GUEST . ' THEN "Guest" ELSE IF(CONCAT(u.FirstName, u.LastName) <> "", CONCAT(u.FirstName, " ", u.LastName), u.Username) END',
+ 'Username' => 'CASE %1$s.LogUserId WHEN ' . USER_ROOT . ' THEN "root" WHEN ' . USER_GUEST . ' THEN "Guest" ELSE IF(CONCAT(u.FirstName, u.LastName) <> "", CONCAT(u.FirstName, " ", u.LastName), IF(u.Username = "", u.Email, u.Username)) END',
),
),
Index: branches/5.2.x/core/units/helpers/page_helper.php
===================================================================
diff -u -N -r15328 -r15563
--- branches/5.2.x/core/units/helpers/page_helper.php (.../page_helper.php) (revision 15328)
+++ branches/5.2.x/core/units/helpers/page_helper.php (.../page_helper.php) (revision 15563)
@@ -1,6 +1,6 @@
Application->getUnitOption('page-revision', 'TableName') . ' pr
LEFT JOIN ' . TABLE_PREFIX . 'Users u ON u.PortalUserId = pr.CreatedById
WHERE (' . implode(') AND (', $where_clause) . ')';
Index: branches/5.2.x/core/install/install_data.sql
===================================================================
diff -u -N -r15552 -r15563
--- branches/5.2.x/core/install/install_data.sql (.../install_data.sql) (revision 15552)
+++ branches/5.2.x/core/install/install_data.sql (.../install_data.sql) (revision 15563)
@@ -114,7 +114,7 @@
# Section "in-portal:configure_users":
INSERT INTO SystemSettings VALUES(DEFAULT, 'User_Allow_New', '3', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_users_allow_new', 'radio', '', '1=la_opt_UserInstantRegistration||2=la_opt_UserNotAllowedRegistration||3=la_opt_UserUponApprovalRegistration||4=la_opt_UserEmailActivation', 10.01, 0, 1, NULL);
INSERT INTO SystemSettings VALUES(DEFAULT, 'AdvancedUserManagement', '0', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_prompt_AdvancedUserManagement', 'checkbox', NULL, NULL, 10.011, 0, 1, NULL);
-INSERT INTO SystemSettings VALUES(DEFAULT, 'RegistrationUsernameRequired', '1', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_config_RegistrationUsernameRequired', 'checkbox', NULL, NULL, 10.02, 0, 0, NULL);
+INSERT INTO SystemSettings VALUES(DEFAULT, 'RegistrationUsernameRequired', '0', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_config_RegistrationUsernameRequired', 'checkbox', NULL, NULL, 10.02, 0, 0, NULL);
INSERT INTO SystemSettings VALUES(DEFAULT, 'RegistrationCaptcha', '0', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_registration_captcha', 'checkbox', NULL, NULL, 10.025, 0, 0, NULL);
INSERT INTO SystemSettings VALUES(DEFAULT, 'Min_UserName', '3', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_text_min_username', 'text', '', 'style="width: 50px;"', 10.03, 1, 0, NULL);
INSERT INTO SystemSettings VALUES(DEFAULT, 'MaxUserName', '', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_text_min_username', 'text', '', 'style="width: 50px;"', 10.03, 2, 0, NULL);
Index: branches/5.2.x/core/units/reviews/reviews_config.php
===================================================================
diff -u -N -r15012 -r15563
--- branches/5.2.x/core/units/reviews/reviews_config.php (.../reviews_config.php) (revision 15012)
+++ branches/5.2.x/core/units/reviews/reviews_config.php (.../reviews_config.php) (revision 15563)
@@ -1,6 +1,6 @@
'int',
'formatter' => 'kLEFTFormatter',
'options' => Array (USER_ROOT => 'root', USER_GUEST => 'Guest'),
- 'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Users
- WHERE `%s` = \'%s\' ',
- 'left_key_field' => 'PortalUserId',
- 'left_title_field' => 'Username',
+ 'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Users WHERE %s',
+ 'left_key_field' => 'PortalUserId', 'left_title_field' => USER_TITLE_FIELD,
'required' => 1, 'default' => NULL,
'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'),
),
Index: branches/5.2.x/core/kernel/constants.php
===================================================================
diff -u -N -r15421 -r15563
--- branches/5.2.x/core/kernel/constants.php (.../constants.php) (revision 15421)
+++ branches/5.2.x/core/kernel/constants.php (.../constants.php) (revision 15563)
@@ -1,6 +1,6 @@
getObject();
/* @var $object kDBItem */
- $user_id = $object->GetDBField($id_field);
- $options = $object->GetFieldOptions($id_field);
-
- if ( isset($options['options'][$user_id]) ) {
- $object->SetDBField($cached_field, $options['options'][$user_id]);
- }
- else {
- $id_field = $this->Application->getUnitOption('u', 'IDField');
- $table_name = $this->Application->getUnitOption('u', 'TableName');
-
- $sql = 'SELECT Username
- FROM ' . $table_name . '
- WHERE ' . $id_field . ' = ' . $user_id;
- $object->SetDBField($cached_field, $this->Conn->GetOne($sql));
- }
+ $object->SetDBField($cached_field, $object->GetField($id_field));
}
/**
Index: branches/5.2.x/core/units/user_groups/user_groups_config.php
===================================================================
diff -u -N -r15012 -r15563
--- branches/5.2.x/core/units/user_groups/user_groups_config.php (.../user_groups_config.php) (revision 15012)
+++ branches/5.2.x/core/units/user_groups/user_groups_config.php (.../user_groups_config.php) (revision 15563)
@@ -1,6 +1,6 @@
Array (
'' => Array(
'UserName' => 'CONCAT(u.LastName, \' \', u.FirstName)',
- 'UserLogin' => 'u.Username',
+ 'UserLogin' => 'IF(u.Username = "", u.Email, u.Username)',
'PrimaryGroup' => 'IF(u.PrimaryGroupId = %1$s.GroupId, 1, 0)',
),
),
Index: branches/5.2.x/core/kernel/utility/formatters/left_formatter.php
===================================================================
diff -u -N -r14748 -r15563
--- branches/5.2.x/core/kernel/utility/formatters/left_formatter.php (.../left_formatter.php) (revision 14748)
+++ branches/5.2.x/core/kernel/utility/formatters/left_formatter.php (.../left_formatter.php) (revision 15563)
@@ -1,6 +1,6 @@
query for it
- $sql = sprintf($options['left_sql'], $options['left_title_field'], $options['left_key_field'], $this->Conn->escape($value));
+ $display_field = $this->_escapeField($options['left_title_field']);
+ $match_field = $this->_escapeField($options['left_key_field']);
+
+ $sql = sprintf($options['left_sql'], $display_field, $match_field . ' = ' . $this->Conn->qstr($value));
$options['options'][$value] = $this->Conn->GetOne($sql);
if ( $options['options'][$value] === false ) {
@@ -58,6 +61,22 @@
}
/**
+ * Escape field names, but not expressions
+ *
+ * @param string $field_name
+ * @return string
+ * @access protected
+ */
+ protected function _escapeField($field_name)
+ {
+ if ( preg_match('/^[a-z_]+$/i', $field_name) ) {
+ return '`' . $field_name . '`';
+ }
+
+ return $field_name;
+ }
+
+ /**
* Performs basic type validation on form field value
*
* @param mixed $value
@@ -81,7 +100,10 @@
}
// requested option is not found in field options -> query for it
- $sql = sprintf($options['left_sql'], $options['left_key_field'], $options['left_title_field'], $this->Conn->escape($value));
+ $display_field = $this->_escapeField($options['left_key_field']);
+ $match_field = $this->_escapeField($options['left_title_field']);
+
+ $sql = sprintf($options['left_sql'], $display_field, $match_field . ' = ' . $this->Conn->qstr($value));
$found = $this->Conn->GetOne($sql);
if ( $found !== false ) {
@@ -90,7 +112,7 @@
}
$skip_errors = array_key_exists('skip_errors', $options) && $options['skip_errors'];
-
+
if ( $found === false && !$skip_errors ) {
// option not found at all -> return not formatted value & set error
$object->SetError($field_name, 'invalid_option', 'la_error_InvalidOption');