diff --git a/addressbook/add.php b/addressbook/add.php index 86283beae7..d8f75ae96f 100755 --- a/addressbook/add.php +++ b/addressbook/add.php @@ -26,58 +26,64 @@ } else if (! $submit && ! $add_email) { form("","add.php","Add","","",""); } else { - if ($bday_month == "" && $bday_day == "" && $bday_year == "") + if ($bday_month == "" && $bday_day == "" && $bday_year == "") { $bday = ""; - else + } else { $bday = "$bday_month/$bday_day/$bday_year"; + } - $access = $phpgw->accounts->array_to_string($access,$n_groups); - if($phpgw_info["apps"]["timetrack"]["enabled"]) { + if ($access != "private" && $access != "public") { + $access = $phpgw->accounts->array_to_string($access,$n_groups); + } + + if ($phpgw_info["apps"]["timetrack"]["enabled"]) { $sql = "insert into addressbook (ab_owner,ab_access,ab_firstname,ab_lastname,ab_title,ab_email," - . "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) values ('" . $phpgw_info["user"]["account_id"] . "','$access','" - . addslashes($firstname). "','" - . addslashes($lastname) . "','" - . addslashes($title) . "','" - . addslashes($email) . "','" - . addslashes($hphone) . "','" - . addslashes($wphone) . "','" - . addslashes($fax) . "','" - . addslashes($pager) . "','" - . addslashes($mphone) . "','" - . addslashes($ophone) . "','" - . addslashes($street) . "','" - . addslashes($address2) . "','" - . addslashes($city) . "','" - . addslashes($state) . "','" - . addslashes($zip) . "','" - . addslashes($bday) . "','" - . addslashes($notes) . "','" - . addslashes($company). "')"; + . "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_url) values ('" . $phpgw_info["user"]["account_id"] . "','$access','" + . addslashes($firstname). "','" + . addslashes($lastname) . "','" + . addslashes($title) . "','" + . addslashes($email) . "','" + . addslashes($hphone) . "','" + . addslashes($wphone) . "','" + . addslashes($fax) . "','" + . addslashes($pager) . "','" + . addslashes($mphone) . "','" + . addslashes($ophone) . "','" + . addslashes($street) . "','" + . addslashes($address2) . "','" + . addslashes($city) . "','" + . addslashes($state) . "','" + . addslashes($zip) . "','" + . addslashes($bday) . "','" + . addslashes($notes) . "','" + . addslashes($company) . "','" + . addslashes($url) . "')"; } else { $sql = "insert into addressbook (ab_owner,ab_access,ab_firstname,ab_lastname,ab_title,ab_email," - . "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) values ('" . $phpgw_info["user"]["account_id"] . "','$access','" - . addslashes($firstname). "','" - . addslashes($lastname) . "','" - . addslashes($title) . "','" - . addslashes($email) . "','" - . addslashes($hphone) . "','" - . addslashes($wphone) . "','" - . addslashes($fax) . "','" - . addslashes($pager) . "','" - . addslashes($mphone) . "','" - . addslashes($ophone) . "','" - . addslashes($street) . "','" - . addslashes($address2) . "','" - . addslashes($city) . "','" - . addslashes($state) . "','" - . addslashes($zip) . "','" - . addslashes($bday) . "','" - . addslashes($notes) . "','" - . addslashes($company). "')"; + . "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_url) values ('" . $phpgw_info["user"]["account_id"] . "','$access','" + . addslashes($firstname). "','" + . addslashes($lastname) . "','" + . addslashes($title) . "','" + . addslashes($email) . "','" + . addslashes($hphone) . "','" + . addslashes($wphone) . "','" + . addslashes($fax) . "','" + . addslashes($pager) . "','" + . addslashes($mphone) . "','" + . addslashes($ophone) . "','" + . addslashes($street) . "','" + . addslashes($address2) . "','" + . addslashes($city) . "','" + . addslashes($state) . "','" + . addslashes($zip) . "','" + . addslashes($bday) . "','" + . addslashes($notes) . "','" + . addslashes($company) . "','" + . addslashes($url) . "')"; } $phpgw->db->query($sql); @@ -86,20 +92,20 @@ } ?> - +
- +
- - - diff --git a/addressbook/edit.php b/addressbook/edit.php index 445c110606..6cfe29394a 100755 --- a/addressbook/edit.php +++ b/addressbook/edit.php @@ -27,31 +27,33 @@ if (! $submit) { $phpgw->db->query("SELECT * FROM addressbook WHERE ab_owner='" - . $phpgw_info["user"]["account_id"] . "' AND ab_id=$ab_id"); + . $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") + $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") ); form("","edit.php","Edit",$fields); @@ -64,45 +66,47 @@ 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) - . "' WHERE ab_owner='" . $phpgw_info["user"]["account_id"] . "' AND ab_id=$ab_id"; + . "', 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_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_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"; } @@ -120,16 +124,16 @@ -
- + + "> - + + "> + " . lang("Cancel"); ?>
+
- - - diff --git a/addressbook/inc/functions.inc.php b/addressbook/inc/functions.inc.php index e083d8294f..3bede63c9f 100755 --- a/addressbook/inc/functions.inc.php +++ b/addressbook/inc/functions.inc.php @@ -32,8 +32,7 @@ function form($format,$action,$title,$fields) { - global $phpgw; - global $phpgw_info; + global $phpgw, $phpgw_info; $email = $fields["email"]; $firstname = $fields["firstname"]; @@ -56,6 +55,7 @@ $ab_company = $fields["company"]; $company_id = $fields["company_id"]; $company_name = $fields["company_name"]; + $url = $fields["url"]; if ($format != "view") { $email = ""; @@ -73,6 +73,8 @@ $city = ""; $state = ""; $zip = ""; + $url = ""; + if($phpgw_info["apps"]["timetrack"]["enabled"]) { $company = ' - + : + + + + + '; + $ab_id = $phpgw->db->f("ab_id"); + while ($column = each($columns_to_display)) { if ($phpgw_info["apps"]["timetrack"]["enabled"]) { if ($column[0] == "company") { @@ -174,46 +176,43 @@ $field = $phpgw->db->f("ab_" . $column[0]); } - if (! $field) { - $field = " "; - } else { - $field = htmlentities($field); - } + $field = htmlentities($field); // Some fields require special formating. if ($column[0] == "url") { echo ''; + . '' . $field. ' '; } else if ($column[0] == "email") { if ($phpgw_info["user"]["apps"]["email"]) { echo ''; + "to=" . urlencode($field)) . '" target="_top">' . $field . ' '; } else { echo ''; + . '' . $field. ' '; } } else { echo ''; + . $field . ' '; } } + reset($columns_to_display); // If we don't reset it, our inside while won't loop ?> - - - - + + + + diff --git a/addressbook/view.php b/addressbook/view.php index 67877bf987..916dfb0341 100755 --- a/addressbook/view.php +++ b/addressbook/view.php @@ -24,71 +24,78 @@ } if ($filter != "private") + { $filtermethod = " or ab_access='public' " . $phpgw->accounts->sql_search("ab_access"); + } - if($phpgw_info["apps"]["timetrack"]["enabled"]) { - $phpgw->db->query("SELECT * FROM addressbook as a, customers as c WHERE a.ab_company_id = c.company_id " - . "AND ab_id=$ab_id AND (ab_owner='" - . $phpgw_info["user"]["account_id"] . "' $filtermethod)"); + if ($phpgw_info["apps"]["timetrack"]["enabled"]) { + $phpgw->db->query("SELECT * FROM addressbook as a, customers as c WHERE a.ab_company_id = c.company_id " + . "AND ab_id=$ab_id AND (ab_owner='" + . $phpgw_info["user"]["account_id"] . "' $filtermethod)"); } else { - $phpgw->db->query("SELECT * FROM addressbook " - . "WHERE ab_id=$ab_id AND (ab_owner='" + $phpgw->db->query("SELECT * FROM addressbook WHERE ab_id=$ab_id AND (ab_owner='" . $phpgw_info["user"]["account_id"] . "' $filtermethod)"); } $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"), - 'company_name' => $phpgw->db->f("company_name"), - 'notes' => $phpgw->db->f("ab_notes") - ); + echo "

 " . lang("Address book - view") . "


"; - $owner = $phpgw->db->f("ab_owner"); - $ab_id = $phpgw->db->f("ab_id"); - form("view","","View",$fields); + $i = 0; + while ($column = each($abc)) { + if ($phpgw->db->f("ab_" . $column[0])) { + $columns_to_display[$i]["field_name"] = $column[1]; + $columns_to_display[$i]["field_value"] = $phpgw->db->f("ab_" . $column[0]); + $i++; + } + } + + echo '

+ "> + " . lang("Cancel"); ?> + " . lang("Delete"); ?>
: - - - + + + + + : + + + + +
: @@ -317,7 +331,7 @@ . ":
' - . '' . $field. '' . '' . $field . '' - . '' . $field. '' - . $field . ' - - + " size="2"> + "> - - - - common->check_owner($phpgw->db->f("ab_owner"),"edit.php",lang("edit"),"ab_id=" . $phpgw->db->f("ab_id")); ?> - -
+ " size="2"> + common->check_owner($phpgw->db->f("ab_owner"),"edit.php",lang("edit"),"ab_id=" . $phpgw->db->f("ab_id")); ?> + +
'; + for ($i=0;$i<200;) { // The $i<200 is only used for a brake + if (! $columns_to_display[$i]["field_name"]) break; + + $columns_html .= "" + . ""; + + $i++; + + if (! $columns_to_display[$i]["field_name"]) break; + + $columns_html .= "" + . ""; + } + $owner = $phpgw->db->f("ab_owner"); + $access = $phpgw->db->f("ab_access"); + + echo $columns_html . ''; + echo "
" . lang($columns_to_display[$i]["field_name"]) . ":" . $columns_to_display[$i]["field_value"] . "" . lang($columns_to_display[$i]["field_name"]) . ":" . $columns_to_display[$i]["field_value"]; + + $i++; + $columns_html .= "
 
" . lang("Record owner") . "" + . $phpgw->common->grab_owner_name($phpgw->db->f("ab_owner")) . "" + . lang("Record Access") . ""; + + if ($access != "private" && $access != "public") { + echo lang("Group access") . $phpgw->accounts->convert_string_to_names_access($access); + } else { + + echo $access; + } + + echo "
"; ?> - - - - - - -
- - - - - - - -
- common->check_owner($ab_id,$owner,"Edit"); - ?> - - ">Done -
-
- + + + + + +
+ common->check_owner($owner,"edit.php","Edit"); + ?> + + ">Done +
+ common->phpgw_footer(); ?>