Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F8197605
Source.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
Source.php
View Options
<?php
namespace
Kolab\FreeBusy
;
/**
* Abstract class to fetch free/busy data from a specific source
*/
abstract
class
Source
{
protected
$config
=
array
();
/**
* Factory method creating an instace of Source according to config
*
* @param array Hash array with config
*/
public
static
function
factory
(
$url
)
{
$config
=
parse_url
(
$url
);
switch
(
$config
[
'scheme'
])
{
case
'file'
:
return
new
SourceFile
(
$config
);
case
'imap'
:
return
new
SourceIMAP
(
$config
);
case
'http'
:
case
'https'
:
return
new
SourceURL
(
$url
);
}
trigger_error
(
"Invalid source configuration: "
.
$url
,
E_USER_ERROR
);
return
null
;
}
/**
* Default constructor
*/
public
function
__construct
(
$config
)
{
$this
->
config
=
$config
;
}
/**
* Retrieve free/busy data for the given user
*
* @param array Hash array with user attributes
*/
abstract
public
function
getFreeBusyData
(
$user
,
$extended
);
/**
* Replace all %varname strings in config with values from $user
*/
protected
function
getUserConfig
(
$user
)
{
$config
=
array
();
foreach
(
$this
->
config
as
$k
=>
$val
)
{
if
(
is_string
(
$val
)
&&
strpos
(
$val
,
'%'
)
!==
false
)
{
$val
=
preg_replace_callback
(
'/%
\{
?([a-z0-9]+)
\}
?/'
,
function
(
$m
)
use
(
$user
)
{
return
$user
[
$m
[
1
]];
},
$val
);
}
$config
[
$k
]
=
$val
;
}
return
$config
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Jul 8, 5:24 PM (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1051649
Default Alt Text
Source.php (1 KB)
Attached To
Mode
R28 freebusy
Attached
Detach File
Event Timeline
Log In to Comment