Author: Chuck Hagenbuch (chuck@horde.org)
Example #1
0
File: Api.php Project: horde/horde
 /**
  * Attempt to lookup the free/busy information for the given email address.
  *
  * @param string $email  The email to lookup free/busy information for.
  * @param boolean $json  Return the data in a simple json format. If false,
  *                       returns the vCalander object.
  * @since 4.1.0
  */
 public function lookupFreeBusy($email, $json = false)
 {
     return Kronolith_FreeBusy::get($email, $json);
 }
Example #2
0
 /**
  * Return fb information for the requested attendee or resource.
  *
  * Uses the following request parameters:
  *<pre>
  *  -email:    The attendee's email address.
  *  -resource: The resource id.
  *</pre>
  */
 public function getFreeBusy()
 {
     $result = new stdClass();
     if ($this->vars->email) {
         try {
             $result->fb = Kronolith_FreeBusy::get($this->vars->email, true);
         } catch (Exception $e) {
             $GLOBALS['notification']->push($e->getMessage(), 'horde.warning');
         }
     } elseif ($this->vars->resource) {
         try {
             $resource = Kronolith::getDriver('Resource')->getResource($this->vars->resource);
             try {
                 $result->fb = $resource->getFreeBusy(null, null, true, true);
             } catch (Horde_Exception $e) {
                 // Resource groups can't provide FB information.
                 $result->fb = null;
             }
         } catch (Exception $e) {
             $GLOBALS['notification']->push($e->getMessage(), 'horde.warning');
         }
     }
     return $result;
 }
Example #3
0
$key = 'kronolith.fb.' . ($user ? 'u.' . $user : '******' . $cal);
$fb = $cache->get($key, 360);
if (!$fb) {
    if ($user) {
        $prefs = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Prefs')->create('kronolith', array('cache' => false, 'user' => $user));
        $registry->setTimeZone();
        $cal = @unserialize($prefs->getValue('fb_cals'));
        if (is_array($cal)) {
            $cal = implode('|', $cal);
        }
        // If the free/busy calendars preference is empty, default to
        // the user's default_share preference, and if that's empty,
        // to their username.
        if (!$cal) {
            $cal = $prefs->getValue('default_share');
            if (!$cal) {
                $cal = $user;
            }
            $cal = 'internal_' . $cal;
        }
    }
    try {
        $fb = Kronolith_FreeBusy::generate(explode('|', $cal), null, null, false, $user);
    } catch (Exception $e) {
        Horde::log($e, 'ERR');
        exit;
    }
    $cache->set($key, $fb);
}
$browser->downloadHeaders(($user ? $user : $cal) . '.vfb', 'text/calendar; charset=' . 'UTF-8', true, strlen($fb));
echo $fb;
Example #4
0
 /**
  * Obtain the freebusy information for this resource.
  *
  * @return mixed string|Horde_Icalendar_Vfreebusy  The Freebusy object or
  *                                                 the iCalendar text.
  */
 public function getFreeBusy($startstamp = null, $endstamp = null, $asObject = false, $json = false)
 {
     $vfb = Kronolith_FreeBusy::generate($this->get('calendar'), $startstamp, $endstamp, true);
     $vfb->removeAttribute('ORGANIZER');
     $vfb->setAttribute('ORGANIZER', $this->get('name'));
     if ($json) {
         return Kronolith_FreeBusy::toJson($vfb);
     } elseif (!$asObject) {
         return $vfb->exportvCalendar();
     }
     return $vfb;
 }
Example #5
0
    if (!$cal) {
        $cal = 'internal_' . $GLOBALS['registry']->getAuth();
    }
    $cal = array($cal);
}
try {
    $vfb = Kronolith_FreeBusy::generate($cal, null, null, true, $GLOBALS['registry']->getAuth());
    $attendee_view->addRequiredMember($vfb);
} catch (Exception $e) {
    $notification->push(sprintf(_("Error retrieving your free/busy information: %s"), $e->getMessage()));
}
// Add the Free/Busy information for each attendee.
foreach ($session->get('kronolith', 'attendees', Horde_Session::TYPE_ARRAY) as $email => $status) {
    if (strpos($email, '@') !== false && ($status['attendance'] == Kronolith::PART_REQUIRED || $status['attendance'] == Kronolith::PART_OPTIONAL)) {
        try {
            $vfb = Kronolith_FreeBusy::get($email);
            $organizer = $vfb->getAttribute('ORGANIZER');
            if (empty($organizer)) {
                $vfb->setAttribute('ORGANIZER', 'mailto:' . $email, array(), false);
            }
            if ($status['attendance'] == Kronolith::PART_REQUIRED) {
                $attendee_view->addRequiredMember($vfb);
            } else {
                $attendee_view->addOptionalMember($vfb);
            }
        } catch (Exception $e) {
            $notification->push(sprintf(_("Error retrieving free/busy information for %s: %s"), $email, $e->getMessage()));
        }
    }
}
// Add Free/Busy for resources
Example #6
0
    $fbView->addRequiredMember($vfb);
} catch (Exception $e) {
    $notification->push(sprintf(_("Error retrieving your free/busy information: %s"), $e->getMessage()));
}
// Add the Free/Busy information for each attendee.
foreach ($session->get('kronolith', 'attendees') as $attendee) {
    if ($attendee->role != Kronolith::PART_REQUIRED && $attendee->role != Kronolith::PART_OPTIONAL) {
        continue;
    }
    try {
        if ($attendee->user) {
            $vfb = Kronolith_Freebusy::getForUser($attendee->user, $fbOpts);
        } elseif (is_null($attendee->addressObject->host)) {
            $vfb = new Horde_Icalendar_Vfreebusy();
        } else {
            $vfb = Kronolith_FreeBusy::get($attendee->email);
        }
    } catch (Exception $e) {
        $notification->push(sprintf(_("Error retrieving free/busy information for %s: %s"), $attendee, $e->getMessage()));
        $vfb = new Horde_Icalendar_Vfreebusy();
    }
    try {
        $organizer = $vfb->getAttribute('ORGANIZER');
    } catch (Horde_Icalendar_Exception $e) {
        $organizer = null;
    }
    if (empty($organizer)) {
        if (strlen($attendee->name)) {
            $name = array('CN' => $attendee->name);
        } else {
            $name = array();
Example #7
0
 /**
  * Return fb information for the requested attendee or resource.
  *
  * Uses the following request parameters:
  *  - user:     The attendee's user name.
  *  - email:    The attendee's email address.
  *  - resource: The resource id.
  */
 public function getFreeBusy()
 {
     global $notification;
     $result = new stdClass();
     if ($this->vars->user) {
         try {
             $result->fb = Kronolith_FreeBusy::getForUser($this->vars->user, array('json' => true, 'start' => $this->vars->start, 'end' => $this->vars->end));
         } catch (Exception $e) {
             $notification->push($e->getMessage(), 'horde.warning');
         }
     } elseif ($this->vars->email) {
         $rfc822 = new Horde_Mail_Rfc822();
         $res = $rfc822->parseAddressList($this->vars->email);
         if ($res[0] && $res[0]->host) {
             try {
                 $result->fb = Kronolith_FreeBusy::get($this->vars->email, true);
             } catch (Exception $e) {
                 $notification->push($e->getMessage(), 'horde.warning');
             }
         }
     } elseif ($this->vars->resource) {
         try {
             $resource = Kronolith::getDriver('Resource')->getResource($this->vars->resource);
             try {
                 $result->fb = $resource->getFreeBusy($this->vars->start, $this->vars->end, true, true);
             } catch (Horde_Exception $e) {
                 // Resource groups can't provide FB information.
                 $result->fb = null;
             }
         } catch (Exception $e) {
             $notification->push($e->getMessage(), 'horde.warning');
         }
     }
     return $result;
 }