From 979d35be5297202ab4950e62dcc0f6d3bfc40292 Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Sun, 21 Jan 2001 06:37:33 +0000 Subject: [PATCH] Add 'add' function to handle new add.php. --- .../inc/class.addressbook_ldap.inc.php | 65 +++++- addressbook/inc/class.addressbook_sql.inc.php | 65 +++++- addressbook/inc/functions.inc.php | 189 +----------------- 3 files changed, 129 insertions(+), 190 deletions(-) diff --git a/addressbook/inc/class.addressbook_ldap.inc.php b/addressbook/inc/class.addressbook_ldap.inc.php index a402aa5090..fb70c16ed0 100644 --- a/addressbook/inc/class.addressbook_ldap.inc.php +++ b/addressbook/inc/class.addressbook_ldap.inc.php @@ -74,6 +74,70 @@ return $this; } + function add_entry() { + global $phpgw,$phpgw_info; + + if($phpgw_info["apps"]["timetrack"]["enabled"]) { + $sql = "INSERT INTO addressbook (" + . "ab_email,ab_firstname,ab_lastname,ab_title,ab_hphone,ab_wphone," + . "ab_fax,ab_pager,ab_mphone,ab_ophone,ab_street,ab_address2," + . "ab_city,ab_state,ab_zip,ab_bday,ab_notes,ab_company_id,ab_access,ab_url," + . "ab_owner) VALUES (" + . " '" . addslashes($this->email) + . "','" . addslashes($this->firstname) + . "','" . addslashes($this->lastname) + . "','" . addslashes($this->title) + . "','" . addslashes($this->hphone) + . "','" . addslashes($this->wphone) + . "','" . addslashes($this->fax) + . "','" . addslashes($this->pager) + . "','" . addslashes($this->mphone) + . "','" . addslashes($this->ophone) + . "','" . addslashes($this->street) + . "','" . addslashes($this->address2) + . "','" . addslashes($this->city) + . "','" . addslashes($this->state) + . "','" . addslashes($this->zip) + . "','" . addslashes($this->bday) + . "','" . addslashes($this->notes) + . "','" . addslashes($this->company_id) + . "','" . addslashes($this->access) + . "','" . addslashes($this->url) + . "','" . $phpgw_info["user"]["account_id"] + . "')"; + } else { + $sql = "INSERT INTO addressbook (" + . "ab_email,ab_firstname,ab_lastname,ab_title,ab_hphone,ab_wphone," + . "ab_fax,ab_pager,ab_mphone,ab_ophone,ab_street,ab_address2," + . "ab_city,ab_state,ab_zip,ab_bday,ab_notes,ab_company,ab_access,ab_url," + . "ab_owner) VALUES (" + . " '" . addslashes($this->email) + . "','" . addslashes($this->firstname) + . "','" . addslashes($this->lastname) + . "','" . addslashes($this->title) + . "','" . addslashes($this->hphone) + . "','" . addslashes($this->wphone) + . "','" . addslashes($this->fax) + . "','" . addslashes($this->pager) + . "','" . addslashes($this->mphone) + . "','" . addslashes($this->ophone) + . "','" . addslashes($this->street) + . "','" . addslashes($this->address2) + . "','" . addslashes($this->city) + . "','" . addslashes($this->state) + . "','" . addslashes($this->zip) + . "','" . addslashes($this->bday) + . "','" . addslashes($this->notes) + . "','" . addslashes($this->company) + . "','" . addslashes($this->access) + . "','" . addslashes($this->url) + . "','" . $phpgw_info["user"]["account_id"] + . "')"; + } + $phpgw->db->query($sql); + return; + } + function update_entry() { global $phpgw,$phpgw_info; @@ -85,7 +149,6 @@ . "', 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) diff --git a/addressbook/inc/class.addressbook_sql.inc.php b/addressbook/inc/class.addressbook_sql.inc.php index a402aa5090..fb70c16ed0 100644 --- a/addressbook/inc/class.addressbook_sql.inc.php +++ b/addressbook/inc/class.addressbook_sql.inc.php @@ -74,6 +74,70 @@ return $this; } + function add_entry() { + global $phpgw,$phpgw_info; + + if($phpgw_info["apps"]["timetrack"]["enabled"]) { + $sql = "INSERT INTO addressbook (" + . "ab_email,ab_firstname,ab_lastname,ab_title,ab_hphone,ab_wphone," + . "ab_fax,ab_pager,ab_mphone,ab_ophone,ab_street,ab_address2," + . "ab_city,ab_state,ab_zip,ab_bday,ab_notes,ab_company_id,ab_access,ab_url," + . "ab_owner) VALUES (" + . " '" . addslashes($this->email) + . "','" . addslashes($this->firstname) + . "','" . addslashes($this->lastname) + . "','" . addslashes($this->title) + . "','" . addslashes($this->hphone) + . "','" . addslashes($this->wphone) + . "','" . addslashes($this->fax) + . "','" . addslashes($this->pager) + . "','" . addslashes($this->mphone) + . "','" . addslashes($this->ophone) + . "','" . addslashes($this->street) + . "','" . addslashes($this->address2) + . "','" . addslashes($this->city) + . "','" . addslashes($this->state) + . "','" . addslashes($this->zip) + . "','" . addslashes($this->bday) + . "','" . addslashes($this->notes) + . "','" . addslashes($this->company_id) + . "','" . addslashes($this->access) + . "','" . addslashes($this->url) + . "','" . $phpgw_info["user"]["account_id"] + . "')"; + } else { + $sql = "INSERT INTO addressbook (" + . "ab_email,ab_firstname,ab_lastname,ab_title,ab_hphone,ab_wphone," + . "ab_fax,ab_pager,ab_mphone,ab_ophone,ab_street,ab_address2," + . "ab_city,ab_state,ab_zip,ab_bday,ab_notes,ab_company,ab_access,ab_url," + . "ab_owner) VALUES (" + . " '" . addslashes($this->email) + . "','" . addslashes($this->firstname) + . "','" . addslashes($this->lastname) + . "','" . addslashes($this->title) + . "','" . addslashes($this->hphone) + . "','" . addslashes($this->wphone) + . "','" . addslashes($this->fax) + . "','" . addslashes($this->pager) + . "','" . addslashes($this->mphone) + . "','" . addslashes($this->ophone) + . "','" . addslashes($this->street) + . "','" . addslashes($this->address2) + . "','" . addslashes($this->city) + . "','" . addslashes($this->state) + . "','" . addslashes($this->zip) + . "','" . addslashes($this->bday) + . "','" . addslashes($this->notes) + . "','" . addslashes($this->company) + . "','" . addslashes($this->access) + . "','" . addslashes($this->url) + . "','" . $phpgw_info["user"]["account_id"] + . "')"; + } + $phpgw->db->query($sql); + return; + } + function update_entry() { global $phpgw,$phpgw_info; @@ -85,7 +149,6 @@ . "', 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) diff --git a/addressbook/inc/functions.inc.php b/addressbook/inc/functions.inc.php index 0ebec0aca1..1acb06eb95 100755 --- a/addressbook/inc/functions.inc.php +++ b/addressbook/inc/functions.inc.php @@ -35,7 +35,7 @@ ); - function form($format,$action,$title,$fields) { + function form($format,$action,$title,$fields) { // used for add/edit global $phpgw, $phpgw_info; $t = new Template($phpgw_info["server"]["app_tpl"]); @@ -279,191 +279,4 @@ $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 .= ''; - $cols .= ''; - $cols .= $phpgw->nextmatchs->show_sort_order($sort,"ab_" . $column[0],$order,"index.php",lang($column[1])); - $cols .= ''; - $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 .= ''; - - $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 .= '' - . '' . $field. ' '; - } else if ($column[0] == "email") { - if ($phpgw_info["user"]["apps"]["email"]) { - $rows .= '' - . '' . $field . ' '; - } else { - $rows .= '' - . '' . $field. ' '; - } - } else { - $rows .= '' - . $field . ' '; - } - #echo ''; - } - reset($columns_to_display); // If we don't reset it, our inside while won't loop - $rows .= ' - - '.lang("View").' - - - - - '.lang("vcard").' - - - - - '.$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).' - - - -'; - } - return array($cols,$rows,$searchreturn,$lang_showing,$search_filter); - } //end list function - ?>