Support Free/Busy information with credentials as part of the URL

This commit is contained in:
Jörg Lehrke 2010-06-26 11:35:11 +00:00
parent 99cb0d791a
commit c5ae8dd8e2
7 changed files with 83 additions and 27 deletions

View File

@ -607,6 +607,8 @@ class addressbook_bo extends addressbook_so
*/
function db2data($data, $date_format='ts')
{
static $fb_url = false;
// convert timestamps from server-time in the db to user-time
foreach ($this->timestamps as $name)
{
@ -620,10 +622,12 @@ class addressbook_bo extends addressbook_so
// set freebusy_uri for accounts
if (!$data['freebusy_uri'] && !$data['owner'] && $data['account_id'] && !is_object($GLOBALS['egw_setup']))
{
static $fb_url;
if (!$fb_url && @is_dir(EGW_SERVER_ROOT.'/calendar/inc')) $fb_url = calendar_bo::freebusy_url('');
if ($fb_url) $data['freebusy_uri'] = $fb_url.urlencode(
isset($data['account_lid']) ? $data['account_lid'] : $GLOBALS['egw']->accounts->id2name($data['account_id']));
if ($fb_url || @is_dir(EGW_SERVER_ROOT.'/calendar/inc'))
{
$fb_url = true;
$user = isset($data['account_lid']) ? $data['account_lid'] : $GLOBALS['egw']->accounts->id2name($data['account_id']);
$data['freebusy_uri'] = calendar_bo::freebusy_url($user);
}
}
return $data;
}

View File

@ -43,6 +43,7 @@ if (strpos($_SERVER['QUERY_STRING'],'=3D') !== false && substr($_GET['user'],0,2
{
$_GET['user'] = substr($_GET['user'],2);
if (isset($_GET['password'])) $_GET['password'] = substr($_GET['password'],2);
if (isset($_GET['cred'])) $_GET['cred'] = substr($_GET['cred'],2);
}
if (!is_numeric($user = $_GET['user']))
{
@ -58,15 +59,46 @@ if ($user === false || !($username = $GLOBALS['egw']->accounts->id2name($user)))
}
if (!$loged_in)
{
$GLOBALS['egw']->preferences->account_id = $user;
$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository();
$GLOBALS['egw_info']['user']['account_id'] = $user;
$GLOBALS['egw_info']['user']['account_lid'] = $username;
$cal_prefs = &$GLOBALS['egw_info']['user']['preferences']['calendar'];
if (!$cal_prefs['freebusy'] || !empty($cal_prefs['freebusy_pw']) && $cal_prefs['freebusy_pw'] != $_GET['password'])
if (empty($_GET['cred']))
{
fail_exit(lang("freebusy: Unknow user '%1', wrong password or not availible to not loged in users !!!",$_GET['user']));
$GLOBALS['egw_info']['user']['account_id'] = $user;
$GLOBALS['egw_info']['user']['account_lid'] = $username;
$GLOBALS['egw']->preferences->account_id = $user;
$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository();
$cal_prefs = &$GLOBALS['egw_info']['user']['preferences']['calendar'];
$loged_in = !empty($cal_prefs['freebusy']) &&
(empty($cal_prefs['freebusy_pw']) || $cal_prefs['freebusy_pw'] == $_GET['password']);
}
else
{
$credentials = base64_decode($_GET['cred']);
list($authuser, $password) = explode(':', $credentials, 2);
if (strpos($authuser, '@') === false)
{
$domain = $GLOBALS['egw_info']['server']['default_domain'];
$authuser .= '@' . $domain;
}
else
{
list(, $domain) = explode('@',$authuser, 2);
}
if (array_key_exists($domain, $GLOBALS['egw_domain']))
{
$_POST['login'] = $authname;
$_REQUEST['domain'] = $domain;
$GLOBALS['egw_info']['server']['default_domain'] = $domain;
$GLOBALS['egw_info']['user']['domain'] = $domain;
$GLOBALS['egw_info']['flags']['currentapp'] = 'login';
$GLOBALS['egw_info']['flags']['noapi'] = false;
require_once(EGW_API_INC . '/functions.inc.php');
$loged_in = $GLOBALS['egw']->session->create($authuser, $password, 'text');
session_unset();
session_destroy();
}
}
if (!$loged_in)
{
fail_exit(lang("freebusy: Unknow user '%1', or not available for unauthenticated users!", $_GET['user']));
}
}
if ($_GET['debug'])

View File

@ -1772,14 +1772,25 @@ class calendar_bo
* @param int|string $user account_id or account_lid
* @param string $pw=null password
*/
static function freebusy_url($user,$pw=null)
static function freebusy_url($user='',$pw=null)
{
if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user);
$credentials = '';
if ($pw)
{
$credentials = '&password='.urlencode($pw);
}
elseif ($GLOBALS['egw_info']['user']['preferences']['calendar']['freebusy'] == 2)
{
$credentials = $GLOBALS['egw_info']['user']['account_lid']
. ':' . $GLOBALS['egw_info']['user']['passwd'];
$credentials = '&cred=' . base64_encode($credentials);
}
return (!$GLOBALS['egw_info']['server']['webserver_url'] || $GLOBALS['egw_info']['server']['webserver_url'][0] == '/' ?
($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['HTTP_HOST'] : '').
$GLOBALS['egw_info']['server']['webserver_url'].'/calendar/freebusy.php?user='.urlencode($user).
($pw ? '&password='.urlencode($pw) : '');
$GLOBALS['egw_info']['server']['webserver_url'].'/calendar/freebusy.php/?user='.urlencode($user).$credentials;
}
/**

View File

@ -240,6 +240,11 @@ class calendar_hooks
'all' => lang('Always'),
'startday' => lang('If start day differs'),
);
$freebusy_values = array(
0 => lang('No'),
1 => lang('Yes'),
2 => lang('With credentials included'),
);
if (!$hook_data['setup']) // does not work at setup time
{
$options = array('0' => lang('none'));
@ -248,7 +253,9 @@ class calendar_hooks
$options[$group['account_id']] = common::grab_owner_name($group['account_id']);
}
$freebusy_url = calendar_bo::freebusy_url($GLOBALS['egw_info']['user']['account_lid'],$GLOBALS['egw_info']['user']['preferences']['calendar']['freebusy_pw']);
$freebusy_help = lang('Should not loged in persons be able to see your freebusy information? You can set an extra password, different from your normal password, to protect this informations. The freebusy information is in iCal format and only include the times when you are busy. It does not include the event-name, description or locations. The URL to your freebusy information is %1.','<a href="'.$freebusy_url.'" target="_blank">'.$freebusy_url.'</a>');
$freebusy_url = '<a href="'.$freebusy_url.'" target="_blank">'.$freebusy_url.'</a>';
$freebusy_help = lang('Should not loged in persons be able to see your freebusy information? You can set an extra password, different from your normal password, to protect this informations. The freebusy information is in iCal format and only include the times when you are busy. It does not include the event-name, description or locations. The URL to your freebusy information is');
$freebusy_help .= ' ' . $freebusy_url;
// Timezone for file exports
$export_tzs = array('0' => 'Use Event TZ');
@ -536,15 +543,16 @@ class calendar_hooks
'admin' => False,
),
'freebusy' => array(
'type' => 'check',
'type' => 'select',
'label' => 'Make freebusy information available to not loged in persons?',
'name' => 'freebusy',
'help' => $freebusy_help,
'values' => $freebusy_values,
'run_lang' => false,
'subst_help' => False,
'xmlrpc' => True,
'admin' => False,
'forced' => false,
'forced' => 0,
),
'freebusy_pw' => array(
'type' => 'input',
@ -553,7 +561,7 @@ class calendar_hooks
'help' => 'If you dont set a password here, the information is available to everyone, who knows the URL!!!',
'xmlrpc' => True,
'admin' => False,
'forced' => 'no'
'forced' => ''
)
);
}

View File

@ -180,7 +180,7 @@ forward one month calendar de einen Monat weiter
forward one year calendar de ein Jahr weiter
four days view calendar de Vier-Tagesansicht
freebusy common de frei / belegt
freebusy: unknow user '%1', wrong password or not availible to not loged in users !!! calendar de Frei / Belegt: Unbekannter Benutzername '%1', falsches Passwort oder nicht verfügbar für nicht angemeldete Benutzer !!!
freebusy: unknow user '%1', or not available for unauthenticated users! calendar de Free/Busy: Unbekannter Benutzer '%1', oder Daten ohne Authentisierung nicht verfügbar!
freetime search calendar de Terminsuche
fri calendar de Fr
full description calendar de vollständige Beschreibung
@ -355,8 +355,7 @@ set new events to private calendar de Neue Termine als private Termine eintragen
setting lock time calender admin de Zeitintervall für Datensatzlock (default 1 sec.)
shall the date parameter be accepted (e.g. from calendar module)? calendar de Soll der Parameter Datum akzeptiert werden (z.B. vom Kalender Modul)?
should new events created as private by default ? calendar de Sollen neue Termine generell als Privat angelegt werden?
should not loged in persons be able to see your freebusy information? you can set an extra password, different from your normal password, to protect this informations. the freebusy information is in ical format and only include the times when you are busy. it does not include the event-name, description or locations. the url to your freebusy information is %1. calendar de Sollen nicht angemeldete Personen Ihre Belegtzeiten einsehen können? Sie können ein Passwort setzen um diese Informationen zu schützen. Das Passwort sollte sich von Ihrem normalen Passwort unterscheiden. Die Belegtzeiten sind im iCal Format und enthalten ausschließlich die Zeiten, an denen Sie nicht verfügbar sind. Sie enthalten NICHT den Namen, die Beschreibung oder den Ort des Termins. Die Adresse (URL) Ihrer Belegtzeiten ist %1.
should not loged in persons be able to see your freebusy information? you can set an extra password, different from your normal password, to protect this informations. the freebusy information is in ical format and only include the times when you are busy. it does not include the event-name, description or locations. the url to your freebusy information is <a href="http://213.183.76.121/egroupware/calendar/freebusy.php?user=mkk" target="_blank">http://213.183.76.121/egroupware/calendar/freebusy.php?user=mkk</a>. calendar de Soll Ihre Verfügbarkeit auch ohne Anmeldung sichtbar sein? Sie können auch ein separates Passwort zum Schutz dieser Information vergeben. Ihre Verfügbarkeit wird im iCal-Format veröffnetlicht und enthält nur die Zeiten, zu denen sie bereits gebucht sind. Titel, Beschreibung und Ort sind so nicht einsehbar.
should not loged in persons be able to see your freebusy information? you can set an extra password, different from your normal password, to protect this informations. the freebusy information is in ical format and only include the times when you are busy. it does not include the event-name, description or locations. the url to your freebusy information is calendar de Sollen nicht angemeldete Personen Ihre Belegtzeiten einsehen können? Sie können ein Passwort setzen um diese Informationen zu schützen. Das Passwort sollte sich von Ihrem normalen Passwort unterscheiden. Die Belegtzeiten sind im iCal Format und enthaltena usschließlich die Zeiten, an denen Sie nicht verfügbar sind. Sie enthalten NICHT den Namen, die Beschreibung oder den Ort des Termins. Die Adresse (URL) Ihrer Belegtzeiten ist
should the grid be shown in the calendar calendar de Soll das Gitternetz im Kalender angezeigt werden?
should the number of weeks be shown on top of the calendar calendar de Soll die Wochenanzahl im Kalander oben abgezeigt werden?
should the number of weeks be shown on top of the calendar (only if offset = 0) calendar de Soll die Kalenderwoche im oberen Teil des Kalenders angezeigt werden (Nur wenn Abstabd=0)
@ -466,6 +465,7 @@ which events do you want to see when you enter the calendar. calendar de Welche
which of calendar view do you want to see, when you start calendar ? calendar de Welche der möglichen Ansichten des Kalenders möchten Sie als Standard sehen, wenn der Kalender geöffnet wird?
whole day calendar de ganztägig
whole query calendar de Ganze Abfrage
with credentials included calendar de Mit Zugangsdaten im URL
wk calendar de KW
work day ends on calendar de Arbeitstag endet um
work day starts on calendar de Arbeitstag beginnt um

View File

@ -180,7 +180,7 @@ forward one month calendar en forward one month
forward one year calendar en forward one year
four days view calendar en Four days view
freebusy common en Free/Busy
freebusy: unknow user '%1', wrong password or not availible to not loged in users !!! calendar en Free/Busy: Unknown user '%1', wrong password or not available to not logged in users !!!
freebusy: unknow user '%1', or not available for unauthenticated users! calendar en freebusy: Unknow user '%1', or not available for unauthenticated users!
freetime search calendar en Freetime Search
fri calendar en Fri
full description calendar en Full description
@ -355,9 +355,7 @@ set new events to private calendar en Set new events to private
setting lock time calender admin en Setting Data lock Time for Calendar (default 1 sec.)
shall the date parameter be accepted (e.g. from calendar module)? calendar en Shall the date parameter be accepted (e.g. from calendar module)?
should new events created as private by default ? calendar en Should new events created as private by default ?
should not loged in persons be able to see your freebusy information? you can set an extra password, different from your normal password, to protect this informations. the freebusy information is in ical format and only include the times when you are busy. it does not include the event-name, description or locations. the url to your freebusy information is %1. calendar en Should not logged in persons be able to see your Free/Busy information? You can set an extra password, different from your normal password, to protect this information. The Free/Busy information is in iCal format and only includes the times when you are busy. It does not include the event-name, description or locations. The URL to your Free/Busy information is %1.
should not loged in persons be able to see your freebusy information? you can set an extra password, different from your normal password, to protect this informations. the freebusy information is in ical format and only include the times when you are busy. it does not include the event-name, description or locations. the url to your freebusy information is <a href="http://213.183.76.121/egroupware/calendar/freebusy.php?user=mkk" target="_blank">http://213.183.76.121/egroupware/calendar/freebusy.php?user=mkk</a>. calendar en Should not loged in persons be able to see your freebusy information? You can set an extra password, different from your normal password, to protect this informations. The freebusy information is in iCal format and only include the times when you are busy. It does not include the event-name, description or locations. The URL to your freebusy information is <a href="http://213.183.76.121/egroupware/calendar/freebusy.php?user=mkk" target="_blank">http://213.183.76.121/egroupware/calendar/freebusy.php?user=mkk</a>.
should not loged in persons be able to see your freebusy information? you can set an extra password, different from your normal password, to protect this informations. the freebusy information is in ical format and only include the times when you are busy. it does not include the event-name, description or locations. the url to your freebusy information is <a href="https://www.serveahead.de/trunk/calendar/freebusy.php?user=admin" target="_blank">https://www.serveahead.de/trunk/calendar/freebusy.php?user=admin</a>. calendar en Should not loged in persons be able to see your freebusy information? You can set an extra password, different from your normal password, to protect this informations. The freebusy information is in iCal format and only include the times when you are busy. It does not include the event-name, description or locations. The URL to your freebusy information is <a href="https://www.serveahead.de/trunk/calendar/freebusy.php?user=admin" target="_blank">https://www.serveahead.de/trunk/calendar/freebusy.php?user=admin</a>.
should not loged in persons be able to see your freebusy information? you can set an extra password, different from your normal password, to protect this informations. the freebusy information is in ical format and only include the times when you are busy. it does not include the event-name, description or locations. the url to your freebusy information is calendar en Should not loged in persons be able to see your freebusy information? You can set an extra password, different from your normal password, to protect this informations. The freebusy information is in iCal format and only include the times when you are busy. It does not include the event-name, description or locations. The URL to your freebusy information is
should the grid be shown in the calendar calendar en Should the grid be shown in the calendar
should the number of weeks be shown on top of the calendar calendar en Should the number of weeks be shown on top of the calendar
should the number of weeks be shown on top of the calendar (only if offset = 0) calendar en Should the number of weeks be shown on top of the calendar (only if offset = 0)
@ -467,6 +465,7 @@ which events do you want to see when you enter the calendar. calendar en Which e
which of calendar view do you want to see, when you start calendar ? calendar en Which of calendar views do you want to see, when you start calendar ?
whole day calendar en Whole day
whole query calendar en whole query
with credentials included calendar en With credentials included
wk calendar en Wk
work day ends on calendar en Work day ends on
work day starts on calendar en Work day starts on

View File

@ -28,6 +28,8 @@ $GLOBALS['egw_info'] = array(
require_once('phpgwapi/inc/class.egw_digest_auth.inc.php');
include(dirname(__FILE__).'/header.inc.php');
$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository();
$headertime = microtime(true);
$groupdav = new groupdav();