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

CalDAVPrincipal::RenderAsXML ( properties,
&$  reply,
props_only = false 
)

Render XML for a single Principal (user) from the DB

Parameters:
array$propertiesThe requested properties for this principal
reference$replyA reference to the XMLDocument being used for the reply
boolean$props_onlyDefault false. If true will only return the fragment with the properties, not a full response fragment.
Returns:
string An XML fragment with the requested properties for this principal

Todo:
This information is semantically valid but presents an incorrect picture.
Todo:
indicating the style for future expansion

Definition at line 257 of file CalDAVPrincipal.php.

References RenderPrivileges().

                                                                    {
    global $session, $c, $request;

    dbg_error_log("CalDAVPrincipal",": RenderAsXML: Principal '%s'", $this->username );

    $prop = new XMLElement("prop");
    $denied = array();
    $not_found = array();
    foreach( $properties AS $k => $tag ) {
      dbg_error_log("CalDAVPrincipal",": RenderAsXML: Principal Property '%s'", $tag );
      switch( $tag ) {
        case 'DAV::getcontenttype':
          $prop->NewElement("getcontenttype", "httpd/unix-directory" );
          break;

        case 'DAV::resourcetype':
          $prop->NewElement("resourcetype", array( new XMLElement("principal"), new XMLElement("collection")) );
          break;

        case 'DAV::displayname':
          $prop->NewElement("displayname", $this->fullname );
          break;

        case 'DAV::principal-URL':
          $prop->NewElement("principal-URL", $this->url );
          break;

        case 'DAV::getlastmodified':
          $prop->NewElement("getlastmodified", $this->modified );
          break;

        case 'DAV::group-member-set':
          $set = array();
          foreach( $this->group_member_set AS $k => $url ) {
            $set[] = $reply->href($url );
          }
          $prop->NewElement("group-member-set", $set );
          break;

        case 'DAV::group-membership':
          $set = array();
          foreach( $this->group_membership AS $k => $url ) {
            $set[] = $reply->href($url );
          }
          $prop->NewElement("group-membership", $set );
          break;

        case 'urn:ietf:params:xml:ns:caldav:schedule-inbox-URL':
          $reply->CalDAVElement($prop, "schedule-inbox-URL", $reply->href($this->schedule_inbox_url) );
          break;

        case 'urn:ietf:params:xml:ns:caldav:schedule-outbox-URL':
          $reply->CalDAVElement($prop, "schedule-outbox-URL", $reply->href($this->schedule_outbox_url) );
          break;

        case 'http://calendarserver.org/ns/:dropbox-home-URL':
          $reply->CalendarserverElement($prop, "dropbox-home-URL", $reply->href($this->dropbox_url) );
          break;

        case 'http://calendarserver.org/ns/:notifications-URL':
          $reply->CalendarserverElement($prop, "notifications-URL", $reply->href($this->notifications_url) );
          break;

        case 'urn:ietf:params:xml:ns:caldav:calendar-home-set':
          $set = array();
          foreach( $this->calendar_home_set AS $k => $url ) {
            $set[] = $reply->href( $url );
          }
          $reply->CalDAVElement($prop, "calendar-home-set", $set );
          break;

        case 'urn:ietf:params:xml:ns:caldav:calendar-user-address-set':
          $set = array();
          foreach( $this->user_address_set AS $k => $v ) {
            $set[] = $reply->href($v );
          }
          $reply->CalDAVElement($prop, "calendar-user-address-set", $set );
          break;

        case 'DAV::getcontentlanguage':
          $locale = (isset($c->current_locale) ? $c->current_locale : "");
          if ( isset($this->locale) && $this->locale != "" ) $locale = $this->locale;
          $prop->NewElement("getcontentlanguage", $locale );
          break;

        case 'DAV::supportedlock':
          $prop->NewElement("supportedlock",
            new XMLElement( "lockentry",
              array(
                new XMLElement("lockscope", new XMLElement("exclusive")),
                new XMLElement("locktype",  new XMLElement("write")),
              )
            )
          );
          break;

        case 'DAV::acl':
          /**
          * @todo This information is semantically valid but presents an incorrect picture.
          */
          $principal = new XMLElement("principal");
          $principal->NewElement("authenticated");
          $grant = new XMLElement( "grant", array($this->RenderPrivileges($request->permissions)) );
          $prop->NewElement("acl", new XMLElement( "ace", array( $principal, $grant ) ) );
          break;

        case 'DAV::current-user-privilege-set':
          $prop->NewElement("current-user-privilege-set", $this->RenderPrivileges($request->permissions) );
          break;

        case 'DAV::supported-privilege-set':
          $prop->NewElement("supported-privilege-set", $this->RenderPrivileges( $request->SupportedPrivileges(), "supported-privilege") );
          break;

        // Empty tag responses.
        case 'DAV::creationdate':
        case 'DAV::alternate-URI-set':
        case 'DAV::getcontentlength':
          $prop->NewElement( $reply->Tag($tag));
          break;

        case 'SOME-DENIED-PROPERTY':  /** @todo indicating the style for future expansion */
          $denied[] = $reply->Tag($tag);
          break;

        default:
          dbg_error_log( 'CalDAVPrincipal', "Request for unsupported property '%s' of principal.", $this->username );
          $not_found[] = $reply->Tag($tag);
          break;
      }
    }

    if ( $props_only ) return $prop;

    $status = new XMLElement("status", "HTTP/1.1 200 OK" );

    $propstat = new XMLElement( "propstat", array( $prop, $status) );
    $href = $reply->href($this->url );

    $elements = array($href,$propstat);

    if ( count($denied) > 0 ) {
      $status = new XMLElement("status", "HTTP/1.1 403 Forbidden" );
      $noprop = new XMLElement("prop");
      foreach( $denied AS $k => $v ) {
        $noprop->NewElement( strtolower($v) );
      }
      $elements[] = new XMLElement( "propstat", array( $noprop, $status) );
    }

    if ( count($not_found) > 0 ) {
      $status = new XMLElement("status", "HTTP/1.1 404 Not Found" );
      $noprop = new XMLElement("prop");
      foreach( $not_found AS $k => $v ) {
        $noprop->NewElement( strtolower($v) );
      }
      $elements[] = new XMLElement( "propstat", array( $noprop, $status) );
    }

    $response = new XMLElement( "response", $elements );

    return $response;
  }

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index