get() public static method

Retrieves the free/busy information for a given email address, if any information is available.
public static get ( string $email, boolean $json = false ) : Horde_Icalendar_Vfreebusy | object
$email string The email address to look for.
$json boolean Whether to return the free/busy data as a simple object suitable to be transferred as json.
return Horde_Icalendar_Vfreebusy | object Free/busy component.
Beispiel #1
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;
 }
Beispiel #2
0
 /**
  * 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);
 }
Beispiel #3
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();
Beispiel #4
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
Beispiel #5
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;
 }