Begin move to classes for addressbook. Note ldap is a copy of sql for now.

This commit is contained in:
Miles Lott 2001-01-21 02:31:24 +00:00
parent b4996f1819
commit aba0107f88
8 changed files with 1086 additions and 409 deletions

View File

@ -24,6 +24,8 @@
@Header("Location: " . $phpgw->link($phpgw_info["server"]["webserver_url"] . "/addressbook/"));
}
$this = CreateObject("addressbook.addressbook");
if ($confirm != "true") {
$phpgw->db->query("select ab_owner from addressbook where ab_id='$ab_id'");
$phpgw->db->next_record();
@ -43,11 +45,10 @@
$phpgw->common->phpgw_footer();
} else {
$this->id = $ab_id;
$this->delete_entry();
$phpgw->db->query("delete from addressbook where ab_owner='" . $phpgw_info["user"]["account_id"]
. "' and ab_id='$ab_id'");
@Header("Location: " . $phpgw->link($phpgw_info["server"]["webserver_url"]. "/addressbook/",
"cd=16&order=$order&sort=$sort&filter=$filter&start=$start&query=$query"));
}
?>

View File

@ -29,104 +29,51 @@
$phpgw->common->phpgw_exit();
}
$this = CreateObject("addressbook.addressbook");
if (! $submit) {
$phpgw->db->query("SELECT * FROM addressbook WHERE ab_owner='"
. $phpgw_info["user"]["account_id"] . "' AND ab_id=$ab_id");
$phpgw->db->next_record();
$fields = array('ab_id' => $phpgw->db->f("ab_id"),
'owner' => $phpgw->db->f("ab_owner"),
'access' => $phpgw->db->f("ab_access"),
'firstname' => $phpgw->db->f("ab_firstname"),
'lastname' => $phpgw->db->f("ab_lastname"),
'title' => $phpgw->db->f("ab_title"),
'email' => $phpgw->db->f("ab_email"),
'hphone' => $phpgw->db->f("ab_hphone"),
'wphone' => $phpgw->db->f("ab_wphone"),
'fax' => $phpgw->db->f("ab_fax"),
'pager' => $phpgw->db->f("ab_pager"),
'mphone' => $phpgw->db->f("ab_mphone"),
'ophone' => $phpgw->db->f("ab_ophone"),
'street' => $phpgw->db->f("ab_street"),
'address2' => $phpgw->db->f("ab_address2"),
'city' => $phpgw->db->f("ab_city"),
'state' => $phpgw->db->f("ab_state"),
'zip' => $phpgw->db->f("ab_zip"),
'bday' => $phpgw->db->f("ab_bday"),
'company' => $phpgw->db->f("ab_company"),
'company_id' => $phpgw->db->f("ab_company_id"),
'notes' => $phpgw->db->f("ab_notes"),
'url' => $phpgw->db->f("ab_url")
);
$fields = $this->get_entry($ab_id);
form("","edit.php","Edit",$fields);
} else {
if ($url == "http://") {
$url = "";
}
if (! $bday_month && ! $bday_day && ! $bday_year) {
$bday = "";
} else {
$bday = "$bday_month/$bday_day/$bday_year";
}
if ($url == "http://") {
$url = "";
}
if (! $bday_month && ! $bday_day && ! $bday_year) {
$bday = "";
} else {
$bday = "$bday_month/$bday_day/$bday_year";
}
if ($access != "private" && $access != "public") {
$access = $phpgw->accounts->array_to_string($access,$n_groups);
$access = $phpgw->accounts->array_to_string($access,$n_groups);
}
if($phpgw_info["apps"]["timetrack"]["enabled"]) {
$sql = "UPDATE addressbook set ab_email='" . addslashes($email)
. "', ab_firstname='" . addslashes($firstname)
. "', ab_lastname='" . addslashes($lastname)
. "', ab_title='" . addslashes($title)
. "', ab_hphone='" . addslashes($hphone)
. "', ab_wphone='" . addslashes($wphone)
. "', ab_fax='" . addslashes($fax)
. "', ab_pager='" . addslashes($pager)
. "', ab_mphone='" . addslashes($mphone)
. "', ab_ophone='" . addslashes($ophone)
. "', ab_street='" . addslashes($street)
. "', ab_address2='" . addslashes($address2)
. "', ab_city='" . addslashes($city)
. "', ab_state='" . addslashes($state)
. "', ab_zip='" . addslashes($zip)
. "', ab_bday='" . addslashes($bday)
. "', ab_notes='" . addslashes($notes)
. "', ab_company_id='" . addslashes($company)
. "', ab_access='" . addslashes($access)
. "', ab_url='" . addslashes($url)
. "' WHERE ab_owner='" . $phpgw_info["user"]["account_id"] . "' AND ab_id=$ab_id";
} else {
$sql = "UPDATE addressbook set ab_email='" . addslashes($email)
. "', ab_firstname='". addslashes($firstname)
. "', ab_lastname='" . addslashes($lastname)
. "', ab_title='" . addslashes($title)
. "', ab_hphone='" . addslashes($hphone)
. "', ab_wphone='" . addslashes($wphone)
. "', ab_fax='" . addslashes($fax)
. "', ab_pager='" . addslashes($pager)
. "', ab_mphone='" . addslashes($mphone)
. "', ab_ophone='" . addslashes($ophone)
. "', ab_street='" . addslashes($street)
. "', ab_address2='" . addslashes($address2)
. "', ab_city='" . addslashes($city)
. "', ab_state='" . addslashes($state)
. "', ab_zip='" . addslashes($zip)
. "', ab_bday='" . addslashes($bday)
. "', ab_notes='" . addslashes($notes)
. "', ab_company='" . addslashes($company)
. "', ab_access='" . addslashes($access)
. "', ab_url='" . addslashes($url)
. "' WHERE ab_owner='" . $phpgw_info["user"]["account_id"] . "' AND ab_id=$ab_id";
}
$this->id = $ab_id;
$this->company = $company;
$this->firstname = $firstname;
$this->lastname = $lastname;
$this->email = $email;
$this->title = $title;
$this->wphone = $wphone;
$this->hphone = $hphone;
$this->fax = $fax;
$this->pager = $pager;
$this->mphone = $mphone;
$this->ophone = $ophone;
$this->street = $street;
$this->address2 = $address2;
$this->city = $city;
$this->state = $state;
$this->zip = $zip;
$this->bday = $bday;
$this->url = $url;
$this->notes = $notes;
$this->access = $access;
$phpgw->db->query($sql);
$this->update_entry($this);
Header("Location: " . $phpgw->link("view.php","&ab_id=$ab_id&order=$order&sort=$sort&filter="
. "$filter&start=$start"));
$phpgw->common->phpgw_exit();
Header("Location: " . $phpgw->link("view.php","&ab_id=$ab_id&order=$order&sort=$sort&filter="
. "$filter&start=$start"));
$phpgw->common->phpgw_exit();
}
$t->set_var("ab_id",$ab_id);
@ -145,6 +92,5 @@
$t->parse("out","edit");
$t->pparse("out","edit");
$phpgw->common->phpgw_footer();
?>

View File

@ -0,0 +1,4 @@
<?php
include($phpgw_info["server"]["include_root"]."/addressbook/inc/class.addressbook_".$phpgw_info["server"]["account_repository"].".inc.php");
include($phpgw_info["server"]["include_root"]."/addressbook/inc/class.addressbook_shared.inc.php");
?>

View File

@ -0,0 +1,310 @@
<?php
/**************************************************************************\
* phpGroupWare - addressbook sql *
* http://www.phpgroupware.org *
* Written by Joseph Engo <jengo@phpgroupware.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
class addressbook_
{
var $id;
var $company;
var $firstname;
var $lastname;
var $email;
var $wphone;
var $hphone;
var $company;
var $fax;
var $pager;
var $mphone;
var $ophone;
var $street;
var $city;
var $state;
var $zip;
var $bday;
var $url;
var $notes;
var $access;
var $searchreturn;
var $search_filter;
var $lang_showing;
var $columns_to_display;
var $cols;
function get_entry($id) {
global $phpgw,$phpgw_info;
$phpgw->db->query("SELECT * FROM addressbook WHERE ab_owner='"
. $phpgw_info["user"]["account_id"] . "' AND ab_id='".$id."'");
$phpgw->db->next_record();
$this->ab_id = stripslashes($phpgw->db->f("ab_id"));
$this->owner = stripslashes($phpgw->db->f("ab_owner"));
$this->access = stripslashes($phpgw->db->f("ab_access"));
$this->firstname = stripslashes($phpgw->db->f("ab_firstname"));
$this->lastname = stripslashes($phpgw->db->f("ab_lastname"));
$this->title = stripslashes($phpgw->db->f("ab_title"));
$this->email = stripslashes($phpgw->db->f("ab_email"));
$this->hphone = stripslashes($phpgw->db->f("ab_hphone"));
$this->wphone = stripslashes($phpgw->db->f("ab_wphone"));
$this->fax = stripslashes($phpgw->db->f("ab_fax"));
$this->pager = stripslashes($phpgw->db->f("ab_pager"));
$this->mphone = stripslashes($phpgw->db->f("ab_mphone"));
$this->ophone = stripslashes($phpgw->db->f("ab_ophone"));
$this->street = stripslashes($phpgw->db->f("ab_street"));
$this->address2 = stripslashes($phpgw->db->f("ab_address2"));
$this->city = stripslashes($phpgw->db->f("ab_city"));
$this->state = stripslashes($phpgw->db->f("ab_state"));
$this->zip = stripslashes($phpgw->db->f("ab_zip"));
$this->bday = stripslashes($phpgw->db->f("ab_bday"));
$this->company = stripslashes($phpgw->db->f("ab_company"));
$this->company_id = stripslashes($phpgw->db->f("ab_company_id"));
$this->notes = stripslashes($phpgw->db->f("ab_notes"));
$this->url = stripslashes($phpgw->db->f("ab_url"));
$this->access = stripslashes($phpgw->db->f("ab_access"));
return $this;
}
function update_entry() {
global $phpgw,$phpgw_info;
if($phpgw_info["apps"]["timetrack"]["enabled"]) {
$sql = "UPDATE addressbook set "
. " ab_email='" . addslashes($this->email)
. "', ab_firstname='" . addslashes($this->firstname)
. "', ab_lastname='" . addslashes($this->lastname)
. "', ab_title='" . addslashes($this->title)
. "', ab_hphone='" . addslashes($this->hphone)
. "', ab_wphone='" . addslashes($this->wphone)
. "', ab_company='" . addslashes($this->company)
. "', ab_fax='" . addslashes($this->fax)
. "', ab_pager='" . addslashes($this->pager)
. "', ab_mphone='" . addslashes($this->mphone)
. "', ab_ophone='" . addslashes($this->ophone)
. "', ab_street='" . addslashes($this->street)
. "', ab_address2='" . addslashes($this->address2)
. "', ab_city='" . addslashes($this->city)
. "', ab_state='" . addslashes($this->state)
. "', ab_zip='" . addslashes($this->zip)
. "', ab_bday='" . addslashes($this->bday)
. "', ab_notes='" . addslashes($this->notes)
. "', ab_company_id='" . addslashes($this->company_id)
. "', ab_access='" . addslashes($this->access)
. "', ab_url='" . addslashes($this->url)
. "' WHERE ab_owner='" . $phpgw_info["user"]["account_id"]
. "' AND ab_id='" . $this->id."'";
} else {
$sql = "UPDATE addressbook set "
. " ab_email='" . addslashes($this->email)
. "', ab_firstname='" . addslashes($this->firstname)
. "', ab_lastname='" . addslashes($this->lastname)
. "', ab_title='" . addslashes($this->title)
. "', ab_hphone='" . addslashes($this->hphone)
. "', ab_wphone='" . addslashes($this->wphone)
. "', ab_fax='" . addslashes($this->fax)
. "', ab_pager='" . addslashes($this->pager)
. "', ab_mphone='" . addslashes($this->mphone)
. "', ab_ophone='" . addslashes($this->ophone)
. "', ab_street='" . addslashes($this->street)
. "', ab_address2='" . addslashes($this->address2)
. "', ab_city='" . addslashes($this->city)
. "', ab_state='" . addslashes($this->state)
. "', ab_zip='" . addslashes($this->zip)
. "', ab_bday='" . addslashes($this->bday)
. "', ab_notes='" . addslashes($this->notes)
. "', ab_company='" . addslashes($this->company)
. "', ab_access='" . addslashes($this->access)
. "', ab_url='" . addslashes($this->url)
. "' WHERE ab_owner='" . $phpgw_info["user"]["account_id"]
. "' AND ab_id='" . $this->id."'";
}
$phpgw->db->query($sql);
return;
}
function delete_entry() {
global $phpgw,$phpgw_info;
$phpgw->db->query("delete from addressbook where ab_owner='"
. $phpgw_info["user"]["account_id"]
. "' and ab_id='".$this->id."'");
return;
}
function count_entries() {
global $phpgw,$phpgw_info;
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
$phpgw->db->query("SELECT count(*) "
. "from addressbook as a, customers as c where a.ab_company_id = c.company_id "
. "AND $filtermethod AND (a.ab_lastname like '"
. "%$query%' OR a.ab_firstname like '%$query%' OR a.ab_email like '%$query%' OR "
. "a.ab_street like '%$query%' OR a.ab_city like '%$query%' OR a.ab_state "
. "like '%$query%' OR a.ab_zip like '%$query%' OR a.ab_notes like "
. "'%$query%' OR c.company_name like '%$query%' OR a.ab_url like '%$query%')",__LINE__,__FILE__);
// . "'%$query%' OR c.company_name like '%$query%')"
} else {
$phpgw->db->query("SELECT count(*) "
. "from addressbook "
. "WHERE $filtermethod AND (ab_lastname like '"
. "%$query%' OR ab_firstname like '%$query%' OR ab_email like '%$query%' OR "
. "ab_street like '%$query%' OR ab_city like '%$query%' OR ab_state "
. "like '%$query%' OR ab_zip like '%$query%' OR ab_notes like "
. "'%$query%' OR ab_company like '%$query%' OR ab_url like '%$query$%')",__LINE__,__FILE__);
// . "'%$query%' OR ab_company like '%$query%')"
}
$phpgw->db->next_record();
if ($phpgw->db->f(0) == 1) {
return lang("your search returned 1 match");
} else {
$this->limit = $phpgw->db->f(0);
return lang("your search returned x matchs",$phpgw->db->f(0));
}
}
function get_entries($query="",$filter="",$sort="",$order="",$start=0) {
global $phpgw,$phpgw_info,$abc;
$limit = $phpgw->nextmatchs->sql_limit($start);
if ($order) {
$ordermethod = "order by $order $sort";
} else {
$ordermethod = "order by ab_lastname,ab_firstname,ab_email asc";
}
if (! $filter) {
$filter = "none";
}
if ($filter != "private") {
if ($filter != "none") {
$filtermethod = " ab_access like '%,$filter,%' ";
} else {
$filtermethod = " (ab_owner='" . $phpgw_info["user"]["account_id"] ."' OR ab_access='public' "
. $phpgw->accounts->sql_search("ab_access") . " ) ";
}
} else {
$filtermethod = " ab_owner='" . $phpgw_info["user"]["account_id"] . "' ";
}
if ($query) {
$this->searchreturn=$this->count_entries();
} else {
$this->searchreturn="";
$phpgw->db->query("select count(*) from addressbook where $filtermethod",__LINE__,__FILE__);
$phpgw->db->next_record();
}
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
$company_sortorder = "c.company_name";
} else {
$company_sortorder = "ab_company";
}
//$phpgw->db->next_record();
if ($phpgw->db->f(0) > $phpgw_info["user"]["preferences"]["common"]["maxmatchs"]) {
$this->lang_showing=lang("showing x - x of x",($start + 1),($start + $phpgw_info["user"]["preferences"]["common"]["maxmatchs"]),$phpgw->db->f(0));
} else {
$this->lang_showing=lang("showing x",$phpgw->db->f(0));
}
$this->search_filter = $phpgw->nextmatchs->show_tpl("index.php",$start,$phpgw->db->f(0),"&order=$order&filter=$filter&sort=$sort&query=$query", "75%", $phpgw_info["theme"]["th_bg"]);
while ($column = each($abc)) {
if (isset($phpgw_info["user"]["preferences"]["addressbook"][$column[0]]) &&
$phpgw_info["user"]["preferences"]["addressbook"][$column[0]]) {
$this->cols .= '<td height="21">';
$this->cols .= '<font size="-1" face="Arial, Helvetica, sans-serif">';
$this->cols .= $phpgw->nextmatchs->show_sort_order($sort,"ab_" . $column[0],$order,"index.php",lang($column[1]));
$this->cols .= '</font></td>';
$this->cols .= "\n";
// To be used when displaying the rows
$this->columns_to_display[$column[0]] = True;
}
}
if (isset($query) && $query) {
if (isset($phpgw_info["apps"]["timetrack"]["enabled"]) &&
$phpgw_info["apps"]["timetrack"]["enabled"]) {
$phpgw->db->query("SELECT a.ab_id,a.ab_owner,a.ab_firstname,a.ab_lastname,a.ab_company_id,"
. "a.ab_email,a.ab_wphone,c.company_name,a.ab_hphone,a.ab_fax,a.ab_mphone "
. "from addressbook as a, customers as c where a.ab_company_id = c.company_id "
. "AND $filtermethod AND (a.ab_lastname like '"
. "%$query%' OR a.ab_firstname like '%$query%' OR a.ab_email like '%$query%' OR "
. "a.ab_street like '%$query%' OR a.ab_city like '%$query%' OR a.ab_state "
. "like '%$query%' OR a.ab_zip like '%$query%' OR a.ab_notes like "
. "'%$query%' OR c.company_name like '%$query%') $ordermethod limit $limit",__LINE__,__FILE__);
} else {
$phpgw->db->query("SELECT * from addressbook WHERE $filtermethod AND (ab_lastname like '"
. "%$query%' OR ab_firstname like '%$query%' OR ab_email like '%$query%' OR "
. "ab_street like '%$query%' OR ab_city like '%$query%' OR ab_state "
. "like '%$query%' OR ab_zip like '%$query%' OR ab_notes like "
. "'%$query%' OR ab_company like '%$query%') $ordermethod limit $limit",__LINE__,__FILE__);
}
} else {
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
$phpgw->db->query("SELECT a.ab_id,a.ab_owner,a.ab_firstname,a.ab_lastname,"
. "a.ab_email,a.ab_wphone,c.company_name "
. "from addressbook as a, customers as c where a.ab_company_id = c.company_id "
. "AND $filtermethod $ordermethod limit $limit",__LINE__,__FILE__);
} else {
$phpgw->db->query("SELECT * from addressbook WHERE $filtermethod $ordermethod limit $limit",__LINE__,__FILE__);
}
}
$i=0;
while ($phpgw->db->next_record()) {
$this->ab_id[$i] = htmlentities(stripslashes($phpgw->db->f("ab_id")));
$this->owner[$i] = htmlentities(stripslashes($phpgw->db->f("ab_owner")));
$this->access[$i] = htmlentities(stripslashes($phpgw->db->f("ab_access")));
$this->firstname[$i] = htmlentities(stripslashes($phpgw->db->f("ab_firstname")));
$this->lastname[$i] = htmlentities(stripslashes($phpgw->db->f("ab_lastname")));
$this->title[$i] = htmlentities(stripslashes($phpgw->db->f("ab_title")));
$this->email[$i] = htmlentities(stripslashes($phpgw->db->f("ab_email")));
$this->hphone[$i] = htmlentities(stripslashes($phpgw->db->f("ab_hphone")));
$this->wphone[$i] = htmlentities(stripslashes($phpgw->db->f("ab_wphone")));
$this->fax[$i] = htmlentities(stripslashes($phpgw->db->f("ab_fax")));
$this->pager[$i] = htmlentities(stripslashes($phpgw->db->f("ab_pager")));
$this->mphone[$i] = htmlentities(stripslashes($phpgw->db->f("ab_mphone")));
$this->ophone[$i] = htmlentities(stripslashes($phpgw->db->f("ab_ophone")));
$this->street[$i] = htmlentities(stripslashes($phpgw->db->f("ab_street")));
$this->address2[$i] = htmlentities(stripslashes($phpgw->db->f("ab_address2")));
$this->city[$i] = htmlentities(stripslashes($phpgw->db->f("ab_city")));
$this->state[$i] = htmlentities(stripslashes($phpgw->db->f("ab_state")));
$this->zip[$i] = htmlentities(stripslashes($phpgw->db->f("ab_zip")));
$this->bday[$i] = htmlentities(stripslashes($phpgw->db->f("ab_bday")));
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
$this->company[$i] = htmlentities(stripslashes($phpgw->db->f("ab_company")));
} else {
$this->company[$i] = htmlentities(stripslashes($phpgw->db->f("company_name")));
}
$this->company_id[$i] = htmlentities(stripslashes($phpgw->db->f("ab_company_id")));
$this->notes[$i] = htmlentities(stripslashes($phpgw->db->f("ab_notes")));
if ($phpgw->db->f("ab_url")) {
if (! ereg("^http://",$phpgw->db->f("ab_url")) ) {
$this->url[$i] = htmlentities("http://".stripslashes($phpgw->db->f("ab_url")));
} else {
$this->url[$i] = htmlentities(stripslashes($phpgw->db->f("ab_url")));
}
} else {
$this->url[$i] = htmlentities("");
}
$i++;
}
return $this;
}
}
?>

View File

@ -0,0 +1,36 @@
<?php
/**************************************************************************\
* phpGroupWare - addressbook *
* http://www.phpgroupware.org *
* Written by Joseph Engo <jengo@phpgroupware.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
class addressbook extends addressbook_
{
function colname($column,$listid) {
if ($column == "company") return $this->company[$listid];
elseif ($column == "firstname") return $this->firstname[$listid];
elseif ($column == "lastname") return $this->lastname[$listid];
elseif ($column == "email") return $this->email[$listid];
elseif ($column == "wphone") return $this->wphone[$listid];
elseif ($column == "hphone") return $this->hphone[$listid];
elseif ($column == "fax") return $this->fax[$listid];
elseif ($column == "pager") return $this->pager[$listid];
elseif ($column == "mphone") return $this->mphone[$listid];
elseif ($column == "ophone") return $this->ophone[$listid];
elseif ($column == "street") return $this->street[$listid];
elseif ($column == "city") return $this->city[$listid];
elseif ($column == "state") return $this->state[$listid];
elseif ($column == "zip") return $this->zip[$listid];
elseif ($column == "bday") return $this->bday[$listid];
elseif ($column == "url") return $this->url[$listid];
else return "";
}
}
?>

View File

@ -0,0 +1,310 @@
<?php
/**************************************************************************\
* phpGroupWare - addressbook sql *
* http://www.phpgroupware.org *
* Written by Joseph Engo <jengo@phpgroupware.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
class addressbook_
{
var $id;
var $company;
var $firstname;
var $lastname;
var $email;
var $wphone;
var $hphone;
var $company;
var $fax;
var $pager;
var $mphone;
var $ophone;
var $street;
var $city;
var $state;
var $zip;
var $bday;
var $url;
var $notes;
var $access;
var $searchreturn;
var $search_filter;
var $lang_showing;
var $columns_to_display;
var $cols;
function get_entry($id) {
global $phpgw,$phpgw_info;
$phpgw->db->query("SELECT * FROM addressbook WHERE ab_owner='"
. $phpgw_info["user"]["account_id"] . "' AND ab_id='".$id."'");
$phpgw->db->next_record();
$this->ab_id = stripslashes($phpgw->db->f("ab_id"));
$this->owner = stripslashes($phpgw->db->f("ab_owner"));
$this->access = stripslashes($phpgw->db->f("ab_access"));
$this->firstname = stripslashes($phpgw->db->f("ab_firstname"));
$this->lastname = stripslashes($phpgw->db->f("ab_lastname"));
$this->title = stripslashes($phpgw->db->f("ab_title"));
$this->email = stripslashes($phpgw->db->f("ab_email"));
$this->hphone = stripslashes($phpgw->db->f("ab_hphone"));
$this->wphone = stripslashes($phpgw->db->f("ab_wphone"));
$this->fax = stripslashes($phpgw->db->f("ab_fax"));
$this->pager = stripslashes($phpgw->db->f("ab_pager"));
$this->mphone = stripslashes($phpgw->db->f("ab_mphone"));
$this->ophone = stripslashes($phpgw->db->f("ab_ophone"));
$this->street = stripslashes($phpgw->db->f("ab_street"));
$this->address2 = stripslashes($phpgw->db->f("ab_address2"));
$this->city = stripslashes($phpgw->db->f("ab_city"));
$this->state = stripslashes($phpgw->db->f("ab_state"));
$this->zip = stripslashes($phpgw->db->f("ab_zip"));
$this->bday = stripslashes($phpgw->db->f("ab_bday"));
$this->company = stripslashes($phpgw->db->f("ab_company"));
$this->company_id = stripslashes($phpgw->db->f("ab_company_id"));
$this->notes = stripslashes($phpgw->db->f("ab_notes"));
$this->url = stripslashes($phpgw->db->f("ab_url"));
$this->access = stripslashes($phpgw->db->f("ab_access"));
return $this;
}
function update_entry() {
global $phpgw,$phpgw_info;
if($phpgw_info["apps"]["timetrack"]["enabled"]) {
$sql = "UPDATE addressbook set "
. " ab_email='" . addslashes($this->email)
. "', ab_firstname='" . addslashes($this->firstname)
. "', ab_lastname='" . addslashes($this->lastname)
. "', ab_title='" . addslashes($this->title)
. "', ab_hphone='" . addslashes($this->hphone)
. "', ab_wphone='" . addslashes($this->wphone)
. "', ab_company='" . addslashes($this->company)
. "', ab_fax='" . addslashes($this->fax)
. "', ab_pager='" . addslashes($this->pager)
. "', ab_mphone='" . addslashes($this->mphone)
. "', ab_ophone='" . addslashes($this->ophone)
. "', ab_street='" . addslashes($this->street)
. "', ab_address2='" . addslashes($this->address2)
. "', ab_city='" . addslashes($this->city)
. "', ab_state='" . addslashes($this->state)
. "', ab_zip='" . addslashes($this->zip)
. "', ab_bday='" . addslashes($this->bday)
. "', ab_notes='" . addslashes($this->notes)
. "', ab_company_id='" . addslashes($this->company_id)
. "', ab_access='" . addslashes($this->access)
. "', ab_url='" . addslashes($this->url)
. "' WHERE ab_owner='" . $phpgw_info["user"]["account_id"]
. "' AND ab_id='" . $this->id."'";
} else {
$sql = "UPDATE addressbook set "
. " ab_email='" . addslashes($this->email)
. "', ab_firstname='" . addslashes($this->firstname)
. "', ab_lastname='" . addslashes($this->lastname)
. "', ab_title='" . addslashes($this->title)
. "', ab_hphone='" . addslashes($this->hphone)
. "', ab_wphone='" . addslashes($this->wphone)
. "', ab_fax='" . addslashes($this->fax)
. "', ab_pager='" . addslashes($this->pager)
. "', ab_mphone='" . addslashes($this->mphone)
. "', ab_ophone='" . addslashes($this->ophone)
. "', ab_street='" . addslashes($this->street)
. "', ab_address2='" . addslashes($this->address2)
. "', ab_city='" . addslashes($this->city)
. "', ab_state='" . addslashes($this->state)
. "', ab_zip='" . addslashes($this->zip)
. "', ab_bday='" . addslashes($this->bday)
. "', ab_notes='" . addslashes($this->notes)
. "', ab_company='" . addslashes($this->company)
. "', ab_access='" . addslashes($this->access)
. "', ab_url='" . addslashes($this->url)
. "' WHERE ab_owner='" . $phpgw_info["user"]["account_id"]
. "' AND ab_id='" . $this->id."'";
}
$phpgw->db->query($sql);
return;
}
function delete_entry() {
global $phpgw,$phpgw_info;
$phpgw->db->query("delete from addressbook where ab_owner='"
. $phpgw_info["user"]["account_id"]
. "' and ab_id='".$this->id."'");
return;
}
function count_entries() {
global $phpgw,$phpgw_info;
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
$phpgw->db->query("SELECT count(*) "
. "from addressbook as a, customers as c where a.ab_company_id = c.company_id "
. "AND $filtermethod AND (a.ab_lastname like '"
. "%$query%' OR a.ab_firstname like '%$query%' OR a.ab_email like '%$query%' OR "
. "a.ab_street like '%$query%' OR a.ab_city like '%$query%' OR a.ab_state "
. "like '%$query%' OR a.ab_zip like '%$query%' OR a.ab_notes like "
. "'%$query%' OR c.company_name like '%$query%' OR a.ab_url like '%$query%')",__LINE__,__FILE__);
// . "'%$query%' OR c.company_name like '%$query%')"
} else {
$phpgw->db->query("SELECT count(*) "
. "from addressbook "
. "WHERE $filtermethod AND (ab_lastname like '"
. "%$query%' OR ab_firstname like '%$query%' OR ab_email like '%$query%' OR "
. "ab_street like '%$query%' OR ab_city like '%$query%' OR ab_state "
. "like '%$query%' OR ab_zip like '%$query%' OR ab_notes like "
. "'%$query%' OR ab_company like '%$query%' OR ab_url like '%$query$%')",__LINE__,__FILE__);
// . "'%$query%' OR ab_company like '%$query%')"
}
$phpgw->db->next_record();
if ($phpgw->db->f(0) == 1) {
return lang("your search returned 1 match");
} else {
$this->limit = $phpgw->db->f(0);
return lang("your search returned x matchs",$phpgw->db->f(0));
}
}
function get_entries($query="",$filter="",$sort="",$order="",$start=0) {
global $phpgw,$phpgw_info,$abc;
$limit = $phpgw->nextmatchs->sql_limit($start);
if ($order) {
$ordermethod = "order by $order $sort";
} else {
$ordermethod = "order by ab_lastname,ab_firstname,ab_email asc";
}
if (! $filter) {
$filter = "none";
}
if ($filter != "private") {
if ($filter != "none") {
$filtermethod = " ab_access like '%,$filter,%' ";
} else {
$filtermethod = " (ab_owner='" . $phpgw_info["user"]["account_id"] ."' OR ab_access='public' "
. $phpgw->accounts->sql_search("ab_access") . " ) ";
}
} else {
$filtermethod = " ab_owner='" . $phpgw_info["user"]["account_id"] . "' ";
}
if ($query) {
$this->searchreturn=$this->count_entries();
} else {
$this->searchreturn="";
$phpgw->db->query("select count(*) from addressbook where $filtermethod",__LINE__,__FILE__);
$phpgw->db->next_record();
}
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
$company_sortorder = "c.company_name";
} else {
$company_sortorder = "ab_company";
}
//$phpgw->db->next_record();
if ($phpgw->db->f(0) > $phpgw_info["user"]["preferences"]["common"]["maxmatchs"]) {
$this->lang_showing=lang("showing x - x of x",($start + 1),($start + $phpgw_info["user"]["preferences"]["common"]["maxmatchs"]),$phpgw->db->f(0));
} else {
$this->lang_showing=lang("showing x",$phpgw->db->f(0));
}
$this->search_filter = $phpgw->nextmatchs->show_tpl("index.php",$start,$phpgw->db->f(0),"&order=$order&filter=$filter&sort=$sort&query=$query", "75%", $phpgw_info["theme"]["th_bg"]);
while ($column = each($abc)) {
if (isset($phpgw_info["user"]["preferences"]["addressbook"][$column[0]]) &&
$phpgw_info["user"]["preferences"]["addressbook"][$column[0]]) {
$this->cols .= '<td height="21">';
$this->cols .= '<font size="-1" face="Arial, Helvetica, sans-serif">';
$this->cols .= $phpgw->nextmatchs->show_sort_order($sort,"ab_" . $column[0],$order,"index.php",lang($column[1]));
$this->cols .= '</font></td>';
$this->cols .= "\n";
// To be used when displaying the rows
$this->columns_to_display[$column[0]] = True;
}
}
if (isset($query) && $query) {
if (isset($phpgw_info["apps"]["timetrack"]["enabled"]) &&
$phpgw_info["apps"]["timetrack"]["enabled"]) {
$phpgw->db->query("SELECT a.ab_id,a.ab_owner,a.ab_firstname,a.ab_lastname,a.ab_company_id,"
. "a.ab_email,a.ab_wphone,c.company_name,a.ab_hphone,a.ab_fax,a.ab_mphone "
. "from addressbook as a, customers as c where a.ab_company_id = c.company_id "
. "AND $filtermethod AND (a.ab_lastname like '"
. "%$query%' OR a.ab_firstname like '%$query%' OR a.ab_email like '%$query%' OR "
. "a.ab_street like '%$query%' OR a.ab_city like '%$query%' OR a.ab_state "
. "like '%$query%' OR a.ab_zip like '%$query%' OR a.ab_notes like "
. "'%$query%' OR c.company_name like '%$query%') $ordermethod limit $limit",__LINE__,__FILE__);
} else {
$phpgw->db->query("SELECT * from addressbook WHERE $filtermethod AND (ab_lastname like '"
. "%$query%' OR ab_firstname like '%$query%' OR ab_email like '%$query%' OR "
. "ab_street like '%$query%' OR ab_city like '%$query%' OR ab_state "
. "like '%$query%' OR ab_zip like '%$query%' OR ab_notes like "
. "'%$query%' OR ab_company like '%$query%') $ordermethod limit $limit",__LINE__,__FILE__);
}
} else {
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
$phpgw->db->query("SELECT a.ab_id,a.ab_owner,a.ab_firstname,a.ab_lastname,"
. "a.ab_email,a.ab_wphone,c.company_name "
. "from addressbook as a, customers as c where a.ab_company_id = c.company_id "
. "AND $filtermethod $ordermethod limit $limit",__LINE__,__FILE__);
} else {
$phpgw->db->query("SELECT * from addressbook WHERE $filtermethod $ordermethod limit $limit",__LINE__,__FILE__);
}
}
$i=0;
while ($phpgw->db->next_record()) {
$this->ab_id[$i] = htmlentities(stripslashes($phpgw->db->f("ab_id")));
$this->owner[$i] = htmlentities(stripslashes($phpgw->db->f("ab_owner")));
$this->access[$i] = htmlentities(stripslashes($phpgw->db->f("ab_access")));
$this->firstname[$i] = htmlentities(stripslashes($phpgw->db->f("ab_firstname")));
$this->lastname[$i] = htmlentities(stripslashes($phpgw->db->f("ab_lastname")));
$this->title[$i] = htmlentities(stripslashes($phpgw->db->f("ab_title")));
$this->email[$i] = htmlentities(stripslashes($phpgw->db->f("ab_email")));
$this->hphone[$i] = htmlentities(stripslashes($phpgw->db->f("ab_hphone")));
$this->wphone[$i] = htmlentities(stripslashes($phpgw->db->f("ab_wphone")));
$this->fax[$i] = htmlentities(stripslashes($phpgw->db->f("ab_fax")));
$this->pager[$i] = htmlentities(stripslashes($phpgw->db->f("ab_pager")));
$this->mphone[$i] = htmlentities(stripslashes($phpgw->db->f("ab_mphone")));
$this->ophone[$i] = htmlentities(stripslashes($phpgw->db->f("ab_ophone")));
$this->street[$i] = htmlentities(stripslashes($phpgw->db->f("ab_street")));
$this->address2[$i] = htmlentities(stripslashes($phpgw->db->f("ab_address2")));
$this->city[$i] = htmlentities(stripslashes($phpgw->db->f("ab_city")));
$this->state[$i] = htmlentities(stripslashes($phpgw->db->f("ab_state")));
$this->zip[$i] = htmlentities(stripslashes($phpgw->db->f("ab_zip")));
$this->bday[$i] = htmlentities(stripslashes($phpgw->db->f("ab_bday")));
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
$this->company[$i] = htmlentities(stripslashes($phpgw->db->f("ab_company")));
} else {
$this->company[$i] = htmlentities(stripslashes($phpgw->db->f("company_name")));
}
$this->company_id[$i] = htmlentities(stripslashes($phpgw->db->f("ab_company_id")));
$this->notes[$i] = htmlentities(stripslashes($phpgw->db->f("ab_notes")));
if ($phpgw->db->f("ab_url")) {
if (! ereg("^http://",$phpgw->db->f("ab_url")) ) {
$this->url[$i] = htmlentities("http://".stripslashes($phpgw->db->f("ab_url")));
} else {
$this->url[$i] = htmlentities(stripslashes($phpgw->db->f("ab_url")));
}
} else {
$this->url[$i] = htmlentities("");
}
$i++;
}
return $this;
}
}
?>

View File

@ -15,7 +15,7 @@
// NOTE: This entire file needs to be rewritten. There is a great deal of code not being used
// anymore. This should also be converted to templates while where at it (jengo)
$abc = array('company' => 'company', // AddressBook Columns and their descriptions
$abc = array('company' => 'company', // AddressBook Columns and their descriptions
'firstname' => 'first name',
'lastname' => 'last name',
'email' => 'email',
@ -23,6 +23,7 @@
'hphone' => 'home phone',
'fax' => 'fax',
'pager' => 'pager',
'title' => 'title',
'mphone' => 'mobile phone',
'ophone' => 'other phone',
'street' => 'street',
@ -33,124 +34,124 @@
'url' => 'URL'
);
function form($format,$action,$title,$fields)
{
global $phpgw, $phpgw_info;
$t = new Template($phpgw_info["server"]["app_tpl"]);
$t->set_file(array( "form" => "form.tpl"));
function form($format,$action,$title,$fields) {
global $phpgw, $phpgw_info;
$email = $fields["email"];
$firstname = $fields["firstname"];
$lastname = $fields["lastname"];
$title = $fields["title"];
$hphone = $fields["hphone"];
$wphone = $fields["wphone"];
$faxi = $fields["fax"];
$pager = $fields["pager"];
$mphone = $fields["mphone"];
$ophone = $fields["ophone"];
$street = $fields["street"];
$address2 = $fields["address2"];
$city = $fields["city"];
$state = $fields["state"];
$zip = $fields["zip"];
$bday = $fields["bday"];
$notes = $fields["notes"];
$access = $fields["access"];
$ab_company = $fields["company"];
$company_id = $fields["company_id"];
$company_name = $fields["company_name"];
$url = $fields["url"];
$t = new Template($phpgw_info["server"]["app_tpl"]);
$t->set_file(array( "form" => "form.tpl"));
$email = $fields->email;
$firstname = $fields->firstname;
$lastname = $fields->lastname;
$title = $fields->title;
$hphone = $fields->hphone;
$wphone = $fields->wphone;
$fax = $fields->fax;
$pager = $fields->pager;
$mphone = $fields->mphone;
$ophone = $fields->ophone;
$street = $fields->street;
$address2 = $fields->address2;
$city = $fields->city;
$state = $fields->state;
$zip = $fields->zip;
$bday = $fields->bday;
$notes = $fields->notes;
$access = $fields->access;
$ab_company = $fields->company;
$company_id = $fields->company_id;
$company_name = $fields->company_name;
$url = $fields->url;
if ($format != "view") {
$email = "<input name=\"email\" value=\"$email\">";
$firstname = "<input name=\"firstname\" value=\"$firstname\">";
$lastname = "<input name=\"lastname\" value=\"$lastname\">";
$title = "<input name=\"title\" value=\"$title\">";
$hphone = "<input name=\"hphone\" value=\"$hphone\">";
$wphone = "<input name=\"wphone\" value=\"$wphone\">";
$fax = "<input name=\"fax\" value=\"$fax\">";
$pager = "<input name=\"pager\" value=\"$pager\">";
$mphone = "<input name=\"mphone\" value=\"$mphone\">";
$ophone = "<input name=\"ophone\" value=\"$ophone\">";
$street = "<input name=\"street\" value=\"$street\">";
$address2 = "<input name=\"address2\" value=\"$address2\">";
$city = "<input name=\"city\" value=\"$city\">";
$state = "<input name=\"state\" value=\"$state\">";
$zip = "<input name=\"zip\" value=\"$zip\">";
//$url = "<input name=\"url\" value=\"$url\">";
$encurl = ($url);
$email = "<input name=\"email\" value=\"$email\">";
$firstname = "<input name=\"firstname\" value=\"$firstname\">";
$lastname = "<input name=\"lastname\" value=\"$lastname\">";
$title = "<input name=\"title\" value=\"$title\">";
$hphone = "<input name=\"hphone\" value=\"$hphone\">";
$wphone = "<input name=\"wphone\" value=\"$wphone\">";
$fax = "<input name=\"fax\" value=\"$fax\">";
$pager = "<input name=\"pager\" value=\"$pager\">";
$mphone = "<input name=\"mphone\" value=\"$mphone\">";
$ophone = "<input name=\"ophone\" value=\"$ophone\">";
$street = "<input name=\"street\" value=\"$street\">";
$address2 = "<input name=\"address2\" value=\"$address2\">";
$city = "<input name=\"city\" value=\"$city\">";
$state = "<input name=\"state\" value=\"$state\">";
$zip = "<input name=\"zip\" value=\"$zip\">";
// $url = "<input name=\"url\" value=\"$encurl\">";
if($phpgw_info["apps"]["timetrack"]["enabled"]) {
$company = '<select name="company">';
$phpgw->db->query("select company_id,company_name from customers order by company_name");
while ($phpgw->db->next_record()) {
$ncust = $phpgw->db->f("company_id");
$company = $company . '<option value="' . $ncust . '"';
if ( $company_id == $ncust ) {
$company = $company . " selected";
}
$company = $company . ">" . $phpgw->db->f("company_name") . "</option>";
}
$company = $company . "</select>";
} else {
$company = "<input name=\"company\" value=\"$ab_company\">";
}
if($phpgw_info["apps"]["timetrack"]["enabled"]) {
$company = '<select name="company">';
$phpgw->db->query("select company_id,company_name from customers order by company_name");
while ($phpgw->db->next_record()) {
$ncust = $phpgw->db->f("company_id");
$company = $company . '<option value="' . $ncust . '"';
if ( $company_id == $ncust ) {
$company = $company . " selected";
}
$company = $company . ">" . $phpgw->db->f("company_name") . "</option>";
}
$company = $company . "</select>";
} else {
$company = "<input name=\"company\" value=\"$ab_company\">";
}
if (strlen($bday) > 2) {
list( $month, $day, $year ) = split( '/', $bday );
$temp_month[$month] = "SELECTED";
if (strlen($bday) > 2) {
list( $month, $day, $year ) = split( '/', $bday );
$temp_month[$month] = "SELECTED";
$bday_month = "<select name=bday_month>"
. "<option value=\"\" $temp_month[0]> </option>"
. "<option value=1 $temp_month[1]>January</option>"
. "<option value=2 $temp_month[2]>February</option>"
. "<option value=3 $temp_month[3]>March</option>"
. "<option value=4 $temp_month[4]>April</option>"
. "<option value=5 $temp_month[5]>May</option>"
. "<option value=6 $temp_month[6]>June</option>"
. "<option value=7 $temp_month[7]>July</option>"
. "<option value=8 $temp_month[8]>August</option>"
. "<option value=9 $temp_month[9]>September</option>"
. "<option value=10 $temp_month[10]>October</option>"
. "<option value=11 $temp_month[11]>November</option>"
. "<option value=12 $temp_month[12]>December</option>"
. "</select>";
$bday_day = '<input maxlength="2" name="bday_day" value="' . $day . '" size="2">'
;
$bday_year = '<input maxlength="4" name="bday_year" value="' . $year . '" size="4">';
} else {
$bday_month = "<select name=bday_month>"
. "<option value=\"\" SELECTED> </option>"
. "<option value=1>January</option>"
. "<option value=2>February</option>"
. "<option value=3>March</option>"
. "<option value=4>April</option>"
. "<option value=5>May</option>"
. "<option value=6>June</option>"
. "<option value=7>July</option>"
. "<option value=8>August</option>"
. "<option value=9>September</option>"
. "<option value=10>October</option>"
. "<option value=11>November</option>"
. "<option value=12>December</option>"
. "</select>";
$bday_day = '<input name="bday_day" size="2" maxlength="2">';
$bday_year = '<input name="bday_year" size="4" maxlength="4">';
}
$bday_month = "<select name=bday_month>"
. "<option value=\"\" $temp_month[0]> </option>"
. "<option value=1 $temp_month[1]>January</option>"
. "<option value=2 $temp_month[2]>February</option>"
. "<option value=3 $temp_month[3]>March</option>"
. "<option value=4 $temp_month[4]>April</option>"
. "<option value=5 $temp_month[5]>May</option>"
. "<option value=6 $temp_month[6]>June</option>"
. "<option value=7 $temp_month[7]>July</option>"
. "<option value=8 $temp_month[8]>August</option>"
. "<option value=9 $temp_month[9]>September</option>"
. "<option value=10 $temp_month[10]>October</option>"
. "<option value=11 $temp_month[11]>November</option>"
. "<option value=12 $temp_month[12]>December</option>"
. "</select>";
$bday_day = '<input maxlength="2" name="bday_day" value="' . $day . '" size="2">';
$bday_year = '<input maxlength="4" name="bday_year" value="' . $year . '" size="4">';
} else {
$bday_month = "<select name=bday_month>"
. "<option value=\"\" SELECTED> </option>"
. "<option value=1>January</option>"
. "<option value=2>February</option>"
. "<option value=3>March</option>"
. "<option value=4>April</option>"
. "<option value=5>May</option>"
. "<option value=6>June</option>"
. "<option value=7>July</option>"
. "<option value=8>August</option>"
. "<option value=9>September</option>"
. "<option value=10>October</option>"
. "<option value=11>November</option>"
. "<option value=12>December</option>"
. "</select>";
$bday_day = '<input name="bday_day" size="2" maxlength="2">';
$bday_year = '<input name="bday_year" size="4" maxlength="4">';
}
$notes = '<TEXTAREA cols="60" name="notes" rows="4">' . $notes . '</TEXTAREA>';
} else {
$notes = "<form><TEXTAREA cols=\"60\" name=\"notes\" rows=\"4\">"
} else {
$notes = "<form><TEXTAREA cols=\"60\" name=\"notes\" rows=\"4\">"
. $notes . "</TEXTAREA></form>";
if ($bday == "//")
if ($bday == "//")
$bday = "";
if($phpgw_info["apps"]["timetrack"]["enabled"]) {
$company = $company_name;
} else {
$company = $ab_company;
}
}
if($phpgw_info["apps"]["timetrack"]["enabled"]) {
$company = $company_name;
} else {
$company = $ab_company;
}
}
if ($action) {
echo "<FORM action=\"".$phpgw->link($action)."\" method=\"post\">\n";
@ -158,12 +159,10 @@
// test:
//echo "Time track app status = " . $phpgw_info["apps"]["timetrack"]["enabled"];
#$url .= '<input name="url" value="';
if (! ereg("^http://",$url)) {
$url .= "http://". $url;
$url = "http://". $url;
}
#$url .= '">';
$birthday = $phpgw->common->dateformatorder($bday_year,$bday_month,$bday_day)
. '<font face="'.$theme["font"].'" size="-2">(e.g. 1969)</font>';
@ -235,48 +234,236 @@
else
$create = '';
$t->set_var("lang_lastname",lang("Last Name"));
$t->set_var("lastname",$lastname);
$t->set_var("lang_firstname",lang("First Name"));
$t->set_var("firstname",$firstname);
$t->set_var("lang_company",lang("Company"));
$t->set_var("company",$company);
$t->set_var("lang_title",lang("Title"));
$t->set_var("title",$title);
$t->set_var("lang_email",lang("Email"));
$t->set_var("email",$email);
$t->set_var("lang_url",lang("url"));
$t->set_var("url",$url);
$t->set_var("lang_hphone",lang("Home Phone"));
$t->set_var("hphone",$hphone);
$t->set_var("lang_fax",lang("fax"));
$t->set_var("fax",$fax);
$t->set_var("lang_wphone",lang("Work Phone"));
$t->set_var("wphone",$wphone);
$t->set_var("lang_pager",lang("Pager"));
$t->set_var("pager",$pager);
$t->set_var("lang_mphone",lang("Mobile"));
$t->set_var("mphone",$mphone);
$t->set_var("lang_ophone",lang("Other Number"));
$t->set_var("ophone",$ophone);
$t->set_var("lang_street",lang("Street"));
$t->set_var("street",$street);
$t->set_var("lang_birthday",lang("Birthday"));
$t->set_var("birthday",$birthday);
$t->set_var("lang_address2",lang("Line 2"));
$t->set_var("address2",$address2);
$t->set_var("lang_city",lang("city"));
$t->set_var("city",$state);
$t->set_var("lang_state",lang("state"));
$t->set_var("state",$state);
$t->set_var("lang_zip",lang("Zip Code"));
$t->set_var("zip",$zip);
$t->set_var("access_link",$access_link);
$t->set_var("create",$create);
$t->set_var("lang_notes",lang("notes"));
$t->set_var("notes",$notes);
$t->set_var("lang_lastname",lang("Last Name"));
$t->set_var("lastname",$lastname);
$t->set_var("lang_firstname",lang("First Name"));
$t->set_var("firstname",$firstname);
$t->set_var("lang_company",lang("Company Name"));
$t->set_var("company",$company);
$t->set_var("lang_title",lang("Title"));
$t->set_var("title",$title);
$t->set_var("lang_email",lang("Email"));
$t->set_var("email",$email);
$t->set_var("lang_url",lang("URL"));
$t->set_var("url",$url);
$t->set_var("lang_hphone",lang("Home Phone"));
$t->set_var("hphone",$hphone);
$t->set_var("lang_fax",lang("fax"));
$t->set_var("fax",$fax);
$t->set_var("lang_wphone",lang("Work Phone"));
$t->set_var("wphone",$wphone);
$t->set_var("lang_pager",lang("Pager"));
$t->set_var("pager",$pager);
$t->set_var("lang_mphone",lang("Mobile"));
$t->set_var("mphone",$mphone);
$t->set_var("lang_ophone",lang("Other Number"));
$t->set_var("ophone",$ophone);
$t->set_var("lang_street",lang("Street"));
$t->set_var("street",$street);
$t->set_var("lang_birthday",lang("Birthday"));
$t->set_var("birthday",$birthday);
$t->set_var("lang_address2",lang("Line 2"));
$t->set_var("address2",$address2);
$t->set_var("lang_city",lang("city"));
$t->set_var("city",$city);
$t->set_var("lang_state",lang("state"));
$t->set_var("state",$state);
$t->set_var("lang_zip",lang("Zip Code"));
$t->set_var("zip",$zip);
$t->set_var("access_link",$access_link);
$t->set_var("create",$create);
$t->set_var("lang_notes",lang("notes"));
$t->set_var("notes",$notes);
$t->parse("out","form");
$t->pparse("out","form");
} //end form function
function NOlist_entries($start="",$sort="",$order="",$query="",$filter="") {
global $phpgw,$phpgw_info;
$limit = $phpgw->nextmatchs->sql_limit($start);
if ($order) {
$ordermethod = "order by $order $sort";
} else {
$ordermethod = "order by ab_lastname,ab_firstname,ab_email asc";
}
if (! $filter) {
$filter = "none";
}
if ($filter != "private") {
if ($filter != "none") {
$filtermethod = " ab_access like '%,$filter,%' ";
} else {
$filtermethod = " (ab_owner='" . $phpgw_info["user"]["account_id"] ."' OR ab_access='public' "
. $phpgw->accounts->sql_search("ab_access") . " ) ";
}
} else {
$filtermethod = " ab_owner='" . $phpgw_info["user"]["account_id"] . "' ";
}
if ($query) {
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
$phpgw->db->query("SELECT count(*) "
. "from addressbook as a, customers as c where a.ab_company_id = c.company_id "
. "AND $filtermethod AND (a.ab_lastname like '"
. "%$query%' OR a.ab_firstname like '%$query%' OR a.ab_email like '%$query%' OR "
. "a.ab_street like '%$query%' OR a.ab_city like '%$query%' OR a.ab_state "
. "like '%$query%' OR a.ab_zip like '%$query%' OR a.ab_notes like "
. "'%$query%' OR c.company_name like '%$query%' OR a.ab_url like '%$query%')",__LINE__,__FILE__);
// . "'%$query%' OR c.company_name like '%$query%')"
// . " $ordermethod limit $limit");
} else {
$phpgw->db->query("SELECT count(*) "
. "from addressbook "
. "WHERE $filtermethod AND (ab_lastname like '"
. "%$query%' OR ab_firstname like '%$query%' OR ab_email like '%$query%' OR "
. "ab_street like '%$query%' OR ab_city like '%$query%' OR ab_state "
. "like '%$query%' OR ab_zip like '%$query%' OR ab_notes like "
. "'%$query%' OR ab_company like '%$query%' OR ab_url like '%$query$%')",__LINE__,__FILE__);
// . "'%$query%' OR ab_company like '%$query%')"
// . " $ordermethod limit $limit");
}
$phpgw->db->next_record();
if ($phpgw->db->f(0) == 1) {
$searchreturn=lang("your search returned 1 match");
} else {
$searchreturn=lang("your search returned x matchs",$phpgw->db->f(0));
}
} else {
$searchreturn="";
$phpgw->db->query("select count(*) from addressbook where $filtermethod",__LINE__,__FILE__);
$phpgw->db->next_record();
}
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
$company_sortorder = "c.company_name";
} else {
$company_sortorder = "ab_company";
}
//$phpgw->db->next_record();
if ($phpgw->db->f(0) > $phpgw_info["user"]["preferences"]["common"]["maxmatchs"]) {
$lang_showing=lang("showing x - x of x",($start + 1),($start + $phpgw_info["user"]["preferences"]["common"]["maxmatchs"]),$phpgw->db->f(0));
} else {
$lang_showing=lang("showing x",$phpgw->db->f(0));
}
$search_filter=$phpgw->nextmatchs->show_tpl("index.php",$start,$phpgw->db->f(0),"&order=$order&filter=$filter&sort=$sort&query=$query", "75%", $phpgw_info["theme"]["th_bg"]);
while ($column = each($this)) {
if (isset($phpgw_info["user"]["preferences"]["addressbook"][$column[0]]) &&
$phpgw_info["user"]["preferences"]["addressbook"][$column[0]]) {
$cols .= '<td height="21">';
$cols .= '<font size="-1" face="Arial, Helvetica, sans-serif">';
$cols .= $phpgw->nextmatchs->show_sort_order($sort,"ab_" . $column[0],$order,"index.php",lang($column[1]));
$cols .= '</font></td>';
$cols .= "\n";
// To be used when displaying the rows
$columns_to_display[$column[0]] = True;
}
}
if (isset($query) && $query) {
if (isset($phpgw_info["apps"]["timetrack"]["enabled"]) &&
$phpgw_info["apps"]["timetrack"]["enabled"]) {
$phpgw->db->query("SELECT a.ab_id,a.ab_owner,a.ab_firstname,a.ab_lastname,a.ab_company_id,"
. "a.ab_email,a.ab_wphone,c.company_name,a.ab_hphone,a.ab_fax,a.ab_mphone "
. "from addressbook as a, customers as c where a.ab_company_id = c.company_id "
. "AND $filtermethod AND (a.ab_lastname like '"
. "%$query%' OR a.ab_firstname like '%$query%' OR a.ab_email like '%$query%' OR "
. "a.ab_street like '%$query%' OR a.ab_city like '%$query%' OR a.ab_state "
. "like '%$query%' OR a.ab_zip like '%$query%' OR a.ab_notes like "
. "'%$query%' OR c.company_name like '%$query%') $ordermethod limit $limit",__LINE__,__FILE__);
} else {
$phpgw->db->query("SELECT * from addressbook WHERE $filtermethod AND (ab_lastname like '"
. "%$query%' OR ab_firstname like '%$query%' OR ab_email like '%$query%' OR "
. "ab_street like '%$query%' OR ab_city like '%$query%' OR ab_state "
. "like '%$query%' OR ab_zip like '%$query%' OR ab_notes like "
. "'%$query%' OR ab_company like '%$query%') $ordermethod limit $limit",__LINE__,__FILE__);
}
} else {
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
$phpgw->db->query("SELECT a.ab_id,a.ab_owner,a.ab_firstname,a.ab_lastname,"
. "a.ab_email,a.ab_wphone,c.company_name "
. "from addressbook as a, customers as c where a.ab_company_id = c.company_id "
. "AND $filtermethod $ordermethod limit $limit",__LINE__,__FILE__);
} else {
$phpgw->db->query("SELECT * from addressbook WHERE $filtermethod $ordermethod limit $limit",__LINE__,__FILE__);
}
} // else $query
$rows="";
while ($phpgw->db->next_record()) {
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$rows .= '<tr bgcolor="#'.$tr_color . '">';
$ab_id = $phpgw->db->f("ab_id");
while ($column = each($columns_to_display)) {
if ($column[0] == "company") {
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
$field = $phpgw->db->f("company_name");
} else {
$field = $phpgw->db->f("ab_company");
}
} else {
$field = $phpgw->db->f("ab_" . $column[0]);
}
$field = htmlentities($field);
// Some fields require special formating.
if ($column[0] == "url") {
if (! ereg("^http://",$field)) {
$data = "http://" . $field;
}
$rows .= '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
. '<a href="' . $field . '" target="_new">' . $field. '</a>&nbsp;</font></td>';
} else if ($column[0] == "email") {
if ($phpgw_info["user"]["apps"]["email"]) {
$rows .= '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
. '<a href="' . $phpgw->link($phpgw_info["server"]["webserver_url"] . "/email/compose.php",
"to=" . urlencode($field)) . '" target="_new">' . $field . '</a>&nbsp;</font></td>';
} else {
$rows .= '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
. '<a href="mailto:' . $field . '">' . $field. '</a>&nbsp;</font></td>';
}
} else {
$rows .= '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
. $field . '&nbsp;</font></td>';
}
#echo '</tr>';
}
reset($columns_to_display); // If we don't reset it, our inside while won't loop
$rows .= '<td valign="top" width="3%">
<font face="'.$phpgw_info["theme"]["font"].'" size="2">
<a href="'. $phpgw->link("view.php","ab_id=$ab_id&start=$start&order=$order&filter="
. "$filter&query=$query&sort=$sort").'
">'.lang("View").'</a>
</font>
</td>
<td valign=top width=3%>
<font face="'.$phpgw_info["theme"]["font"].'" size=2>
<a href="'.$phpgw->link("vcardout.php","ab_id=$ab_id&start=$start&order=$order&filter="
. "$filter&query=$query&sort=$sort").'
">'.lang("vcard").'</a>
</font>
</td>
<td valign="top" width="5%">
<font face="'.$phpgw_info["theme"]["font"].'" size="2">
'.$phpgw->common->check_owner($phpgw->db->f("ab_owner"),"edit.php",lang("edit"),"ab_id=" . $phpgw->db->f("ab_id")."&start=".$start."&sort=".$sort."&order=".$order).'
</font>
</td>
</tr>
';
}
return array($cols,$rows,$searchreturn,$lang_showing,$search_filter);
} //end list function
$t->parse("out","form");
$t->pparse("out","form");
}
?>

View File

@ -27,188 +27,71 @@
"body" => "list.tpl",
"addressbook_footer" => "footer.tpl" ));
# $t->set_block("addressbook_header","searchfilter","body",
# "addressbook_footer","output");
$this = CreateObject("addressbook.addressbook");
$entries = $this->get_entries($query,$filter,$sort,$order,$start);
$limit =$phpgw->nextmatchs->sql_limit($start);
if ($order)
$ordermethod = "order by $order $sort";
else
$ordermethod = "order by ab_lastname,ab_firstname,ab_email asc";
if (! $filter) {
$filter = "none";
}
if ($filter != "private") {
if ($filter != "none") {
$filtermethod = " ab_access like '%,$filter,%' ";
} else {
$filtermethod = " (ab_owner='" . $phpgw_info["user"]["account_id"] ."' OR ab_access='public' "
. $phpgw->accounts->sql_search("ab_access") . " ) ";
}
} else {
$filtermethod = " ab_owner='" . $phpgw_info["user"]["account_id"] . "' ";
}
if ($query) {
if ($phpgw_info["apps"]["timetrack"]["enabled"]){
$phpgw->db->query("SELECT count(*) "
. "from addressbook as a, customers as c where a.ab_company_id = c.company_id "
. "AND $filtermethod AND (a.ab_lastname like '"
. "%$query%' OR a.ab_firstname like '%$query%' OR a.ab_email like '%$query%' OR "
. "a.ab_street like '%$query%' OR a.ab_city like '%$query%' OR a.ab_state "
. "like '%$query%' OR a.ab_zip like '%$query%' OR a.ab_notes like "
. "'%$query%' OR c.company_name like '%$query%' OR a.ab_url like '%$query%')",__LINE__,__FILE__);
// . "'%$query%' OR c.company_name like '%$query%')"
// . " $ordermethod limit $limit");
} else {
$phpgw->db->query("SELECT count(*) "
. "from addressbook "
. "WHERE $filtermethod AND (ab_lastname like '"
. "%$query%' OR ab_firstname like '%$query%' OR ab_email like '%$query%' OR "
. "ab_street like '%$query%' OR ab_city like '%$query%' OR ab_state "
. "like '%$query%' OR ab_zip like '%$query%' OR ab_notes like "
. "'%$query%' OR ab_company like '%$query%' OR ab_url like '%$query$%')",__LINE__,__FILE__);
// . "'%$query%' OR ab_company like '%$query%')"
// . " $ordermethod limit $limit");
}
$phpgw->db->next_record();
if ($phpgw->db->f(0) == 1)
$t->set_var(searchreturn,lang("your search returned 1 match"));
else
$t->set_var(searchreturn,lang("your search returned x matchs",$phpgw->db->f(0)));
} else {
$t->set_var(searchreturn,"");
$phpgw->db->query("select count(*) from addressbook where $filtermethod",__LINE__,__FILE__);
$phpgw->db->next_record();
}
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
$company_sortorder = "c.company_name";
} else {
$company_sortorder = "ab_company";
}
//$phpgw->db->next_record();
if ($phpgw->db->f(0) > $phpgw_info["user"]["preferences"]["common"]["maxmatchs"])
$t->set_var(lang_showing,lang("showing x - x of x",($start + 1),($start + $phpgw_info["user"]["preferences"]["common"]["maxmatchs"]),$phpgw->db->f(0)));
else
$t->set_var(lang_showing,lang("showing x",$phpgw->db->f(0)));
$t->set_var("search_filter",$phpgw->nextmatchs->show_tpl("index.php",$start,$phpgw->db->f(0),"&order=$order&filter=$filter&sort=$sort&query=$query", "75%", $phpgw_info["theme"]["th_bg"]));
while ($column = each($abc)) {
if (isset($phpgw_info["user"]["preferences"]["addressbook"][$column[0]]) &&
$phpgw_info["user"]["preferences"]["addressbook"][$column[0]]) {
$cols .= '<td height="21">';
$cols .= '<font size="-1" face="Arial, Helvetica, sans-serif">';
$cols .= $phpgw->nextmatchs->show_sort_order($sort,"ab_" . $column[0],$order,"index.php",lang($column[1]));
$cols .= '</font></td>';
$cols .= "\n";
// To be used when displaying the rows
$columns_to_display[$column[0]] = True;
}
}
if (isset($query) && $query) {
if (isset($phpgw_info["apps"]["timetrack"]["enabled"]) &&
$phpgw_info["apps"]["timetrack"]["enabled"]) {
$phpgw->db->query("SELECT a.ab_id,a.ab_owner,a.ab_firstname,a.ab_lastname,a.ab_company_id,"
. "a.ab_email,a.ab_wphone,c.company_name,a.ab_hphone,a.ab_fax,a.ab_mphone "
. "from addressbook as a, customers as c where a.ab_company_id = c.company_id "
. "AND $filtermethod AND (a.ab_lastname like '"
. "%$query%' OR a.ab_firstname like '%$query%' OR a.ab_email like '%$query%' OR "
. "a.ab_street like '%$query%' OR a.ab_city like '%$query%' OR a.ab_state "
. "like '%$query%' OR a.ab_zip like '%$query%' OR a.ab_notes like "
. "'%$query%' OR c.company_name like '%$query%') $ordermethod limit $limit",__LINE__,__FILE__);
} else {
$phpgw->db->query("SELECT * from addressbook WHERE $filtermethod AND (ab_lastname like '"
. "%$query%' OR ab_firstname like '%$query%' OR ab_email like '%$query%' OR "
. "ab_street like '%$query%' OR ab_city like '%$query%' OR ab_state "
. "like '%$query%' OR ab_zip like '%$query%' OR ab_notes like "
. "'%$query%' OR ab_company like '%$query%') $ordermethod limit $limit",__LINE__,__FILE__);
}
} else {
if ($phpgw_info["apps"]["timetrack"]["enabled"]){
$phpgw->db->query("SELECT a.ab_id,a.ab_owner,a.ab_firstname,a.ab_lastname,"
. "a.ab_email,a.ab_wphone,c.company_name "
. "from addressbook as a, customers as c where a.ab_company_id = c.company_id "
. "AND $filtermethod $ordermethod limit $limit",__LINE__,__FILE__);
} else {
$phpgw->db->query("SELECT * from addressbook WHERE $filtermethod $ordermethod limit $limit",__LINE__,__FILE__);
}
} // else $query
$rows="";
while ($phpgw->db->next_record()) {
$columns_to_display=$this->columns_to_display;
if($phpgw_info["user"]["preferences"]["common"]["maxmatchs"] ) {
$limit = $phpgw_info["user"]["preferences"]["common"]["maxmatchs"];
} else { // this must be broken, but it works
$limit = 15;
}
for ($i=0;$i<$limit;$i++) { // each entry
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$rows .= '<tr bgcolor="#'.$tr_color . '">';
$ab_id = $phpgw->db->f("ab_id");
while ($column = each($columns_to_display)) {
if ($column[0] == "company") {
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
$field = $phpgw->db->f("company_name");
} else {
$field = $phpgw->db->f("ab_company");
}
} else {
$field = $phpgw->db->f("ab_" . $column[0]);
}
$field = htmlentities($field);
// Some fields require special formating.
while ($column = each($columns_to_display)) { // each entry column
$colname = $this->colname($column[0],$i);
$myid = $entries->ab_id[$i];
$myowner = $entries->owner[$i];
// Some fields require special formatting.
if ($column[0] == "url") {
if (! ereg("^http://",$field)) {
$data = "http://" . $field;
$rows .= '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
. '<a href="' . $colname . '" target="_new">' . $colname . '</a>&nbsp;</font></td>';
} else if ($column[0] == "email") {
if ($phpgw_info["user"]["apps"]["email"]) {
$rows .= '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
. '<a href="' . $phpgw->link($phpgw_info["server"]["webserver_url"] . "/email/compose.php",
"to=" . urlencode($colname)) . '" target="_new">' . $colname . '</a>&nbsp;</font></td>';
} else {
$rows .= '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
. '<a href="mailto:' . $colname . '">' . $colname . '</a>&nbsp;</font></td>';
}
} else { // But these do not
$rows .= '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
. '<a href="' . $field . '" target="_new">' . $field. '</a>&nbsp;</font></td>';
} else if ($column[0] == "email") {
if ($phpgw_info["user"]["apps"]["email"]) {
$rows .= '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
. '<a href="' . $phpgw->link($phpgw_info["server"]["webserver_url"] . "/email/compose.php",
"to=" . urlencode($field)) . '" target="_new">' . $field . '</a>&nbsp;</font></td>';
} else {
$rows .= '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
. '<a href="mailto:' . $field . '">' . $field. '</a>&nbsp;</font></td>';
}
} else {
$rows .= '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
. $field . '&nbsp;</font></td>';
. $colname . '&nbsp;</font></td>';
}
#echo '</tr>';
}
reset($columns_to_display); // If we don't reset it, our inside while won't loop
reset($columns_to_display); // If we don't reset it, our inside while won't loop
$rows .= '<td valign="top" width="3%">
<font face="'.$phpgw_info["theme"]["font"].'" size="2">
<a href="'. $phpgw->link("view.php","ab_id=$ab_id&start=$start&order=$order&filter="
. "$filter&query=$query&sort=$sort").'
">'.lang("View").'</a>
<font face="'.$phpgw_info["theme"]["font"].'" size="2">
<a href="'. $phpgw->link("view.php","ab_id=$myid&start=$start&order=$order&filter="
. "$filter&query=$query&sort=$sort").'
">'.lang("View").'</a>
</font>
</td>
<td valign=top width=3%>
<font face="'.$phpgw_info["theme"]["font"].'" size=2>
<a href="'.$phpgw->link("vcardout.php","ab_id=$ab_id&start=$start&order=$order&filter="
. "$filter&query=$query&sort=$sort").'
<a href="'.$phpgw->link("vcardout.php","ab_id=$myid&start=$start&order=$order&filter="
. "$filter&query=$query&sort=$sort").'
">'.lang("vcard").'</a>
</font>
</td>
<td valign="top" width="5%">
<font face="'.$phpgw_info["theme"]["font"].'" size="2">
'.$phpgw->common->check_owner($phpgw->db->f("ab_owner"),"edit.php",lang("edit"),"ab_id=" . $phpgw->db->f("ab_id")."&start=".$start."&sort=".$sort."&order=".$order).'
'.$phpgw->common->check_owner($myowner,"edit.php",lang("edit"),"ab_id=".$myid."&start=".$start."&sort=".$sort."&order=".$order).'
</font>
</td>
</tr>
';
}
$t->set_var(searchreturn,$this->searchreturn);
$t->set_var(lang_showing,$this->lang_showing);
$t->set_var(search_filter,$this->search_filter);
$t->set_var("lang_addressbook",lang("Address book"));
$t->set_var("th_bg",$phpgw_info["theme"]["th_bg"]);
$t->set_var("th_font",$phpgw_info["theme"]["font"]);
@ -229,7 +112,7 @@
$t->set_var("actionurl",$phpgw->link("add.php?sort=$sort&order=$order&filter=$filter&start=$start"));
$t->set_var("start",$start);
$t->set_var("filter",$filter);
$t->set_var("cols",$cols);
$t->set_var("cols",$this->cols);
$t->set_var("rows",$rows);
$t->parse("out","addressbook_header");