[dev] Patch for import permissions in kronolith

Jason Rust jrust at rustyparts.com
Thu May 15 12:20:13 PDT 2003


The attached patch changes the import page to be consistent with the
edit page in terms of what calendars are displayed.  Before all
calendars were part of the select list, regardless of permissions or if
default_share was locked.  The patch fixes that.

-Jason

-- 
http://www.rustyparts.com/
ferrous oxidation
-------------- next part --------------
Index: import.inc
===================================================================
RCS file: /repository/kronolith/templates/data/import.inc,v
retrieving revision 1.8
diff -u -r1.8 import.inc
--- import.inc	15 Dec 2002 23:26:40 -0000	1.8
+++ import.inc	15 May 2003 18:54:04 -0000
@@ -23,12 +23,19 @@
       <option value="icalendar"><?php echo _("vCalendar/iCalendar") ?></option>
     </select><br />
 
+    <?php if (!$prefs->isLocked('default_share') && count($calendars = Kronolith::listCalendars())): ?>
     <?php echo _("Select the calendar to import to:") ?><br />
     <select name="importCal">
-      <?php foreach (Kronolith::listCalendars() as $id => $cal): ?>
-      <option value="<?php echo $id ?>"><?php echo $cal->getShareName() ?></option>
-      <?php endforeach; ?>
+      <?php
+      foreach ($calendars as $id => $cal) {
+          if ($cal->hasPermission(Auth::getAuth(), _PERMS_EDIT)) {
+              echo sprintf('<option value="%s">%s</option>', $id, $cal->getShareName()) . "\n";
+          }
+      } ?>
     </select><br /><br />
+    <?php else: ?>
+    <input type="hidden" name="importCal" value="<?php echo htmlspecialchars($prefs->getValue('default_share')) ?>" />
+    <?php endif; ?>
     <?php echo _("Select the file to import:") ?><br />
     <input type="file" name="import_file" class="fixed" size="40" />
     <input type="submit" value="<?php echo _("Import") ?>" class="button" />


More information about the dev mailing list