Move hasPermisson to the base class, implement ::get() to behave like
authorMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 9 Sep 2009 19:31:28 +0000 (15:31 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 29 Sep 2009 20:53:52 +0000 (16:53 -0400)
a share.

kronolith/lib/Resource/Base.php
kronolith/lib/Resource/Single.php
kronolith/resources.php
kronolith/templates/edit/edit.inc

index 35dde64..e3a4b24 100644 (file)
@@ -46,6 +46,38 @@ abstract class Kronolith_Resource_Base
     }
 
     /**
+     * @TODO: need to fine tune this
+     *
+     *
+     *
+     * @param $user
+     * @param $permission
+     * @param $restrict
+     * @return unknown_type
+     */
+    public function hasPermission($user, $permission = PERMS_READ, $restrict = null)
+    {
+        if (Horde_Auth::isAdmin()) {
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * Implemented to stand in as a share object.
+     *
+     * @param $property
+     * @return unknown_type
+     */
+    public function get($property)
+    {
+       return $this->{$property};
+    }
+
+
+
+    /**
      * Should this take an event, or a time range?
      *
      * @param $startTime
index 874f1b3..25a89dc 100644 (file)
@@ -124,21 +124,4 @@ class Kronolith_Resource_Single extends Kronolith_Resource_Base
             throw new Horde_Exception(_("Resource already exists. Cannot change the id."));
         }
     }
-
-    /**
-     * @TODO: need to fine tune this
-     * @param $user
-     * @param $permission
-     * @param $restrict
-     * @return unknown_type
-     */
-    public function hasPermission($user, $permission = PERMS_READ, $restrict = null)
-    {
-        if (Horde_Auth::isAdmin()) {
-            return true;
-        }
-
-        return false;
-    }
-
 }
\ No newline at end of file
index cffeebe..4117e6f 100644 (file)
@@ -72,10 +72,10 @@ var_dump($resources);
 $resource = Kronolith::getDriver('Resource')->getResource(9);
 
 /* Any driver/event */
-//$driver = Kronolith::getDriver('Sql');
-//$event = $driver->getByUID('20090904121938.17551lvwtt52y728@localhost');
-//$event->addResource($resource, Kronolith::RESPONSE_NONE);
-//$event->save();
+$driver = Kronolith::getDriver('Sql');
+$event = $driver->getByUID('20090909152832.6360407aq83e5nsw@localhost');
+$event->addResource($resource, Kronolith::RESPONSE_NONE);
+$event->save();
 
 
 //
index 22c84a1..3a94947 100644 (file)
@@ -1,4 +1,5 @@
-<?php $showCalSelect = (!$GLOBALS['prefs']->isLocked('default_share') && count($calendars) > 1); ?>
+<?php $showCalSelect = (!$GLOBALS['prefs']->isLocked('default_share') && count($calendars) > 1 && empty($GLOBALS['show_resource_calendars'])); ?>
+
 <form action="<?php echo ($event->isInitialized() && !$event->isRemote() ? 'edit.php' : 'add.php') ?>" method="post" name="eventform" id="eventform">
 <?php Horde_Util::pformInput() ?>
 <input type="hidden" name="year" value="<?php if (isset($year)) echo htmlspecialchars($year) ?>" />
     <select id="targetcalendar" name="targetcalendar">
     <?php
     $creator = $event->getCreatorId();
-    foreach ($calendars as $id => $cal) {
-        $delegates = array();
-        if ($cal->hasPermission(Horde_Auth::getAuth(), PERMS_EDIT, $creator)) {
-            $delegates[$id] = htmlspecialchars($cal->get('name'));
-        } else {
-            $delegates[$id . ':' . $cal->get('owner')] = htmlspecialchars($cal->get('name'). ' (' . sprintf(_("as %s"), Kronolith::getUserName($cal->get('owner'))) . ')');
-        }
-        foreach ($delegates as $delegate_id => $cal_name) {
-            $sel = ($delegate_id == $calendar_id) ? ' selected="selected"' : '';
+    if (!empty($GLOBALS['display_resource_calendars'])) {
+        foreach ($GLOBALS['display_resource_calendars'] as $cal) {
+            echo $cal;
             printf('<option value="%s"%s>%s</option>',
-                   htmlspecialchars($delegate_id), $sel, $cal_name) . "\n";
+                    htmlspecialchars($cal), '', $cal) . "\n";
+        }
+    } else {
+
+        foreach ($calendars as $id => $cal) {
+            $delegates = array();
+            if ($cal->hasPermission(Horde_Auth::getAuth(), PERMS_EDIT, $creator)) {
+                $delegates[$id] = htmlspecialchars($cal->get('name'));
+            } else {
+                $delegates[$id . ':' . $cal->get('owner')] = htmlspecialchars($cal->get('name'). ' (' . sprintf(_("as %s"), Kronolith::getUserName($cal->get('owner'))) . ')');
+            }
+            foreach ($delegates as $delegate_id => $cal_name) {
+                $sel = ($delegate_id == $calendar_id) ? ' selected="selected"' : '';
+                printf('<option value="%s"%s>%s</option>',
+                       htmlspecialchars($delegate_id), $sel, $cal_name) . "\n";
+            }
         }
-    } ?>
+    }?>
     </select>
 
  </td>