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

CalDAVRequest::setPermissions (  )

Permissions are controlled as follows: 1. if the path is '/', the request has read privileges 2. if the requester is an admin, the request has read/write priviliges 3. if there is a <user name>=""> component which matches the logged on user then the request has read/write privileges 4. otherwise we query the defined relationships between users and use the minimum privileges returned from that analysis.

Parameters:
int$user_noThe current user number

In other cases we need to query the database for permissions

Definition at line 346 of file CalDAVRequest.php.

Referenced by CalDAVRequest().

                            {
    global $session;

    if ( $this->path == '/' || $this->path == '' ) {
      $this->permissions = array("read" => 'read' );
      dbg_error_log( "caldav", "Read permissions for user accessing /" );
      return;
    }

    if ( $session->AllowedTo("Admin") || $session->user_no == $this->user_no ) {
      $this->permissions = array('all' => 'all' );
      dbg_error_log( "caldav", "Full permissions for %s", ( $session->user_no == $this->user_no ? "user accessing their own hierarchy" : "a systems administrator") );
      return;
    }

    $permissions = array();

    /**
    * In other cases we need to query the database for permissions
    */
    $qry = new PgQuery( "SELECT get_permissions( ?, ? ) AS perm;", $session->user_no, $this->user_no);
    if ( $qry->Exec("caldav") && $permission_result = $qry->Fetch() ) {
      $permission_result = "!".$permission_result->perm; // We prepend something to ensure we get a non-zero position.
      $this->permissions = array();
      if ( strpos($permission_result,"A") )
        $this->permissions['all'] = 'all';
      else {
        if ( strpos($permission_result,"F") )       $this->permissions['freebusy'] = 'freebusy';
        if ( strpos($permission_result,"R") )       $this->permissions['read'] = 'read';
        if ( strpos($permission_result,"W") )
          $this->permissions['write'] = 'write';
        else {
          if ( strpos($permission_result,"C") )       $this->permissions['bind'] = 'bind';      // PUT of new content (i.e. Create)
          if ( strpos($permission_result,"D") )       $this->permissions['unbind'] = 'unbind';  // DELETE
          if ( strpos($permission_result,"M") )       $this->permissions['write-content'] = 'write-content';  // PUT Modify
        }
      }
      dbg_error_log( "caldav", "Restricted permissions for user accessing someone elses hierarchy: %s", implode( ", ", $this->permissions ) );
    }
  }

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index