fixed freetimesearch, which failed to work with new default etemplate requests stored directly in the form, using the new ajax_submit() function of etemplate

This commit is contained in:
Ralf Becker 2009-04-29 14:17:46 +00:00
parent 0930d0a739
commit a3adbcecd6
3 changed files with 106 additions and 49 deletions

View File

@ -1110,33 +1110,23 @@ class calendar_uiforms extends calendar_ui
}
/**
* Freetime search
* Callback for freetimesearch button in edit
*
* As the function is called in a popup via javascript, parametes get initialy transfered via the url
* @param array $content=null array with parameters or false (default) to use the get-params
* @param string start[str] start-date
* @param string start[hour] start-hour
* @param string start[min] start-minutes
* @param string end[str] end-date
* @param string end[hour] end-hour
* @param string end[min] end-minutes
* @param string participants ':' delimited string of user-id's
* It stores the data of the submitted form in the session under 'freetimesearch_args_'.$edit_content['id'],
* for later retrival of the freetimesearch method, called by the returned window.open() command.
*
* @param array $edit_content
* @return string with xajaxResponse
*/
function freetimesearch($content = null)
function ajax_freetimesearch(array $edit_content)
{
$etpl =& CreateObject('etemplate.etemplate','calendar.freetimesearch');
$response = new xajaxResponse();
//$response->addAlert(__METHOD__.'('.array2string($content).')');
$sel_options['search_window'] = array(
7*DAY_s => lang('one week'),
14*DAY_s => lang('two weeks'),
31*DAY_s => lang('one month'),
92*DAY_s => lang('three month'),
365*DAY_s => lang('one year'),
);
if (!is_array($content))
if (!(int)$edit_content['id'])
{
$edit_content = $etpl->process_values2url();
throw new egw_exception_wrong_parameter(__METHOD__.'() missing id in request!');
}
if ($edit_content['duration'])
{
$edit_content['end'] = $edit_content['start'] + $edit_content['duration'];
@ -1164,7 +1154,7 @@ class calendar_uiforms extends calendar_ui
{
$content['participants'][] = $data['uid'];
}
elseif ($key == 'account' && $data)
elseif ($key == 'account' && !is_array($data) && $data)
{
$content['participants'][] = $data;
}
@ -1179,6 +1169,51 @@ class calendar_uiforms extends calendar_ui
$content['weekdays'] = MCAL_M_WEEKDAYS;
$content['search_window'] = 7 * DAY_s;
// store content in session
egw_cache::setSession('calendar','freetimesearch_args_'.$edit_content['id'],$content);
//menuaction=calendar.calendar_uiforms.freetimesearch&values2url('start,end,duration,participants,recur_type,whole_day'),ft_search,700,500
$link = egw::link('/index.php',array(
'menuaction' => 'calendar.calendar_uiforms.freetimesearch',
'cal_id' => $edit_content['id'],
));
$response->addScriptCall('egw_openWindowCentered2',$link,'ft_search',700,500);
return $response->getXML();
}
/**
* Freetime search
*
* As the function is called in a popup via javascript, parametes get initialy transfered via the url
* @param array $content=null array with parameters or false (default) to use the get-params
* @param string start[str] start-date
* @param string start[hour] start-hour
* @param string start[min] start-minutes
* @param string end[str] end-date
* @param string end[hour] end-hour
* @param string end[min] end-minutes
* @param string participants ':' delimited string of user-id's
*/
function freetimesearch($content = null)
{
$etpl = new etemplate('calendar.freetimesearch');
$sel_options['search_window'] = array(
7*DAY_s => lang('one week'),
14*DAY_s => lang('two weeks'),
31*DAY_s => lang('one month'),
92*DAY_s => lang('three month'),
365*DAY_s => lang('one year'),
);
if (!is_array($content))
{
// get content from session (and delete it immediatly)
$content = egw_cache::getSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']);
egw_cache::unsetSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']);
// pick a searchwindow fitting the duration (search for a 10 day slot in a one week window never succeeds)
foreach($sel_options['search_window'] as $window => $label)
{

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="calendar.edit.general" template="" lang="" group="0" version="1.5.002">
<template id="calendar.edit.general" template="" lang="" group="0" version="1.7.001">
<hbox options="0,0">
<grid width="100%" height="200">
<columns>
@ -27,7 +27,7 @@
</row>
<row>
<description/>
<buttononly label="Freetime search" onclick="window.open(egw::link('/index.php','menuaction=calendar.calendar_uiforms.freetimesearch')+values2url(this.form,'start,end,duration,participants,recur_type,whole_day'),'ft_search','dependent=yes,width=700,height=500,scrollbars=yes,status=yes'); return false;" width="0" id="freetime" statustext="Find free timeslots where the selected participants are availible for the given timespan"/>
<buttononly label="Freetime search" onclick="ajax_submit(this.form,'calendar.calendar_uiforms.ajax_freetimesearch'); return false;" width="0" id="freetime" statustext="Find free timeslots where the selected participants are availible for the given timespan"/>
</row>
<row class="row">
<description options=",,,location" value="Location" width="0"/>
@ -276,7 +276,7 @@
<textbox size="80" maxlength="255" id="title" span="all" needed="1"/>
</row>
<row>
<tabbox span="all">
<tabbox span="all" id="general|description|participants|recurrence|custom|links|alarms">
<tabs>
<tab label="General" statustext="Location, Start- and Endtimes, ..."/>
<tab label="Description" statustext="Full description"/>