diff --git a/addressbook/add.php b/addressbook/add.php index 0f3a17d0ac..1f612b9e78 100755 --- a/addressbook/add.php +++ b/addressbook/add.php @@ -33,9 +33,9 @@ $access = $phpgw->accounts->array_to_string($access,$n_groups); - $sql = "insert into addressbook (owner,access,firstname,lastname,email," - . "hphone,wphone,fax,pager,mphone,ophone,street,city,state,zip,bday," - . "notes,company) values ('" . $phpgw_info["user"]["userid"] . "','$access','" + $sql = "insert into addressbook (ab_owner,ab_access,ab_firstname,ab_lastname,ab_email," + . "ab_hphone,ab_wphone,ab_fax,ab_pager,ab_mphone,ab_ophone,ab_street,ab_city,ab_state,ab_zip,ab_bday," + . "ab_notes,ab_company) values ('" . $phpgw_info["user"]["userid"] . "','$access','" . addslashes($firstname). "','" . addslashes($lastname) . "','" . addslashes($email) . "','" diff --git a/addressbook/edit.php b/addressbook/edit.php index 3a5a207aab..95a502e6de 100755 --- a/addressbook/edit.php +++ b/addressbook/edit.php @@ -12,45 +12,44 @@ /* $Id$ */ - if ($submit) { + if ($submit || ! $ab_id) { $phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True); } $phpgw_info["flags"]["currentapp"] = "addressbook"; include("../header.inc.php"); - if (! $con) { + if (! $ab_id) { Header("Location: " . $phpgw->link($phpgw_info["server"]["webserver_url"]. "/addressbook/", "cd=16&order=$order&sort=$sort&filter=$filter&start=$start&query=$query")); exit; } if (! $submit) { - $phpgw->db->query("SELECT * FROM addressbook WHERE owner='" - . $phpgw_info["user"]["userid"] . "' AND con='$con'"); + $phpgw->db->query("SELECT * FROM addressbook WHERE ab_owner='" + . $phpgw_info["user"]["userid"] . "' AND ab_id='$ab_id'"); $phpgw->db->next_record(); - $fields = array( - 'con' => $phpgw->db->f("con"), - 'owner' => $phpgw->db->f("owner"), - 'access' => $phpgw->db->f("access"), - 'firstname' => $phpgw->db->f("firstname"), - 'lastname' => $phpgw->db->f("lastname"), - 'email' => $phpgw->db->f("email"), - 'hphone' => $phpgw->db->f("hphone"), - 'wphone' => $phpgw->db->f("wphone"), - 'fax' => $phpgw->db->f("fax"), - 'pager' => $phpgw->db->f("pager"), - 'mphone' => $phpgw->db->f("mphone"), - 'ophone' => $phpgw->db->f("ophone"), - 'street' => $phpgw->db->f("street"), - 'city' => $phpgw->db->f("city"), - 'state' => $phpgw->db->f("state"), - 'zip' => $phpgw->db->f("zip"), - 'bday' => $phpgw->db->f("bday"), - 'notes' => $phpgw->db->f("notes"), - 'company' => $phpgw->db->f("company") - ); + $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"), + '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"), + '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"), + 'notes' => $phpgw->db->f("ab_notes") + ); form("","edit.php","Edit",$fields); @@ -58,29 +57,29 @@ $bday = $bday_month . "/" . $bday_day . "/" . $bday_year; $access = $phpgw->accounts->array_to_string($access,$n_groups); - $sql = "UPDATE addressbook set email='" . addslashes($email) - . "', firstname='" . addslashes($firstname) - . "', lastname='" . addslashes($lastname) - . "', hphone='" . addslashes($hphone) - . "', wphone='" . addslashes($wphone) - . "', fax='" . addslashes($fax) - . "', pager='" . addslashes($pager) - . "', mphone='" . addslashes($mphone) - . "', ophone='" . addslashes($ophone) - . "', street='" . addslashes($street) - . "', city='" . addslashes($city) - . "', state='" . addslashes($state) - . "', zip='" . addslashes($zip) - . "', bday='" . addslashes($bday) - . "', notes='" . addslashes($notes) - . "', company='" . addslashes($company) - . "', access='" . addslashes($access) - . "' WHERE owner='" . $phpgw_info["user"]["userid"] . "' AND con='$con'"; + $sql = "UPDATE addressbook set ab_email='" . addslashes($email) + . "', ab_firstname='". addslashes($firstname) + . "', ab_lastname='" . addslashes($lastname) + . "', 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_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) + . "' WHERE ab_owner='" . $phpgw_info["user"]["userid"] . "' AND ab_id='$ab_id'"; $phpgw->db->query($sql); Header("Location: " . $phpgw->link("view.php","&con=$con&order=$order&sort=$sort&filter=" - . "$filter&start=$start")); + . "$filter&start=$start")); exit; } diff --git a/addressbook/index.php b/addressbook/index.php index 3fb0183e2d..f5c31cba27 100755 --- a/addressbook/index.php +++ b/addressbook/index.php @@ -26,7 +26,7 @@ if ($order) $ordermethod = "order by $order $sort"; else - $ordermethod = "order by lastname,firstname,email asc"; + $ordermethod = "order by ab_lastname,ab_firstname,ab_email asc"; if (! $filter) { $filter = "none"; @@ -34,21 +34,21 @@ if ($filter != "private") { if ($filter != "none") { - $filtermethod = " access like '%,$filter,%' "; + $filtermethod = " ab_access like '%,$filter,%' "; } else { - $filtermethod = " (owner='" . $phpgw_info["user"]["userid"] ."' OR access='public' " - . $phpgw->accounts->sql_search("access") . " ) "; + $filtermethod = " (ab_owner='" . $phpgw_info["user"]["userid"] ."' OR ab_access='public' " + . $phpgw->accounts->sql_search("ab_access") . " ) "; } } else { - $filtermethod = " owner='" . $phpgw_info["user"]["userid"] . "' "; + $filtermethod = " ab_owner='" . $phpgw_info["user"]["userid"] . "' "; } if ($query) { - $phpgw->db->query("select count(*) from addressbook where $filtermethod AND (lastname " - . "like '%$query%' OR firstname like '%$query%' OR email like '%$query%" - . "' OR street like '%$query%' OR city like '%$query%' OR state like '" - . "%$query%' OR zip like '%$query%' OR notes like '%$query%' OR company" - . " like '%$query%')"); + $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%')"); $phpgw->db->next_record(); @@ -70,9 +70,8 @@ ?> nextmatchs->show("index.php",$start,$phpgw->db->f(0), - "&order=$order&filter=$filter&sort=" - . "$sort&query=$query", "75%", $phpgw_info["theme"][th_bg]); + $phpgw->nextmatchs->show("index.php",$start,$phpgw->db->f(0),"&order=$order&filter=$filter&sort=" + . "$sort&query=$query", "75%", $phpgw_info["theme"][th_bg]); ?> @@ -81,35 +80,34 @@ if ( $phpgw_info["user"]["preferences"]["addressbook_view_company"] == "True" ) { echo ''; } if ( $phpgw_info["user"]["preferences"]["addressbook_view_lastname"] == "True" ) { echo ''; } if ( $phpgw_info["user"]["preferences"]["addressbook_view_firstname"] == "True" ) { echo ''; } if ( $phpgw_info["user"]["preferences"]["addressbook_view_email"] == "True" ) { echo ''; } if ( $phpgw_info["user"]["preferences"]["addressbook_view_wphone"] == "True" ) { echo ''; } @@ -131,25 +129,24 @@ db->query("SELECT * FROM addressbook WHERE $filtermethod AND (lastname like '" - . "%$query%' OR firstname like '%$query%' OR email like '%$query%' OR " - . "street like '%$query%' OR city like '%$query%' OR state " - . "like '%$query%' OR zip like '%$query%' OR notes like " - . "'%$query%' OR company like %$query%') $ordermethod limit $limit"); + $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"); } else { - $phpgw->db->query("SELECT * FROM addressbook WHERE $filtermethod $ordermethod limit " - . $limit); + $phpgw->db->query("SELECT * FROM addressbook WHERE $filtermethod $ordermethod limit $limit"); } while ($phpgw->db->next_record()) { $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color); - $firstname = $phpgw->db->f("firstname"); - $lastname = $phpgw->db->f("lastname"); - $email = $phpgw->db->f("email"); - $company = $phpgw->db->f("company"); - $wphone = $phpgw->db->f("wphone"); - $con = $phpgw->db->f("con"); + $firstname = $phpgw->db->f("ab_firstname"); + $lastname = $phpgw->db->f("ab_lastname"); + $email = $phpgw->db->f("ab_email"); + $company = $phpgw->db->f("ab_company"); + $wphone = $phpgw->db->f("ab_wphone"); + $ab_id = $phpgw->db->f("ab_id"); if($firstname == "") $firstname = " "; if($lastname == "") $lastname = " "; @@ -193,14 +190,14 @@ ?> diff --git a/addressbook/view.php b/addressbook/view.php index 64b328442d..e1d7f44c12 100755 --- a/addressbook/view.php +++ b/addressbook/view.php @@ -12,47 +12,47 @@ /* $Id$ */ - if ($submit) { + if ($submit || ! $ab_id) { $phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True); } $phpgw_info["flags"]["currentapp"] = "addressbook"; include("../header.inc.php"); - if (! $con) - Header("Location: " . $phpgw_info["server"]["webserver_url"] . - "/addressbook/?sessionid=" . $phpgw_info["user"]["sessionid"]); + + if (! $ab_id) { + Header("Location: " . $phpgw->link("index.php")); + } if ($filter != "private") - $filtermethod = " or access='public' " . $phpgw->accounts->sql_search("access"); + $filtermethod = " or ab_access='public' " . $phpgw->accounts->sql_search("ab_access"); - $phpgw->db->query("SELECT * FROM addressbook WHERE con='$con' AND (owner='" + $phpgw->db->query("SELECT * FROM addressbook WHERE ab_id='$ab_id' AND (ab_owner='" . $phpgw_info["user"]["userid"] . "' $filtermethod)"); $phpgw->db->next_record(); - $fields = array( - 'con' => $phpgw->db->f("con"), - 'owner' => $phpgw->db->f("owner"), - 'access' => $phpgw->db->f("access"), - 'firstname' => $phpgw->db->f("firstname"), - 'lastname' => $phpgw->db->f("lastname"), - 'email' => $phpgw->db->f("email"), - 'hphone' => $phpgw->db->f("hphone"), - 'wphone' => $phpgw->db->f("wphone"), - 'fax' => $phpgw->db->f("fax"), - 'pager' => $phpgw->db->f("pager"), - 'mphone' => $phpgw->db->f("mphone"), - 'ophone' => $phpgw->db->f("ophone"), - 'street' => $phpgw->db->f("street"), - 'city' => $phpgw->db->f("city"), - 'state' => $phpgw->db->f("state"), - 'zip' => $phpgw->db->f("zip"), - 'bday' => $phpgw->db->f("bday"), - 'company' => $phpgw->db->f("company"), - 'notes' => $phpgw->db->f("notes") - ); + $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"), + '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"), + '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"), + 'notes' => $phpgw->db->f("ab_notes") + ); - $owner = $phpgw->db->f("owner"); - $con = $phpgw->db->f("con"); + $owner = $phpgw->db->f("ab_owner"); + $ab_id = $phpgw->db->f("ab_id"); form("view","","View",$fields); ?> @@ -65,7 +65,7 @@
'; echo ''; - echo $phpgw->nextmatchs->show_sort_order($sort,"company",$order,"index.php", - lang("Company Name")); + echo $phpgw->nextmatchs->show_sort_order($sort,"ab_company",$order,"index.php",lang("Company Name")); echo ''; echo ''; - echo $phpgw->nextmatchs->show_sort_order($sort,"lastname",$order,"index.php", + echo $phpgw->nextmatchs->show_sort_order($sort,"ab_lastname",$order,"index.php", lang("Last Name")); echo ''; echo ''; - echo $phpgw->nextmatchs->show_sort_order($sort,"firstname",$order,"index.php", + echo $phpgw->nextmatchs->show_sort_order($sort,"ab_firstname",$order,"index.php", lang("First Name")); echo ''; echo ''; - echo $phpgw->nextmatchs->show_sort_order($sort,"email",$order,"index.php", + echo $phpgw->nextmatchs->show_sort_order($sort,"ab_email",$order,"index.php", lang("Email")); echo ''; echo ''; - echo $phpgw->nextmatchs->show_sort_order($sort,"wphone",$order,"index.php", + echo $phpgw->nextmatchs->show_sort_order($sort,"ab_wphone",$order,"index.php", lang("Work Phone")); echo ' - "> - common->check_owner($phpgw->db->f("owner"),"edit.php",lang("edit"),"con=" . $phpgw->db->f("con")); ?> + common->check_owner($phpgw->db->f("ab_owner"),"edit.php",lang("edit"),"ab_id=" . $phpgw->db->f("ab_id")); ?>
common->check_owner($con,$owner,"Edit"); + echo $phpgw->common->check_owner($ab_id,$owner,"Edit"); ?> @@ -79,5 +79,4 @@
- diff --git a/doc/create_tables.mysql b/doc/create_tables.mysql index e99b54eff7..19da9aca6e 100755 --- a/doc/create_tables.mysql +++ b/doc/create_tables.mysql @@ -97,26 +97,26 @@ CREATE TABLE profiles ( ); CREATE TABLE addressbook ( - con int(11) DEFAULT '0' NOT NULL auto_increment, - owner varchar(25), - access varchar(10), - firstname varchar(255), - lastname varchar(255), - email varchar(255), - hphone varchar(255), - wphone varchar(255), - fax varchar(255), - pager varchar(255), - mphone varchar(255), - ophone varchar(255), - street varchar(255), - city varchar(255), - state varchar(255), - zip varchar(255), - bday varchar(255), - notes text, - company varchar(255), - PRIMARY KEY (con) + ab_id int(11) DEFAULT '0' NOT NULL auto_increment, + ab_owner varchar(25), + ab_access varchar(10), + ab_firstname varchar(255), + ab_lastname varchar(255), + ab_email varchar(255), + ab_hphone varchar(255), + ab_wphone varchar(255), + ab_fax varchar(255), + ab_pager varchar(255), + ab_mphone varchar(255), + ab_ophone varchar(255), + ab_street varchar(255), + ab_city varchar(255), + ab_state varchar(255), + ab_zip varchar(255), + ab_bday varchar(255), + ab_notes text, + ab_company varchar(255), + PRIMARY KEY (ab_id) ); CREATE TABLE todo ( diff --git a/doc/create_tables.orasql b/doc/create_tables.orasql index a134c726c5..5652915e97 100755 --- a/doc/create_tables.orasql +++ b/doc/create_tables.orasql @@ -209,26 +209,26 @@ end; ----------------- CREATE TABLE addressbook ( - con number(11) DEFAULT '0' NOT NULL , --auto-increment - owner varchar2(25), - addr_access varchar2(10), - firstname varchar2(255), - lastname varchar2(255), - email varchar2(255), - hphone varchar2(255), - wphone varchar2(255), - fax varchar2(255), - pager varchar2(255), - mphone varchar2(255), - ophone varchar2(255), - street varchar2(255), - city varchar2(255), - state varchar2(255), - zip varchar2(255), - bday varchar2(255), - notes varchar2(4000), - company varchar2(255), - PRIMARY KEY (con) + ab_id number(11) DEFAULT '0' NOT NULL , --auto-increment + ab_owner varchar2(25), + ab_addr_access varchar2(10), + ab_firstname varchar2(255), + ab_lastname varchar2(255), + ab_email varchar2(255), + ab_hphone varchar2(255), + ab_wphone varchar2(255), + ab_fax varchar2(255), + ab_pager varchar2(255), + ab_mphone varchar2(255), + ab_ophone varchar2(255), + ab_street varchar2(255), + ab_city varchar2(255), + ab_state varchar2(255), + ab_zip varchar2(255), + ab_bday varchar2(255), + ab_notes varchar2(4000), + ab_company varchar2(255), + PRIMARY KEY (ab_id) ); create sequence addressbook_seq diff --git a/doc/create_tables.pgsql b/doc/create_tables.pgsql index d8034a5c08..c4f20f3ef1 100755 --- a/doc/create_tables.pgsql +++ b/doc/create_tables.pgsql @@ -94,24 +94,24 @@ CREATE TABLE profiles ( ); create table addressbook ( - con serial, - owner varchar(25), - access varchar(10), - firstname varchar(255), - lastname varchar(255), - email varchar(255), - hphone varchar(255), - wphone varchar(255), - fax varchar(255), - pager varchar(255), - mphone varchar(255), - ophone varchar(255), - street varchar(255), - city varchar(255), - state varchar(255), - zip varchar(255), - bday varchar(255), - notes TEXT, + ab_id serial, + ab_owner varchar(25), + ab_access varchar(10), + ab_firstname varchar(255), + ab_lastname varchar(255), + ab_email varchar(255), + ab_hphone varchar(255), + ab_wphone varchar(255), + ab_fax varchar(255), + ab_pager varchar(255), + ab_mphone varchar(255), + ab_ophone varchar(255), + ab_street varchar(255), + ab_city varchar(255), + ab_state varchar(255), + ab_zip varchar(255), + ab_bday varchar(255), + ab_notes TEXT, company varchar(255) );