Revision: 2130
http://mrbs.svn.sourceforge.net/mrbs/?rev=2130&view=rev
Author: cimorrison
Date: 2011-10-20 14:00:13 +0000 (Thu, 20 Oct 2011)
Log Message:
-----------
Prevented dragging of new rooms to create repeats or multi-room bookings if not
allowed
Modified Paths:
--------------
mrbs/branches/draggable_bookings/web/Themes/default/header.inc
mrbs/branches/draggable_bookings/web/edit_entry.php
Modified: mrbs/branches/draggable_bookings/web/Themes/default/header.inc
===================================================================
--- mrbs/branches/draggable_bookings/web/Themes/default/header.inc
2011-10-20 12:56:07 UTC (rev 2129)
+++ mrbs/branches/draggable_bookings/web/Themes/default/header.inc
2011-10-20 14:00:13 UTC (rev 2130)
@@ -1431,7 +1431,7 @@
var snapGap = (force) ? 100000: 20; <?php // px ?>
var tolerance = 2; <?php //px ?>
var isLR = (side=='left') || (side=='right');
-
+
data = (isLR) ? tableData.x.data : tableData.y.data;
for (var i=0; i<(data.length -1); i++)
@@ -1466,6 +1466,7 @@
((i==(data.length-2)) && (gapBottomRight<0)) )
{
var gap = bottomRight - topLeft;
+
if ((gapTopLeft <= gap/2) && (gapTopLeft < snapGap))
{
switch (side)
@@ -1601,14 +1602,45 @@
var downHandler = function(e) {
<?php // Apply a wrapper to turn off highlighting ?>
table.wrap('<div class="resizing"><\/div>');
- downHandler.origin = $(e.target).offset();
+ var jqTarget = $(e.target);
+ downHandler.origin = jqTarget.offset();
downHandler.firstPosition = {x: e.pageX, y: e.pageY};
<?php
// Get the original link in case we need it later. We can't be
sure whether
// the target was the <a> or the <td> so play safe and get all
possibilities
?>
- downHandler.originalLink =
$(e.target).find('a').andSelf('a').attr('href');
+ downHandler.originalLink =
jqTarget.find('a').andSelf('a').attr('href');
downHandler.box = $('<div class="div_select">');
+ <?php
+ if (!$is_admin)
+ {
+ // If we're not an admin and we're not allowed to book repeats
(in
+ // the week view) or select multiple rooms (in the day view)
then
+ // constrain the box to fit in the current slot width/height
+ if ((($page == 'week') && $auth['only_admin_can_book_repeat']) ||
+ (($page == 'day') &&
$auth['only_admin_can_select_multiroom']))
+ {
+ if ($times_along_top)
+ {
+ ?>
+ var slotHeight = jqTarget.outerHeight();
+ downHandler.maxHeight = true;
+ downHandler.box.css('max-height', slotHeight + 'px');
+ downHandler.box.css('min-height', slotHeight + 'px');
+ <?php
+ }
+ else
+ {
+ ?>
+ var slotWidth = jqTarget.outerWidth();
+ downHandler.maxWidth = true;
+ downHandler.box.css('max-width', slotWidth + 'px');
+ downHandler.box.css('min-width', slotWidth + 'px');
+ <?php
+ }
+ }
+ }
+ ?>
downHandler.box.offset(downHandler.origin);
$(document.body).append(downHandler.box);
};
@@ -1630,6 +1662,16 @@
box.removeClass('outside');
moveHandler.outside = false;
}
+ <?php
+ // Check to see if we're only allowed to go one slot wide/high
+ // and have gone over that limit. If so, do nothing and return
+ ?>
+ if ((downHandler.maxWidth && (e.pageX < downHandler.origin.left))
||
+ (downHandler.maxHeight && (e.pageY < downHandler.origin.top)))
+ {
+ return;
+ }
+ <?php // Otherwise redraw the box ?>
if (e.pageX < downHandler.origin.left)
{
if (e.pageY < downHandler.origin.top)
Modified: mrbs/branches/draggable_bookings/web/edit_entry.php
===================================================================
--- mrbs/branches/draggable_bookings/web/edit_entry.php 2011-10-20 12:56:07 UTC
(rev 2129)
+++ mrbs/branches/draggable_bookings/web/edit_entry.php 2011-10-20 14:00:13 UTC
(rev 2130)
@@ -137,6 +137,23 @@
$start_date = get_form_var('start_date', 'string');
$end_date = get_form_var('end_date', 'string');
+
+// Check the user is authorised for this page
+checkAuthorised();
+
+// Also need to know whether they have admin rights
+$user = getUserName();
+$is_admin = (authGetUserLevel($user) >= 2);
+// You're only allowed to make repeat bookings if you're an admin
+// or else if $auth['only_admin_can_book_repeat'] is not set
+$repeats_allowed = $is_admin || empty($auth['only_admin_can_book_repeat']);
+// Similarly for multi-day
+$multiday_allowed = $is_admin || empty($auth['only_admin_can_book_multiday']);
+// Similarly for multiple room selection
+$multiroom_allowed = $is_admin ||
empty($auth['only_admin_can_select_multiroom']);
+
+
+
if (isset($start_seconds))
{
$minutes = intval($start_seconds/60);
@@ -154,7 +171,7 @@
if (isset($start_date))
{
list($year, $month, $day) = explode('-', $start_date);
- if (isset($end_date) && ($start_date != $end_date))
+ if (isset($end_date) && ($start_date != $end_date) && $repeats_allowed)
{
$rep_type = REP_DAILY;
list($rep_end_year, $rep_end_month, $rep_end_day) = explode('-',
$end_date);
@@ -173,19 +190,7 @@
$returl = isset($HTTP_REFERER) ? $HTTP_REFERER : "";
}
-// Check the user is authorised for this page
-checkAuthorised();
-// Also need to know whether they have admin rights
-$user = getUserName();
-$is_admin = (authGetUserLevel($user) >= 2);
-// You're only allowed to make repeat bookings if you're an admin
-// or else if $auth['only_admin_can_book_repeat'] is not set
-$repeats_allowed = $is_admin || empty($auth['only_admin_can_book_repeat']);
-// Similarly for multi-day
-$multiday_allowed = $is_admin || empty($auth['only_admin_can_book_multiday']);
-// Similarly for multiple room selection
-$multiroom_allowed = $is_admin ||
empty($auth['only_admin_can_select_multiroom']);
// This page will either add or modify a booking
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Ciosco Self-Assessment and learn
about Cisco certifications, training, and career opportunities.
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits