Changeset:
        3dcb50054078
        
https://sourceforge.net/p/mrbs/hg-code/ci/3dcb500540782bb1619aa52fcf39bbc9c28f9c1f
Author:
        Campbell Morrison <[email protected]>
Date:
        Fri Mar 10 09:55:43 2017 +0000
Log message:

Added a warning symbol on the edit_entry page instead of a green tick when an
admin makes a booking that would normally violate one or more of the policy
rules.  See SF Support Requests 1171.

diffstat:

 web/css/mrbs-ielte8.css    |   10 +++-
 web/css/mrbs.css.php       |   25 ++++++++-
 web/edit_entry.php         |   10 ++-
 web/edit_entry_handler.php |    6 +-
 web/import.php             |    4 +-
 web/js/edit_entry.js.php   |   23 +++++++-
 web/js/resizable.js.php    |    4 +-
 web/lang/lang.en           |   29 +++++-----
 web/mrbs_sql.inc           |  114 +++++++++++++++++++++++++-------------------
 9 files changed, 140 insertions(+), 85 deletions(-)

diffs (truncated from 495 to 300 lines):

diff -r 9b016fa1083d -r 3dcb50054078 web/css/mrbs-ielte8.css
--- a/web/css/mrbs-ielte8.css   Thu Mar 09 13:12:59 2017 +0000
+++ b/web/css/mrbs-ielte8.css   Fri Mar 10 09:55:43 2017 +0000
@@ -30,12 +30,18 @@
   content: '? ';
 }
 
-div.good:after {
+.good:after {
   content: '\002714';  /* checkmark */
   color: green;
 }
 
-div.bad:after {
+.notice::after {
+  content: '!';
+  font-weight: bold;
+  color: #ff5722;
+}
+
+.bad:after {
   content: '\002718';  /* cross */
   color: red;
 }
diff -r 9b016fa1083d -r 3dcb50054078 web/css/mrbs.css.php
--- a/web/css/mrbs.css.php      Thu Mar 09 13:12:59 2017 +0000
+++ b/web/css/mrbs.css.php      Fri Mar 10 09:55:43 2017 +0000
@@ -859,15 +859,32 @@
 
 .form_general label.secondary {font-weight: normal; width: auto}
 
-div#conflict_check, div#policy_check {float: left; clear: none; width: 2em; 
padding: 1em 0.5em; cursor: pointer}
-div#conflict_check {margin-left: 3em}
+div#checks {
+  float: left; 
+  clear: none; 
+  width: auto;
+  white-space: nowrap;
+  letter-spacing: 0.9em;
+  padding: 1em 0;
+  margin-left: 3em;
+}
 
-div.good::after {
+div#checks span {
+  cursor: pointer;
+}
+
+.good::after {
   content: '\002714';  <?php // checkmark ?>
   color: green;
 }
 
-div.bad::after {
+.notice::after {
+  content: '!';
+  font-weight: bold;
+  color: #ff5722;
+}
+
+.bad::after {
   content: '\002718';  <?php // cross ?>
   color: red;
 }
diff -r 9b016fa1083d -r 3dcb50054078 web/edit_entry.php
--- a/web/edit_entry.php        Thu Mar 09 13:12:59 2017 +0000
+++ b/web/edit_entry.php        Fri Mar 10 09:55:43 2017 +0000
@@ -1431,12 +1431,14 @@
     // The Submit button
     echo "<div id=\"edit_entry_submit_save\">\n";
     echo "<input class=\"submit default_action\" type=\"submit\" 
name=\"save_button\" value=\"" .
-      get_vocab("save") . "\">\n";
+          get_vocab("save") . "\">\n";
     echo "</div>\n";
     
-    // divs to hold the results of the Ajax checking of the booking
-    echo "<div id=\"conflict_check\"></div>\n";
-    echo "<div id=\"policy_check\"></div>\n";
+    // div to hold the results of the Ajax checking of the booking
+    echo "<div id=\"checks\">\n";
+    echo "<span id=\"conflict_check\"></span>\n";
+    echo "<span id=\"policy_check\"></span>\n";
+    echo "</div>\n";
     
     echo "</fieldset>";
     
diff -r 9b016fa1083d -r 3dcb50054078 web/edit_entry_handler.php
--- a/web/edit_entry_handler.php        Thu Mar 09 13:12:59 2017 +0000
+++ b/web/edit_entry_handler.php        Fri Mar 10 09:55:43 2017 +0000
@@ -764,13 +764,13 @@
   print_header($day, $month, $year, $area, isset($room) ? $room : null);
     
   echo "<h2>" . get_vocab("sched_conflict") . "</h2>\n";
-  if (!empty($result['rules_broken']))
+  if (!empty($result['violations']['errors']))
   {
     echo "<p>\n";
     echo get_vocab("rules_broken") . ":\n";
     echo "</p>\n";
     echo "<ul>\n";
-    foreach ($result['rules_broken'] as $rule)
+    foreach ($result['violations']['errors'] as $rule)
     {
       echo "<li>$rule</li>\n";
     }
@@ -802,7 +802,7 @@
 
 // Skip and Book button (to book the entries that don't conflict)
 // Only show this button if there were no policies broken and it's a series
-if (empty($result['rules_broken'])  &&
+if (empty($result['violations']['errors'])  &&
     isset($rep_type) && ($rep_type != REP_NONE))
 {
   echo "<form method=\"post\" action=\"" . htmlspecialchars(this_page()) . 
"\">\n";
diff -r 9b016fa1083d -r 3dcb50054078 web/import.php
--- a/web/import.php    Thu Mar 09 13:12:59 2017 +0000
+++ b/web/import.php    Fri Mar 10 09:55:43 2017 +0000
@@ -441,11 +441,11 @@
   {
     echo "<li>" . htmlspecialchars($problem) . "</li>\n";
   }
-  if (!empty($result['rules_broken']))
+  if (!empty($result['violations']['errors']))
   {
     echo "<li>" . get_vocab("rules_broken") . "\n";
     echo "<ul>\n";
-    foreach ($result['rules_broken'] as $rule)
+    foreach ($result['violations']['errors'] as $rule)
     {
       echo "<li>$rule</li>\n";
     }
diff -r 9b016fa1083d -r 3dcb50054078 web/js/edit_entry.js.php
--- a/web/js/edit_entry.js.php  Thu Mar 09 13:12:59 2017 +0000
+++ b/web/js/edit_entry.js.php  Fri Mar 10 09:55:43 2017 +0000
@@ -620,11 +620,24 @@
             conflictDiv.attr('title', titleText);
             scheduleDetails.html(detailsHTML);
             var policyDiv = $('#policy_check');
-            if (result.rules_broken.length === 0)
+            if (result.violations.errors.length === 0)
             {
-              policyDiv.attr('class', 'good');
-              titleText = '<?php echo 
escape_js(mrbs_entity_decode(get_vocab("no_rules_broken"))) ?>';
-              detailsHTML = titleText;
+              if (result.violations.notices.length === 0)
+              {
+                policyDiv.attr('class', 'good');
+                titleText = '<?php echo 
escape_js(mrbs_entity_decode(get_vocab("no_rules_broken"))) ?>';
+                detailsHTML = titleText;
+              }
+              else
+              {
+                policyDiv.attr('class', 'notice');
+                detailsHTML = "<p>";
+                titleText = '<?php echo 
escape_js(mrbs_entity_decode(get_vocab("rules_broken_notices"))) ?>' + ":  
\n\n";
+                detailsHTML += titleText + "<\/p>";
+                var rulesList = getErrorList(result.violations.notices);
+                detailsHTML += rulesList.html;
+                titleText += rulesList.text;
+              }
             }
             else
             {
@@ -632,7 +645,7 @@
               detailsHTML = "<p>";
               titleText = '<?php echo 
escape_js(mrbs_entity_decode(get_vocab("rules_broken"))) ?>' + ":  \n\n";
               detailsHTML += titleText + "<\/p>";
-              var rulesList = getErrorList(result.rules_broken);
+              var rulesList = getErrorList(result.violations.errors);
               detailsHTML += rulesList.html;
               titleText += rulesList.text;
             }
diff -r 9b016fa1083d -r 3dcb50054078 web/js/resizable.js.php
--- a/web/js/resizable.js.php   Thu Mar 09 13:12:59 2017 +0000
+++ b/web/js/resizable.js.php   Fri Mar 10 09:55:43 2017 +0000
@@ -1116,14 +1116,14 @@
                                   var conflictsList = 
getErrorList(result.conflicts);
                                   alertMessage += conflictsList.text;
                                 }
-                                if (result.rules_broken.length > 0)
+                                if (result.violations.errors.length > 0)
                                 {
                                   if (result.conflicts.length > 0)
                                   {
                                     alertMessage += "\n\n";
                                   }
                                   alertMessage += '<?php echo 
escape_js(mrbs_entity_decode(get_vocab("rules_broken"))) ?>' + ":  \n\n";
-                                  var rulesList = 
getErrorList(result.rules_broken);
+                                  var rulesList = 
getErrorList(result.violations.errors);
                                   alertMessage += rulesList.text;
                                 }
                                 window.alert(alertMessage);
diff -r 9b016fa1083d -r 3dcb50054078 web/lang/lang.en
--- a/web/lang/lang.en  Thu Mar 09 13:12:59 2017 +0000
+++ b/web/lang/lang.en  Fri Mar 10 09:55:43 2017 +0000
@@ -147,20 +147,21 @@
 $vocab["no"]                  = "No";
 
 // Used in edit_entry_handler.php
-$vocab["error"]              = "Error";
-$vocab["sched_conflict"]     = "Scheduling Conflict";
-$vocab["conflict"]           = "The new booking will conflict with the 
following entries";
-$vocab["no_conflicts"]       = "No scheduling conflicts";
-$vocab["rules_broken"]       = "The new booking will conflict with the 
following policies";
-$vocab["no_rules_broken"]    = "No policy conflicts";
-$vocab["schedule"]           = "Schedule";
-$vocab["policy"]             = "Policy";
-$vocab["too_may_entrys"]     = "The selected options will create too many 
entries.<br>Please use different options!";
-$vocab["returncal"]          = "Return to calendar view";
-$vocab["failed_to_acquire"]  = "Failed to acquire exclusive database access";
-$vocab["invalid_booking"]    = "Invalid booking";
-$vocab["must_set_description"] = "You must set a brief description for the 
booking. Please go back and enter one.";
-$vocab["no_rooms_selected"]    = "You must select a room.";
+$vocab["error"]                  = "Error";
+$vocab["sched_conflict"]         = "Scheduling Conflict";
+$vocab["conflict"]               = "The new booking will conflict with the 
following entries";
+$vocab["no_conflicts"]           = "No scheduling conflicts";
+$vocab["rules_broken"]           = "The new booking will conflict with the 
following policies";
+$vocab["rules_broken_notices"]   = "[Information only] The new booking would 
conflict with the following policies";
+$vocab["no_rules_broken"]        = "No policy conflicts";
+$vocab["schedule"]               = "Schedule";
+$vocab["policy"]                 = "Policy";
+$vocab["too_may_entrys"]         = "The selected options will create too many 
entries.<br>Please use different options!";
+$vocab["returncal"]              = "Return to calendar view";
+$vocab["failed_to_acquire"]      = "Failed to acquire exclusive database 
access";
+$vocab["invalid_booking"]        = "Invalid booking";
+$vocab["must_set_description"]   = "You must set a brief description for the 
booking. Please go back and enter one.";
+$vocab["no_rooms_selected"]      = "You must select a room.";
 $vocab["mail_subject_approved"]  = "Entry approved for $mrbs_company MRBS";
 $vocab["mail_subject_rejected"]  = "Entry rejected for $mrbs_company MRBS";
 $vocab["mail_subject_more_info"] = "$mrbs_company MRBS: more information 
requested";
diff -r 9b016fa1083d -r 3dcb50054078 web/mrbs_sql.inc
--- a/web/mrbs_sql.inc  Thu Mar 09 13:12:59 2017 +0000
+++ b/web/mrbs_sql.inc  Fri Mar 10 09:55:43 2017 +0000
@@ -240,8 +240,8 @@
  *            - FALSE:  We're intending to create an entry (the default)
  * 
  * Returns:
- *            - An array of human readable errors.   If no errors the array has
- *              length 0
+ *            - An array of human readable errors, index by 'notices' or 
'errors'.
+ *              If there are no policy violations the array has length 0.
  */
 function mrbsCheckPolicy(&$booking, $ignore, $repignore, $delete=FALSE)
 {
@@ -255,14 +255,16 @@
   global $max_per_interval_global_enabled, $max_per_interval_area_enabled;
   global $interval_types, $strftime_format;
 
-  $errors = array();
+  $result = array('notices' => array(),
+                  'errors'  => array());
+                  
+  $violations = array();
   
-  // The booking policies don't apply to booking admins for this room
+  // If the user is a booking admin for this room then we still check for 
policy
+  // violations, but they are for information only and are classed as 'notices'
   $user = getUserName();
-  if (auth_book_admin($user, $booking['room_id']))
-  {
-    return $errors;
-  }
+  $violation_status = (auth_book_admin($user, $booking['room_id'])) ? 
'notices' : 'errors';
+
    
   // Because MRBS has no notion of where we are in the day if we're using 
periods,
   // we'll just assume that we're at the beginning of the day.
@@ -282,7 +284,7 @@
       if (($booking['start_time'] - $now) < $min_delete_ahead)
       {
         toTimeString($min_delete_ahead, $units);
-        $errors[] = get_vocab('min_delete_time_before', $min_delete_ahead, 
$units);
+        $violations[] = get_vocab('min_delete_time_before', $min_delete_ahead, 
$units);
       }
     }
     
@@ -296,7 +298,7 @@
       if (($booking['end_time'] - $now) > $max_delete_ahead)
       {
         toTimeString($max_delete_ahead, $units);
-        $errors[] = get_vocab('max_delete_time_before', $max_delete_ahead, 
$units);
+        $violations[] = get_vocab('max_delete_time_before', $max_delete_ahead, 
$units);
       }
     }
   }
@@ -314,7 +316,7 @@
       if (($booking['start_time'] - $now) < $min_create_ahead)
       {
         toTimeString($min_create_ahead, $units);
-        $errors[] = get_vocab('min_create_time_before', $min_create_ahead, 
$units);
+        $violations[] = get_vocab('min_create_time_before', $min_create_ahead, 
$units);
       }
     }
     
@@ -331,7 +333,7 @@
       if (($booking['end_time'] - $now) > $max_create_ahead)
       {
         toTimeString($max_create_ahead, $units);
-        $errors[] = get_vocab('max_create_time_before', $max_create_ahead, 
$units);

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to