Revision: 1487
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1487&view=rev
Author:   cimorrison
Date:     2010-10-06 14:59:45 +0000 (Wed, 06 Oct 2010)

Log Message:
-----------
Added the ability to choose which fields in the entry table should be regarded 
as private.  Controlled by an array $is_private_field in the config file, 
indexed by tablename.columnname.

Modified Paths:
--------------
    mrbs/trunk/web/edit_entry.php
    mrbs/trunk/web/functions.inc
    mrbs/trunk/web/month.php
    mrbs/trunk/web/mrbs_sql.inc
    mrbs/trunk/web/systemdefaults.inc.php
    mrbs/trunk/web/view_entry.php

Modified: mrbs/trunk/web/edit_entry.php
===================================================================
--- mrbs/trunk/web/edit_entry.php       2010-10-05 07:47:50 UTC (rev 1486)
+++ mrbs/trunk/web/edit_entry.php       2010-10-06 14:59:45 UTC (rev 1487)
@@ -130,6 +130,21 @@
   $area = get_area($row['room_id']);
   get_area_settings($area);
   
+  $private = $row['private'];
+  if ($private_mandatory) 
+  {
+    $private = $private_default;
+  }
+  // Need to clear some data if entry is private and user
+  // does not have permission to edit/view details
+  if (isset($copy) && ($create_by != $row['create_by'])) 
+  {
+    // Entry being copied by different user
+    // If they don't have rights to view details, clear them
+    $privatewriteable = getWritable($row['create_by'], $user, $row['room_id']);
+    $keep_private = (is_private_event($private) && !$privatewriteable);
+  }
+  
   foreach ($row as $column => $value)
   {
     switch ($column)
@@ -142,6 +157,7 @@
       case 'info_time':
       case 'info_user':
       case 'info_text':
+      case 'private':    // We've already got the privacy status above
         break;
         
       case 'name':
@@ -149,8 +165,7 @@
       case 'type':
       case 'room_id':
       case 'entry_type':
-      case 'private':
-        $$column = $row[$column];
+        $$column = ($keep_private && $is_private_field["entry.$column"]) ? '' 
: $row[$column];
         break;
       
       case 'repeat_id':
@@ -176,28 +191,11 @@
         break;
         
       default:
-        $custom_fields[$column] = $row[$column];
+        $custom_fields[$column] = ($keep_private && 
$is_private_field["entry.$column"]) ? '' : $row[$column];
         break;
     }
   }
   
-  if ($private_mandatory) 
-  {
-    $private = $private_default;
-  }
-  // Need to clear some data if entry is private and user
-  // does not have permission to edit/view details
-  if (isset($copy) && ($create_by != $row['create_by'])) 
-  {
-    // Entry being copied by different user
-    // If they don't have rights to view details, clear them
-    $privatewriteable = getWritable($row['create_by'], $user, $room_id);
-    if (is_private_event($private) && !$privatewriteable) 
-    {
-        $name = '';
-        $description = '' ;
-    }
-  }
 
   if($entry_type >= 1)
   {

Modified: mrbs/trunk/web/functions.inc
===================================================================
--- mrbs/trunk/web/functions.inc        2010-10-05 07:47:50 UTC (rev 1486)
+++ mrbs/trunk/web/functions.inc        2010-10-06 14:59:45 UTC (rev 1487)
@@ -1125,14 +1125,21 @@
   // start or end at a recognized time still appear.
   
   global $resolution;
+  global $is_private_field;
   
   $user = getUserName();
   if (is_private_event($row['entry_private']) &&
          !getWritable($row['entry_create_by'], $user, $row['room_id']))
   {
     $is_private = TRUE;
-    $row['name']= "[".get_vocab('unavailable')."]";
-    $row['entry_description']= "[".get_vocab('unavailable')."]";
+    if ($is_private_field['entry.name'])
+    {
+      $row['name']= "[".get_vocab('unavailable')."]";
+    }
+    if ($is_private_field['entry.description'])
+    {
+      $row['entry_description']= "[".get_vocab('unavailable')."]";
+    }
   }
   else
   {

Modified: mrbs/trunk/web/month.php
===================================================================
--- mrbs/trunk/web/month.php    2010-10-05 07:47:50 UTC (rev 1486)
+++ mrbs/trunk/web/month.php    2010-10-06 14:59:45 UTC (rev 1487)
@@ -305,7 +305,7 @@
         $private = FALSE;
       }
 
-      if ($private) 
+      if ($private & $is_private_field['entry.name']) 
       {
         $d[$day_num]["shortdescrip"][] = '['.get_vocab('unavailable').']';
       }

Modified: mrbs/trunk/web/mrbs_sql.inc
===================================================================
--- mrbs/trunk/web/mrbs_sql.inc 2010-10-05 07:47:50 UTC (rev 1486)
+++ mrbs/trunk/web/mrbs_sql.inc 2010-10-06 14:59:45 UTC (rev 1487)
@@ -71,7 +71,7 @@
                                 $row['start_time']);
     }
     
-    if (is_private_event($row['private']) &&
+    if (is_private_event($row['private']) && $is_private_field['entry.name'] &&
          !getWritable($row['create_by'], $user, $room_id))
     {
        $row['name'] = get_vocab("private");

Modified: mrbs/trunk/web/systemdefaults.inc.php
===================================================================
--- mrbs/trunk/web/systemdefaults.inc.php       2010-10-05 07:47:50 UTC (rev 
1486)
+++ mrbs/trunk/web/systemdefaults.inc.php       2010-10-06 14:59:45 UTC (rev 
1487)
@@ -444,7 +444,17 @@
            // Overrides $private_default and $private_mandatory
            // Consider your users' expectations of privacy before
            // changing to "public" or from "private" to "none"
-    
+
+// Choose which fields should be private by setting 
+// $is_private_field['tablename.columnname'] = TRUE
+// At the moment only fields in the entry table can be marked as private,
+// including custom fields, but with the exception of the following fields:
+// start_time, end_time, entry_type, repeat_id, room_id, timestamp, type, 
status,
+// reminded, info_time, info_user, info_text.
+$is_private_field['entry.name'] = TRUE;
+$is_private_field['entry.description'] = TRUE;
+$is_private_field['entry.create_by'] = TRUE;
+
                   
 // PROVISIONAL BOOKINGS SETTINGS - PER-AREA
 

Modified: mrbs/trunk/web/view_entry.php
===================================================================
--- mrbs/trunk/web/view_entry.php       2010-10-05 07:47:50 UTC (rev 1486)
+++ mrbs/trunk/web/view_entry.php       2010-10-06 14:59:45 UTC (rev 1487)
@@ -159,6 +159,17 @@
 
 $row = mrbsGetBookingInfo($id, $series);
 
+// Get the area settings for the entry's area.   In particular we want
+// to know how to display private/public bookings in this area.
+get_area_settings($row['area_id']);
+
+// Work out whether this event should be kept private
+$private = $row['private'];
+$writeable = getWritable($row['create_by'], $user, $row['room_id']);
+$keep_private = (is_private_event($private) && !$writeable);
+$private_text = "[" . get_vocab("private") . "]";
+
+
 $custom_fields = array();
 foreach ($row as $column => $value)
 {
@@ -192,7 +203,7 @@
     case 'repeat_info_time':
     case 'repeat_info_user':
     case 'repeat_info_text':
-      $$column = $row[$column];
+      $$column = ($keep_private && $is_private_field["entry.$column"]) ? 
$private_text : $row[$column];
       break;
 
     case 'last_updated':
@@ -200,7 +211,7 @@
       break;
 
     default:
-      $custom_fields[$column] = $row[$column];
+      $custom_fields[$column] = ($keep_private && 
$is_private_field["entry.$column"]) ? $private_text : $row[$column];
       break;
   }
 }
@@ -212,25 +223,9 @@
 // so that user see what he expects to see
 $duration      = $row['duration'] - cross_dst($row['start_time'],
                                               $row['end_time']);
-$writeable     = getWritable($row['create_by'], $user, $room_id);
 
 
-// Get the area settings for the entry's area.   In particular we want
-// to know how to display private/public bookings in this area.
-get_area_settings($row['area_id']);
 
-if (is_private_event($private) && !$writeable) 
-{
-  $name = "[".get_vocab('private')."]";
-  $description = $name;
-  $create_by = $name;
-  $keep_private = TRUE;
-}
-else
-{
-  $keep_private = FALSE;
-}
-
 if ($enable_periods)
 {
   list($start_period, $start_date) =  period_date_string($row['start_time']);
@@ -332,11 +327,11 @@
 // Now that we know all the data we start drawing it
 
 
-echo "<h3" . (($keep_private) ? " class=\"private\"" : "") . ">\n";
+echo "<h3" . (($keep_private && $is_private_field['entry.name']) ? " 
class=\"private\"" : "") . ">\n";
 echo htmlspecialchars($name);
 if (is_private_event($private) && $writeable) 
 {
-  echo ' ('.get_vocab('private').')';
+  echo ' ('.get_vocab("private").')';
 }
 echo "</h3>\n";
 
@@ -431,7 +426,7 @@
   <tr>
     <td><?php echo get_vocab("description") ?>:</td>
     <?php
-    echo "<td" . (($keep_private) ? " class=\"private\"" : "") . ">" . 
mrbs_nl2br(htmlspecialchars($description)) . "</td>\n";
+    echo "<td" . (($keep_private & $is_private_field['entry.description']) ? " 
class=\"private\"" : "") . ">" . mrbs_nl2br(htmlspecialchars($description)) . 
"</td>\n";
     ?>
   </tr>
   <?php
@@ -466,7 +461,7 @@
   <tr>
     <td><?php echo get_vocab("createdby") ?>:</td>
     <?php
-    echo "<td" . (($keep_private) ? " class=\"private\"" : "") . ">" . 
htmlspecialchars($create_by) . "</td>\n";
+    echo "<td" . (($keep_private && $is_private_field['entry.create_by']) ? " 
class=\"private\"" : "") . ">" . htmlspecialchars($create_by) . "</td>\n";
     ?>
   </tr>
   <tr>
@@ -488,14 +483,21 @@
       if (($field['nature'] == 'boolean') || 
           (($field['nature'] == 'integer') && isset($field['length']) && 
($field['length'] <= 2)) )
       {
-        $shown_value = empty($custom_fields[$key]) ? get_vocab("no") : 
get_vocab("yes");
+        if ($keep_private && $is_private_field["entry.$key"])
+        {
+          $shown_value = $custom_fields[$key];  // Will have been set 
previously
+        }
+        else
+        {
+          $shown_value = empty($custom_fields[$key]) ? get_vocab("no") : 
get_vocab("yes");
+        }
       }
       // Otherwise output a string
       else
       {
         $shown_value = (isset($custom_fields[$key])) ? 
mrbs_nl2br(htmlspecialchars($custom_fields[$key])): "&nbsp;"; 
       }
-      echo "<td>$shown_value</td>\n";
+      echo "<td" . (($keep_private && $is_private_field["entry.$key"]) ? " 
class=\"private\"" : "") . ">$shown_value</td>\n";
       echo "</tr>\n";
     }
   }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to