Changeset:
73d40778ac8c
https://sourceforge.net/p/mrbs/hg-code/ci/73d40778ac8cb98813d7a48ea445ba886c34aa57
Author:
Campbell Morrison <[email protected]>
Date:
Wed Feb 22 15:21:35 2017 +0000
Log message:
Allowed users just to use the local-part of their email address when logging
in, provided the authentication type supports it (only 'db' at the moment).
Enabled by a config variable.
diffstat:
web/auth/auth_db.inc | 24 ++++-
web/lib/MRBS/DB_mysql.php | 22 ++++
web/systemdefaults.inc.php | 219 +++++++++++++++++++++++---------------------
3 files changed, 155 insertions(+), 110 deletions(-)
diffs (truncated from 592 to 300 lines):
diff -r 4a980973586b -r 73d40778ac8c web/auth/auth_db.inc
--- a/web/auth/auth_db.inc Wed Feb 22 12:04:12 2017 +0000
+++ b/web/auth/auth_db.inc Wed Feb 22 15:21:35 2017 +0000
@@ -137,7 +137,7 @@
$valid_usernames = array_merge($valid_usernames, authValidateEmail($user,
$pass));
$valid_usernames = array_unique($valid_usernames);
-
+
return (count($valid_usernames) == 1) ? $valid_usernames[0] : false;
}
@@ -199,6 +199,7 @@
function authValidateEmail($email, $pass)
{
global $tbl_users;
+ global $auth;
$valid_usernames = array();
@@ -209,11 +210,28 @@
// be case sensitive. But before we can take account of this, the email
addresses in the database
// need to be normalised so that all the domain names are stored in lower
case. Then it will be
// possible to do a case sensitive comparison.
- //
+ if (strpos($email, '@') === false)
+ {
+ if (!empty($auth['allow_local_part_email']))
+ {
+ // We're just checking the local-part of the email address
+ $condition = "LOWER(?)=LOWER(" . db()->syntax_simple_split('email', '@',
1, $sql_params) .")";
+ }
+ else
+ {
+ return $valid_usernames;
+ }
+ }
+ else
+ {
+ // Check the complete email address
+ $condition = "LOWER(?)=LOWER(email)";
+ }
+
// Email addresses are not unique in the users table, so we need to find all
of them.
$sql = "SELECT password_hash, name
FROM $tbl_users
- WHERE LOWER(email)=LOWER(?)";
+ WHERE $condition";
$res = db()->query($sql, $sql_params);
diff -r 4a980973586b -r 73d40778ac8c web/lib/MRBS/DB_mysql.php
--- a/web/lib/MRBS/DB_mysql.php Wed Feb 22 12:04:12 2017 +0000
+++ b/web/lib/MRBS/DB_mysql.php Wed Feb 22 15:21:35 2017 +0000
@@ -285,4 +285,26 @@
{
return "^";
}
+
+ // Returns the syntax for a simple split of a column's value into two
+ // parts, separated by a delimiter. $part can be 1 or 2.
+ // Also takes a required pass-by-reference parameter to modify the SQL
+ // parameters appropriately.
+ public function syntax_simple_split($fieldname, $delimiter, $part, &$params)
+ {
+ switch ($part)
+ {
+ case 1:
+ $count = 1;
+ break;
+ case 2:
+ $count = -1;
+ default:
+ throw new Exception("Invalid value ($part) given for " . '$part.');
+ break;
+ }
+
+ $params[] = $delimiter;
+ return "SUBSTRING_INDEX($fieldname, ?, $count)";
+ }
}
diff -r 4a980973586b -r 73d40778ac8c web/systemdefaults.inc.php
--- a/web/systemdefaults.inc.php Wed Feb 22 12:04:12 2017 +0000
+++ b/web/systemdefaults.inc.php Wed Feb 22 15:21:35 2017 +0000
@@ -39,12 +39,12 @@
// time to time to see if there is a later version available on the web. If
your
// site prevents external access to the web, this check will time out. However
// you can avoid the timeout and stop MRBS checking for up to date versions by
-// setting $zoneinfo_update = FALSE;
-$zoneinfo_update = TRUE;
+// setting $zoneinfo_update = false;
+$zoneinfo_update = true;
// The VTIMEZONE definitions exist in two forms - normal and Outlook
compatible.
// $zoneinfo_outlook_compatible determines which ones to use.
-$zoneinfo_outlook_compatible = TRUE;
+$zoneinfo_outlook_compatible = true;
// The VTIMEZONE definitions are cached in the database with an expiry time
// of $zoneinfo_expiry seconds. If your server does not have external
internet
@@ -79,13 +79,13 @@
// Prefix for table names. This will allow multiple installations where only
// one database is available
$db_tbl_prefix = "mrbs_";
-// Set $db_persist to TRUE to use PHP persistent (pooled) database
connections. Note
+// Set $db_persist to true to use PHP persistent (pooled) database
connections. Note
// that persistent connections are not recommended unless your system suffers
significant
// performance problems without them. They can cause problems with
transactions and
// locks (see http://php.net/manual/en/features.persistent-connections.php)
and although
// MRBS tries to avoid those problems, it is generally better not to use
persistent
// connections if you can.
-$db_persist = FALSE;
+$db_persist = false;
/*********************************
@@ -185,7 +185,7 @@
// expect to see in the day and week views. It is used by mrbs.css.php for
// creating classes. It does not matter if it is too large, except for the
// fact that more CSS than necessary will be generated. (The variable is
ignored
-// if $times_along_top is set to TRUE).
+// if $times_along_top is set to true).
$max_slots = 60;
@@ -201,7 +201,7 @@
// PERIODS SETTINGS
// ----------------
-// The "Periods" settings are ignored if $enable_periods is FALSE.
+// The "Periods" settings are ignored if $enable_periods is false.
// Define the name or description for your periods in chronological order
// For example:
@@ -245,19 +245,19 @@
// by the $weekstarts setting). These are global settings, but you can
additionally
// configure per area settings. This would allow you to set policies such as
allowing
// a maximum of 10 bookings per month in total with a maximum of 1 per day in
Area A.
-$max_per_interval_global_enabled['day'] = FALSE;
+$max_per_interval_global_enabled['day'] = false;
$max_per_interval_global['day'] = 1; // max 1 bookings per day in total
-$max_per_interval_global_enabled['week'] = FALSE;
+$max_per_interval_global_enabled['week'] = false;
$max_per_interval_global['week'] = 5; // max 5 bookings per week in total
-$max_per_interval_global_enabled['month'] = FALSE;
+$max_per_interval_global_enabled['month'] = false;
$max_per_interval_global['month'] = 10; // max 10 bookings per month in total
-$max_per_interval_global_enabled['year'] = FALSE;
+$max_per_interval_global_enabled['year'] = false;
$max_per_interval_global['year'] = 50; // max 50 bookings per year in total
-$max_per_interval_global_enabled['future'] = FALSE;
+$max_per_interval_global_enabled['future'] = false;
$max_per_interval_global['future'] = 100; // max 100 bookings in the future in
total
// Set the latest date for which you can make a booking. This can be useful
if you
@@ -266,7 +266,7 @@
// using the area settings. Note that it is possible to have both a relative
and absolute
// date, eg "no more than a week away and in any case not past the end of
term".
// Note that bookings are allowed on the $max_booking_date, but not after it.
-$max_booking_date_enabled = FALSE;
+$max_booking_date_enabled = false;
$max_booking_date = "2012-07-23"; // Must be a string in the format
"yyyy-mm-dd"
// Set the earliest date for which you can make a booking. This can be
useful if you
@@ -275,7 +275,7 @@
// using the area settings. Note that it is possible to have both a relative
and absolute
// date, eg "no earlier than a week away and in any case not before the
beginning of term".
// Note that bookings are allowed on the $min_booking_date, but not before it.
-$min_booking_date_enabled = FALSE;
+$min_booking_date_enabled = false;
$min_booking_date = "2012-04-23"; // Must be a string in the format
"yyyy-mm-dd"
/******************
@@ -323,7 +323,7 @@
$strftime_format['datetime'] = "%c"; // Used in Help
$strftime_format['datetime12'] = "%I:%M:%S%p - %A %d %B %Y"; // 12 hour
clock
$strftime_format['datetime24'] = "%H:%M:%S - %A %d %B %Y"; // 24 hour
clock
-// If you prefer dates as "10 Jul" instead of "Jul 10" ($dateformat = TRUE in
+// If you prefer dates as "10 Jul" instead of "Jul 10" ($dateformat = true in
// MRBS 1.4.5 and earlier) then use
// $strftime_format['daymonth'] = "%d %b";
$strftime_format['daymonth'] = "%b %d"; // Used in trailer
@@ -331,7 +331,7 @@
$strftime_format['monthyear'] = "%B %Y"; // Used in Month view
// Whether or not to display the timezone
-$display_timezone = FALSE;
+$display_timezone = false;
// Results per page for searching:
$search["count"] = 20;
@@ -345,10 +345,10 @@
// Set to 0 to disable
$ajax_refresh_rate = 10;
-// Trailer type. FALSE gives a trailer complete with links to days, weeks
and months before
-// and after the current date. TRUE gives a simpler trailer that just has
links to the
+// Trailer type. false gives a trailer complete with links to days, weeks
and months before
+// and after the current date. true gives a simpler trailer that just has
links to the
// current day, week and month.
-$simple_trailer = FALSE;
+$simple_trailer = false;
// should areas be shown as a list or a drop-down select box?
$area_list_format = "list";
@@ -361,33 +361,33 @@
$monthly_view_entries_details = "both";
// To view weeks in the bottom trailer as week numbers (42) instead of
-// 'first day of the week' (13 Oct), set this to TRUE. Will also give week
+// 'first day of the week' (13 Oct), set this to true. Will also give week
// numbers in the month view
-$view_week_number = FALSE;
+$view_week_number = false;
// To display week numbers in the mini-calendars, set this to true. The week
// numbers are only accurate if you set $weekstarts to 1, i.e. set the
// start of the week to Monday
-$mincals_week_numbers = FALSE;
+$mincals_week_numbers = false;
// To display times on the x-axis (along the top) and rooms or days on the
y-axis (down the side)
-// set to TRUE; the default/traditional version of MRBS has rooms (or days)
along the top and
+// set to true; the default/traditional version of MRBS has rooms (or days)
along the top and
// times along the side. Transposing the table can be useful if you have a
large number of
// rooms and not many time slots.
-$times_along_top = FALSE;
+$times_along_top = false;
// To display the row labels (times, rooms or days) on the right hand side as
well as the
-// left hand side in the day and week views, set to TRUE;
+// left hand side in the day and week views, set to true;
// (was called $times_right_side in earlier versions of MRBS)
-$row_labels_both_sides = FALSE;
+$row_labels_both_sides = false;
// To display the column headers (times, rooms or days) on the bottom of the
table as
-// well as the top in the day and week views, set to TRUE;
-$column_labels_both_ends = FALSE;
+// well as the top in the day and week views, set to true;
+$column_labels_both_ends = false;
// To display the mini caldandars at the bottom of the day week and month views
-// set this value to TRUE
-$display_calendar_bottom = FALSE;
+// set this value to true
+$display_calendar_bottom = false;
// Define default starting view (month, week or day)
// Default is day
@@ -400,24 +400,24 @@
$default_room = 0;
// Define clipping behaviour for the cells in the day and week views.
-// Set to TRUE if you want the cells in the day and week views to be clipped.
This
+// Set to true if you want the cells in the day and week views to be clipped.
This
// gives a table where all the rows have the same height, regardless of
content.
-// Alternatively set to FALSE if you want the cells to expand to fit the
content.
-// (FALSE not supported in IE6 and IE7 due to their incomplete CSS support)
-$clipped = TRUE;
+// Alternatively set to false if you want the cells to expand to fit the
content.
+// (false not supported in IE6 and IE7 due to their incomplete CSS support)
+$clipped = true;
// Define clipping behaviour for the cells in the month view.
-// Set to TRUE if you want all entries to have the same height. The
-// short description may be clipped in this case. If set to FALSE,
+// Set to true if you want all entries to have the same height. The
+// short description may be clipped in this case. If set to false,
// each booking entry will be large enough to display all information.
-$clipped_month = TRUE;
+$clipped_month = true;
-// Set to TRUE if you want the cells in the month view to scroll if there are
too
-// many bookings to display; set to FALSE if you want the table cell to expand
to
+// Set to true if you want the cells in the month view to scroll if there are
too
+// many bookings to display; set to false if you want the table cell to expand
to
// accommodate the bookings. (NOTE: (1) scrolling doesn't work in IE6 and so
the table
// cell will always expand in IE6. (2) In IE8 Beta 2 scrolling doesn't work
either and
-// the cell content is clipped when $month_cell_scrolling is set to TRUE.)
-$month_cell_scrolling = TRUE;
+// the cell content is clipped when $month_cell_scrolling is set to true.)
+$month_cell_scrolling = true;
// Define the maximum length of a string that can be displayed in an admin
table cell
// (eg the rooms and users lists) before it is truncated. (This is necessary
because
@@ -455,7 +455,7 @@
// Default report span in days:
$default_report_days = 60;
-$show_plus_link = FALSE; // Change to TRUE to always show the (+) link as in
+$show_plus_link = false; // Change to true to always show the (+) link as in
// MRBS 1.1.
@@ -465,15 +465,15 @@
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits