mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-05-05 16:50:50 +00:00
eliminate trailing whitespace, expand tabs
This commit is contained in:
parent
063048802f
commit
eb7f2edc0c
@ -38,7 +38,7 @@ function early_exception_handler($e) {
|
||||
foreach( $trace AS $k => $v ) {
|
||||
printf( "%s[%d] %s%s%s()\n", $v['file'], $v['line'], (isset($v['class'])?$v['class']:''), (isset($v['type'])?$v['type']:''), (isset($v['function'])?$v['function']:'') );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
set_exception_handler('early_exception_handler');
|
||||
|
||||
@ -155,12 +155,12 @@ $c->protocol_server_port = sprintf( '%s://%s%s',
|
||||
(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'? 'https' : 'http'),
|
||||
$_SERVER['SERVER_NAME'],
|
||||
(
|
||||
( (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')
|
||||
&& (!isset($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == 80) )
|
||||
|| (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'
|
||||
&& (!isset($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == 443) )
|
||||
? ''
|
||||
: ':'.$_SERVER['SERVER_PORT']
|
||||
( (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')
|
||||
&& (!isset($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == 80) )
|
||||
|| ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'
|
||||
&& (!isset($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == 443) )
|
||||
? ''
|
||||
: ':'.$_SERVER['SERVER_PORT']
|
||||
) );
|
||||
$c->protocol_server_port_script = $c->protocol_server_port . ($_SERVER['SCRIPT_NAME'] == '/index.php' ? '' : $_SERVER['SCRIPT_NAME']);
|
||||
|
||||
@ -389,20 +389,20 @@ function ISODateToHTTPDate( $isodate ) {
|
||||
// It is necessary to use English for this, explicitly. See Debian BTS Bug#661985 for more info.
|
||||
$month = gmstrftime('%m', strtotime($isodate));
|
||||
switch( intval($month) ) {
|
||||
case 1: $month = 'Jan'; break;
|
||||
case 2: $month = 'Feb'; break;
|
||||
case 3: $month = 'Mar'; break;
|
||||
case 4: $month = 'Apr'; break;
|
||||
case 5: $month = 'May'; break;
|
||||
case 6: $month = 'Jun'; break;
|
||||
case 7: $month = 'Jul'; break;
|
||||
case 8: $month = 'Aug'; break;
|
||||
case 9: $month = 'Sep'; break;
|
||||
case 10: $month = 'Oct'; break;
|
||||
case 11: $month = 'Nov'; break;
|
||||
case 12: $month = 'Dec'; break;
|
||||
default:
|
||||
throw new Exception('Invalid month '.$month);
|
||||
case 1: $month = 'Jan'; break;
|
||||
case 2: $month = 'Feb'; break;
|
||||
case 3: $month = 'Mar'; break;
|
||||
case 4: $month = 'Apr'; break;
|
||||
case 5: $month = 'May'; break;
|
||||
case 6: $month = 'Jun'; break;
|
||||
case 7: $month = 'Jul'; break;
|
||||
case 8: $month = 'Aug'; break;
|
||||
case 9: $month = 'Sep'; break;
|
||||
case 10: $month = 'Oct'; break;
|
||||
case 11: $month = 'Nov'; break;
|
||||
case 12: $month = 'Dec'; break;
|
||||
default:
|
||||
throw new Exception('Invalid month '.$month);
|
||||
}
|
||||
// Use strtotime since strptime is not available on Windows platform.
|
||||
return( gmstrftime('%a, %d '.$month.' %Y %H:%M:%S GMT', strtotime($isodate)) );
|
||||
|
||||
@ -22,13 +22,13 @@ elseif ( isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] == '/autodiscover
|
||||
|
||||
function logRequestHeaders() {
|
||||
global $c;
|
||||
|
||||
|
||||
/** Log the request headers */
|
||||
$lines = apache_request_headers();
|
||||
dbg_error_log( "LOG ", "***************** Request Header ****************" );
|
||||
dbg_error_log( "LOG ", "%s %s", $_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI'] );
|
||||
foreach( $lines AS $k => $v ) {
|
||||
if ( $k != 'Authorization' || (isset($c->dbg['password']) && $c->dbg['password'] ) )
|
||||
if ( $k != 'Authorization' || (isset($c->dbg['password']) && $c->dbg['password'] ) )
|
||||
dbg_error_log( "LOG headers", "-->%s: %s", $k, $v );
|
||||
else
|
||||
dbg_error_log( "LOG headers", "-->%s: %s", $k, 'Delicious tasty password eaten by debugging monster!' );
|
||||
|
||||
@ -53,7 +53,7 @@ function caldav_get_feed( $request, $collection ) {
|
||||
if ( $response !== false ) return $response;
|
||||
|
||||
$principal = $collection->GetProperty('principal');
|
||||
|
||||
|
||||
/**
|
||||
* The CalDAV specification does not define GET on a collection, but typically this is
|
||||
* used as a .ics download for the whole collection, which is what we do also.
|
||||
@ -92,9 +92,9 @@ function caldav_get_feed( $request, $collection ) {
|
||||
$feed->setLink($url);
|
||||
$feed->setFeedLink($c->protocol_server_port_script . $request->path, 'atom');
|
||||
$feed->addAuthor(array(
|
||||
'name' => $principal->GetProperty('displayname'),
|
||||
'email' => $principal->GetProperty('email'),
|
||||
'uri' => $c->protocol_server_port . $principal->url(),
|
||||
'name' => $principal->GetProperty('displayname'),
|
||||
'email' => $principal->GetProperty('email'),
|
||||
'uri' => $c->protocol_server_port . $principal->url(),
|
||||
));
|
||||
$feed_description = $collection->GetProperty('description');
|
||||
if ( isset($feed_description) && $feed_description != '' ) $feed->setDescription($feed_description);
|
||||
@ -112,7 +112,7 @@ function caldav_get_feed( $request, $collection ) {
|
||||
|
||||
$ical = new vComponent( $event->caldav_data );
|
||||
$event_data = $ical->GetComponents('VTIMEZONE', false);
|
||||
|
||||
|
||||
$item = $feed->createEntry();
|
||||
$item->setId( $c->protocol_server_port_script . ConstructURL($event->dav_name) );
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@ function SRVOk ( $value, $name, $row ) {
|
||||
global $BrowserCurrentRow;
|
||||
if ( empty($BrowserCurrentRow->domain) ) return ''; // skip empty rows
|
||||
$s = new iSchedule();
|
||||
$s->domain = $BrowserCurrentRow->domain;
|
||||
$s->domain = $BrowserCurrentRow->domain;
|
||||
return translate( ( $s->getServer()?'OK': SRVFormat ( $s->domain ) ) );
|
||||
}
|
||||
|
||||
|
||||
@ -100,7 +100,7 @@ if ( $c->metrics_style != 'counters' ) {
|
||||
if ( $c->metrics_style != 'memcache' ) {
|
||||
// These are more basic metrics. Just counts of requests, by type.
|
||||
$sql = <<<QUERY
|
||||
SELECT
|
||||
SELECT
|
||||
(SELECT last_value FROM metrics_count_get) AS get_count,
|
||||
(SELECT last_value FROM metrics_count_put) AS put_count,
|
||||
(SELECT last_value FROM metrics_count_propfind) AS propfind_count,
|
||||
|
||||
@ -9,7 +9,7 @@ function i18n($value) {
|
||||
$skip_errors = false; // We need to hide a couple of unsightly errors even here...
|
||||
function log_setup_error($errno , $errstr , $errfile , $errline) {
|
||||
global $skip_errors;
|
||||
if ( $skip_errors ) return;
|
||||
if ( $skip_errors ) return;
|
||||
error_log('DAViCal setup.php: Informational: '.$errfile.'('.$errline.'): ['.$errno.'] '.$errstr);
|
||||
}
|
||||
|
||||
@ -51,13 +51,13 @@ class CheckResult {
|
||||
private $ok;
|
||||
private $use_class;
|
||||
private $description;
|
||||
|
||||
|
||||
function __construct( $success, $description=null, $use_class=null ) {
|
||||
$this->ok = (boolean) $success;
|
||||
$this->description = (isset($description)?$description : ($success===true? i18n('Passed') : i18n('Fail')));
|
||||
$this->use_class = (isset($use_class)?$use_class:($success===true?'dep_ok' : 'dep_fail'));
|
||||
$this->use_class = (isset($use_class)?$use_class:($success===true?'dep_ok' : 'dep_fail'));
|
||||
}
|
||||
|
||||
|
||||
public function getClass() {
|
||||
return $this->use_class;
|
||||
}
|
||||
@ -169,7 +169,7 @@ $loaded_extensions = array_flip(get_loaded_extensions());
|
||||
|
||||
|
||||
function do_error( $errormessage ) {
|
||||
// We can't translate this because we're testing these things even before
|
||||
// We can't translate this because we're testing these things even before
|
||||
// the translation interface is available...
|
||||
printf("<p class='error'><br/>%s</p>", $errormessage );
|
||||
}
|
||||
@ -185,7 +185,7 @@ function get_phpinfo() {
|
||||
phpinfo();
|
||||
$phpinfo = ob_get_contents( );
|
||||
ob_end_clean( );
|
||||
|
||||
|
||||
$phpinfo = preg_replace( '{^.*?<body>}s', '', $phpinfo);
|
||||
$phpinfo = preg_replace( '{</body>.*?$}s', '', $phpinfo);
|
||||
return $phpinfo;
|
||||
@ -275,16 +275,16 @@ function check_davical_version() {
|
||||
|
||||
function check_awl_version() {
|
||||
global $c;
|
||||
|
||||
|
||||
if ( !function_exists('awl_version') ) return new CheckResult(false);
|
||||
|
||||
|
||||
$result = new CheckResult($c->want_awl_version == awl_version());
|
||||
if ( ! $result->getOK() ) {
|
||||
$result->setDescription( sprintf(i18n('Want: %s, Currently: %s'), $c->want_awl_version, awl_version()) );
|
||||
if ( $c->want_awl_version < awl_version() ) $result->setClass('dep_warning');
|
||||
}
|
||||
return $result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -318,7 +318,7 @@ EOTABLE;
|
||||
|
||||
function build_dependencies_table( ) {
|
||||
global $c;
|
||||
|
||||
|
||||
$dependencies = array(
|
||||
translate('Current DAViCal version ') => 'check_davical_version',
|
||||
translate('AWL Library version ') => 'check_awl_version',
|
||||
@ -343,7 +343,7 @@ function build_dependencies_table( ) {
|
||||
}
|
||||
|
||||
$translated_failure_code = translate('<a href="http://wiki.davical.org/w/Setup_Failure_Codes/%s">Explanation on DAViCal Wiki</a>');
|
||||
|
||||
|
||||
$dependencies_table = '';
|
||||
$dep_tpl = '<tr class="%s">
|
||||
<td>%s</td>
|
||||
@ -359,7 +359,7 @@ function build_dependencies_table( ) {
|
||||
rawurlencode($k)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return $dependencies_table;
|
||||
}
|
||||
|
||||
|
||||
@ -78,7 +78,7 @@ class Tools {
|
||||
$html = '<div id="entryform">';
|
||||
$html .= '<h1>'.translate('Import all .ics files of a directory') .'</h1>';
|
||||
$html .= '<p>'.translate('This process will import each file in a directory named "username.ics" and create a user and calendar for each file to import.') .'</p>';
|
||||
|
||||
|
||||
$data = (object) array('directory_path' => '/path/to/your/ics/files','calendar_path' => 'calendar');
|
||||
$ef = new EntryForm( $_SERVER['REQUEST_URI'],$data , true,true );
|
||||
$html .= "<table width=\"100%\" class=\"data\">\n";
|
||||
|
||||
@ -12,18 +12,18 @@ define('XHTML_XMLNS','http://www.w3.org/1999/xhtml');
|
||||
* in a DAViCal way, and we have some huge limitations:
|
||||
* - We *only* support Atom feeds.
|
||||
* - We *only* support creating them.
|
||||
*
|
||||
*
|
||||
* @author Andrew McMillan <andrew@morphoss.com>
|
||||
*
|
||||
*/
|
||||
|
||||
class AtomXHTMLContent /* extends XMLElement */ {
|
||||
private $content_string;
|
||||
|
||||
|
||||
function __construct($xhtml) {
|
||||
$this->content_string = $xhtml;
|
||||
}
|
||||
|
||||
|
||||
function Render( $ignore1, $ignore2, $ignore3 ) {
|
||||
return $this->content_string . "\n";
|
||||
}
|
||||
@ -58,28 +58,28 @@ class AtomEntry {
|
||||
$this->id = new XMLElement('id', rtrim($new_value,"\r\n"));
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
|
||||
public function setTitle( $new_value, $type = 'text' ) {
|
||||
$this->title = new XMLElement('title', $new_value, array( 'type' => $type ));
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
|
||||
public static function setDate( $tagname, $epoch ) {
|
||||
// e.g. 2010-12-26T17:49:16+13:00
|
||||
return new XMLElement($tagname, date('Y-m-d\TH:i:sP',$epoch));
|
||||
}
|
||||
|
||||
|
||||
public function setDateModified( $epoch ) {
|
||||
$this->updated = self::setDate('updated', $epoch);
|
||||
return $this->updated;
|
||||
}
|
||||
|
||||
|
||||
public function setDateCreated( $epoch ) {
|
||||
$node = self::setDate('published', $epoch);
|
||||
$this->nodes[] = $node;
|
||||
return $node;
|
||||
}
|
||||
|
||||
|
||||
public function setLink( $new_value, $type="text/calendar", $rel='alternate' ) {
|
||||
return $this->addNode('link', $new_value, array( 'rel' => $rel, 'type' => $type ) );
|
||||
}
|
||||
@ -95,7 +95,7 @@ class AtomEntry {
|
||||
throw new Exception("AtomFeed::addAuthor(\$new_value) the \$new_value MUST be an array with at least a 'name' element. RFC4287-3.2");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function addCategory( $new_value ) {
|
||||
if ( is_array($new_value) && isset($new_value['term']) ) {
|
||||
$category = $this->addNode('category', null, $new_value );
|
||||
@ -104,22 +104,22 @@ class AtomEntry {
|
||||
throw new Exception("AtomFeed::addCategory(\$new_value) the \$new_value MUST be an array with at least a 'term' element, and potentially a 'scheme' and a 'label' element. RFC4287-4.2.2");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function setDescription( $new_value, $type = 'text' ) {
|
||||
return $this->addNode('summary', $new_value, array( 'type' => $type ) );
|
||||
}
|
||||
|
||||
|
||||
public function setContent( $new_value, $type = 'xhtml' ) {
|
||||
$content = $this->addNode('content', null, array( 'type' => $type ) );
|
||||
if ( $type == 'xhtml' ) {
|
||||
$content->NewElement('div', array( new AtomXHTMLContent($new_value) ), array('xmlns' => XHTML_XMLNS));
|
||||
}
|
||||
else {
|
||||
$content->SetContent($new_value);
|
||||
$content->SetContent($new_value);
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
public function addNode( $in_tag, $content=false, $attributes=false, $xmlns=null ) {
|
||||
$node = new XMLElement($in_tag,$content,$attributes,$xmlns);
|
||||
if ( !isset($node) ) return null;
|
||||
@ -170,17 +170,17 @@ class AtomFeed extends XMLDocument {
|
||||
$this->id = $this->NewXMLElement('id', $new_value);
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
|
||||
public function setTitle( $new_value, $type = 'text' ) {
|
||||
$this->title = $this->NewXMLElement('title', $new_value, array( 'type' => $type ));
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
|
||||
public function setDateModified( $epoch ) {
|
||||
$this->updated = AtomEntry::setDate('updated', $epoch);
|
||||
return $this->updated;
|
||||
}
|
||||
|
||||
|
||||
public function setLink( $new_value, $type="text/calendar", $rel='alternate' ) {
|
||||
return $this->addNode('link', $new_value, array( 'rel' => $rel, 'type' => $type ) );
|
||||
}
|
||||
@ -189,15 +189,15 @@ class AtomFeed extends XMLDocument {
|
||||
/**
|
||||
* Sets the feed link (rel=self), ignoring the parameter which is for
|
||||
* compatibility with the Zend library API, although we use this for
|
||||
* the Id, whereas they use the first link that is set.
|
||||
* the Id, whereas they use the first link that is set.
|
||||
* @param uri $new_value The link target
|
||||
* @return XMLElement the node that was added.
|
||||
* @return XMLElement the node that was added.
|
||||
*/
|
||||
public function setFeedLink( $new_value, $type = null ) {
|
||||
$this->setId($new_value);
|
||||
return $this->setLink($new_value , 'application/atom+xml', 'self' );
|
||||
}
|
||||
|
||||
|
||||
public function addAuthor( $new_value ) {
|
||||
if ( is_array($new_value) && isset($new_value['name']) ) {
|
||||
$author = $this->addNode('author' );
|
||||
@ -209,11 +209,11 @@ class AtomFeed extends XMLDocument {
|
||||
throw new Exception("AtomFeed::addAuthor(\$new_value) the \$new_value MUST be an array with at leas a 'name' element. RFC4287-3.2");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function setDescription( $new_value, $type = 'text' ) {
|
||||
return $this->addNode('subtitle', $new_value, array( 'type' => $type ) );
|
||||
}
|
||||
|
||||
|
||||
public function addNode( $in_tag, $content=false, $attributes=false, $xmlns=null ) {
|
||||
$node = $this->NewXMLElement($in_tag,$content,$attributes,$xmlns);
|
||||
if ( !isset($node) ) return null;
|
||||
|
||||
@ -111,7 +111,7 @@ class CalDAVRequest
|
||||
* can test that value with the PreferMinimal() method.
|
||||
*/
|
||||
private $prefer;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new CalDAVRequest object.
|
||||
*/
|
||||
@ -127,8 +127,8 @@ class CalDAVRequest
|
||||
else if ( isset($_SERVER['HTTP_BRIEF']) && (strtoupper($_SERVER['HTTP_BRIEF']) == 'T') ) {
|
||||
$this->prefer = array( 'return-minimal');
|
||||
}
|
||||
else
|
||||
$this->prefer = array();
|
||||
else
|
||||
$this->prefer = array();
|
||||
|
||||
/**
|
||||
* Our path is /<script name>/<user name>/<user controlled> if it ends in
|
||||
@ -377,7 +377,7 @@ EOSQL;
|
||||
$cache = getCacheInstance();
|
||||
$cache->delete( 'collection-'.$params[':dav_name'], null );
|
||||
$cache->delete( 'principal-'.$params[':parent_container'], null );
|
||||
|
||||
|
||||
$qry = new AwlQuery( "SELECT * FROM collection WHERE dav_name = :dav_name", array( ':dav_name' => $matches[1] ) );
|
||||
if ( $qry->Exec('caldav',__LINE__,__FILE__) && $qry->rows() == 1 && ($row = $qry->Fetch()) ) {
|
||||
$this->collection_id = $row->collection_id;
|
||||
@ -718,7 +718,7 @@ EOSQL;
|
||||
}
|
||||
|
||||
|
||||
private static function supportedPrivileges() {
|
||||
private static function supportedPrivileges() {
|
||||
return array(
|
||||
'all' => array(
|
||||
'read' => translate('Read the content of a resource or collection'),
|
||||
@ -748,7 +748,7 @@ EOSQL;
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the dav_name of the resource in our internal namespace
|
||||
*/
|
||||
@ -1116,13 +1116,13 @@ EOSQL;
|
||||
|
||||
/**
|
||||
* Check that the incoming Etag matches the one for the existing (or non-existing) resource.
|
||||
*
|
||||
*
|
||||
* @param boolean $exists Whether the destination exists
|
||||
* @param string $dest_etag The etag for the destination.
|
||||
*/
|
||||
function CheckEtagMatch( $exists, $dest_etag ) {
|
||||
global $c;
|
||||
|
||||
|
||||
if ( ! $exists ) {
|
||||
if ( (isset($this->etag_if_match) && $this->etag_if_match != '') ) {
|
||||
/**
|
||||
@ -1135,7 +1135,7 @@ EOSQL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
if ( isset($c->strict_etag_checking) && $c->strict_etag_checking )
|
||||
$trim_chars = '\'\\" ';
|
||||
else
|
||||
@ -1166,7 +1166,7 @@ EOSQL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Is the user has the privileges to do what is requested.
|
||||
*/
|
||||
@ -1270,7 +1270,7 @@ EOSQL;
|
||||
public static function kill_on_exit() {
|
||||
posix_kill( getmypid(), 28 );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Utility function we call when we have a simple status-based response to
|
||||
* return to the client. Possibly
|
||||
|
||||
@ -427,8 +427,8 @@ EOSQL;
|
||||
SELECT collection.*, path_privs(:session_principal::int8, collection.dav_name,:scan_depth::int), p.principal_id,
|
||||
p.type_id AS principal_type_id, p.displayname AS principal_displayname, p.default_privileges AS principal_default_privileges,
|
||||
timezones.vtimezone, dav_binding.access_ticket_id, dav_binding.parent_container AS bind_parent_container,
|
||||
dav_binding.dav_displayname, owner.dav_name AS bind_owner_url, dav_binding.dav_name AS bound_to,
|
||||
dav_binding.external_url AS external_url, dav_binding.type AS external_type, dav_binding.bind_id AS bind_id
|
||||
dav_binding.dav_displayname, owner.dav_name AS bind_owner_url, dav_binding.dav_name AS bound_to,
|
||||
dav_binding.external_url AS external_url, dav_binding.type AS external_type, dav_binding.bind_id AS bind_id
|
||||
FROM dav_binding
|
||||
LEFT JOIN collection ON (collection.collection_id=bound_source_id)
|
||||
LEFT JOIN principal p USING (user_no)
|
||||
@ -481,15 +481,15 @@ EOSQL;
|
||||
$this->collection->dav_name = preg_replace('{/[^/]*$}', '/', $this->dav_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find the collection associated with this resource.
|
||||
*/
|
||||
protected function FetchCollection() {
|
||||
global $session;
|
||||
|
||||
|
||||
/**
|
||||
* RFC4918, 8.3: Identifiers for collections SHOULD end in '/'
|
||||
* - also discussed at more length in 5.2
|
||||
@ -528,7 +528,7 @@ EOSQL;
|
||||
}
|
||||
@dbg_error_log( 'DAVResource', ':FetchCollection: Read cached collection named "%s" of type "%s".', $this->collection->dav_name, $this->collection->type );
|
||||
}
|
||||
|
||||
|
||||
if ( isset($this->collection->bound_from) ) {
|
||||
$this->_is_binding = true;
|
||||
$this->bound_from = str_replace( $this->collection->bound_to, $this->collection->bound_from, $this->dav_name);
|
||||
@ -537,7 +537,7 @@ EOSQL;
|
||||
$this->tickets[] = new DAVTicket($this->collection->access_ticket_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->_is_collection = ( $this->_is_principal || $this->collection->dav_name == $this->dav_name || $this->collection->dav_name == $this->dav_name.'/' );
|
||||
if ( $this->_is_collection ) {
|
||||
$this->dav_name = $this->collection->dav_name;
|
||||
@ -754,7 +754,7 @@ EOQRY;
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fetch the parent to this resource. This is deprecated - use GetParentContainer() instead.
|
||||
*/
|
||||
@ -1312,7 +1312,7 @@ EOQRY;
|
||||
dbg_error_log('DAVResource', 'Request for a%scached sync-token', ($cachedOK ? ' ' : 'n un') );
|
||||
if ( $this->IsPrincipal() ) return null;
|
||||
if ( $this->collection_id() == 0 ) return null;
|
||||
if ( !isset($this->sync_token) || !$cachedOK ) {
|
||||
if ( !isset($this->sync_token) || !$cachedOK ) {
|
||||
$sql = 'SELECT new_sync_token( 0, :collection_id) AS sync_token';
|
||||
$params = array( ':collection_id' => $this->collection_id());
|
||||
$qry = new AwlQuery($sql, $params );
|
||||
@ -1325,7 +1325,7 @@ EOQRY;
|
||||
dbg_error_log('DAVResource', 'Returning sync token of "%s"', $this->sync_token );
|
||||
return $this->sync_token;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks whether the target collection is publicly_readable
|
||||
*/
|
||||
@ -1473,7 +1473,7 @@ EOQRY;
|
||||
dbg_error_log( 'DAVResource', ':GetProperty: dav-data: fetched resource does%s exist.', ($this->exists?'':' not') );
|
||||
return $this->resource->caldav_data;
|
||||
break;
|
||||
|
||||
|
||||
case 'principal':
|
||||
if ( !isset($this->principal) ) $this->FetchPrincipal();
|
||||
return clone($this->principal);
|
||||
@ -1483,7 +1483,7 @@ EOQRY;
|
||||
if ( isset($this->{$name}) ) {
|
||||
if ( ! is_object($this->{$name}) ) return $this->{$name};
|
||||
return clone($this->{$name});
|
||||
}
|
||||
}
|
||||
if ( $this->_is_principal ) {
|
||||
if ( !isset($this->principal) ) $this->FetchPrincipal();
|
||||
if ( isset($this->principal->{$name}) ) return $this->principal->{$name};
|
||||
@ -1503,7 +1503,7 @@ EOQRY;
|
||||
if ( isset($this->{$name}) ) {
|
||||
if ( ! is_object($this->{$name}) ) return $this->{$name};
|
||||
return clone($this->{$name});
|
||||
}
|
||||
}
|
||||
// dbg_error_log( 'DAVResource', ':GetProperty: Failed to find property "%s" on "%s".', $name, $this->dav_name );
|
||||
}
|
||||
|
||||
@ -1537,7 +1537,7 @@ EOQRY;
|
||||
global $c, $session, $request;
|
||||
|
||||
// dbg_error_log( 'DAVResource', 'Processing "%s" on "%s".', $tag, $this->dav_name );
|
||||
|
||||
|
||||
if ( $reply === null ) $reply = $GLOBALS['reply'];
|
||||
|
||||
switch( $tag ) {
|
||||
@ -1694,7 +1694,7 @@ EOQRY;
|
||||
if ( isset($c->disable_caldav_proxy) && $c->disable_caldav_proxy ) return false;
|
||||
if ( !isset($proxy_type) ) $proxy_type = 'write';
|
||||
// ProxyFor is an already constructed URL
|
||||
$this->FetchPrincipal();
|
||||
$this->FetchPrincipal();
|
||||
$reply->CalendarserverElement($prop, 'calendar-proxy-'.$proxy_type.'-for', $reply->href( $this->principal->ProxyFor($proxy_type) ) );
|
||||
break;
|
||||
|
||||
|
||||
@ -50,11 +50,11 @@ class DAViCalSession extends Session
|
||||
|
||||
public $principal_id;
|
||||
private $privilege_resources = array();
|
||||
|
||||
|
||||
/**
|
||||
* Create a new DAViCalSession object.
|
||||
*
|
||||
* We create a Session and extend it with some additional useful DAViCal
|
||||
* We create a Session and extend it with some additional useful DAViCal
|
||||
* related information.
|
||||
*
|
||||
* @param string $sid A session identifier.
|
||||
|
||||
@ -152,7 +152,7 @@ class HTTPAuthSession {
|
||||
|
||||
/**
|
||||
* Maybe some external authentication didn't return false for an inactive
|
||||
* user, so we'll be pedantic here.
|
||||
* user, so we'll be pedantic here.
|
||||
*/
|
||||
if ( $p->user_active ) {
|
||||
$this->AssignSessionDetails($p);
|
||||
@ -194,7 +194,7 @@ class HTTPAuthSession {
|
||||
if ( isset($_SERVER['HTTP_USER_AGENT']) ) $opaque .= $_SERVER['HTTP_USER_AGENT'];
|
||||
if ( isset($_SERVER['REMOTE_ADDR']) ) $opaque .= $_SERVER['REMOTE_ADDR'];
|
||||
$opaque = sha1($opaque);
|
||||
|
||||
|
||||
if ( ! empty($_SERVER['PHP_AUTH_DIGEST'])) {
|
||||
// analyze the PHP_AUTH_DIGEST variable
|
||||
if ( $data = $this->ParseDigestHeader($_SERVER['PHP_AUTH_DIGEST']) ) {
|
||||
@ -204,7 +204,7 @@ class HTTPAuthSession {
|
||||
$this->AuthFailedResponse();
|
||||
// Does not return
|
||||
}
|
||||
|
||||
|
||||
// generate the valid response
|
||||
$test_user = new Principal('username', $data['username']);
|
||||
|
||||
@ -220,7 +220,7 @@ class HTTPAuthSession {
|
||||
// dbg_error_log( "HTTPAuth", "DigestAuthString: %s", $auth_string);
|
||||
$valid_response = md5($auth_string);
|
||||
// dbg_error_log( "HTTPAuth", "DigestResponse: %s", $valid_response);
|
||||
|
||||
|
||||
if ( $data['response'] == $valid_response ) {
|
||||
$this->AssignSessionDetails($test_user);
|
||||
// dbg_error_log( "HTTPAuth", "Success!!!" );
|
||||
@ -269,14 +269,14 @@ class HTTPAuthSession {
|
||||
dbg_error_log( "HTTPAuth", 'Received: %s: %s', $m[1], $m[2] );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@dbg_error_log( "HTTPAuth", 'Received: nonce: %s, nc: %s, cnonce: %s, qop: %s, username: %s, uri: %s, response: %s',
|
||||
$data['nonce'], $data['nc'], $data['cnonce'], $data['qop'], $data['username'], $data['uri'], $data['response']
|
||||
);
|
||||
return $needed_parts ? false : $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* CheckPassword does all of the password checking and
|
||||
* returns a user record object, or false if it all ends in tears.
|
||||
@ -321,7 +321,7 @@ class HTTPAuthSession {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Checks whether a user is allowed to do something.
|
||||
*
|
||||
@ -373,7 +373,7 @@ class HTTPAuthSession {
|
||||
$this->email = $principal->email();
|
||||
$this->dav_name = $principal->dav_name();
|
||||
$this->principal = $principal;
|
||||
|
||||
|
||||
$this->GetRoles();
|
||||
$this->logged_in = true;
|
||||
if ( function_exists("awl_set_locale") && isset($this->locale) && $this->locale != "" ) {
|
||||
|
||||
@ -24,19 +24,19 @@ class Principal {
|
||||
*/
|
||||
private static $db_tablename = 'dav_principal';
|
||||
private static $db_mandatory_fields = array(
|
||||
'username',
|
||||
'username',
|
||||
);
|
||||
|
||||
public static function updateableFields() {
|
||||
return array(
|
||||
'username', 'email', 'user_active', 'modified', 'password', 'fullname',
|
||||
'username', 'email', 'user_active', 'modified', 'password', 'fullname',
|
||||
'email_ok', 'date_format_type', 'locale', 'type_id', 'displayname', 'default_privileges'
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* We cache these so if we try and access a row by principal_id/user_no/e_mail that we've
|
||||
* already read we don't read it again.
|
||||
* already read we don't read it again.
|
||||
* @var unknown_type
|
||||
*/
|
||||
private static $byUserno = array();
|
||||
@ -52,22 +52,22 @@ class Principal {
|
||||
protected $email;
|
||||
protected $dav_name;
|
||||
public $user_active;
|
||||
public $created;
|
||||
public $modified;
|
||||
public $created;
|
||||
public $modified;
|
||||
public $password;
|
||||
public $fullname;
|
||||
public $email_ok;
|
||||
public $date_format_type;
|
||||
public $locale;
|
||||
public $fullname;
|
||||
public $email_ok;
|
||||
public $date_format_type;
|
||||
public $locale;
|
||||
public $type_id;
|
||||
public $displayname;
|
||||
public $default_privileges;
|
||||
public $displayname;
|
||||
public $default_privileges;
|
||||
public $is_principal;
|
||||
public $is_calendar;
|
||||
public $collection_id;
|
||||
public $is_addressbook;
|
||||
public $collection_id;
|
||||
public $is_addressbook;
|
||||
public $resourcetypes;
|
||||
public $privileges;
|
||||
public $privileges;
|
||||
|
||||
/**
|
||||
* Whether this Principal actually exists in the database yet.
|
||||
@ -78,18 +78,18 @@ class Principal {
|
||||
/**
|
||||
* @var The home URL of the principal
|
||||
*/
|
||||
protected $url;
|
||||
protected $url;
|
||||
|
||||
/**
|
||||
* @var The actual requested URL for this principal, when the request was for /principals/... or such
|
||||
*/
|
||||
protected $original_request_url;
|
||||
|
||||
protected $original_request_url;
|
||||
|
||||
/**
|
||||
* Whether this was retrieved using an e-mail address
|
||||
* @var boolean
|
||||
*/
|
||||
protected $by_email;
|
||||
protected $by_email;
|
||||
|
||||
/**
|
||||
* If we're using memcached this is the namespace we'll put stuff in
|
||||
@ -104,7 +104,7 @@ class Principal {
|
||||
|
||||
/**
|
||||
* Construct a new Principal object. The principal record will be retrieved from the database, or (if not found) initialised to a new record. You can test for whether the Principal exists by calling the Exists() method on the returned object.
|
||||
*
|
||||
*
|
||||
* Depending on the supplied $type, the following behaviour will occur:
|
||||
* path: Will attempt to extract a username or email from the supplied path, and then do what those do.
|
||||
* dav_name: Expects the dav_name of a <em>principal</em>, exactly, like: /principal/ and will use that as for username.
|
||||
@ -112,9 +112,9 @@ class Principal {
|
||||
* principal_id: Expects an integer which is the principal.principal_id
|
||||
* email: Will try and retrieve a unique principal by using the email address. Will fail (subsequent call to Exists() will be false) if there is not a unique match.
|
||||
* username: Will retrieve based on strtolower($value) = lower(usr.username)
|
||||
*
|
||||
*
|
||||
* @param string $type One of 'path', 'dav_name', 'user_no', 'principal_id', 'email' or 'username'
|
||||
* @param mixed $value A value appropriate to the $type requested.
|
||||
* @param mixed $value A value appropriate to the $type requested.
|
||||
* @param boolean $use_cache Whether to use an available cache source (default true)
|
||||
* @throws Exception When provided with an invalid $type parameter.
|
||||
* @return Principal
|
||||
@ -219,7 +219,7 @@ class Principal {
|
||||
break;
|
||||
}
|
||||
$params[':param'] = $value;
|
||||
|
||||
|
||||
$qry = new AwlQuery( $sql, $params );
|
||||
if ( $qry->Exec('Principal',__LINE__,__FILE__) && $qry->rows() == 1 && $row = $qry->Fetch() ) {
|
||||
$this->exists = true;
|
||||
@ -249,17 +249,17 @@ class Principal {
|
||||
* @param $property
|
||||
*/
|
||||
public function __get( $property ) {
|
||||
return $this->{$property};
|
||||
return $this->{$property};
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This will allow protected properties to be examined for whether they are set
|
||||
* without making them writable. PHP 5.1 or later only.
|
||||
* @param $property
|
||||
*/
|
||||
public function __isset( $property ) {
|
||||
return isset($this->{$property});
|
||||
return isset($this->{$property});
|
||||
}
|
||||
|
||||
private function assignGuestValues() {
|
||||
@ -271,25 +271,25 @@ class Principal {
|
||||
$this->is_principal = true;
|
||||
$this->is_calendar = false;
|
||||
$this->principal_id = -1;
|
||||
$this->privileges = $this->default_privileges = 0;
|
||||
$this->privileges = $this->default_privileges = 0;
|
||||
}
|
||||
|
||||
private function assignRowValues( $db_row ) {
|
||||
foreach( $db_row AS $k => $v ) {
|
||||
$this->{$k} = $v;
|
||||
$this->{$k} = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function Exists() {
|
||||
return $this->exists;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function byEmail() {
|
||||
return $this->by_email;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Work out the username, based on elements of the path.
|
||||
* @param string $path The path to be used.
|
||||
@ -309,11 +309,11 @@ class Principal {
|
||||
$username = $path_split[1];
|
||||
if ( $path_split[1] == 'principals' && isset($path_split[3]) ) {
|
||||
$username = $path_split[3];
|
||||
$this->original_request_url = $path;
|
||||
$this->original_request_url = $path;
|
||||
}
|
||||
if ( substr($username,0,1) == '~' ) {
|
||||
$username = substr($username,1);
|
||||
$this->original_request_url = $path;
|
||||
$username = substr($username,1);
|
||||
$this->original_request_url = $path;
|
||||
}
|
||||
|
||||
if ( isset($c->allow_by_email) && $c->allow_by_email && preg_match( '#^(\S+@\S+[.]\S+)$#', $username) ) {
|
||||
@ -325,7 +325,7 @@ class Principal {
|
||||
return $username;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return the username
|
||||
* @return string The username
|
||||
@ -387,7 +387,7 @@ class Principal {
|
||||
return $this->dav_name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Ensure the principal's dead properties are loaded
|
||||
*/
|
||||
@ -402,15 +402,15 @@ class Principal {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fetch the list of collections for this principal
|
||||
* @return string The internal dav_name for the home_calendar, or null if there is none
|
||||
*/
|
||||
protected function FetchCollections() {
|
||||
if ( isset($this->collections) ) return;
|
||||
|
||||
|
||||
$this->collections = array();
|
||||
$qry = new AwlQuery('SELECT * FROM collection WHERE user_no= :user_no', array(':user_no' => $this->user_no()) );
|
||||
if ( $qry->Exec('Principal') ) {
|
||||
@ -420,14 +420,14 @@ class Principal {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return the default calendar for this principal
|
||||
* @return string The internal dav_name for the home_calendar, or false if there is none
|
||||
*/
|
||||
function default_calendar() {
|
||||
global $c;
|
||||
|
||||
|
||||
if ( !isset($this->default_calendar) ) {
|
||||
$this->default_calendar = false;
|
||||
if ( !isset($this->dead_properties) ) $this->FetchDeadProperties();
|
||||
@ -458,7 +458,7 @@ class Principal {
|
||||
return $this->default_calendar;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return the URL for this principal
|
||||
* @param string $type The type of URL we want (the principal, by default)
|
||||
@ -467,14 +467,14 @@ class Principal {
|
||||
*/
|
||||
public function url($type = 'principal', $internal=false ) {
|
||||
global $c;
|
||||
|
||||
|
||||
if ( $internal )
|
||||
$result = $this->dav_name();
|
||||
else {
|
||||
if ( isset($this->original_request_url) && $type == 'principal' )
|
||||
$result = $this->original_request_url;
|
||||
else
|
||||
$result = $this->url;
|
||||
$result = $this->url;
|
||||
}
|
||||
|
||||
switch( $type ) {
|
||||
@ -490,19 +490,19 @@ class Principal {
|
||||
return ConstructURL(DeconstructURL($result));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function internal_url($type = 'principal' ) {
|
||||
return $this->url($type,true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function unCache() {
|
||||
if ( !isset($this->cacheNs) ) return;
|
||||
if ( !isset($this->cacheNs) ) return;
|
||||
$cache = getCacheInstance();
|
||||
$cache->delete($this->cacheNs, null );
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function Write( $field_values, $inserting=true ) {
|
||||
global $c;
|
||||
if ( is_array($field_values) ) $field_values = (object) $field_values;
|
||||
@ -519,8 +519,8 @@ class Principal {
|
||||
$field_values->{'type_id'} = 1; // Default to 'person'
|
||||
if ( !isset($field_values->{'default_privileges'}) && $inserting )
|
||||
$field_values->{'default_privileges'} = sprintf('%024s',decbin(privilege_to_bits($c->default_privileges)));
|
||||
|
||||
|
||||
|
||||
|
||||
$sql = '';
|
||||
if ( $inserting ) {
|
||||
$insert_fields = array();
|
||||
@ -534,7 +534,7 @@ class Principal {
|
||||
if ( !isset($field_values->{$k}) && !isset($this->{$k}) ) continue;
|
||||
|
||||
$param_name = ':'.$k;
|
||||
$sql_params[$param_name] = (isset($field_values->{$k}) ? $field_values->{$k} : $this->{$k});
|
||||
$sql_params[$param_name] = (isset($field_values->{$k}) ? $field_values->{$k} : $this->{$k});
|
||||
if ( $k == 'default_privileges' ) {
|
||||
$sql_params[$param_name] = sprintf('%024s',$sql_params[$param_name]);
|
||||
$param_name = 'cast('.$param_name.' as text)::BIT(24)';
|
||||
@ -558,11 +558,11 @@ class Principal {
|
||||
foreach( self::$db_mandatory_fields AS $k ) {
|
||||
if ( !isset($sql_params[':'.$k]) ) {
|
||||
throw new Exception( get_class($this).'::Create: Mandatory field "'.$k.'" is not set.');
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( isset($this->user_no) ) {
|
||||
$param_names[] = ':user_no';
|
||||
$insert_fields[] = 'user_no';
|
||||
$insert_fields[] = 'user_no';
|
||||
$sql_params[':user_no'] = $this->user_no;
|
||||
}
|
||||
if ( isset($this->created) ) {
|
||||
@ -575,7 +575,7 @@ class Principal {
|
||||
else {
|
||||
$sql = 'UPDATE '.self::$db_tablename.' SET '.implode(',',$update_list);
|
||||
$sql .= ' WHERE principal_id=:principal_id';
|
||||
$sql_params[':principal_id'] = $this->principal_id;
|
||||
$sql_params[':principal_id'] = $this->principal_id;
|
||||
}
|
||||
|
||||
$qry = new AwlQuery($sql, $sql_params);
|
||||
@ -588,7 +588,7 @@ class Principal {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function Create( $field_values ) {
|
||||
$this->Write($field_values, true);
|
||||
}
|
||||
@ -609,7 +609,7 @@ class Principal {
|
||||
$cache->delete('principal-'.$row->dav_name, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static public function cacheDelete( $type, $value ) {
|
||||
$cache = getCacheInstance();
|
||||
@ -618,5 +618,5 @@ class Principal {
|
||||
$value = '/'.$value.'/';
|
||||
}
|
||||
$cache->delete('principal-'.$value, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,11 +69,11 @@ class PublicSession {
|
||||
$this->email = $principal->email();
|
||||
$this->dav_name = $principal->dav_name();
|
||||
$this->principal = $principal;
|
||||
|
||||
|
||||
if ( function_exists("awl_set_locale") && isset($this->locale) && $this->locale != "" ) {
|
||||
awl_set_locale($this->locale);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->groups = ( isset($c->public_groups) ? $c->public_groups : array() );
|
||||
$this->roles = array( 'Public' => true );
|
||||
|
||||
@ -16,18 +16,18 @@ class WritableCollection extends DAVResource {
|
||||
if ( !isset($p) ) return null;
|
||||
return $p->GetParameterValue('TZID');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Writes the data to a member in the collection and returns the segment_name of the
|
||||
* Writes the data to a member in the collection and returns the segment_name of the
|
||||
* resource in our internal namespace.
|
||||
*
|
||||
*
|
||||
* @param vCalendar $vcal The resource to be written.
|
||||
* @param boolean $create_resource True if this is a new resource.
|
||||
* @param boolean $do_scheduling True if we should also do scheduling for this write. Default false.
|
||||
* @param string $segment_name The name of the resource within the collection, or null if this
|
||||
* call should invent one based on the UID of the vCalendar.
|
||||
* @param boolean $log_action Whether to log this action. Defaults to false since this is normally called
|
||||
* in situations where one is writing secondary data.
|
||||
* in situations where one is writing secondary data.
|
||||
* @return string The segment_name of the resource within the collection, as written, or false on failure.
|
||||
*/
|
||||
function WriteCalendarMember( vCalendar $vcal, $create_resource, $do_scheduling=false, $segment_name = null, $log_action=false ) {
|
||||
@ -37,7 +37,7 @@ class WritableCollection extends DAVResource {
|
||||
}
|
||||
|
||||
global $session, $caldav_context;
|
||||
|
||||
|
||||
$resources = $vcal->GetComponents('VTIMEZONE',false); // Not matching VTIMEZONE
|
||||
$user_no = $this->user_no();
|
||||
$collection_id = $this->collection_id();
|
||||
@ -51,7 +51,7 @@ class WritableCollection extends DAVResource {
|
||||
$first = $resources[0];
|
||||
$resource_type = $first->GetType();
|
||||
}
|
||||
|
||||
|
||||
$uid = $vcal->GetUID();
|
||||
if ( empty($segment_name) ) {
|
||||
$segment_name = $uid.'.ics';
|
||||
@ -61,12 +61,12 @@ class WritableCollection extends DAVResource {
|
||||
$caldav_data = $vcal->Render();
|
||||
$etag = md5($caldav_data);
|
||||
$weak_etag = null;
|
||||
|
||||
|
||||
$qry = new AwlQuery();
|
||||
$existing_transaction_state = $qry->TransactionState();
|
||||
if ( $existing_transaction_state == 0 ) $qry->Begin();
|
||||
|
||||
|
||||
|
||||
|
||||
if ( $create_resource ) {
|
||||
$qry->QDo('SELECT nextval(\'dav_id_seq\') AS dav_id');
|
||||
}
|
||||
@ -102,7 +102,7 @@ class WritableCollection extends DAVResource {
|
||||
':session_user' => $session->user_no,
|
||||
':weak_etag' => $weak_etag
|
||||
) );
|
||||
|
||||
|
||||
if ( !$this->IsSchedulingCollection() && $do_scheduling ) {
|
||||
if ( do_scheduling_requests($vcal, $create_resource ) ) {
|
||||
$dav_params[':dav_data'] = $vcal->Render(null, true);
|
||||
@ -123,13 +123,13 @@ class WritableCollection extends DAVResource {
|
||||
rollback_on_error( $caldav_context, $user_no, $path);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$dtstart = $first->GetPValue('DTSTART');
|
||||
$calitem_params[':dtstart'] = $dtstart;
|
||||
if ( (!isset($dtstart) || $dtstart == '') && $first->GetPValue('DUE') != '' ) {
|
||||
$dtstart = $first->GetPValue('DUE');
|
||||
}
|
||||
|
||||
|
||||
$dtend = $first->GetPValue('DTEND');
|
||||
if ( isset($dtend) && $dtend != '' ) {
|
||||
dbg_error_log( 'PUT', ' DTEND: "%s", DTSTART: "%s", DURATION: "%s"', $dtend, $dtstart, $first->GetPValue('DURATION') );
|
||||
@ -165,19 +165,19 @@ class WritableCollection extends DAVResource {
|
||||
$dtend = ':dtstart';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$last_modified = $first->GetPValue('LAST-MODIFIED');
|
||||
if ( !isset($last_modified) || $last_modified == '' ) {
|
||||
$last_modified = gmdate( 'Ymd\THis\Z' );
|
||||
}
|
||||
$calitem_params[':modified'] = $last_modified;
|
||||
|
||||
|
||||
$dtstamp = $first->GetPValue('DTSTAMP');
|
||||
if ( !isset($dtstamp) || $dtstamp == '' ) {
|
||||
$dtstamp = $last_modified;
|
||||
}
|
||||
$calitem_params[':dtstamp'] = $dtstamp;
|
||||
|
||||
|
||||
$class = $first->GetPValue('CLASS');
|
||||
/*
|
||||
* It seems that some calendar clients don't set a class...
|
||||
@ -187,14 +187,14 @@ class WritableCollection extends DAVResource {
|
||||
$class = 'PUBLIC';
|
||||
}
|
||||
$calitem_params[':class'] = $class;
|
||||
|
||||
|
||||
/** Calculate what timezone to set, first, if possible */
|
||||
$last_olson = 'Turkmenikikamukau'; // I really hope this location doesn't exist!
|
||||
$tzid = self::GetTZID($first);
|
||||
if ( !empty($tzid) ) {
|
||||
$tz = $vcal->GetTimeZone($tzid);
|
||||
$olson = $vcal->GetOlsonName($tz);
|
||||
|
||||
|
||||
if ( !empty($olson) && ($olson != $last_olson) ) {
|
||||
dbg_error_log( 'PUT', ' Setting timezone to %s', $olson );
|
||||
$qry->QDo('SET TIMEZONE TO \''.$olson."'" );
|
||||
@ -205,7 +205,7 @@ class WritableCollection extends DAVResource {
|
||||
$created = $first->GetPValue('CREATED');
|
||||
if ( $created == '00001231T000000Z' ) $created = '20001231T000000Z';
|
||||
$calitem_params[':created'] = $created;
|
||||
|
||||
|
||||
$calitem_params[':tzid'] = $tzid;
|
||||
$calitem_params[':uid'] = $uid;
|
||||
$calitem_params[':summary'] = $first->GetPValue('SUMMARY');
|
||||
@ -241,7 +241,7 @@ UPDATE calendar_item SET dav_etag=:etag, uid=:uid, dtstamp=:dtstamp,
|
||||
EOSQL;
|
||||
$sync_change = 200;
|
||||
}
|
||||
|
||||
|
||||
if ( !$this->IsSchedulingCollection() ) {
|
||||
$this->WriteCalendarAlarms($dav_id, $vcal);
|
||||
$this->WriteCalendarAttendees($dav_id, $vcal);
|
||||
@ -262,27 +262,27 @@ EOSQL;
|
||||
}
|
||||
$qry->QDo("SELECT write_sync_change( $collection_id, $sync_change, :dav_name)", array(':dav_name' => $path ) );
|
||||
if ( $existing_transaction_state == 0 ) $qry->Commit();
|
||||
|
||||
|
||||
dbg_error_log( 'PUT', 'User: %d, ETag: %s, Path: %s', $session->user_no, $etag, $path);
|
||||
|
||||
|
||||
|
||||
|
||||
return $segment_name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Writes the data to a member in the collection and returns the segment_name of the
|
||||
* Writes the data to a member in the collection and returns the segment_name of the
|
||||
* resource in our internal namespace.
|
||||
*
|
||||
*
|
||||
* A caller who wants scheduling not to happen for this write must already
|
||||
* know they are dealing with a calendar, so should be calling WriteCalendarMember
|
||||
* directly.
|
||||
*
|
||||
*
|
||||
* @param $resource mixed The resource to be written.
|
||||
* @param $create_resource boolean True if this is a new resource.
|
||||
* @param $segment_name The name of the resource within the collection, or false on failure.
|
||||
* @param boolean $log_action Whether to log this action. Defaults to true since this is normally called
|
||||
* in situations where one is writing primary data.
|
||||
* @return string The segment_name that was given, or one that was assigned if null was given.
|
||||
* @return string The segment_name that was given, or one that was assigned if null was given.
|
||||
*/
|
||||
function WriteMember( $resource, $create_resource, $segment_name = null, $log_action=true ) {
|
||||
if ( ! $this->IsCollection() ) {
|
||||
@ -291,7 +291,7 @@ EOSQL;
|
||||
}
|
||||
if ( ! is_object($resource) ) {
|
||||
dbg_error_log( 'PUT', 'No data supplied!' );
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $resource instanceof vCalendar ) {
|
||||
@ -299,11 +299,11 @@ EOSQL;
|
||||
}
|
||||
else if ( $resource instanceof VCard )
|
||||
return $this->WriteAddressbookMember($resource,$create_resource,$segment_name, $log_action);
|
||||
|
||||
|
||||
return $segment_name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Given a dav_id and an original vCalendar, pull out each of the VALARMs
|
||||
* and write the values into the calendar_alarm table.
|
||||
@ -315,7 +315,7 @@ EOSQL;
|
||||
$qry->Exec('PUT',__LINE__,__FILE__);
|
||||
|
||||
$components = $vcal->GetComponents();
|
||||
|
||||
|
||||
$qry->SetSql('INSERT INTO calendar_alarm ( dav_id, action, trigger, summary, description, component, next_trigger )
|
||||
VALUES( '.$dav_id.', :action, :trigger, :summary, :description, :component,
|
||||
:related::timestamp with time zone + :related_trigger::interval )' );
|
||||
@ -363,8 +363,8 @@ EOSQL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parse out the attendee property and write a row to the
|
||||
* calendar_attendee table for each one.
|
||||
@ -375,10 +375,10 @@ EOSQL;
|
||||
function WriteCalendarAttendees( $dav_id, vCalendar $vcal ) {
|
||||
$qry = new AwlQuery('DELETE FROM calendar_attendee WHERE dav_id = '.$dav_id );
|
||||
$qry->Exec('PUT',__LINE__,__FILE__);
|
||||
|
||||
|
||||
$attendees = $vcal->GetAttendees();
|
||||
if ( count($attendees) < 1 ) return;
|
||||
|
||||
|
||||
$qry->SetSql('INSERT INTO calendar_attendee ( dav_id, status, partstat, cn, attendee, role, rsvp, property )
|
||||
VALUES( '.$dav_id.', :status, :partstat, :cn, :attendee, :role, :rsvp, :property )' );
|
||||
$qry->Prepare();
|
||||
@ -402,11 +402,11 @@ EOSQL;
|
||||
$processed[$attendee] = $v->Render();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Writes the data to a member in the collection and returns the segment_name of the
|
||||
* Writes the data to a member in the collection and returns the segment_name of the
|
||||
* resource in our internal namespace.
|
||||
*
|
||||
*
|
||||
* @param vCalendar $member_dav_name The path to the resource to be deleted.
|
||||
* @return boolean Success is true, or false on failure.
|
||||
*/
|
||||
@ -423,7 +423,7 @@ EOSQL;
|
||||
// We need to serialise access to this process just for this collection
|
||||
$cache = getCacheInstance();
|
||||
$myLock = $cache->acquireLock('collection-'.$this->dav_name());
|
||||
|
||||
|
||||
$qry = new AwlQuery();
|
||||
$params = array( ':dav_name' => $member_dav_name );
|
||||
|
||||
@ -434,13 +434,13 @@ EOSQL;
|
||||
@dbg_error_log( "DELETE", "DELETE: Calendar member %s deleted from calendar '%s'", $member_dav_name, $this->dav_name() );
|
||||
|
||||
$cache->releaseLock($myLock);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$cache->releaseLock($myLock);
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ function early_exception_handler($e) {
|
||||
foreach( $trace AS $k => $v ) {
|
||||
printf( "%s[%d] %s%s%s()\n", $v['file'], $v['line'], (isset($v['class'])?$v['class']:''), (isset($v['type'])?$v['type']:''), (isset($v['function'])?$v['function']:'') );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
set_exception_handler('early_exception_handler');
|
||||
|
||||
@ -155,12 +155,12 @@ $c->protocol_server_port = sprintf( '%s://%s%s',
|
||||
(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'? 'https' : 'http'),
|
||||
$_SERVER['SERVER_NAME'],
|
||||
(
|
||||
( (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')
|
||||
&& (!isset($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == 80) )
|
||||
|| (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'
|
||||
&& (!isset($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == 443) )
|
||||
? ''
|
||||
: ':'.$_SERVER['SERVER_PORT']
|
||||
( (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')
|
||||
&& (!isset($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == 80) )
|
||||
|| ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'
|
||||
&& (!isset($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == 443) )
|
||||
? ''
|
||||
: ':'.$_SERVER['SERVER_PORT']
|
||||
) );
|
||||
$c->protocol_server_port_script = $c->protocol_server_port . ($_SERVER['SCRIPT_NAME'] == '/index.php' ? '' : $_SERVER['SCRIPT_NAME']);
|
||||
|
||||
@ -389,20 +389,20 @@ function ISODateToHTTPDate( $isodate ) {
|
||||
// It is necessary to use English for this, explicitly. See Debian BTS Bug#661985 for more info.
|
||||
$month = gmstrftime('%m', strtotime($isodate));
|
||||
switch( intval($month) ) {
|
||||
case 1: $month = 'Jan'; break;
|
||||
case 2: $month = 'Feb'; break;
|
||||
case 3: $month = 'Mar'; break;
|
||||
case 4: $month = 'Apr'; break;
|
||||
case 5: $month = 'May'; break;
|
||||
case 6: $month = 'Jun'; break;
|
||||
case 7: $month = 'Jul'; break;
|
||||
case 8: $month = 'Aug'; break;
|
||||
case 9: $month = 'Sep'; break;
|
||||
case 10: $month = 'Oct'; break;
|
||||
case 11: $month = 'Nov'; break;
|
||||
case 12: $month = 'Dec'; break;
|
||||
default:
|
||||
throw new Exception('Invalid month '.$month);
|
||||
case 1: $month = 'Jan'; break;
|
||||
case 2: $month = 'Feb'; break;
|
||||
case 3: $month = 'Mar'; break;
|
||||
case 4: $month = 'Apr'; break;
|
||||
case 5: $month = 'May'; break;
|
||||
case 6: $month = 'Jun'; break;
|
||||
case 7: $month = 'Jul'; break;
|
||||
case 8: $month = 'Aug'; break;
|
||||
case 9: $month = 'Sep'; break;
|
||||
case 10: $month = 'Oct'; break;
|
||||
case 11: $month = 'Nov'; break;
|
||||
case 12: $month = 'Dec'; break;
|
||||
default:
|
||||
throw new Exception('Invalid month '.$month);
|
||||
}
|
||||
// Use strtotime since strptime is not available on Windows platform.
|
||||
return( gmstrftime('%a, %d '.$month.' %Y %H:%M:%S GMT', strtotime($isodate)) );
|
||||
|
||||
@ -213,7 +213,7 @@ function CreateDefaultRelationships( $username ) {
|
||||
|
||||
|
||||
function UpdateCollectionTimezones( $username, $new_timezone=null ) {
|
||||
if ( empty($new_timezone) ) return;
|
||||
if ( empty($new_timezone) ) return;
|
||||
$qry = new AwlQuery('UPDATE collection SET timezone=? WHERE dav_name LIKE ? AND is_calendar', '/'.$username.'/%', $new_timezone);
|
||||
$qry->Exec();
|
||||
}
|
||||
@ -260,7 +260,7 @@ function UpdateUserFromExternal( &$usr ) {
|
||||
}
|
||||
else
|
||||
$type = "INSERT";
|
||||
|
||||
|
||||
$params = array();
|
||||
if ( $type != 'INSERT' ) $params[':user_no'] = $usr->user_no;
|
||||
$qry = new AwlQuery( sql_from_object( $usr, $type, 'usr', 'WHERE user_no= :user_no' ), $params );
|
||||
|
||||
@ -97,16 +97,16 @@ if ( ! $grantor->Exists() ) $request->DoResponse( 404 );
|
||||
if ( ! $grantor->IsCollection() )
|
||||
$request->PreconditionFailed(403,'not-supported-privilege','ACLs are only supported on Principals or Collections');
|
||||
|
||||
$grantor->NeedPrivilege('write-acl');
|
||||
$grantor->NeedPrivilege('write-acl');
|
||||
|
||||
$cache_delete_list = array();
|
||||
|
||||
|
||||
$qry = new AwlQuery('BEGIN');
|
||||
$qry->Exec('ACL',__LINE__,__FILE__);
|
||||
|
||||
function process_ace( $grantor, $by_principal, $by_collection, $ace ) {
|
||||
global $cache_delete_list, $request;
|
||||
|
||||
|
||||
$elements = $ace->GetContent();
|
||||
$principal_node = $elements[0];
|
||||
$grant = $elements[1];
|
||||
|
||||
@ -48,8 +48,8 @@ if ( $destination->Exists() ) {
|
||||
}
|
||||
|
||||
// external binds shouldn't ever point back to ourselves but they should be a valid http[s] url
|
||||
if ( preg_match ( '{^(?:https?://|file:///)([^/]+)(:[0-9]\+)?/.+$}', $href, $matches )
|
||||
&& strcasecmp( $matches[0], 'localhost' ) !== 0 && strcasecmp( $matches[0], '127.0.0.1' ) !== 0
|
||||
if ( preg_match ( '{^(?:https?://|file:///)([^/]+)(:[0-9]\+)?/.+$}', $href, $matches )
|
||||
&& strcasecmp( $matches[0], 'localhost' ) !== 0 && strcasecmp( $matches[0], '127.0.0.1' ) !== 0
|
||||
&& strcasecmp( $matches[0], $_SERVER['SERVER_NAME'] ) !== 0 && strcasecmp( $matches[0], $_SERVER['SERVER_ADDR'] ) !== 0 ) {
|
||||
require_once('external-fetch.php');
|
||||
$qry = new AwlQuery( );
|
||||
@ -60,7 +60,7 @@ if ( preg_match ( '{^(?:https?://|file:///)([^/]+)(:[0-9]\+)?/.+$}', $href, $mat
|
||||
else {
|
||||
create_external ( '/.external/'. md5($href) ,true,false );
|
||||
$qry->QDo('SELECT collection_id FROM collection WHERE dav_name = :dav_name ', array( ':dav_name' => '/.external/'. md5($href) ));
|
||||
if ( $qry->rows() != 1 || !($row = $qry->Fetch()) )
|
||||
if ( $qry->rows() != 1 || !($row = $qry->Fetch()) )
|
||||
$request->DoResponse(500,translate('Database Error'));
|
||||
$dav_id = $row->collection_id;
|
||||
}
|
||||
@ -80,25 +80,25 @@ if ( preg_match ( '{^(?:https?://|file:///)([^/]+)(:[0-9]\+)?/.+$}', $href, $mat
|
||||
$qry = new AwlQuery( $sql, $params );
|
||||
if ( $qry->Exec('BIND',__LINE__,__FILE__) ) {
|
||||
$qry = new AwlQuery( 'SELECT bind_id from dav_binding where dav_name = :dav_name', array( ':dav_name' => $destination_path ) );
|
||||
if ( ! $qry->Exec('BIND',__LINE__,__FILE__) || $qry->rows() != 1 || !($row = $qry->Fetch()) )
|
||||
if ( ! $qry->Exec('BIND',__LINE__,__FILE__) || $qry->rows() != 1 || !($row = $qry->Fetch()) )
|
||||
$request->DoResponse(500,translate('Database Error'));
|
||||
fetch_external ( $row->bind_id, '' );
|
||||
$request->DoResponse(201);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$request->DoResponse(500,translate('Database Error'));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$source = new DAVResource( $href );
|
||||
if ( !$source->Exists() ) {
|
||||
$request->PreconditionFailed(403,'DAV::bind-source-exists',translate('The BIND Request MUST identify an existing resource.'));
|
||||
}
|
||||
|
||||
|
||||
if ( $source->IsPrincipal() || !$source->IsCollection() ) {
|
||||
$request->PreconditionFailed(403,'DAV::binding-allowed',translate('DAViCal only allows BIND requests for collections at present.'));
|
||||
}
|
||||
|
||||
|
||||
if ( $source->IsBinding() )
|
||||
$source = new DAVResource( $source->bound_from() );
|
||||
|
||||
@ -113,7 +113,7 @@ else {
|
||||
external_url TEXT,
|
||||
type TEXT
|
||||
*/
|
||||
|
||||
|
||||
$sql = 'INSERT INTO dav_binding ( bound_source_id, access_ticket_id, dav_owner_id, parent_container, dav_name, dav_displayname )
|
||||
VALUES( :target_id, :ticket_id, :session_principal, :parent_container, :dav_name, :displayname )';
|
||||
$params = array(
|
||||
@ -127,12 +127,12 @@ else {
|
||||
$qry = new AwlQuery( $sql, $params );
|
||||
if ( $qry->Exec('BIND',__LINE__,__FILE__) ) {
|
||||
header('Location: '. ConstructURL($destination_path) );
|
||||
|
||||
|
||||
// Uncache anything to do with the target
|
||||
$cache = getCacheInstance();
|
||||
$cache_ns = 'collection-'.$destination_path;
|
||||
$cache->delete( $cache_ns, null );
|
||||
|
||||
|
||||
$request->DoResponse(201);
|
||||
}
|
||||
else {
|
||||
|
||||
@ -57,7 +57,7 @@ if ( $dav_resource->IsCollection() ) {
|
||||
$myLock = $cache->acquireLock('collection-'.$dav_resource->parent_path());
|
||||
if ( $dav_resource->IsBinding() ) {
|
||||
$params = array( ':dav_name' => $dav_resource->dav_name() );
|
||||
|
||||
|
||||
if ( $qry->QDo("DELETE FROM dav_binding WHERE dav_name = :dav_name", $params )
|
||||
&& $qry->Commit() ) {
|
||||
$cache->delete( 'collection-'.$dav_resource->dav_name(), null );
|
||||
@ -85,7 +85,7 @@ else {
|
||||
|
||||
// Check to see if we need to do any scheduling transactions for this one.
|
||||
do_scheduling_for_delete($dav_resource);
|
||||
|
||||
|
||||
// We need to serialise access to this process just for this collection
|
||||
$cache = getCacheInstance();
|
||||
$myLock = $cache->acquireLock('collection-'.$dav_resource->parent_path());
|
||||
@ -99,7 +99,7 @@ else {
|
||||
if ( function_exists('log_caldav_action') ) {
|
||||
log_caldav_action( 'DELETE', $dav_resource->GetProperty('uid'), $dav_resource->GetProperty('user_no'), $collection_id, $request->path );
|
||||
}
|
||||
|
||||
|
||||
$qry->Commit();
|
||||
@dbg_error_log( "DELETE", "DELETE: User: %d, ETag: %s, Path: %s", $session->user_no, $request->etag_if_match, $request->path);
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@ function export_iCalendar( DAVResource $dav_resource ) {
|
||||
$vcal->AddProperty("AUTO-REFRESH", $c->auto_refresh_duration);
|
||||
$vcal->AddProperty("X-PUBLISHED-TTL", $c->auto_refresh_duration);
|
||||
}
|
||||
|
||||
|
||||
$need_zones = array();
|
||||
$timezones = array();
|
||||
while( $event = $qry->Fetch() ) {
|
||||
@ -133,6 +133,6 @@ function export_iCalendar( DAVResource $dav_resource ) {
|
||||
foreach( $need_zones AS $tzid => $v ) {
|
||||
if ( isset($timezones[$tzid]) ) $vcal->AddComponent($timezones[$tzid]);
|
||||
}
|
||||
|
||||
|
||||
return $vcal->Render();
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ $dav_resource->NeedPrivilege( array('urn:ietf:params:xml:ns:caldav:read-free-bus
|
||||
if ( $dav_resource->IsExternal() ) {
|
||||
require_once("external-fetch.php");
|
||||
update_external ( $dav_resource );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $dav_resource->Exists() ) {
|
||||
$request->DoResponse( 404, translate("Resource Not Found.") );
|
||||
|
||||
@ -66,7 +66,7 @@ if ( isset($request->xml_tags) ) {
|
||||
foreach( $setprops AS $k => $setting ) {
|
||||
$tag = $setting->GetNSTag();
|
||||
$content = $setting->RenderContent(0,null,true);
|
||||
|
||||
|
||||
dbg_error_log( 'MKCOL', 'Processing tag "%s"', $tag);
|
||||
|
||||
switch( $tag ) {
|
||||
|
||||
@ -130,7 +130,7 @@ if ( $src->IsCollection() ) {
|
||||
$sql .= ', parent_container=:parent ';
|
||||
$params[':parent'] = $dest->parent_path();
|
||||
$cachekeys[] = ($dest->ContainerType() == 'principal' ? 'principal' : 'collection').'-'.$dest->parent_path();
|
||||
}
|
||||
}
|
||||
$sql .= 'WHERE collection_id = :src_collection';
|
||||
$params[':src_collection'] = $src_collection;
|
||||
$qry = new AwlQuery( $sql, $params );
|
||||
|
||||
@ -80,7 +80,7 @@ function handle_freebusy_request( $ic ) {
|
||||
$responses[] = $response;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
foreach ( $answer as $a )
|
||||
{
|
||||
if ( $a === false ) {
|
||||
@ -132,7 +132,7 @@ function handle_cancel_request( $ic ) {
|
||||
global $c, $session, $request;
|
||||
|
||||
$request->NeedPrivilege('CALDAV:schedule-send-reply');
|
||||
|
||||
|
||||
$reply = new XMLDocument( array("DAV:" => "", "urn:ietf:params:xml:ns:caldav" => "C" ) );
|
||||
|
||||
$response = $reply->NewXMLElement( "response", false, false, 'urn:ietf:params:xml:ns:caldav' );
|
||||
|
||||
@ -132,7 +132,7 @@ function get_collection_contents( $depth, $collection, $parent_path = null ) {
|
||||
$sql .= 'ORDER BY usr.user_no';
|
||||
}
|
||||
else {
|
||||
if ( !( isset($c->hide_bound) && (
|
||||
if ( !( isset($c->hide_bound) && (
|
||||
((is_bool($c->hide_bound) || is_numeric($c->hide_bound)) && $c->hide_bound != false) ||
|
||||
(is_string($c->hide_bound) && preg_match($c->hide_bound, $_SERVER['HTTP_USER_AGENT'])) ||
|
||||
(is_array($c->hide_bound) && count(array_uintersect_assoc(
|
||||
@ -261,10 +261,10 @@ else {
|
||||
$request->PreconditionFailed( 404, 'must-exist', translate('That resource is not present on this server.') );
|
||||
}
|
||||
$resource->NeedPrivilege('DAV::read');
|
||||
if ( $resource->IsExternal() ) {
|
||||
require_once("external-fetch.php");
|
||||
update_external ( $resource );
|
||||
}
|
||||
if ( $resource->IsExternal() ) {
|
||||
require_once("external-fetch.php");
|
||||
update_external ( $resource );
|
||||
}
|
||||
if ( $resource->IsCollection() ) {
|
||||
dbg_error_log('PROPFIND','Getting collection contents: Depth %d, Path: %s', $request->depth, $resource->dav_name() );
|
||||
$responses[] = $resource->RenderAsXML($property_list, $reply);
|
||||
|
||||
@ -65,7 +65,7 @@ function add_failure( $type, $tag, $status, $description=null, $error_tag = null
|
||||
if ( isset($error_tag) )
|
||||
$propstat[] = new XMLElement( 'error', new XMLElement( $error_tag ) );
|
||||
|
||||
$failure[$type.'-'.$tag] = new XMLElement('propstat', $propstat );
|
||||
$failure[$type.'-'.$tag] = new XMLElement('propstat', $propstat );
|
||||
}
|
||||
|
||||
|
||||
@ -187,7 +187,7 @@ foreach( $setprops AS $k => $setting ) {
|
||||
$params[':vtimezone'] = (isset($tz) ? $tz->Render() : null );
|
||||
$qry->QDo('INSERT INTO timezones (tzid, olson_name, active, vtimezone) VALUES(:tzid,:olson_name,false,:vtimezone)', $params );
|
||||
}
|
||||
|
||||
|
||||
$qry->QDo('UPDATE collection SET timezone = :tzid WHERE dav_name = :dav_name',
|
||||
array( ':tzid' => $tzid, ':dav_name' => $dav_resource->dav_name()) );
|
||||
}
|
||||
@ -286,20 +286,20 @@ foreach( $rmprops AS $k => $setting ) {
|
||||
if ( count($failure) > 0 ) {
|
||||
|
||||
$qry->Rollback();
|
||||
|
||||
|
||||
$url = ConstructURL($request->path);
|
||||
$multistatus = new XMLElement('multistatus');
|
||||
array_unshift($failure,new XMLElement('responsedescription', translate("Some properties were not able to be changed.") ));
|
||||
array_unshift($failure,new XMLElement('href', $url));
|
||||
$response = $reply->DAVElement($multistatus,'response', $failure);
|
||||
|
||||
if ( !empty($success) ) {
|
||||
|
||||
if ( !empty($success) ) {
|
||||
$prop = new XMLElement('prop');
|
||||
foreach( $success AS $tag => $v ) {
|
||||
$reply->NSElement($prop, $tag);
|
||||
}
|
||||
$reply->DAVElement($response, 'propstat', array( $prop, new XMLElement( 'status', 'HTTP/1.1 424 Failed Dependency' )) );
|
||||
}
|
||||
}
|
||||
$request->DoResponse( 207, $reply->Render($multistatus), 'text/xml; charset="utf-8"' );
|
||||
|
||||
}
|
||||
@ -336,10 +336,10 @@ if ( $qry->Commit() ) {
|
||||
$reply->NSElement($prop, $tag);
|
||||
}
|
||||
$reply->DAVElement($response, 'propstat', array( $prop, new XMLElement( 'status', 'HTTP/1.1 200 OK' )) );
|
||||
|
||||
|
||||
$url = ConstructURL($request->path);
|
||||
array_unshift( $failure, new XMLElement('href', $url ) );
|
||||
|
||||
|
||||
$request->DoResponse( 207, $reply->Render($multistatus), 'text/xml; charset="utf-8"' );
|
||||
}
|
||||
|
||||
|
||||
@ -127,7 +127,7 @@ VALUES( :user_no, :parent_container, :dav_name, :dav_etag, :dav_displayname, TRU
|
||||
}
|
||||
else if ( isset($public) ) {
|
||||
$collection = $qry->Fetch();
|
||||
if ( empty($collection->is_public) ) $collection->is_public = 'f';
|
||||
if ( empty($collection->is_public) ) $collection->is_public = 'f';
|
||||
if ( $collection->is_public == ($public?'t':'f') ) {
|
||||
$sql = 'UPDATE collection SET publicly_readable = :is_public::boolean WHERE collection_id = :collection_id';
|
||||
$params = array( ':is_public' => ($public?'t':'f'), ':collection_id' => $collection->collection_id );
|
||||
@ -217,7 +217,7 @@ function handle_schedule_request( $ical ) {
|
||||
|
||||
if ( isset($c->enable_auto_schedule) && !$c->enable_auto_schedule ) {
|
||||
// In this case we're being asked not to do auto-scheduling, so we build
|
||||
// a response back for the client saying we can't...
|
||||
// a response back for the client saying we can't...
|
||||
$attendee->SetParameterValue ('SCHEDULE-STATUS','5.3;No scheduling support for user');
|
||||
continue;
|
||||
}
|
||||
@ -372,7 +372,7 @@ function do_scheduling_reply( vCalendar $resource, vProperty $organizer ) {
|
||||
$schedule_reply = GetItip(new vCalendar($schedule_original->Render(null, true)), 'REPLY', $attendee->Value(), array('CUTYPE'=>true, 'SCHEDULE-STATUS'=>true));
|
||||
|
||||
dbg_error_log( 'PUT', 'Writing scheduling REPLY from %s to %s', $request->principal->email(), $organizer_principal->email() );
|
||||
|
||||
|
||||
$response = '3.7'; // Organizer was not found on server.
|
||||
if ( !$organizer_calendar->Exists() ) {
|
||||
dbg_error_log('ERROR','Default calendar at "%s" does not exist for user "%s"',
|
||||
@ -400,7 +400,7 @@ function do_scheduling_reply( vCalendar $resource, vProperty $organizer ) {
|
||||
$organizer->SetParameterValue( 'SCHEDULE-STATUS', $response );
|
||||
$resource->UpdateOrganizerStatus($organizer);
|
||||
$scheduling_actions = true;
|
||||
|
||||
|
||||
$calling_attendee = clone($attendee);
|
||||
$attendees = $schedule_original->GetAttendees();
|
||||
foreach( $attendees AS $attendee ) {
|
||||
@ -461,7 +461,7 @@ function do_scheduling_reply( vCalendar $resource, vProperty $organizer ) {
|
||||
else if ( $attendee_inbox->WriteCalendarMember($schedule_request, false) !== false ) {
|
||||
$response = '1.2'; // Scheduling invitation delivered successfully
|
||||
if ( $attendee_calendar->WriteCalendarMember($schedule_original, false) === false ) {
|
||||
dbg_error_log('ERROR','Could not write updated calendar member to %s',
|
||||
dbg_error_log('ERROR','Could not write updated calendar member to %s',
|
||||
$attendee_calendar->dav_name(), $attendee_calendar->dav_name(), $schedule_target->username());
|
||||
trace_bug('Failed to write scheduling resource.');
|
||||
}
|
||||
@ -471,11 +471,11 @@ function do_scheduling_reply( vCalendar $resource, vProperty $organizer ) {
|
||||
dbg_error_log( 'PUT', 'Status for attendee <%s> set to "%s"', $attendee->Value(), $response );
|
||||
$attendee->SetParameterValue( 'SCHEDULE-STATUS', $response );
|
||||
$scheduling_actions = true;
|
||||
|
||||
|
||||
$resource->UpdateAttendeeStatus($email, clone($attendee));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $scheduling_actions;
|
||||
}
|
||||
|
||||
@ -490,7 +490,7 @@ function do_scheduling_reply( vCalendar $resource, vProperty $organizer ) {
|
||||
function do_scheduling_requests( vCalendar $resource, $create, $old_data = null ) {
|
||||
global $request, $c;
|
||||
if ( !isset($request) || (isset($c->enable_auto_schedule) && !$c->enable_auto_schedule) ) return false;
|
||||
|
||||
|
||||
if ( ! is_object($resource) ) {
|
||||
trace_bug( 'do_scheduling_requests called with non-object parameter (%s)', gettype($resource) );
|
||||
return false;
|
||||
@ -989,7 +989,7 @@ EOSQL;
|
||||
if ( empty($dtstart_prop) ) {
|
||||
dbg_error_log('PUT','Invalid VEVENT without DTSTART, UID="%s" in collection %d', $uid, $collection_id);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$value_type = $dtstart_prop->GetParameterValue('VALUE');
|
||||
dbg_error_log('PUT','DTSTART without DTEND. DTSTART value type is %s', $value_type );
|
||||
if ( isset($value_type) && $value_type == 'DATE' )
|
||||
@ -1193,7 +1193,7 @@ function write_attendees( $dav_id, vCalendar $ical ) {
|
||||
/**
|
||||
* Actually write the resource to the database. All checking of whether this is reasonable
|
||||
* should be done before this is called.
|
||||
*
|
||||
*
|
||||
* @param DAVResource $resource The resource being written
|
||||
* @param string $caldav_data The actual data to be written
|
||||
* @param DAVResource $collection The collection containing the resource being written
|
||||
@ -1204,7 +1204,7 @@ function write_attendees( $dav_id, vCalendar $ical ) {
|
||||
* @param string Either 'INSERT' or 'UPDATE': the type of action we are doing
|
||||
* @param boolean $log_action Whether to log the fact that we are writing this into an action log (if configured)
|
||||
* @param string $weak_etag An etag that is NOT modified on ATTENDEE changes for this event
|
||||
*
|
||||
*
|
||||
* @return boolean True for success, false for failure.
|
||||
*/
|
||||
function write_resource( DAVResource $resource, $caldav_data, DAVResource $collection, $author, &$etag, $put_action_type, $caldav_context, $log_action=true, $weak_etag=null ) {
|
||||
@ -1228,7 +1228,7 @@ function write_resource( DAVResource $resource, $caldav_data, DAVResource $colle
|
||||
}
|
||||
$resource_type = $first->GetType();
|
||||
}
|
||||
|
||||
|
||||
$collection_id = $collection->collection_id();
|
||||
|
||||
$qry = new AwlQuery();
|
||||
@ -1264,14 +1264,14 @@ function write_resource( DAVResource $resource, $caldav_data, DAVResource $colle
|
||||
$calitem_params[':dav_id'] = $dav_id;
|
||||
|
||||
$due = null;
|
||||
if ( $first->GetType() == 'VTODO' ) $due = $first->GetPValue('DUE');
|
||||
if ( $first->GetType() == 'VTODO' ) $due = $first->GetPValue('DUE');
|
||||
$calitem_params[':due'] = $due;
|
||||
$dtstart = $first->GetPValue('DTSTART');
|
||||
if ( empty($dtstart) ) $dtstart = $due;
|
||||
if (preg_match("/^1[0-8][0-9][0-9][01][0-9][0-3][0-9]$/", $dtstart))
|
||||
$dtstart = $dtstart . "T000000Z";
|
||||
$calitem_params[':dtstart'] = $dtstart;
|
||||
|
||||
|
||||
$dtend = $first->GetPValue('DTEND');
|
||||
if ( isset($dtend) && $dtend != '' ) {
|
||||
dbg_error_log( 'PUT', ' DTEND: "%s", DTSTART: "%s", DURATION: "%s"', $dtend, $dtstart, $first->GetPValue('DURATION') );
|
||||
@ -1353,7 +1353,7 @@ function write_resource( DAVResource $resource, $caldav_data, DAVResource $colle
|
||||
foreach( $timezones AS $k => $tz ) {
|
||||
if ( $tz->GetPValue('TZID') != $tzid ) {
|
||||
/**
|
||||
* We'll skip any tz definitions that are for a TZID other than the DTSTART/DUE on the first VEVENT/VTODO
|
||||
* We'll skip any tz definitions that are for a TZID other than the DTSTART/DUE on the first VEVENT/VTODO
|
||||
*/
|
||||
dbg_error_log( 'ERROR', ' Event uses TZID[%s], skipping included TZID[%s]!', $tz->GetPValue('TZID'), $tzid );
|
||||
continue;
|
||||
|
||||
@ -29,7 +29,7 @@ if ( $add_member ) {
|
||||
$vcalendar->SetUID($uid);
|
||||
$request->path = $request->dav_name() . $uid . '.ics';
|
||||
$dav_resource = new DAVResource($request->path);
|
||||
|
||||
|
||||
if ( $dav_resource->Exists() ) throw new Exception("Failed to generate unique segment name for add-member!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ else {
|
||||
$response_code = 201;
|
||||
$qry->QDo( $sql, $params );
|
||||
$put_action_type = 'INSERT';
|
||||
|
||||
|
||||
$qry->QDo("SELECT currval('dav_id_seq') AS dav_id" );
|
||||
}
|
||||
$row = $qry->Fetch();
|
||||
|
||||
@ -42,7 +42,7 @@ while (list($idx, $qqq) = each($qry_content))
|
||||
if ( $propertyname == 'urn:ietf:params:xml:ns:caldav:calendar-data' ) check_for_expansion($v);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'DAV::allprop':
|
||||
$properties['DAV::allprop'] = 1;
|
||||
if ( $qry_content[$idx]->GetNSTag() == 'DAV::include' ) {
|
||||
@ -362,9 +362,9 @@ if ( $qry->Exec("calquery",__LINE__,__FILE__) && $qry->rows() > 0 ) {
|
||||
$vResource = new vComponent($dav_object->caldav_data);
|
||||
$expanded = getVCalendarRange($vResource);
|
||||
if ( !$expanded->overlaps($range_filter) ) continue;
|
||||
|
||||
|
||||
$expanded = expand_event_instances($vResource, $expand_range_start, $expand_range_end, $expand_as_floating );
|
||||
|
||||
|
||||
if ( $expanded->ComponentCount() == 0 ) continue;
|
||||
if ( $need_expansion ) $dav_object->caldav_data = $expanded->Render();
|
||||
}
|
||||
|
||||
@ -117,10 +117,10 @@ EOSQL;
|
||||
}
|
||||
}
|
||||
$qry = new AwlQuery($sql, $params );
|
||||
|
||||
|
||||
$last_dav_name = '';
|
||||
$first_status = 0;
|
||||
|
||||
|
||||
if ( $qry->Exec("REPORT",__LINE__,__FILE__) ) {
|
||||
if ( $qry->rows() > 50 ) {
|
||||
// If there are more than 50 rows to send we should not send full data in response ...
|
||||
|
||||
@ -61,17 +61,17 @@ switch( $xmltree->GetNSTag() ) {
|
||||
include("caldav-REPORT-pps-set.php");
|
||||
exit; // Not that it should return anyway.
|
||||
case 'DAV::sync-collection':
|
||||
if ( $target->IsExternal() ) {
|
||||
require_once("external-fetch.php");
|
||||
update_external ( $target );
|
||||
}
|
||||
if ( $target->IsExternal() ) {
|
||||
require_once("external-fetch.php");
|
||||
update_external ( $target );
|
||||
}
|
||||
include("caldav-REPORT-sync-collection.php");
|
||||
exit; // Not that it should return anyway.
|
||||
case 'DAV::expand-property':
|
||||
if ( $target->IsExternal() ) {
|
||||
require_once("external-fetch.php");
|
||||
update_external ( $target );
|
||||
}
|
||||
require_once("external-fetch.php");
|
||||
update_external ( $target );
|
||||
}
|
||||
include("caldav-REPORT-expand-property.php");
|
||||
exit; // Not that it should return anyway.
|
||||
case 'DAV::principal-match':
|
||||
@ -201,7 +201,7 @@ function component_to_xml( $properties, $item ) {
|
||||
}
|
||||
$elements[] = new XMLElement( "propstat", array( $noprop, $status) );
|
||||
}
|
||||
|
||||
|
||||
if ( ! $request->PreferMinimal() && count($unsupported) > 0 ) {
|
||||
$status = new XMLElement("status", "HTTP/1.1 404 Not Found" );
|
||||
$noprop = new XMLElement("prop");
|
||||
@ -218,8 +218,8 @@ function component_to_xml( $properties, $item ) {
|
||||
}
|
||||
|
||||
if ( $target->IsExternal() ) {
|
||||
require_once("external-fetch.php");
|
||||
update_external ( $target );
|
||||
require_once("external-fetch.php");
|
||||
update_external ( $target );
|
||||
}
|
||||
|
||||
// These reports are always allowed to see the resource_data because they are special
|
||||
|
||||
@ -85,10 +85,10 @@ class CalDAVClient {
|
||||
protected $httpResponseCode = 0; // http response code
|
||||
protected $httpResponseHeaders = "";
|
||||
protected $httpParsedHeaders;
|
||||
protected $httpResponseBody = "";
|
||||
protected $httpResponseBody = "";
|
||||
|
||||
protected $parser; // our XML parser object
|
||||
|
||||
|
||||
private $debug = false; // Whether we are debugging
|
||||
|
||||
/**
|
||||
@ -123,7 +123,7 @@ class CalDAVClient {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Call this to enable / disable debugging. It will return the prior value of the debugging flag.
|
||||
* @param boolean $new_value The new value for debugging.
|
||||
@ -138,8 +138,8 @@ class CalDAVClient {
|
||||
return $old_value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds an If-Match or If-None-Match header
|
||||
*
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* @category Technical
|
||||
* @subpackage ldap
|
||||
* @author Oliver Schulze <oliver@samera.com.py>,
|
||||
* Andrew McMillan <andrew@mcmillan.net.nz>
|
||||
* Andrew McMillan <andrew@mcmillan.net.nz>
|
||||
* @copyright Based on Eric Seigne script drivers_squid_pam.php
|
||||
* @license http://gnu.org/copyleft/gpl.html GNU GPL v2 or later
|
||||
*/
|
||||
@ -62,7 +62,7 @@ function IMAP_PAM_check($username, $password ){
|
||||
//$imap_url = '{localhost:993/imap/ssl/novalidate-cert}';
|
||||
$imap_url = $c->authenticate_hook['config']['imap_url'];
|
||||
$auth_result = "ERR";
|
||||
|
||||
|
||||
$imap_stream = @imap_open($imap_url, $imap_username, $password, OP_HALFOPEN);
|
||||
//print_r(imap_errors());
|
||||
if ( $imap_stream ) {
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* @category Technical
|
||||
* @subpackage ldap
|
||||
* @author Maxime Delorme <mdelorme@tennaxia.net>,
|
||||
* Andrew McMillan <andrew@mcmillan.net.nz>
|
||||
* Andrew McMillan <andrew@mcmillan.net.nz>
|
||||
* @copyright Maxime Delorme
|
||||
* @license http://gnu.org/copyleft/gpl.html GNU GPL v2 or later
|
||||
*/
|
||||
@ -170,7 +170,7 @@ class ldapDrivers
|
||||
$row[$arr[$j]] = count($arr[$arr[$j]])>2?$arr[$arr[$j]]:$arr[$arr[$j]][0];
|
||||
}
|
||||
$ret[]=$row;
|
||||
unset($row);
|
||||
unset($row);
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
@ -303,7 +303,7 @@ function sync_user_from_LDAP( Principal &$principal, $mapping, $ldap_values ) {
|
||||
dbg_error_log( "LDAP", "Setting usr->%s to %s from configured defaults", $field, $c->authenticate_hook['config']['default_value'][$field] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( $principal->Exists() ) {
|
||||
$principal->Update($fields_to_set);
|
||||
}
|
||||
@ -413,10 +413,10 @@ function LDAP_check($username, $password ){
|
||||
dbg_error_log( "LDAP", "user %s doesn't exist in local DB, we need to create it",$username );
|
||||
}
|
||||
$principal->setUsername($username);
|
||||
|
||||
|
||||
// The local cached user doesn't exist, or is older, so we create/update their details
|
||||
sync_user_from_LDAP( $principal, $mapping, $valid );
|
||||
|
||||
|
||||
return $principal;
|
||||
|
||||
}
|
||||
|
||||
@ -6,8 +6,8 @@
|
||||
* @category Technical
|
||||
* @subpackage pwauth
|
||||
* @author Eric Seigne <eric.seigne@ryxeo.com>,
|
||||
* Michael B. Trausch <mike@trausch.us>,
|
||||
* Andrew McMillan <andrew@mcmillan.net.nz>
|
||||
* Michael B. Trausch <mike@trausch.us>,
|
||||
* Andrew McMillan <andrew@mcmillan.net.nz>
|
||||
* @copyright Eric Seigne
|
||||
* @license http://gnu.org/copyleft/gpl.html GNU GPL v2 or later
|
||||
*
|
||||
@ -95,8 +95,7 @@ function PWAUTH_PAM_check($username, $password) {
|
||||
|
||||
case 3:
|
||||
// STATUS_BLOCKED: UID for username is < pwauth's MIN_UNIX_UID
|
||||
dbg_error_log('pwauth', 'UID for username %s is < pwauth MIN_UNIX_UID',
|
||||
$username);
|
||||
dbg_error_log('pwauth', 'UID for username %s is < pwauth MIN_UNIX_UID', $username);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
@ -106,8 +105,7 @@ function PWAUTH_PAM_check($username, $password) {
|
||||
|
||||
case 5:
|
||||
// STATUS_PW_EXPIRED: The user account's password has expired.
|
||||
dbg_error_log('pwauth', 'The account password for user %s has expired',
|
||||
$username);
|
||||
dbg_error_log('pwauth', 'The account password for user %s has expired', $username);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
@ -117,14 +115,12 @@ function PWAUTH_PAM_check($username, $password) {
|
||||
|
||||
case 7:
|
||||
// STATUS_MANYFAILS: Too many login failures for user account.
|
||||
dbg_error_log('pwauth', 'Login rejected for %s, too many failures',
|
||||
$username);
|
||||
dbg_error_log('pwauth', 'Login rejected for %s, too many failures', $username);
|
||||
break;
|
||||
|
||||
case 50:
|
||||
// STATUS_INT_USER: Configuration error, Web server cannot use pwauth
|
||||
dbg_error_log('pwauth', 'config error: see pwauth man page (%s)',
|
||||
'STATUS_INT_USER');
|
||||
dbg_error_log('pwauth', 'config error: see pwauth man page (%s)', 'STATUS_INT_USER');
|
||||
break;
|
||||
|
||||
case 51:
|
||||
@ -134,20 +130,17 @@ function PWAUTH_PAM_check($username, $password) {
|
||||
|
||||
case 52:
|
||||
// STATUS_INT_ERR: unknown error
|
||||
dbg_error_log('pwauth', 'error: see pwauth man page (%s)',
|
||||
'STATUS_INT_ERR');
|
||||
dbg_error_log('pwauth', 'error: see pwauth man page (%s)', 'STATUS_INT_ERR');
|
||||
break;
|
||||
|
||||
case 53:
|
||||
// STATUS_INT_NOROOT: pwauth could not read the password database
|
||||
dbg_error_log('pwauth', 'config error: cannot read password database (%s)',
|
||||
'STATUS_INT_NOROOT');
|
||||
dbg_error_log('pwauth', 'config error: cannot read password database (%s)', 'STATUS_INT_NOROOT');
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
// Unknown error code.
|
||||
dbg_error_log('pwauth', 'An unknown error (%d) has occurred',
|
||||
$return_status);
|
||||
dbg_error_log('pwauth', 'An unknown error (%d) has occurred', $return_status);
|
||||
}
|
||||
|
||||
return(FALSE);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* @category Technical
|
||||
* @subpackage ldap
|
||||
* @author Oliver Schulze <oliver@samera.com.py>,
|
||||
* Andrew McMillan <andrew@mcmillan.net.nz>
|
||||
* Andrew McMillan <andrew@mcmillan.net.nz>
|
||||
* @copyright Based on Eric Seigne script drivers_squid_pam.php
|
||||
* @license http://gnu.org/copyleft/gpl.html GNU GPL v2 or later
|
||||
*/
|
||||
@ -66,7 +66,7 @@ function RIMAP_check($username, $password ){
|
||||
//$imap_url = '{localhost:993/imap/ssl/novalidate-cert}';
|
||||
$imap_url = $c->authenticate_hook['config']['imap_url'];
|
||||
$auth_result = "ERR";
|
||||
|
||||
|
||||
$imap_stream = @imap_open($imap_url, $imap_username, $password, OP_HALFOPEN);
|
||||
//print_r(imap_errors());
|
||||
if ( $imap_stream ) {
|
||||
|
||||
@ -86,9 +86,9 @@ function fetch_external ( $bind_id, $min_age = '1 hour' )
|
||||
curl_close ( $curl );
|
||||
if ( is_string ( $ics ) && strlen ( $ics ) > 20 ) {
|
||||
// BUGlet: should track server-time instead of local-time
|
||||
$qry = new AwlQuery( 'UPDATE collection SET modified=NOW(), dav_etag=:etag WHERE collection_id = :cid',
|
||||
$qry = new AwlQuery( 'UPDATE collection SET modified=NOW(), dav_etag=:etag WHERE collection_id = :cid',
|
||||
array ( ':cid' => $row->collection_id, ':etag' => md5($ics) ) );
|
||||
$qry->Exec('DAVResource');
|
||||
$qry->Exec('DAVResource');
|
||||
require_once ( 'caldav-PUT-functions.php');
|
||||
import_collection ( $ics , $row->user_no, $row->path, 'External Fetch' , false ) ;
|
||||
return true;
|
||||
@ -102,7 +102,7 @@ function fetch_external ( $bind_id, $min_age = '1 hour' )
|
||||
|
||||
function update_external ( $request )
|
||||
{
|
||||
global $c;
|
||||
global $c;
|
||||
if ( $c->external_refresh < 1 )
|
||||
return ;
|
||||
if ( ! function_exists ( "curl_init" ) ) {
|
||||
@ -111,11 +111,11 @@ function update_external ( $request )
|
||||
}
|
||||
$sql = 'SELECT bind_id, external_url as url from dav_binding LEFT JOIN collection ON (collection.collection_id=bound_source_id) WHERE dav_binding.dav_name = :dav_name AND collection.modified + interval :interval < NOW()';
|
||||
$qry = new AwlQuery( $sql, array ( ':dav_name' => $request->dav_name(), ':interval' => $c->external_refresh . ' minutes' ) );
|
||||
dbg_error_log("external", "checking if external resource needs update");
|
||||
dbg_error_log("external", "checking if external resource needs update");
|
||||
if ( $qry->Exec('DAVResource') && $qry->rows() > 0 && $row = $qry->Fetch() ) {
|
||||
if ( $row->bind_id != 0 ) {
|
||||
dbg_error_log("external", "external resource needs updating, this might take a minute : %s", $row->url );
|
||||
fetch_external ( $row->bind_id, $c->external_refresh . ' minutes' );
|
||||
}
|
||||
if ( $row->bind_id != 0 ) {
|
||||
dbg_error_log("external", "external resource needs updating, this might take a minute : %s", $row->url );
|
||||
fetch_external ( $row->bind_id, $c->external_refresh . ' minutes' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ if ( $d->validateRequest ( ) ) {
|
||||
$rcpt = explode ( ',', $_SERVER['HTTP_RECIPIENT'] );
|
||||
foreach ( $rcpt as $k => $v ) {
|
||||
$recipients[$k] = preg_replace( '/^mailto:/i', '', trim ( $v ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ! in_array ( preg_replace( '/^mailto:/i', '', $_SERVER['HTTP_ORIGINATOR'] ), $addresses ) ) { // should this be case sensitive?
|
||||
$request->DoResponse( 412, translate('sender must be organizer or attendee of event') );
|
||||
@ -169,9 +169,9 @@ function ischedule_freebusy_request( $ic, $attendees, $attendees_fail) {
|
||||
|
||||
$response = $reply->NewXMLElement( "response", false, false, 'urn:ietf:params:xml:ns:ischedule' );
|
||||
$response->NewElement( "recipient", 'mailto:'.$attendee->email, false, 'urn:ietf:params:xml:ns:ischedule' );
|
||||
$response->NewElement( "request-status", "2.0;Success", false, 'urn:ietf:params:xml:ns:ischedule' );
|
||||
$response->NewElement( "request-status", "2.0;Success", false, 'urn:ietf:params:xml:ns:ischedule' );
|
||||
$response->NewElement( "calendar-data", $vcal->Render(), false, 'urn:ietf:params:xml:ns:ischedule' );
|
||||
|
||||
|
||||
$responses[] = $response;
|
||||
}
|
||||
|
||||
@ -219,14 +219,14 @@ function ischedule_request( $ic, $attendees, $attendees_fail ) {
|
||||
}
|
||||
dbg_error_log( 'ischedule', 'Status for attendee <%s> set to "%s"', $attendee->email, $response );
|
||||
$XMLresponse->NewElement("recipient", 'mailto:'.$attendee->email, false, 'urn:ietf:params:xml:ns:ischedule' );
|
||||
$XMLresponse->NewElement("request-status", $response, false, 'urn:ietf:params:xml:ns:ischedule' );
|
||||
$XMLresponse->NewElement("request-status", $response, false, 'urn:ietf:params:xml:ns:ischedule' );
|
||||
$responses[] = $XMLresponse;
|
||||
}
|
||||
|
||||
foreach ( $attendees_fail AS $k => $attendee ) {
|
||||
$XMLresponse = $reply->NewXMLElement("response", false, false, 'urn:ietf:params:xml:ns:ischedule');
|
||||
$XMLresponse->NewElement("recipient", 'mailto:'.$attendee->email, false, 'urn:ietf:params:xml:ns:ischedule' );
|
||||
$XMLresponse->NewElement("request-status", '5.3;cannot schedule this user, unknown or access denied', false, 'urn:ietf:params:xml:ns:ischedule' );
|
||||
$XMLresponse->NewElement("request-status", '5.3;cannot schedule this user, unknown or access denied', false, 'urn:ietf:params:xml:ns:ischedule' );
|
||||
$responses[] = $XMLresponse;
|
||||
}
|
||||
|
||||
@ -265,14 +265,14 @@ function ischedule_cancel( $ic, $attendees, $attendees_fail ) {
|
||||
}
|
||||
dbg_error_log( 'PUT', 'Status for attendee <%s> set to "%s"', $attendee->email, $response );
|
||||
$XMLresponse->NewElement("recipient", $reply->href('mailto:'.$attendee->email), false, 'urn:ietf:params:xml:ns:ischedule' );
|
||||
$XMLresponse->NewElement("request-status", $response, false, 'urn:ietf:params:xml:ns:ischedule' );
|
||||
$XMLresponse->NewElement("request-status", $response, false, 'urn:ietf:params:xml:ns:ischedule' );
|
||||
$responses[] = $XMLresponse;
|
||||
}
|
||||
|
||||
foreach ( $attendees_fail AS $k => $attendee ) {
|
||||
$XMLresponse = $reply->NewXMLElement("response", false, false, 'urn:ietf:params:xml:ns:ischedule');
|
||||
$XMLresponse->NewElement("recipient", $reply->href('mailto:'.$attendee->email), false, 'urn:ietf:params:xml:ns:ischedule' );
|
||||
$XMLresponse->NewElement("request-status", '5.3;cannot schedule this user, unknown or access denied', false, 'urn:ietf:params:xml:ns:ischedule' );
|
||||
$XMLresponse->NewElement("request-status", '5.3;cannot schedule this user, unknown or access denied', false, 'urn:ietf:params:xml:ns:ischedule' );
|
||||
$responses[] = $XMLresponse;
|
||||
}
|
||||
|
||||
|
||||
@ -35,17 +35,17 @@ class iSchedule
|
||||
private $subdomainsOK = true;
|
||||
private $remote_public_key ;
|
||||
private $required_headers = Array ( 'host', // draft 01 section 7.1 required headers
|
||||
'originator',
|
||||
'recipient',
|
||||
'originator',
|
||||
'recipient',
|
||||
'content-type' );
|
||||
private $disallowed_headers = Array ( 'connection', // draft 01 section 7.1 disallowed headers
|
||||
'keep-alive',
|
||||
'dkim-signature',
|
||||
'proxy-authenticate',
|
||||
'proxy-authorization',
|
||||
'te',
|
||||
'trailers',
|
||||
'transfer-encoding',
|
||||
'keep-alive',
|
||||
'dkim-signature',
|
||||
'proxy-authenticate',
|
||||
'proxy-authorization',
|
||||
'te',
|
||||
'trailers',
|
||||
'transfer-encoding',
|
||||
'upgrade' );
|
||||
|
||||
function __construct ( )
|
||||
@ -73,8 +73,8 @@ class iSchedule
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the domainkey TXT record from DNS
|
||||
*/
|
||||
* gets the domainkey TXT record from DNS
|
||||
*/
|
||||
function getTxt ()
|
||||
{
|
||||
global $icfg;
|
||||
@ -84,7 +84,7 @@ class iSchedule
|
||||
$this->dk = $icfg [ $this->remote_selector . '._domainkey.' . $this->remote_server ];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
$dkim = dns_get_record ( $this->remote_selector . '._domainkey.' . $this->remote_server , DNS_TXT );
|
||||
if ( count ( $dkim ) > 0 )
|
||||
{
|
||||
@ -95,17 +95,17 @@ class iSchedule
|
||||
foreach ( $dkim [ 0 ] [ 'entries' ] as $v )
|
||||
{
|
||||
$this->dk .= trim ( $v );
|
||||
}
|
||||
}
|
||||
}
|
||||
dbg_error_log( 'ischedule', 'getTxt '. $this->dk . ' XX');
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
dbg_error_log( 'ischedule', 'getTxt FAILED '. print_r ( $dkim ) );
|
||||
$this->failed = true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -118,7 +118,7 @@ class iSchedule
|
||||
|
||||
/**
|
||||
* parses DNS TXT record from domainkey lookup
|
||||
*/
|
||||
*/
|
||||
function parseTxt ( )
|
||||
{
|
||||
if ( $this->failed == true )
|
||||
@ -137,10 +137,10 @@ class iSchedule
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* validates that domainkey is acceptable for the current request
|
||||
*/
|
||||
*/
|
||||
function validateKey ( )
|
||||
{
|
||||
$this->failed = true;
|
||||
@ -174,7 +174,7 @@ class iSchedule
|
||||
{
|
||||
if ( preg_match ( '/[^A-Za-z0-9_=+\/]/', $this->parsed [ 'p' ] ) )
|
||||
return false;
|
||||
$data = "-----BEGIN PUBLIC KEY-----\n" . implode ("\n",str_split ( $this->parsed [ 'p' ], 64 )) . "\n-----END PUBLIC KEY-----";
|
||||
$data = "-----BEGIN PUBLIC KEY-----\n" . implode ("\n",str_split ( $this->parsed [ 'p' ], 64 )) . "\n-----END PUBLIC KEY-----";
|
||||
if ( $data === false )
|
||||
return false;
|
||||
$this->remote_public_key = $data;
|
||||
@ -189,7 +189,7 @@ class iSchedule
|
||||
|
||||
/**
|
||||
* finds a remote calendar server via DNS SRV records
|
||||
*/
|
||||
*/
|
||||
function getServer ( )
|
||||
{
|
||||
global $icfg;
|
||||
@ -204,11 +204,11 @@ class iSchedule
|
||||
$parts = explode ( '.', $this->domain );
|
||||
$tld = $parts [ count ( $parts ) - 1 ];
|
||||
$len = 2;
|
||||
if ( strlen ( $tld ) == 2 && in_array ( $tld, Array ( 'uk', 'nz' ) ) )
|
||||
if ( strlen ( $tld ) == 2 && in_array ( $tld, Array ( 'uk', 'nz' ) ) )
|
||||
$len = 3; // some country code tlds should have 3 components
|
||||
if ( $this->domain == 'mycaldav' || $this->domain == 'altcaldav' )
|
||||
$len = 1;
|
||||
while ( count ( $parts ) >= $len )
|
||||
while ( count ( $parts ) >= $len )
|
||||
{
|
||||
$r = dns_get_record ( '_ischedules._tcp.' . implode ( '.', $parts ) , DNS_SRV );
|
||||
if ( 0 < count ( $r ) )
|
||||
@ -230,7 +230,7 @@ class iSchedule
|
||||
}
|
||||
array_shift ( $parts );
|
||||
}
|
||||
if ( ! isset ( $remote_server ) )
|
||||
if ( ! isset ( $remote_server ) )
|
||||
{
|
||||
if ( $this->try_anyway == true )
|
||||
{
|
||||
@ -251,15 +251,15 @@ class iSchedule
|
||||
}
|
||||
|
||||
/**
|
||||
* get capabilities from remote server
|
||||
*/
|
||||
* get capabilities from remote server
|
||||
*/
|
||||
function getCapabilities ( $domain = null )
|
||||
{
|
||||
if ( $domain != null && $this->domain != $domain )
|
||||
$this->domain = $domain;
|
||||
if ( ! isset ( $this->remote_server ) && isset ( $this->domain ) && ! $this->getServer ( ) )
|
||||
return false;
|
||||
$this->remote_url = 'http'. ( $this->remote_ssl ? 's' : '' ) . '://' .
|
||||
$this->remote_url = 'http'. ( $this->remote_ssl ? 's' : '' ) . '://' .
|
||||
$this->remote_server . ':' . $this->remote_port . '/.well-known/ischedule';
|
||||
$remote_capabilities = file_get_contents ( $this->remote_url . '?query=capabilities' );
|
||||
if ( $remote_capabilities === false )
|
||||
@ -276,13 +276,13 @@ class iSchedule
|
||||
dbg_error_log('ischedule', $this->domain . ' iSchedule error parsing remote xml' );
|
||||
return false;
|
||||
}
|
||||
xml_parser_free($xml_parser);
|
||||
xml_parser_free($xml_parser);
|
||||
$xmltree = BuildXMLTree( $this->xml_tags );
|
||||
if ( !is_object($xmltree) ) {
|
||||
dbg_error_log('ischedule', $this->domain . ' iSchedule error in remote xml' );
|
||||
$request->DoResponse( 406, translate("REPORT body is not valid XML data!") );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
dbg_error_log('ischedule', $this->domain . ' got capabilites' );
|
||||
$this->capabilities_xml = $xmltree;
|
||||
return true;
|
||||
@ -290,7 +290,7 @@ class iSchedule
|
||||
|
||||
/**
|
||||
* query capabilities retrieved from server
|
||||
*/
|
||||
*/
|
||||
function queryCapabilities ( $capability, $domain = null )
|
||||
{
|
||||
if ( ! isset ( $this->capabilities_xml ) )
|
||||
@ -353,7 +353,7 @@ class iSchedule
|
||||
}
|
||||
|
||||
/**
|
||||
* signs a POST body and headers
|
||||
* signs a POST body and headers
|
||||
*
|
||||
* @param string $body the body of the POST
|
||||
* @param array $headers the headers to sign as passed to header ();
|
||||
@ -361,7 +361,7 @@ class iSchedule
|
||||
function signDKIM ( $headers, $body )
|
||||
{
|
||||
if ( $this->scheduling_dkim_domain == null )
|
||||
return false;
|
||||
return false;
|
||||
$b = '';
|
||||
if ( is_array ( $headers ) !== true )
|
||||
return false;
|
||||
@ -381,7 +381,7 @@ class iSchedule
|
||||
$dk['t'] = time ( ); // timestamp of signature, optional
|
||||
if ( isset ( $this->valid_time ) )
|
||||
$dk['x'] = $this->valid_time; // unix timestamp expiriation of signature, optional
|
||||
$dk['h'] = implode ( ':', array_keys ( $headers ) );
|
||||
$dk['h'] = implode ( ':', array_keys ( $headers ) );
|
||||
$dk['bh'] = base64_encode ( hash ( 'sha256', $body , true ) );
|
||||
$value = '';
|
||||
foreach ( $dk as $key => $val )
|
||||
@ -398,13 +398,13 @@ class iSchedule
|
||||
* send request to remote server
|
||||
* $address should be an email address or an array of email addresses all with the same domain
|
||||
* $type should be in the format COMPONENT/METHOD eg (VFREEBUSY, VEVENT/REQUEST, VEVENT/REPLY, etc. )
|
||||
* $data is the vcalendar data N.B. must already be rendered into text format
|
||||
*/
|
||||
* $data is the vcalendar data N.B. must already be rendered into text format
|
||||
*/
|
||||
function sendRequest ( $address, $type, $data )
|
||||
{
|
||||
global $session;
|
||||
if ( empty($this->scheduling_dkim_domain) )
|
||||
return false;
|
||||
return false;
|
||||
if ( is_array ( $address ) )
|
||||
list ( $user, $domain ) = explode ( '@', $address[0] );
|
||||
else
|
||||
@ -433,16 +433,16 @@ class iSchedule
|
||||
if ( $headers['DKIM-Signature'] == false )
|
||||
return false;
|
||||
$request_headers = array ( );
|
||||
foreach ( $headers as $k => $v )
|
||||
foreach ( $headers as $k => $v )
|
||||
$request_headers[] = $k . ': ' . $v;
|
||||
$curl = curl_init ( $this->remote_url );
|
||||
curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt ( $curl, CURLOPT_HTTPHEADER, array() ); // start with no headers set
|
||||
curl_setopt ( $curl, CURLOPT_HTTPHEADER, $request_headers );
|
||||
curl_setopt ( $curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt ( $curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt ( $curl, CURLOPT_POST, 1);
|
||||
curl_setopt ( $curl, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt ( $curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt ( $curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt ( $curl, CURLOPT_POST, 1);
|
||||
curl_setopt ( $curl, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt ( $curl, CURLOPT_CUSTOMREQUEST, 'POST' );
|
||||
$xmlresponse = curl_exec ( $curl );
|
||||
$info = curl_getinfo ( $curl );
|
||||
@ -452,7 +452,7 @@ class iSchedule
|
||||
dbg_error_log ( 'ischedule', 'remote server returned error (%s)', $info['http_code'] );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
error_log ( 'remote response '. $xmlresponse . print_r ( $info, true ) );
|
||||
$xml_parser = xml_parser_create_ns('UTF-8');
|
||||
$xml_tags = array();
|
||||
@ -466,7 +466,7 @@ class iSchedule
|
||||
return false;
|
||||
}
|
||||
$xmltree = BuildXMLTree( $xml_tags );
|
||||
xml_parser_free($xml_parser);
|
||||
xml_parser_free($xml_parser);
|
||||
if ( !is_object($xmltree) ) {
|
||||
dbg_error_log( 'ERROR', 'iSchedule RESPONSE body is not valid XML data!' );
|
||||
return false;
|
||||
@ -499,7 +499,7 @@ class iSchedule
|
||||
}
|
||||
|
||||
/**
|
||||
* parses and validates DK header
|
||||
* parses and validates DK header
|
||||
*
|
||||
* @param string $sig the value of the DKIM-Signature header
|
||||
*/
|
||||
@ -527,15 +527,15 @@ class iSchedule
|
||||
// signing algorythm REQUIRED
|
||||
if ( $dkim['a'] != 'rsa-sha1' && $dkim['a'] != 'rsa-sha256' ) // we only support the minimum required
|
||||
return 'bad signing algorythm:' . $dkim['a'] ;
|
||||
// query method to retrieve public key, could/should we add https to the spec? REQUIRED
|
||||
if ( $dkim['q'] != 'dns/txt' )
|
||||
// query method to retrieve public key, could/should we add https to the spec? REQUIRED
|
||||
if ( $dkim['q'] != 'dns/txt' )
|
||||
return 'bad query method';
|
||||
// domain of the signing entity REQUIRED
|
||||
if ( ! isset ( $dkim['d'] ) )
|
||||
if ( ! isset ( $dkim['d'] ) )
|
||||
return 'missing signing domain';
|
||||
$this->remote_server = $dkim['d'];
|
||||
// identity of signing AGENT, OPTIONAL
|
||||
if ( isset ( $dkim['i'] ) )
|
||||
if ( isset ( $dkim['i'] ) )
|
||||
{
|
||||
// if present, domain of the signing agent must be a match or a subdomain of the signing domain
|
||||
if ( ! stristr ( $dkim['i'], $dkim['d'] ) ) // RFC4871 does not specify a case match requirement
|
||||
@ -545,14 +545,14 @@ class iSchedule
|
||||
$this->remote_user = substr ( $dkim [ 'i' ], 0, strpos ( $dkim [ 'i' ], '@' ) - 1 );
|
||||
}
|
||||
// selector used to retrieve public key REQUIRED
|
||||
if ( ! isset ( $dkim['s'] ) )
|
||||
if ( ! isset ( $dkim['s'] ) )
|
||||
return 'missing selector';
|
||||
$this->remote_selector = $dkim['s'];
|
||||
// signed header fields, colon seperated REQUIRED
|
||||
if ( ! isset ( $dkim['h'] ) )
|
||||
if ( ! isset ( $dkim['h'] ) )
|
||||
return 'missing list of signed headers';
|
||||
$this->signed_headers = preg_split ( '/:/', $dkim['h'] );
|
||||
|
||||
|
||||
$sh = Array ();
|
||||
foreach ( $this->signed_headers as $h )
|
||||
{
|
||||
@ -564,23 +564,23 @@ class iSchedule
|
||||
if ( ! in_array ( strtolower ( $h ), $sh ) )
|
||||
return "$h is REQUIRED but missing in signed header fields per iSchedule";
|
||||
// body hash REQUIRED
|
||||
if ( ! isset ( $dkim['bh'] ) )
|
||||
if ( ! isset ( $dkim['bh'] ) )
|
||||
return 'missing body signature';
|
||||
// signed header hash REQUIRED
|
||||
if ( ! isset ( $dkim['b'] ) )
|
||||
if ( ! isset ( $dkim['b'] ) )
|
||||
return 'missing signature in b field';
|
||||
// length of body used for signing
|
||||
if ( isset ( $dkim['l'] ) )
|
||||
if ( isset ( $dkim['l'] ) )
|
||||
$this->signed_length = $dkim['l'];
|
||||
$this->failed = false;
|
||||
$this->DKSig = $dkim;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* split up a mailto uri into domain and user components
|
||||
* TODO handle other uri types (eg http)
|
||||
*/
|
||||
* TODO handle other uri types (eg http)
|
||||
*/
|
||||
function parseURI ( $uri )
|
||||
{
|
||||
if ( preg_match ( '/^mailto:([^@]+)@([^\s\t\n]+)/', $uri, $matches ) )
|
||||
@ -593,9 +593,9 @@ class iSchedule
|
||||
}
|
||||
|
||||
/**
|
||||
* verifies parsed DKIM header is valid for current message with a signature from the public key in DNS
|
||||
* TODO handle multiple headers of the same name
|
||||
*/
|
||||
* verifies parsed DKIM header is valid for current message with a signature from the public key in DNS
|
||||
* TODO handle multiple headers of the same name
|
||||
*/
|
||||
function verifySignature ( )
|
||||
{
|
||||
global $request,$c;
|
||||
@ -608,9 +608,9 @@ class iSchedule
|
||||
$signed .= "$h: " . $_SERVER[ strtoupper ( strtr ( $h, '-', '_' ) ) ] . "\r\n";
|
||||
if ( ! isset ( $_SERVER['HTTP_ORIGINATOR'] ) || stripos ( $signed, 'Originator' ) === false ) //required header, must be signed
|
||||
return "missing Originator";
|
||||
if ( ! isset ( $_SERVER['HTTP_RECIPIENT'] ) || stripos ( $signed, 'Recipient' ) === false ) //required header, must be signed
|
||||
if ( ! isset ( $_SERVER['HTTP_RECIPIENT'] ) || stripos ( $signed, 'Recipient' ) === false ) //required header, must be signed
|
||||
return "missing Recipient";
|
||||
if ( ! isset ( $_SERVER['HTTP_ISCHEDULE_VERSION'] ) || $_SERVER['HTTP_ISCHEDULE_VERSION'] != '1' ) //required header and we only speak version 1 for now
|
||||
if ( ! isset ( $_SERVER['HTTP_ISCHEDULE_VERSION'] ) || $_SERVER['HTTP_ISCHEDULE_VERSION'] != '1' ) //required header and we only speak version 1 for now
|
||||
return "missing or mismatch ischedule-version header";
|
||||
$body = $request->raw_post;
|
||||
if ( ! isset ( $this->signed_length ) ) // Should we use the Content-Length header if the signed length is missing?
|
||||
@ -641,7 +641,7 @@ class iSchedule
|
||||
|
||||
/**
|
||||
* checks that current request has a valid DKIM signature signed by a currently valid key from DNS
|
||||
*/
|
||||
*/
|
||||
function validateRequest ( )
|
||||
{
|
||||
global $request;
|
||||
@ -654,7 +654,7 @@ class iSchedule
|
||||
}
|
||||
if ( isset ( $_SERVER['HTTP_ORGANIZER'] ) )
|
||||
$request->DoResponse( 403, translate('Organizer Missing') );
|
||||
|
||||
|
||||
dbg_error_log ('ischedule','beginning validation');
|
||||
$err = $this->parseDKIM ( $sig );
|
||||
if ( $err !== true || $this->failed )
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
# Translators: in the sense of 'systems admin'
|
||||
i18n("Admin");
|
||||
|
||||
# Translators: in the sense of a group of people
|
||||
# Translators: in the sense of a group of people
|
||||
i18n("Group");
|
||||
|
||||
# Translators: in the sense of being available to all users
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Functions for handling CalDAV Scheduling.
|
||||
*
|
||||
*
|
||||
* @package davical
|
||||
* @subpackage caldav
|
||||
* @author Andrew McMillan <andrew@morphoss.com>
|
||||
@ -24,7 +24,7 @@ require_once('RRule-v2.php');
|
||||
function do_scheduling_for_delete(DAVResource $deleted_resource ) {
|
||||
// By the time we arrive here the resource *has* actually been deleted from disk
|
||||
// we can only fail to (de-)schedule the activity...
|
||||
global $request, $c;
|
||||
global $request, $c;
|
||||
|
||||
if ( !isset($request) || (isset($c->enable_auto_schedule) && !$c->enable_auto_schedule) ) return true;
|
||||
if ( $deleted_resource->IsInSchedulingCollection() ) return true;
|
||||
@ -124,7 +124,7 @@ function doItipAttendeeReply( vCalendar $resource, $partstat ) {
|
||||
$response = '3.7'; // Organizer was not found on server.
|
||||
if ( !$organizer_calendar->Exists() ) {
|
||||
if ( doImipMessage('REPLY', $organizer_principal->email(), $vcal) ) {
|
||||
$response = '1.1'; // Scheduling whoosit 'Sent'
|
||||
$response = '1.1'; // Scheduling whoosit 'Sent'
|
||||
}
|
||||
else {
|
||||
dbg_error_log('ERROR','Default calendar at "%s" does not exist for user "%s"',
|
||||
@ -186,7 +186,7 @@ function doItipAttendeeReply( vCalendar $resource, $partstat ) {
|
||||
|
||||
function GetItip( VCalendar $vcal, $method, $attendee_value, $clear_attendee_parameters = null ) {
|
||||
$iTIP = $vcal->GetItip($method, $attendee_value, $clear_attendee_parameters );
|
||||
$components = $iTIP->GetComponents();
|
||||
$components = $iTIP->GetComponents();
|
||||
foreach( $components AS $comp ) {
|
||||
$comp->AddProperty('REQUEST-STATUS','2.0');
|
||||
$properties = array();
|
||||
@ -243,7 +243,7 @@ function doItipOrganizerCancel( vCalendar $vcal ) {
|
||||
$schedule_target = new Principal('email',$email);
|
||||
if ( !$schedule_target->Exists() ) {
|
||||
if ( doImipMessage('CANCEL', $email, $vcal) ) {
|
||||
$response = '1.1'; // Scheduling whoosit 'Sent'
|
||||
$response = '1.1'; // Scheduling whoosit 'Sent'
|
||||
}
|
||||
else {
|
||||
$response = '3.7';
|
||||
@ -273,7 +273,7 @@ function doItipOrganizerCancel( vCalendar $vcal ) {
|
||||
/**
|
||||
* Does the actual processing of the iTIP CANCEL message on behalf of an ATTENDEE,
|
||||
* which generally means writing it into the ATTENDEE's default calendar.
|
||||
*
|
||||
*
|
||||
* @param vCalendar $vcal The message.
|
||||
* @param vProperty $attendee
|
||||
* @param WritableCollection $attendee_calendar
|
||||
@ -285,7 +285,7 @@ function processItipCancel( vCalendar $vcal, vProperty $attendee, WritableCollec
|
||||
//TODO: header( "Debug: Could maybe do the iMIP message dance for attendee ". $attendee->Value() );
|
||||
if ( !$attendee_calendar->Exists() ) {
|
||||
if ( doImipMessage('CANCEL', $attendee_principal->email(), $vcal) ) {
|
||||
return '1.1'; // Scheduling whoosit 'Sent'
|
||||
return '1.1'; // Scheduling whoosit 'Sent'
|
||||
}
|
||||
else {
|
||||
dbg_error_log('ERROR', 'Default calendar at "%s" does not exist for attendee "%s"',
|
||||
@ -324,10 +324,10 @@ function processItipCancel( vCalendar $vcal, vProperty $attendee, WritableCollec
|
||||
|
||||
/**
|
||||
* Delivers the iTIP CANCEL message to an ATTENDEE's Scheduling Inbox Collection.
|
||||
*
|
||||
*
|
||||
* This is pretty simple at present, but could be extended in the future to do the sending
|
||||
* of e-mail to a remote attendee.
|
||||
*
|
||||
*
|
||||
* @param vCalendar $iTIP
|
||||
* @param vProperty $attendee
|
||||
* @param WritableCollection $attendee_inbox
|
||||
@ -342,7 +342,7 @@ require_once('EMail.php');
|
||||
|
||||
/**
|
||||
* Send an iMIP message since they look like a non-local user.
|
||||
*
|
||||
*
|
||||
* @param string $method The METHOD parameter from the iTIP
|
||||
* @param string $to_email The e-mail address we're going to send to
|
||||
* @param vCalendar $vcal The iTIP part of the message.
|
||||
|
||||
@ -34,14 +34,14 @@ echo <<<EOCAP
|
||||
<action>list</action>
|
||||
<description>List timezone identifiers and localized forms
|
||||
</description>
|
||||
|
||||
|
||||
<accept-parameter>
|
||||
<name>lang</name>
|
||||
<required>false</required>
|
||||
<multi>true</multi>
|
||||
<description>Specify desired localized form(s)</description>
|
||||
</accept-parameter>
|
||||
|
||||
|
||||
<accept-parameter>
|
||||
<name>changedsince</name>
|
||||
<required>false</required>
|
||||
@ -50,7 +50,7 @@ echo <<<EOCAP
|
||||
given date
|
||||
</description>
|
||||
</accept-parameter>
|
||||
|
||||
|
||||
<accept-parameter>
|
||||
<name>returnall</name>
|
||||
<required>false</required>
|
||||
@ -59,14 +59,14 @@ echo <<<EOCAP
|
||||
</description>
|
||||
</accept-parameter>
|
||||
</operation>
|
||||
|
||||
|
||||
<operation>
|
||||
<action>get</action>
|
||||
<description>
|
||||
Returns one or more timezones as specified by the
|
||||
tzid parameter.
|
||||
</description>
|
||||
|
||||
|
||||
<accept-parameter>
|
||||
<name>format</name>
|
||||
<required>false</required>
|
||||
@ -76,14 +76,14 @@ echo <<<EOCAP
|
||||
<description>Specify required format for timezone.
|
||||
</description>
|
||||
</accept-parameter>
|
||||
|
||||
|
||||
<accept-parameter>
|
||||
<name>lang</name>
|
||||
<required>false</required>
|
||||
<multi>true</multi>
|
||||
<description>Specify desired localized form(s)</description>
|
||||
</accept-parameter>
|
||||
|
||||
|
||||
<accept-parameter>
|
||||
<name>tzid</name>
|
||||
<required>true</required>
|
||||
@ -92,21 +92,21 @@ echo <<<EOCAP
|
||||
</description>
|
||||
</accept-parameter>
|
||||
</operation>
|
||||
|
||||
|
||||
<operation>
|
||||
<action>expand</action>
|
||||
<description>
|
||||
Expands the specified timezone(s) into local onset and UTC
|
||||
offsets
|
||||
</description>
|
||||
|
||||
|
||||
<accept-parameter>
|
||||
<name>tzid</name>
|
||||
<required>true</required>
|
||||
<multi>true</multi>
|
||||
<description>Specify desired timezone identifiers</description>
|
||||
</accept-parameter>
|
||||
|
||||
|
||||
<accept-parameter>
|
||||
<name>start</name>
|
||||
<required>false</required>
|
||||
@ -116,7 +116,7 @@ echo <<<EOCAP
|
||||
current year is assumed.
|
||||
</description>
|
||||
</accept-parameter>
|
||||
|
||||
|
||||
<accept-parameter>
|
||||
<name>end</name>
|
||||
<required>false</required>
|
||||
@ -127,7 +127,7 @@ echo <<<EOCAP
|
||||
</description>
|
||||
</accept-parameter>
|
||||
</operation>
|
||||
|
||||
|
||||
<operation>
|
||||
<action>capabilities</action>
|
||||
<description>Gets the capabilities of the server</description>
|
||||
|
||||
@ -38,10 +38,10 @@ $tz = $qry->Fetch();
|
||||
|
||||
// define( 'DEBUG_EXPAND', true);
|
||||
define( 'DEBUG_EXPAND', false );
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Expand the instances for a STANDARD or DAYLIGHT component of a VTIMEZONE
|
||||
* Expand the instances for a STANDARD or DAYLIGHT component of a VTIMEZONE
|
||||
*
|
||||
* @param object $vResource is a VCALENDAR with a VTIMEZONE containing components needing expansion
|
||||
* @param object $range_start A RepeatRuleDateTime which is the beginning of the range for events.
|
||||
@ -61,7 +61,7 @@ function expand_timezone_onsets( vCalendar $vResource, RepeatRuleDateTime $range
|
||||
$is_date = false;
|
||||
$has_repeats = false;
|
||||
$zone_tz = $vtz->GetPValue('TZID');
|
||||
|
||||
|
||||
foreach( $components AS $k => $comp ) {
|
||||
if ( DEBUG_EXPAND ) {
|
||||
printf( "Starting TZ expansion for component '%s' in timezone '%s'\n", $comp->GetType(), $zone_tz);
|
||||
@ -119,7 +119,7 @@ function expand_timezone_onsets( vCalendar $vResource, RepeatRuleDateTime $range
|
||||
if ( $rdate > $range_end ) break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( DEBUG_EXPAND ) {
|
||||
print( "After rdate_expand");
|
||||
foreach( $instances AS $k => $v ) {
|
||||
@ -144,7 +144,7 @@ function expand_timezone_onsets( vCalendar $vResource, RepeatRuleDateTime $range
|
||||
if ( $utc < $start_utc ) {
|
||||
continue;
|
||||
}
|
||||
$onsets[$utc] = array(
|
||||
$onsets[$utc] = array(
|
||||
'from' => $comp->GetPValue('TZOFFSETFROM'),
|
||||
'to' => $comp->GetPValue('TZOFFSETTO'),
|
||||
'name' => $comp->GetPValue('TZNAME'),
|
||||
@ -186,7 +186,7 @@ foreach( $observances AS $onset => $details ) {
|
||||
new XMLElement('onset', $onset ),
|
||||
new XMLElement('utc-offset-from', substr($details['from'],0,-2).':'.substr($details['from'],-2) ),
|
||||
new XMLElement('utc-offset-to', substr($details['to'],0,-2).':'.substr($details['to'],-2) )
|
||||
));
|
||||
));
|
||||
}
|
||||
|
||||
$timezones->NewElement('tzdata', $tzdata );
|
||||
|
||||
@ -93,7 +93,7 @@ if ( $can_write_collection && $editor->IsSubmit() ) {
|
||||
else {
|
||||
$c->messages[] = i18n("Updating Collection record.");
|
||||
}
|
||||
if ( !$editor->Write() ) {
|
||||
if ( !$editor->Write() ) {
|
||||
$c->messages[] = i18n("Failed to write collection.");
|
||||
if ( $id > 0 ) $editor->GetRecord();
|
||||
}
|
||||
@ -137,7 +137,7 @@ if ( $editor->Available() ) {
|
||||
$entryqry = new AwlQuery( 'SELECT count(*) as count from caldav_data where collection_id='.$editor->Value('collection_id') );
|
||||
$entryqry->Exec('admin-collection-edit');
|
||||
$entries = $entryqry->Fetch(); $entries = $entries->count;
|
||||
|
||||
|
||||
$externalqry = new AwlQuery( 'SELECT external_url from dav_binding where bound_source_id=:id limit 1', array(':id' => $editor->Value('collection_id') ) );
|
||||
$externalqry->Exec('external-bind-url');
|
||||
$external = $externalqry->Fetch(); $external_url = $external->external_url;
|
||||
@ -332,7 +332,7 @@ label.privilege {
|
||||
<tr> <th class="right">$prompt_dav_name:</th> <td class="left">$value_dav_name</td> </tr>$external_bind
|
||||
<tr> <th class="right">$prompt_entries:</th> <td class="left">$entries</td> </tr>
|
||||
<tr> <th class="right">$prompt_load_file:</th> <td class="left">##ics_file.file.60## ##mode.checkbox##
|
||||
</td> </tr>
|
||||
</td> </tr>
|
||||
<tr> <th class="right">$prompt_displayname:</th> <td class="left">##dav_displayname.input.50##</td> </tr>
|
||||
<tr> <th class="right">$prompt_public:</th> <td class="left">##publicly_readable.checkbox##</td> </tr>
|
||||
<tr> <th class="right">$prompt_calendar:</th> <td class="left">##is_calendar.checkbox##</td> </tr>
|
||||
@ -367,7 +367,7 @@ toggle_visible('fld_use_default_privs','!privileges_settings');
|
||||
|
||||
EOTEMPLATE;
|
||||
|
||||
|
||||
|
||||
|
||||
$editor->SetTemplate( $template );
|
||||
$page_elements[] = $editor;
|
||||
@ -519,15 +519,15 @@ EOTEMPLATE;
|
||||
$browser->DoQuery();
|
||||
$page_elements[] = $browser;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
bind_id | bigint | not null default nextval('dav_id_seq'::regclass)
|
||||
bound_source_id | bigint |
|
||||
access_ticket_id | text |
|
||||
bound_source_id | bigint |
|
||||
access_ticket_id | text |
|
||||
dav_owner_id | bigint | not null
|
||||
parent_container | text | not null
|
||||
dav_name | text | not null
|
||||
dav_displayname | text |
|
||||
dav_displayname | text |
|
||||
*/
|
||||
|
||||
$browser = new Browser(translate('Bindings to this Collection'));
|
||||
|
||||
@ -29,9 +29,9 @@ $page_elements[] = $browser;
|
||||
|
||||
$externalqry = new AwlQuery( "SELECT count(*) as count from collection where parent_container='/.external/' and collection_id not in ( select bound_source_id from dav_binding where external_url is not null)" );
|
||||
$externalqry->Exec('external-bind-url');
|
||||
$external = $externalqry->Fetch();
|
||||
$external = $externalqry->Fetch();
|
||||
if ( $external->count > 0 ) {
|
||||
$link = '<a href="'.$c->base_url . '/admin.php?action=edit&t=external&subaction=clean" class="submit">'.
|
||||
$link = '<a href="'.$c->base_url . '/admin.php?action=edit&t=external&subaction=clean" class="submit">'.
|
||||
translate("Remove dangling external calendars").'('.$external->count.')</a>';
|
||||
$c->stylesheets[] = 'css/edit.css';
|
||||
$page_elements[] = $link;
|
||||
|
||||
@ -48,7 +48,7 @@ function handle_subaction( $subaction ) {
|
||||
global $delete_ticket_confirmation_required;
|
||||
global $delete_bind_in_confirmation_required;
|
||||
global $delete_binding_confirmation_required;
|
||||
|
||||
|
||||
dbg_error_log('admin-principal-edit',':handle_action: Action %s', $subaction );
|
||||
|
||||
switch( $subaction ) {
|
||||
@ -162,7 +162,7 @@ function handle_subaction( $subaction ) {
|
||||
function principal_editor() {
|
||||
global $c, $id, $can_write_principal, $session;
|
||||
$editor = new Editor(translate('Principal'), 'dav_principal');
|
||||
|
||||
|
||||
$editor->SetLookup( 'date_format_type', "SELECT 'E', 'European' UNION SELECT 'U', 'US Format' UNION SELECT 'I', 'ISO Format'" );
|
||||
$editor->SetLookup( 'type_id', 'SELECT principal_type_id, principal_type_desc FROM principal_type ORDER BY principal_type_id' );
|
||||
$editor->SetLookup( 'locale', 'SELECT \'\', \''.translate("*** Default Locale ***").'\' UNION SELECT locale, locale_name_locale FROM supported_locales ORDER BY 1 ASC' );
|
||||
@ -170,12 +170,12 @@ function principal_editor() {
|
||||
$editor->AddAttribute( 'fullname', 'title', translate("The full name for this person, group or other type of principal.") );
|
||||
$editor->AddAttribute( 'email', 'title', translate("The email address identifies principals when processing invitations and freebusy lookups. It should be set to a unique value.") );
|
||||
$editor->SetWhere( 'principal_id='.$id );
|
||||
|
||||
|
||||
$editor->AddField('is_admin', 'EXISTS( SELECT 1 FROM role_member WHERE role_no = 1 AND role_member.user_no = dav_principal.user_no )' );
|
||||
$editor->AddAttribute('is_admin', 'title', translate('An "Administrator" user has full rights to the whole DAViCal System'));
|
||||
|
||||
|
||||
$post_values = false;
|
||||
|
||||
|
||||
if ( isset($_POST['xxxxusername']) ) {
|
||||
$_POST['xxxxusername'] = trim(str_replace('/', '', $_POST['xxxxusername']));
|
||||
if ( $_POST['xxxxusername'] == '' ) {
|
||||
@ -190,7 +190,7 @@ function principal_editor() {
|
||||
if ( isset($_POST['email']) && trim($_POST['email']) == '' ) {
|
||||
$c->messages[] = i18n("The email address really should not be blank.");
|
||||
}
|
||||
|
||||
|
||||
$pwstars = '@@@@@@@@@@';
|
||||
if ( $can_write_principal && $editor->IsSubmit() ) {
|
||||
$editor->WhereNewRecord( "principal_id=(SELECT CURRVAL('dav_id_seq'))" );
|
||||
@ -287,9 +287,9 @@ function principal_editor() {
|
||||
$prompt_locale = translate('Locale');
|
||||
$prompt_type = translate('Principal Type');
|
||||
$prompt_privileges = translate('Privileges granted to All Users');
|
||||
|
||||
|
||||
$privs_html = build_privileges_html( $editor, 'default_privileges');
|
||||
|
||||
|
||||
$admin_row_entry = '';
|
||||
$delete_principal_button = '';
|
||||
if ( $session->AllowedTo('Admin') ) {
|
||||
@ -386,14 +386,14 @@ EOTEMPLATE;
|
||||
|
||||
function build_privileges_html( $ed, $fname ) {
|
||||
global $privilege_xlate, $privilege_names;
|
||||
|
||||
|
||||
$btn_all = htmlspecialchars(translate('All')); $btn_all_title = htmlspecialchars(translate('Toggle all privileges'));
|
||||
$btn_rw = htmlspecialchars(translate('Read/Write')); $btn_rw_title = htmlspecialchars(translate('Set read+write privileges'));
|
||||
$btn_read = htmlspecialchars(translate('Read')); $btn_read_title = htmlspecialchars(translate('Set read privileges'));
|
||||
$btn_fb = htmlspecialchars(translate('Free/Busy')); $btn_fb_title = htmlspecialchars(translate('Set free/busy privileges'));
|
||||
$btn_sd = htmlspecialchars(translate('Schedule Deliver')); $btn_sd_title = htmlspecialchars(translate('Privileges to allow delivery of scheduling messages'));
|
||||
$btn_ss = htmlspecialchars(translate('Schedule Send')); $btn_ss_title = htmlspecialchars(translate('Privileges to delegate scheduling decisions'));
|
||||
|
||||
|
||||
$privs_dec = bindec($ed->Value($fname));
|
||||
$privileges_set = sprintf('<div id="privileges"><input type="hidden" name="%s[fake_privilege_for_input]" value="0">%s', $fname, "\n");
|
||||
for( $i=0; $i < count($privilege_names); $i++ ) {
|
||||
@ -448,7 +448,7 @@ function privilege_format_function( $value, $column, $row ) {
|
||||
}
|
||||
|
||||
|
||||
function confirm_delete_principal($confirmation_hash, $displayname ) {
|
||||
function confirm_delete_principal($confirmation_hash, $displayname ) {
|
||||
$html = '<p class="error">';
|
||||
$html .= sprintf('<b>%s</b> \'%s\' <a class="error" href="%s&%s">%s</a> %s',
|
||||
translate('Deleting Principal:'), $displayname, $_SERVER['REQUEST_URI'],
|
||||
@ -459,7 +459,7 @@ function confirm_delete_principal($confirmation_hash, $displayname ) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function group_memberships_browser() {
|
||||
global $c, $id, $editor;
|
||||
$browser = new Browser(translate('Group Memberships'));
|
||||
@ -626,7 +626,7 @@ function grant_row_editor() {
|
||||
|
||||
function edit_grant_row( $row_data ) {
|
||||
global $id, $grantrow;
|
||||
|
||||
|
||||
$orig_to_id = intval($row_data->to_principal);
|
||||
if ( $orig_to_id > -1 ) {
|
||||
$grantrow->SetRecord( $row_data );
|
||||
@ -634,7 +634,7 @@ function edit_grant_row( $row_data ) {
|
||||
else {
|
||||
$grantrow->Initialise( $row_data );
|
||||
}
|
||||
|
||||
|
||||
$privs_html = build_privileges_html( $grantrow, 'grant_privileges' );
|
||||
|
||||
$form_id = $grantrow->Id();
|
||||
@ -655,7 +655,7 @@ EOTEMPLATE;
|
||||
return $grantrow->Render();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function principal_grants_browser() {
|
||||
global $c, $id, $editor, $can_write_principal;
|
||||
$browser = new Browser(translate('Principal Grants'));
|
||||
@ -710,15 +710,15 @@ function ticket_row_editor() {
|
||||
$ticketrow = new Editor("Tickets", "access_ticket");
|
||||
$ticketrow->SetSubmitName( 'ticketrow' );
|
||||
if ( $can_write_principal && $ticketrow->IsSubmit() ) {
|
||||
|
||||
|
||||
$username = $editor->Value('username');
|
||||
$ugly_path = $_POST['target'];
|
||||
if ( $ugly_path == '/'.$username || $ugly_path == '/'.$username.'/' ) {
|
||||
$target_collection = $id;
|
||||
}
|
||||
else {
|
||||
else {
|
||||
$username_len = strlen($username) + 2;
|
||||
$sql = "SELECT collection_id FROM collection WHERE dav_name = :exact_name";
|
||||
$sql = "SELECT collection_id FROM collection WHERE dav_name = :exact_name";
|
||||
$sql .= " AND substring(dav_name FROM 1 FOR $username_len) = '/$username/'";
|
||||
$params = array( ':exact_name' => $ugly_path );
|
||||
if ( !preg_match( '#/$#', $ugly_path ) ) {
|
||||
@ -737,7 +737,7 @@ function ticket_row_editor() {
|
||||
return $ticketrow;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$_POST['dav_owner_id'] = $id;
|
||||
$_POST['target_collection_id'] = $target_collection;
|
||||
$ticket_id = check_by_regex($_POST['ticket_id'], '/[A-Za-z0-9]+/');
|
||||
@ -820,7 +820,7 @@ function access_ticket_browser() {
|
||||
return $browser;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function confirm_delete_ticket($confirmation_hash) {
|
||||
$html = '<table><tr><td class="error">';
|
||||
$html .= sprintf('<b>%s</b> "%s" <a class="error" href="%s&%s">%s</a> %s',
|
||||
@ -865,7 +865,7 @@ function principal_collection_browser() {
|
||||
$browser->DoQuery();
|
||||
return $browser;
|
||||
}
|
||||
|
||||
|
||||
function confirm_delete_collection($confirmation_hash) {
|
||||
$html = '<table><tr><td class="error">';
|
||||
$html .= sprintf('<b>%s</b> "%s" <a class="error" href="%s&%s">%s</a> %s',
|
||||
@ -900,7 +900,7 @@ function bindings_to_other_browser() {
|
||||
$browser->DoQuery();
|
||||
return $browser;
|
||||
}
|
||||
|
||||
|
||||
function confirm_delete_bind_in($confirmation_hash) {
|
||||
$html = '<table><tr><td class="error">';
|
||||
$html .= sprintf('<b>%s</b> "%s" <a class="error" href="%s&%s">%s</a> %s',
|
||||
@ -911,8 +911,8 @@ function confirm_delete_bind_in($confirmation_hash) {
|
||||
$html .= "</td></tr></table>\n";
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function bindings_to_us_browser() {
|
||||
global $c, $page_elements, $id, $editor;
|
||||
$browser = new Browser(translate('Bindings to this Principal\'s Collections'));
|
||||
@ -936,7 +936,7 @@ function bindings_to_us_browser() {
|
||||
$browser->DoQuery();
|
||||
return $browser;
|
||||
}
|
||||
|
||||
|
||||
function confirm_delete_binding( $confirmation_hash ) {
|
||||
$html = '<table><tr><td class="error">';
|
||||
$html .= sprintf('<b>%s</b> "%s" <a class="error" href="%s&%s">%s</a> %s',
|
||||
@ -951,7 +951,7 @@ function confirm_delete_binding( $confirmation_hash ) {
|
||||
|
||||
if ( isset($_GET['subaction']) ) {
|
||||
if ( handle_subaction($_GET['subaction']) && 'delete_principal' == $_GET['subaction'] ) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -964,8 +964,8 @@ if ( isset($id) && $id > 0 ) {
|
||||
|
||||
if ( isset($delete_principal_confirmation_required) )
|
||||
$page_elements[] = confirm_delete_principal($delete_principal_confirmation_required, $editor->Value('displayname'));
|
||||
|
||||
|
||||
|
||||
|
||||
$page_elements[] = group_memberships_browser();
|
||||
if ( $editor->Value('type_id') == 3 ) {
|
||||
$grouprow = group_row_editor();
|
||||
@ -973,18 +973,18 @@ if ( isset($id) && $id > 0 ) {
|
||||
}
|
||||
$grantrow = grant_row_editor();
|
||||
$page_elements[] = principal_grants_browser();
|
||||
if ( isset($delete_grant_confirmation_required) ) $page_elements[] = confirm_delete_grant($delete_grant_confirmation_required);
|
||||
|
||||
if ( isset($delete_grant_confirmation_required) ) $page_elements[] = confirm_delete_grant($delete_grant_confirmation_required);
|
||||
|
||||
$ticketrow = ticket_row_editor();
|
||||
$page_elements[] = access_ticket_browser();
|
||||
if ( isset($delete_ticket_confirmation_required) ) $page_elements[] = confirm_delete_ticket($delete_ticket_confirmation_required);
|
||||
if ( isset($delete_ticket_confirmation_required) ) $page_elements[] = confirm_delete_ticket($delete_ticket_confirmation_required);
|
||||
|
||||
$page_elements[] = principal_collection_browser();
|
||||
if ( isset($delete_collection_confirmation_required) ) $page_elements[] = confirm_delete_collection($delete_collection_confirmation_required);
|
||||
|
||||
if ( isset($delete_collection_confirmation_required) ) $page_elements[] = confirm_delete_collection($delete_collection_confirmation_required);
|
||||
|
||||
$page_elements[] = bindings_to_other_browser();
|
||||
if ( isset($delete_bind_in_confirmation_required) ) $page_elements[] = confirm_delete_bind_in($delete_bind_in_confirmation_required);
|
||||
|
||||
if ( isset($delete_bind_in_confirmation_required) ) $page_elements[] = confirm_delete_bind_in($delete_bind_in_confirmation_required);
|
||||
|
||||
$page_elements[] = bindings_to_us_browser();
|
||||
if ( isset($delete_binding_confirmation_required) ) $page_elements[] = confirm_delete_binding($delete_binding_confirmation_required);
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ class VTimezone extends vComponent {
|
||||
$vtz = new vComponent($row->vtimezone);
|
||||
if ( $vtz->GetType() == 'VTIMEZONE' ) return $vtz;
|
||||
$tmp = $vtz->GetComponents('VTIMEZONE');
|
||||
if ( count($tmp) < 1 || $tmp[0]->GetType() != 'VTIMEZONE' ) return null;
|
||||
if ( count($tmp) < 1 || $tmp[0]->GetType() != 'VTIMEZONE' ) return null;
|
||||
$vtz = $tmp[0];
|
||||
return $vtz;
|
||||
}
|
||||
@ -102,7 +102,7 @@ class VTimezone extends vComponent {
|
||||
case 74: return('Asia/Riyadh');
|
||||
case 75: return('Asia/Taipei');
|
||||
case 76: return('Australia/Sydney');
|
||||
|
||||
|
||||
case 57: // null
|
||||
case 52: // null
|
||||
default: // null
|
||||
@ -110,5 +110,5 @@ class VTimezone extends vComponent {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -22,7 +22,7 @@ switch ( $request->path ) {
|
||||
$parameters = '';
|
||||
foreach( $_GET as $k => $v ) {
|
||||
$parameters .= ($parameters == '' ? '?' : '&' );
|
||||
$parameters .= $k.'='.rawurlencode($v);
|
||||
$parameters .= $k.'='.rawurlencode($v);
|
||||
}
|
||||
header('Location: ' . $c->protocol_server_port . str_replace('/caldav.php', '', ConstructURL('/tz.php',true)).$parameters );
|
||||
$request->DoResponse(301); // Moved permanently
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user