Make some of those unused functions really not be used!

This commit is contained in:
Andrew McMillan 2009-12-21 21:41:37 +13:00
parent 1cd3d8c896
commit 1eb677de16
7 changed files with 87 additions and 62 deletions

View File

@ -275,12 +275,12 @@ class DAVResource
'is_calendar' => false, 'is_principal' => false, 'is_addressbook' => false
);
$base_sql = 'SELECT collection.*, path_privileges(:session_principal, collection.dav_name), ';
$base_sql = 'SELECT collection.*, path_privs(:session_principal, collection.dav_name,:scan_depth), ';
$base_sql .= 'p.principal_id, p.type_id AS principal_type_id, ';
$base_sql .= 'p.displayname AS principal_displayname, p.default_privileges AS principal_default_privileges ';
$base_sql .= 'FROM collection LEFT JOIN principal p USING (user_no) WHERE ';
$sql = $base_sql .'collection.dav_name = :raw_path ';
$params = array( ':raw_path' => $this->dav_name, ':session_principal' => $session->principal_id );
$params = array( ':raw_path' => $this->dav_name, ':session_principal' => $session->principal_id, ':scan_depth' => $c->permission_scan_depth );
if ( !preg_match( '#/$#', $this->dav_name ) ) {
$sql .= ' OR collection.dav_name = :up_to_slash OR collection.dav_name = :plus_slash ';
$params[':up_to_slash'] = preg_replace( '#[^/]*$#', '', $this->dav_name);
@ -472,16 +472,16 @@ EOQRY;
$this->privileges = 0;
if ( !isset($this->collection->path_privileges) ) {
if ( !isset($this->collection->path_privs) ) {
$parent_path = preg_replace('{/[^/]*/$}', '/', $this->collection->dav_name );
dbg_error_log( 'DAVResource', 'Checking privileges of "%s" - parent of "%s"', $parent_path, $this->collection->dav_name );
$parent = new DAVResource( $parent_path );
$this->collection->path_privileges = $parent->Privileges();
$this->collection->path_privs = $parent->Privileges();
$this->collection->user_no = $parent->GetProperty('user_no');
}
$this->privileges = $this->collection->path_privileges;
$this->privileges = $this->collection->path_privs;
}

View File

@ -169,9 +169,9 @@ function getUserByName( $username, $use_cache = true ) {
// Provide some basic caching in case this ends up being overused.
if ( $use_cache && isset( $_known_users_name[$username] ) ) return $_known_users_name[$username];
global $session;
global $c, $session;
if ( isset($session->user_no) )
$qry = new PgQuery( "SELECT *, to_char(updated at time zone 'GMT','Dy, DD Mon IYYY HH24:MI:SS \"GMT\"') AS modified, principal.*, user_privileges(?,usr.user_no) AS privileges FROM usr LEFT JOIN principal USING(user_no) WHERE lower(username) = lower(?) ", $session->user_no, $username );
$qry = new PgQuery( "SELECT *, to_char(updated at time zone 'GMT','Dy, DD Mon IYYY HH24:MI:SS \"GMT\"') AS modified, principal.*, pprivs(?,principal.principal_id,?) AS privileges FROM usr LEFT JOIN principal USING(user_no) WHERE lower(username) = lower(?) ", $session->principal_id, $c->permission_scan_depth, $username );
else
$qry = new PgQuery( "SELECT *, to_char(updated at time zone 'GMT','Dy, DD Mon IYYY HH24:MI:SS \"GMT\"') AS modified, principal.*, 0::BIT(24) AS privileges FROM usr LEFT JOIN principal USING(user_no) WHERE lower(username) = lower(?) ", $username );
if ( $qry->Exec('always',__LINE__,__FILE__) && $qry->rows == 1 ) {
@ -194,8 +194,8 @@ function getUserByID( $user_no, $use_cache = true ) {
// Provide some basic caching in case this ends up being overused.
if ( $use_cache && isset( $_known_users_id[$user_no] ) ) return $_known_users_id[$user_no];
global $session;
$qry = new PgQuery( "SELECT *, to_char(updated at time zone 'GMT','Dy, DD Mon IYYY HH24:MI:SS \"GMT\"') AS modified, principal.*, user_privileges(?,usr.user_no) AS privileges FROM usr LEFT JOIN principal USING(user_no) WHERE user_no = ? ", $session->user_no, intval($user_no) );
global $c, $session;
$qry = new PgQuery( "SELECT *, to_char(updated at time zone 'GMT','Dy, DD Mon IYYY HH24:MI:SS \"GMT\"') AS modified, principal.*, pprivs(?,principal.principal_id,?) AS privileges FROM usr LEFT JOIN principal USING(user_no) WHERE user_no = ? ", $session->principal_id, $c->permission_scan_depth, intval($user_no) );
if ( $qry->Exec('always',__LINE__,__FILE__) && $qry->rows == 1 ) {
$_known_users_id[$user_no] = $qry->Fetch();
$name = $_known_users_id[$user_no]->username;

View File

@ -169,9 +169,9 @@ function getUserByName( $username, $use_cache = true ) {
// Provide some basic caching in case this ends up being overused.
if ( $use_cache && isset( $_known_users_name[$username] ) ) return $_known_users_name[$username];
global $session;
global $c, $session;
if ( isset($session->user_no) )
$qry = new PgQuery( "SELECT *, to_char(updated at time zone 'GMT','Dy, DD Mon IYYY HH24:MI:SS \"GMT\"') AS modified, principal.*, user_privileges(?,usr.user_no) AS privileges FROM usr LEFT JOIN principal USING(user_no) WHERE lower(username) = lower(?) ", $session->user_no, $username );
$qry = new PgQuery( "SELECT *, to_char(updated at time zone 'GMT','Dy, DD Mon IYYY HH24:MI:SS \"GMT\"') AS modified, principal.*, pprivs(?,principal.principal_id,?) AS privileges FROM usr LEFT JOIN principal USING(user_no) WHERE lower(username) = lower(?) ", $session->principal_id, $c->permission_scan_depth, $username );
else
$qry = new PgQuery( "SELECT *, to_char(updated at time zone 'GMT','Dy, DD Mon IYYY HH24:MI:SS \"GMT\"') AS modified, principal.*, 0::BIT(24) AS privileges FROM usr LEFT JOIN principal USING(user_no) WHERE lower(username) = lower(?) ", $username );
if ( $qry->Exec('always',__LINE__,__FILE__) && $qry->rows == 1 ) {
@ -194,8 +194,8 @@ function getUserByID( $user_no, $use_cache = true ) {
// Provide some basic caching in case this ends up being overused.
if ( $use_cache && isset( $_known_users_id[$user_no] ) ) return $_known_users_id[$user_no];
global $session;
$qry = new PgQuery( "SELECT *, to_char(updated at time zone 'GMT','Dy, DD Mon IYYY HH24:MI:SS \"GMT\"') AS modified, principal.*, user_privileges(?,usr.user_no) AS privileges FROM usr LEFT JOIN principal USING(user_no) WHERE user_no = ? ", $session->user_no, intval($user_no) );
global $c, $session;
$qry = new PgQuery( "SELECT *, to_char(updated at time zone 'GMT','Dy, DD Mon IYYY HH24:MI:SS \"GMT\"') AS modified, principal.*, pprivs(?,principal.principal_id,?) AS privileges FROM usr LEFT JOIN principal USING(user_no) WHERE user_no = ? ", $session->principal_id, $c->permission_scan_depth, intval($user_no) );
if ( $qry->Exec('always',__LINE__,__FILE__) && $qry->rows == 1 ) {
$_known_users_id[$user_no] = $qry->Fetch();
$name = $_known_users_id[$user_no]->username;

View File

@ -98,7 +98,7 @@ function get_collection_contents( $depth, $user_no, $collection ) {
/**
* Calendar/Addressbook collections may not contain collections, so we won't look
*/
$params = array( ':session_principal' => $session->principal_id );
$params = array( ':session_principal' => $session->principal_id, ':scan_depth' => $c->permission_scan_depth );
if ( $collection->dav_name() == '/' ) {
$sql = "SELECT usr.*, '/' || username || '/' AS dav_name, md5(username || updated::text) AS dav_etag, ";
$sql .= "to_char(joined at time zone 'GMT',$date_format) AS created, ";
@ -107,13 +107,13 @@ function get_collection_contents( $depth, $user_no, $collection ) {
$sql .= 'principal_id AS collection_id, ';
$sql .= 'principal.* ';
$sql .= 'FROM usr JOIN principal USING (user_no) ';
$sql .= "WHERE (principal_privileges(:session_principal,principal.principal_id) & 1::BIT(24))::INT4::BOOLEAN ";
$sql .= "WHERE (pprivs(:session_principal::int8,principal.principal_id,:scan_depth::int) & 1::BIT(24))::INT4::BOOLEAN ";
$sql .= 'ORDER BY usr.user_no';
}
else {
$sql = 'SELECT principal.*, collection.*, \'collection\' AS type FROM collection LEFT JOIN principal USING (user_no) ';
$sql .= 'WHERE parent_container = :this_dav_name ';
$sql .= "AND (path_privileges(:session_principal,collection.dav_name) & 1::BIT(24))::INT4::BOOLEAN ";
$sql .= "AND (path_privs(:session_principal::int8,collection.dav_name,:scan_depth::int) & 1::BIT(24))::INT4::BOOLEAN ";
$sql .= ' ORDER BY collection_id';
$params[':this_dav_name'] = $collection->dav_name();
}

View File

@ -2,7 +2,7 @@ HTTP/1.1 200 OK
Date: Dow, 01 Jan 2000 00:00:00 GMT
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule, extended-mkcol
Allow: OPTIONS, PROPFIND, REPORT, DELETE, LOCK, UNLOCK, MOVE, POST, GET, PUT, HEAD, PROPPATCH
ETag: "ae241cc30505f7f7148b7fee176731fb"
ETag: "some valid etag"
Content-Length: 968
Content-Type: text/xml; charset="utf-8"

View File

@ -1,4 +1,4 @@
#
#---------
# POST to scheduling outbox for freebusy query on user2
#
TYPE=POST
@ -15,6 +15,7 @@ HEADER=Recipient: mailto:user3@example.net
HEAD
REPLACE=/^DTSTAMP:\d{4}[01]\d[0123]\dT[012]\d[0-5]\d[0-6]\dZ\r?$/DTSTAMP:yyyymmddThhmmssZ/
REPLACE=/^ETag: "[0-9a-f]+".?$/ETag: "some valid etag"/
BEGINDATA
BEGIN:VCALENDAR

View File

@ -2,8 +2,8 @@ HTTP/1.1 207 Multi-Status
Date: Dow, 01 Jan 2000 00:00:00 GMT
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule, extended-mkcol
Allow: OPTIONS, PROPFIND, REPORT
ETag: "8dade0339d83135c772d8f0838cc8339"
Content-Length: 8407
ETag: "d3163c39f62cb97290677e0a12032a26"
Content-Length: 8679
Content-Type: text/xml; charset="utf-8"
<?xml version="1.0" encoding="utf-8" ?>
@ -139,33 +139,15 @@ Content-Type: text/xml; charset="utf-8"
</resourcetype>
<getcontenttype>httpd/unix-directory</getcontenttype>
<current-user-privilege-set>
<privilege>
<read/>
</privilege>
<privilege>
<C:read-free-busy/>
</privilege>
<privilege>
<C:schedule-deliver/>
</privilege>
<privilege>
<C:schedule-deliver-invite/>
</privilege>
<privilege>
<C:schedule-deliver-reply/>
</privilege>
<privilege>
<C:schedule-query-freebusy/>
</privilege>
<privilege>
<C:schedule-send/>
</privilege>
<privilege>
<C:schedule-send-invite/>
</privilege>
<privilege>
<C:schedule-send-reply/>
</privilege>
<privilege>
<C:schedule-send-freebusy/>
</privilege>
</current-user-privilege-set>
<C2:getctag>ab4a67c917e242e0989cd278c75a510e</C2:getctag>
</prop>
@ -195,33 +177,15 @@ Content-Type: text/xml; charset="utf-8"
</resourcetype>
<getcontenttype>httpd/unix-directory</getcontenttype>
<current-user-privilege-set>
<privilege>
<read/>
</privilege>
<privilege>
<C:read-free-busy/>
</privilege>
<privilege>
<C:schedule-deliver/>
</privilege>
<privilege>
<C:schedule-deliver-invite/>
</privilege>
<privilege>
<C:schedule-deliver-reply/>
</privilege>
<privilege>
<C:schedule-query-freebusy/>
</privilege>
<privilege>
<C:schedule-send/>
</privilege>
<privilege>
<C:schedule-send-invite/>
</privilege>
<privilege>
<C:schedule-send-reply/>
</privilege>
<privilege>
<C:schedule-send-freebusy/>
</privilege>
</current-user-privilege-set>
<C2:getctag>4d470212545b8dd76f702fe2444accad</C2:getctag>
</prop>
@ -251,12 +215,42 @@ Content-Type: text/xml; charset="utf-8"
</resourcetype>
<getcontenttype>httpd/unix-directory</getcontenttype>
<current-user-privilege-set>
<privilege>
<all/>
</privilege>
<privilege>
<read/>
</privilege>
<privilege>
<unlock/>
</privilege>
<privilege>
<read-acl/>
</privilege>
<privilege>
<read-current-user-privilege-set/>
</privilege>
<privilege>
<write-acl/>
</privilege>
<privilege>
<C:read-free-busy/>
</privilege>
<privilege>
<write/>
</privilege>
<privilege>
<write-properties/>
</privilege>
<privilege>
<write-content/>
</privilege>
<privilege>
<bind/>
</privilege>
<privilege>
<unbind/>
</privilege>
<privilege>
<C:schedule-deliver/>
</privilege>
@ -310,12 +304,42 @@ Content-Type: text/xml; charset="utf-8"
</resourcetype>
<getcontenttype>httpd/unix-directory</getcontenttype>
<current-user-privilege-set>
<privilege>
<all/>
</privilege>
<privilege>
<read/>
</privilege>
<privilege>
<unlock/>
</privilege>
<privilege>
<read-acl/>
</privilege>
<privilege>
<read-current-user-privilege-set/>
</privilege>
<privilege>
<write-acl/>
</privilege>
<privilege>
<C:read-free-busy/>
</privilege>
<privilege>
<write/>
</privilege>
<privilege>
<write-properties/>
</privilege>
<privilege>
<write-content/>
</privilege>
<privilege>
<bind/>
</privilege>
<privilege>
<unbind/>
</privilege>
<privilege>
<C:schedule-deliver/>
</privilege>