diff --git a/addressbook/delete.php b/addressbook/delete.php
index b9efccdcdb..c902779e5a 100755
--- a/addressbook/delete.php
+++ b/addressbook/delete.php
@@ -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"));
}
?>
-
diff --git a/addressbook/edit.php b/addressbook/edit.php
index ad92cbb405..6d720e83fe 100755
--- a/addressbook/edit.php
+++ b/addressbook/edit.php
@@ -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);
-
- Header("Location: " . $phpgw->link("view.php","&ab_id=$ab_id&order=$order&sort=$sort&filter="
- . "$filter&start=$start"));
- $phpgw->common->phpgw_exit();
+ $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();
}
$t->set_var("ab_id",$ab_id);
@@ -145,6 +92,5 @@
$t->parse("out","edit");
$t->pparse("out","edit");
-
$phpgw->common->phpgw_footer();
?>
diff --git a/addressbook/inc/class.addressbook.inc.php b/addressbook/inc/class.addressbook.inc.php
new file mode 100644
index 0000000000..e2582d88ff
--- /dev/null
+++ b/addressbook/inc/class.addressbook.inc.php
@@ -0,0 +1,4 @@
+
diff --git a/addressbook/inc/class.addressbook_ldap.inc.php b/addressbook/inc/class.addressbook_ldap.inc.php
new file mode 100644
index 0000000000..5f81395f83
--- /dev/null
+++ b/addressbook/inc/class.addressbook_ldap.inc.php
@@ -0,0 +1,310 @@
+ *
+ * -------------------------------------------- *
+ * 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 .= '
';
+ $this->cols .= '';
+ $this->cols .= $phpgw->nextmatchs->show_sort_order($sort,"ab_" . $column[0],$order,"index.php",lang($column[1]));
+ $this->cols .= ' | ';
+ $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;
+ }
+ }
+?>
diff --git a/addressbook/inc/class.addressbook_shared.inc.php b/addressbook/inc/class.addressbook_shared.inc.php
new file mode 100644
index 0000000000..6b1b77e07f
--- /dev/null
+++ b/addressbook/inc/class.addressbook_shared.inc.php
@@ -0,0 +1,36 @@
+ *
+ * -------------------------------------------- *
+ * 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 "";
+ }
+ }
+?>
diff --git a/addressbook/inc/class.addressbook_sql.inc.php b/addressbook/inc/class.addressbook_sql.inc.php
new file mode 100644
index 0000000000..5f81395f83
--- /dev/null
+++ b/addressbook/inc/class.addressbook_sql.inc.php
@@ -0,0 +1,310 @@
+ *
+ * -------------------------------------------- *
+ * 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 .= '';
+ $this->cols .= '';
+ $this->cols .= $phpgw->nextmatchs->show_sort_order($sort,"ab_" . $column[0],$order,"index.php",lang($column[1]));
+ $this->cols .= ' | ';
+ $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;
+ }
+ }
+?>
diff --git a/addressbook/inc/functions.inc.php b/addressbook/inc/functions.inc.php
index e7c25e9cea..0ebec0aca1 100755
--- a/addressbook/inc/functions.inc.php
+++ b/addressbook/inc/functions.inc.php
@@ -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"));
- $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"];
+ 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"));
+
+ $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 = "";
- $firstname = "";
- $lastname = "";
- $title = "";
- $hphone = "";
- $wphone = "";
- $fax = "";
- $pager = "";
- $mphone = "";
- $ophone = "";
- $street = "";
- $address2 = "";
- $city = "";
- $state = "";
- $zip = "";
- //$url = "";
+ $encurl = ($url);
+ $email = "";
+ $firstname = "";
+ $lastname = "";
+ $title = "";
+ $hphone = "";
+ $wphone = "";
+ $fax = "";
+ $pager = "";
+ $mphone = "";
+ $ophone = "";
+ $street = "";
+ $address2 = "";
+ $city = "";
+ $state = "";
+ $zip = "";
+// $url = "";
- if($phpgw_info["apps"]["timetrack"]["enabled"]) {
- $company = '";
- } else {
- $company = "";
- }
+ if($phpgw_info["apps"]["timetrack"]["enabled"]) {
+ $company = '";
+ } else {
+ $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 = "";
- $bday_day = ''
-;
- $bday_year = '';
- } else {
- $bday_month = "";
- $bday_day = '';
- $bday_year = '';
- }
+ $bday_month = "";
+ $bday_day = '';
+ $bday_year = '';
+ } else {
+ $bday_month = "";
+ $bday_day = '';
+ $bday_year = '';
+ }
$notes = '';
- } else {
- $notes = "