diff --git a/addressbook/inc/class.boaddressbook.inc.php b/addressbook/inc/class.boaddressbook.inc.php index 7aa721fbff..7e5c5dc7d1 100644 --- a/addressbook/inc/class.boaddressbook.inc.php +++ b/addressbook/inc/class.boaddressbook.inc.php @@ -34,6 +34,7 @@ var $order; var $filter; var $cat_id; + var $total; var $use_session = False; @@ -117,6 +118,8 @@ function read_entries($start,$limit,$qcols,$qfilter,$userid='') { $entries = $this->so->read_entries($start,$limit,$qcols,$this->query,$qfilter,$this->sort,$this->order,$userid); + $this->total = $this->so->contacts->total_records; + if($this->debug) { echo '
Total records="' . $this->total . '"'; } return $this->strip_html($entries); } diff --git a/addressbook/inc/class.soaddressbook.inc.php b/addressbook/inc/class.soaddressbook.inc.php index 28baa50ad6..b32ed035e3 100644 --- a/addressbook/inc/class.soaddressbook.inc.php +++ b/addressbook/inc/class.soaddressbook.inc.php @@ -19,22 +19,30 @@ function soaddressbook() { - global $phpgw,$rights; + global $rights; - $phpgw->contacts = CreateObject('phpgwapi.contacts'); + $this->rights = $rights; + } - $this->contacts = $phpgw->contacts; - $this->rights = $rights; + function makeobj() + { + if (!is_object($this->contacts)) + { + $this->contacts = CreateObject('phpgwapi.contacts'); + } + return; } function read_entries($start,$offset,$qcols,$query,$qfilter,$sort,$order) { + $this->makeobj(); $readrights = $this->rights & PHPGW_ACL_READ; return $this->contacts->read($start,$offset,$qcols,$query,$qfilter,$sort,$order,$readrights); } function read_entry($id,$fields) { + $this->makeobj(); if ($this->rights & PHPGW_ACL_READ) { return $this->contacts->read_single_entry($id,$fields); @@ -48,6 +56,7 @@ function read_last_entry($fields) { + $this->makeobj(); if ($this->rights & PHPGW_ACL_READ) { return $this->contacts->read_last_entry($fields); @@ -61,6 +70,7 @@ function add_entry($userid,$fields) { + $this->makeobj(); if ($this->rights & PHPGW_ACL_ADD) { $this->contacts->add($userid,$fields,$fields['access'],$fields['cat_id'],$fields['tid']); @@ -70,6 +80,7 @@ function get_lastid() { + $this->makeobj(); $entry = $this->contacts->read_last_entry(); $ab_id = $entry[0]['id']; return $ab_id; @@ -77,6 +88,7 @@ function update_entry($userid,$fields) { + $this->makeobj(); if ($this->rights & PHPGW_ACL_EDIT) { $this->contacts->update($fields['ab_id'],$userid,$fields,$fields['access'],$fields['cat_id']); diff --git a/addressbook/inc/class.uiaddressbook.inc.php b/addressbook/inc/class.uiaddressbook.inc.php index 00788badc4..34a0e74aff 100644 --- a/addressbook/inc/class.uiaddressbook.inc.php +++ b/addressbook/inc/class.uiaddressbook.inc.php @@ -58,7 +58,7 @@ $this->bo = CreateObject('addressbook.boaddressbook',True); $this->template = $phpgw->template; - $this->contacts = $this->bo->so->contacts; + $this->contacts = CreateObject('phpgwapi.contacts'); $this->cat = CreateObject('phpgwapi.categories'); $this->company = CreateObject('phpgwapi.categories','addressbook_company'); $this->prefs = $phpgw_info['user']['preferences']['addressbook']; @@ -412,12 +412,13 @@ if ($nosearch && !$this->query) { $entries = array(); - $this->contacts->total_records = 0; + $total_records = 0; } else { /* read the entry list */ $entries = $this->bo->read_entries($this->start,$this->limit,$columns_to_display,$qfilter,$userid); + $total_records = $this->bo->total; } /* global here so nextmatchs accepts our setting of $query */ @@ -425,11 +426,11 @@ $query = $this->query; $search_filter = $phpgw->nextmatchs->show_tpl('/index.php', - $this->start, $this->contacts->total_records,'&menuaction=addressbook.uiaddressbook.get_list',"75%", + $this->start, $total_records,'&menuaction=addressbook.uiaddressbook.get_list',"75%", $phpgw_info["theme"]["th_bg"],1,1,1,1); $query = ''; - $lang_showing = $phpgw->nextmatchs->show_hits($this->contacts->total_records,$this->start); + $lang_showing = $phpgw->nextmatchs->show_hits($total_records,$this->start); /* set basic vars and parse the header */ $this->template->set_var('font',$phpgw_info['theme']['font']);