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]); ?>
'; 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 ' | '; } if ( $phpgw_info["user"]["preferences"]["addressbook_view_lastname"] == "True" ) { 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 ' | '; } if ( $phpgw_info["user"]["preferences"]["addressbook_view_firstname"] == "True" ) { 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 ' | '; } if ( $phpgw_info["user"]["preferences"]["addressbook_view_email"] == "True" ) { 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 ' | '; } if ( $phpgw_info["user"]["preferences"]["addressbook_view_wphone"] == "True" ) { 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 ' | '; } @@ -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 @@ ?>- "> | - 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")); ?> | 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 @@
common->check_owner($con,$owner,"Edit"); + echo $phpgw->common->check_owner($ab_id,$owner,"Edit"); ?> | @@ -79,5 +79,4 @@ |