Fixes for globals and session data - which is mostly unused for now

This commit is contained in:
Miles Lott 2003-10-19 07:00:53 +00:00
parent 760bed3735
commit 4a49600904
2 changed files with 113 additions and 56 deletions

View File

@ -31,6 +31,7 @@
var $cat_id;
var $use_session = False;
var $debug = False;
function boXport($session=False)
{
@ -41,32 +42,60 @@
$this->read_sessiondata();
$this->use_session = True;
}
global $start,$limit,$query,$sort,$order,$filter,$cat_id;
$_start = get_var('_start',array('POST','GET'));
$_query = get_var('_query',array('POST','GET'));
$_sort = get_var('_sort',array('POST','GET'));
$_order = get_var('_order',array('POST','GET'));
$_filter = get_var('_filter',array('POST','GET'));
$_cat_id = get_var('_cat_id',array('POST','GET'));
$_fcat_id = get_var('_fcat_id',array('POST','GET'));
if($start || $start == 0) { $this->start = $start; }
if($limit) { $this->limit = $limit; }
if($query) { $this->query = $query; }
if($sort) { $this->sort = $sort; }
if($order) { $this->order = $order; }
if($filter) { $this->filter = $filter; }
$this->cat_id = $cat_id;
if(!empty($_start) || ($_start == '0') || ($_start == 0))
{
if($this->debug) { echo '<br>overriding $start: "' . $this->start . '" now "' . $_start . '"'; }
$this->start = $_start;
}
if($_limit)
{
$this->limit = $_limit;
}
if((empty($_query) && !empty($this->query)) || !empty($_query))
{
$this->query = $_query;
}
function save_sessiondata()
if(isset($GLOBALS['HTTP_POST_VARS']['fcat_id']) || isset($GLOBALS['HTTP_POST_VARS']['fcat_id']))
{
global $start,$limit,$query,$sort,$order,$filter,$cat_id;
$this->cat_id = $_fcat_id;
}
else
{
$this->cat_id = -1;
}
if(isset($_sort) && !empty($_sort))
{
if($this->debug) { echo '<br>overriding $sort: "' . $this->sort . '" now "' . $_sort . '"'; }
$this->sort = $_sort;
}
if(isset($_order) && !empty($_order))
{
if($this->debug) { echo '<br>overriding $order: "' . $this->order . '" now "' . $_order . '"'; }
$this->order = $_order;
}
if(isset($_filter) && !empty($_filter))
{
if($this->debug) { echo '<br>overriding $filter: "' . $this->filter . '" now "' . $_filter . '"'; }
$this->filter = $_filter;
}
}
function save_sessiondata($data)
{
if($this->use_session)
{
$data = array(
'start' => $start,
'limit' => $limit,
'query' => $query,
'sort' => $sort,
'order' => $order,
'filter' => $filter,
'cat_id' => $cat_id
);
if($this->debug) { echo '<br>Save:'; _debug_array($data); }
$GLOBALS['phpgw']->session->appsession('session_data','addressbook',$data);
}
@ -84,13 +113,17 @@
$this->order = $data['order'];
$this->filter = $data['filter'];
$this->cat_id = $data['cat_id'];
if($this->debug) { echo '<br>read_sessiondata();'; $this->_debug_sqsof(); }
}
function import($tsvfile,$conv_type,$private,$fcat_id)
{
include(PHPGW_APP_INC . '/import/' . $conv_type);
if ($private == '') { $private = 'public'; }
if($private == '')
{
$private = 'public';
}
$row = 0;
$buffer = array();
$contacts = new import_conv;
@ -159,12 +192,12 @@
$test = split(',mail=',$value);
if($test[1])
{
$name = "mail";
$name = 'mail';
$value = $test[1];
}
if($url)
{
$name = "homeurl";
$name = 'homeurl';
$value = $url. ':' . $value;
}
//echo '<br>'.$j.': '.$name.' => '.$value;
@ -221,8 +254,10 @@
}
}
if($needToCallEndRecord)
{
$buffer = $contacts->import_end_record($buffer);
}
}
fclose($fp);
$buffer = $contacts->import_end_file($buffer,$private,$fcat_id);
@ -251,6 +286,7 @@
'address2' => 'address2',
'address3' => 'address3'
);
if($contacts->type != 'vcard')
{
$contacts->qfields = $contacts->stock_contact_fields;# + $extrafields;# + $customfields;

View File

@ -37,6 +37,11 @@
$this->bo = CreateObject('addressbook.boXport',True);
$this->browser = CreateObject('phpgwapi.browser');
$this->_set_sessiondata();
}
function _set_sessiondata()
{
$this->start = $this->bo->start;
$this->limit = $this->bo->limit;
$this->query = $this->bo->query;
@ -44,6 +49,22 @@
$this->order = $this->bo->order;
$this->filter = $this->bo->filter;
$this->cat_id = $this->bo->cat_id;
if($this->debug) { $this->_debug_sqsof(); }
}
/* Called only by index(), just prior to page footer. */
function save_sessiondata()
{
$data = array(
'start' => $this->start,
'limit' => $this->limit,
'query' => $this->query,
'sort' => $this->sort,
'order' => $this->order,
'filter' => $this->filter,
'cat_id' => $this->cat_id
);
$this->bo->save_sessiondata($data);
}
/* Return a select form element with the categories option dialog in it */