getForUser() public static method

Retrieves the free/busy information for a given user.
public static getForUser ( string $user, array $opts = [] ) : Horde_Icalendar_Vfreebusy | object
$user string The user to look for.
$opts array Options: - json: (boolean) Whether to return the free/busy data as a simple object suitable to be transferred as json. DEFAULT: false - start: (integer) The start of the time period to retrieve. DEFAULT: now - end: (integer) The end of the time period to retrieve. DEFAULT: now + freebusy_days pref
return Horde_Icalendar_Vfreebusy | object Free/busy component.
コード例 #1
0
ファイル: fb.php プロジェクト: horde/horde
 */
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('kronolith', array('authentication' => 'none', 'session_control' => 'none'));
// Determine the username to show free/busy time for.
$cal = Horde_Util::getFormData('c');
$user = Horde_Util::getFormData('u');
if (!empty($cal)) {
    if (is_array($cal)) {
        $cal = implode('|', $cal);
    }
} elseif ($pathInfo = Horde_Util::getPathInfo()) {
    $user = basename($pathInfo);
}
$cache = $injector->getInstance('Horde_Cache');
$key = 'kronolith.fb.' . ($user ? 'u.' . $user : '******' . $cal);
$fb = $cache->get($key, 360);
if (!$fb) {
    try {
        if ($user) {
            $fb = Kronolith_FreeBusy::getForUser($user)->exportvCalendar();
        } else {
            $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;
コード例 #2
0
ファイル: attendees.php プロジェクト: horde/horde
        // Make sure URL is unique.
        $url->unique()->redirect();
    case 'clear':
        // Remove all the attendees and resources.
        $session->remove('kronolith', 'attendees');
        $session->remove('kronolith', 'resources');
        break;
}
// Pre-format our delete image/link.
$delimg = Horde::img('delete.png', _("Remove Attendee"));
$ident = $injector->getInstance('Horde_Core_Factory_Identity')->create();
$identities = $ident->getAll('id');
$fbView = Kronolith_FreeBusy_View::singleton($view);
$fbOpts = array('start' => $start->datestamp(), 'end' => $end->datestamp());
try {
    $vfb = Kronolith_FreeBusy::getForUser($GLOBALS['registry']->getAuth(), $fbOpts);
    $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 {
コード例 #3
0
ファイル: Handler.php プロジェクト: horde/horde
 /**
  * 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;
 }