Logo Search packages:      
Sourcecode: davical version File versions  Download package

CalDAVPrincipal::InitialiseRecord ( usr )

Initialise the Principal object from a $usr record from the DB.

Parameters:
object$usrThe usr record from the DB.

calendar-free-busy-set has been dropped from draft 5 of the scheduling extensions for CalDAV but we'll keep replying to it for a while longer since iCal appears to want it...

Definition at line 126 of file CalDAVPrincipal.php.

Referenced by CalDAVPrincipal().

                                  {
    global $c;
    foreach( $usr AS $k => $v ) {
      $this->{$k} = $v;
    }

    $this->by_email = false;
    $this->url = ConstructURL( "/".$this->username."/" );

    $this->calendar_home_set = array( $this->url );

    $this->user_address_set = array(
       "mailto:".$this->email,
       ConstructURL( "/".$this->username."/" ),
//       ConstructURL( "/~".$this->username."/" ),
//       ConstructURL( "/__uuids__/".$this->username."/" ),
    );
    $this->schedule_inbox_url = sprintf( "%s.in/", $this->url);
    $this->schedule_outbox_url = sprintf( "%s.out/", $this->url);
    $this->dropbox_url = sprintf( "%s.drop/", $this->url);
    $this->notifications_url = sprintf( "%s.notify/", $this->url);

    $this->group_member_set = array();
    $qry = new PgQuery("SELECT * FROM relationship LEFT JOIN usr ON (from_user = usr.user_no) LEFT JOIN role_member ON (to_user = role_member.user_no) LEFT JOIN roles USING (role_no) WHERE to_user = ? AND role_name = 'Group';", $this->user_no );
    if ( $qry->Exec("CalDAVPrincipal") && $qry->rows > 0 ) {
      while( $membership = $qry->Fetch() ) {
            $this->group_member_set[] = ConstructURL( "/". $membership->username . "/");
      }
    }

    $this->group_membership = array();
    $qry = new PgQuery("SELECT * FROM relationship LEFT JOIN usr ON (to_user = user_no) LEFT JOIN role_member USING (user_no) LEFT JOIN roles USING (role_no) WHERE from_user = ? AND role_name = 'Group';", $this->user_no );
    if ( $qry->Exec("CalDAVPrincipal") && $qry->rows > 0 ) {
      while( $membership = $qry->Fetch() ) {
        $this->group_membership[] = ConstructURL( "/". $membership->username . "/");
      }
    }

    /**
    * calendar-free-busy-set has been dropped from draft 5 of the scheduling extensions for CalDAV
    * but we'll keep replying to it for a while longer since iCal appears to want it...
    */
    $qry = new PgQuery("SELECT dav_name FROM collection WHERE user_no = ? AND is_calendar", $this->user_no);
    $this->calendar_free_busy_set = array();
    if( $qry->Exec("CalDAVPrincipal",__LINE__,__FILE__) && $qry->rows > 0 ) {
      while( $calendar = $qry->Fetch() ) {
        $this->calendar_free_busy_set[] = ConstructURL($calendar->dav_name);
      }
    }

    dbg_error_log( "principal", "User: %s (%d) URL: %s, Home: %s, By Email: %d", $this->username, $this->user_no, $this->url, $this->calendar_home_set, $this->by_email );
  }

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index