Working on merging in a patch for the addressbook, but first cleaning up some code

This commit is contained in:
jengo 2000-11-01 10:26:14 +00:00
parent 46ca74feff
commit 793040b5ba
9 changed files with 157 additions and 149 deletions

View File

@ -12,31 +12,49 @@
/* $Id$ */
$abc = array('company' => 'company', // AddressBook Columns and their descriptions
'firstname' => 'first name',
'lastname' => 'last name',
'email' => 'email',
'wphone' => 'work phone',
'hphone' => 'home phone',
'fax' => 'fax',
'pager' => 'pager',
'mphone' => 'mobile phone',
'ophone' => 'other phone',
'street' => 'street',
'city' => 'city',
'state' => 'state',
'zip' => 'zip code',
'bday' => 'birthday',
'url' => 'URL'
);
function form($format,$action,$title,$fields)
{
global $phpgw;
global $phpgw_info;
$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"];
$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"];
if ($format != "view") {

View File

@ -52,7 +52,7 @@
. "%$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%')");
. "'%$query%' OR c.company_name like '%$query%' OR a.ab_url like '%$query%')");
// . "'%$query%' OR c.company_name like '%$query%')"
// . " $ordermethod limit $limit");
} else {
@ -62,7 +62,7 @@
. "%$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%')");
. "'%$query%' OR ab_company like '%$query%' OR ab_url like '%$query$%')");
// . "'%$query%' OR ab_company like '%$query%')"
// . " $ordermethod limit $limit");
}
@ -100,39 +100,17 @@
<table width=75% border=0 cellspacing=1 cellpadding=3>
<tr bgcolor="<?php echo $phpgw_info["theme"]["th_bg"]; ?>">
<?php
if ($phpgw_info["user"]["preferences"]["addressbook"]["company"]) {
echo '<td height="21">';
echo '<font size="-1" face="Arial, Helvetica, sans-serif">';
echo $phpgw->nextmatchs->show_sort_order($sort,$company_sortorder,$order,"index.php",lang("Company Name"));
echo '</font></td>';
}
if ($phpgw_info["user"]["preferences"]["addressbook"]["lastname"]) {
echo '<td height="21">';
echo '<font size="-1" face="Arial, Helvetica, sans-serif">';
echo $phpgw->nextmatchs->show_sort_order($sort,"ab_lastname",$order,"index.php",
lang("Last Name"));
echo '</font></td>';
}
if ($phpgw_info["user"]["preferences"]["addressbook"]["firstname"]) {
echo '<td height="21">';
echo '<font size="-1" face="Arial, Helvetica, sans-serif">';
echo $phpgw->nextmatchs->show_sort_order($sort,"ab_firstname",$order,"index.php",
lang("First Name"));
echo '</font></td>';
}
if ($phpgw_info["user"]["preferences"]["addressbook"]["email"]) {
echo '<td height="21">';
echo '<font size="-1" face="Arial, Helvetica, sans-serif">';
echo $phpgw->nextmatchs->show_sort_order($sort,"ab_email",$order,"index.php",
lang("Email"));
echo '</font></td>';
}
if ($phpgw_info["user"]["preferences"]["addressbook"]["wphone"]) {
echo '<td height="21">';
echo '<font size="-1" face="Arial, Helvetica, sans-serif">';
echo $phpgw->nextmatchs->show_sort_order($sort,"ab_wphone",$order,"index.php",
lang("Work Phone"));
echo '</font></td>';
while ($column = each($abc)) {
if ($phpgw_info["user"]["preferences"]["addressbook"][$column[0]]) {
echo '<td height="21">';
echo '<font size="-1" face="Arial, Helvetica, sans-serif">';
echo $phpgw->nextmatchs->show_sort_order($sort,"ab_" . $column[0],$order,"index.php",lang($column[1]));
echo '</font></td>';
echo "\n";
// To be used when displaying the rows
$columns_to_display[$column[0]] = True;
}
}
?>
@ -149,97 +127,80 @@
</tr>
</form>
<?php
if ($query) {
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 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");
} else {
$phpgw->db->query("SELECT ab_id,ab_owner,ab_firstname,ab_lastname,"
. "ab_email,ab_wphone,ab_company "
. "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");
}
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 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");
} else {
$phpgw->db->query("SELECT ab_id,ab_owner,ab_firstname,ab_lastname,"
. "ab_email,ab_wphone,ab_company "
. "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 {
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");
} else {
$phpgw->db->query("SELECT ab_id,ab_owner,ab_firstname,ab_lastname,"
. "ab_email,ab_wphone,ab_company "
. "from addressbook "
. "WHERE $filtermethod $ordermethod limit $limit");
}
}
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");
} else {
$phpgw->db->query("SELECT * from addressbook WHERE $filtermethod $ordermethod limit $limit");
}
} // else $query
while ($phpgw->db->next_record()) {
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
echo '<tr bgcolor="#' . $tr_color . '">';
while ($column = each($columns_to_display)) {
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
if ($column[0] == "company") {
$field = $phpgw->db->f("company_name");
} else {
$field = $phpgw->db->f("ab_company");
}
} else {
$field = $phpgw->db->f("ab_" . $column[0]);
}
$firstname = $phpgw->db->f("ab_firstname");
$lastname = $phpgw->db->f("ab_lastname");
$email = $phpgw->db->f("ab_email");
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
$company = $phpgw->db->f("company_name");
} else {
$company = $phpgw->db->f("ab_company");
if (! $field) {
$field = "&nbsp;";
} else {
$field = htmlentities($field);
}
// Some fields require special formating.
if ($column[0] == "url") {
echo '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
. '<a href="' . $field . '" target="_top">' . $field. '</a></font></td>';
} else if ($column[0] == "email") {
if ($phpgw_info["user"]["apps"]["email"]) {
echo '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
. '<a href="' . $phpgw->link($phpgw_info["server"]["webserver_url"] . "/email/compose.php",
"to=" . urlencode($field)) . '" target="_top">' . $field . '</a></font></td>';
} else {
echo '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
. '<a href="mailto:' . $field . '" target="_top">' . $field. '</a></font></td>';
}
} else {
echo '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
. $field . '</font></td>';
}
}
$wphone = $phpgw->db->f("ab_wphone");
$ab_id = $phpgw->db->f("ab_id");
if ($firstname == "") $firstname = "&nbsp;";
if ($lastname == "") $lastname = "&nbsp;";
if ($email == "") $email = "&nbsp;";
if ($company == "") $company = "&nbsp;";
if ($wphone == "") $wphone = "&nbsp;";
?>
<?php
echo '<tr bgcolor="#'.$tr_color.'";>';
if ($phpgw_info["user"]["preferences"]["addressbook"]["company"]) {
echo '<td valign=top>';
echo '<font face=Arial, Helvetica, sans-serif size=2>';
echo $company;
echo '</font></td>';
};
if ($phpgw_info["user"]["preferences"]["addressbook"]["lastname"]) {
echo '<td valign=top>';
echo '<font face=Arial, Helvetica, sans-serif size=2>';
echo $lastname;
echo '</font></td>';
};
if ($phpgw_info["user"]["preferences"]["addressbook"]["firstname"]) {
echo '<td valign=top>';
echo '<font face=Arial, Helvetica, sans-serif size=2>';
echo $firstname;
echo '</font></td>';
};
if ($phpgw_info["user"]["preferences"]["addressbook"]["email"]) {
echo '<td valign=top>';
echo '<font face=Arial, Helvetica, sans-serif size=2>';
echo '<a href="mailto:' . $email . '">' . $email . '</a>';
echo '</font></td>';
};
if ($phpgw_info["user"]["preferences"]["addressbook"]["wphone"]) {
echo '<td valign=top>';
echo '<font face=Arial, Helvetica, sans-serif size=2>';
echo $wphone;
echo '</font></td>';
};
?>
<td valign=top width=3%>
<td valign=top width=3%>
<font face=Arial, Helvetica, sans-serif size=2>
<a href="<?php echo $phpgw->link("view.php","ab_id=$ab_id&start=$start&order=$order&filter="
. "$filter&query=$query&sort=$sort");

View File

@ -47,17 +47,18 @@
// I need to create a common function to handle displaying multiable columns
echo '<tr bgcolor="' . $phpgw_info["theme"]["th_bg"] . '"><td colspan="3">&nbsp;</td></tr>';
$abc = get_abc(); # AddressBook Columns
$i = 0; $j = 0;
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
echo '<tr bgcolor="' . $tr_color . '">';
while (list($col, $descr) = each($abc)) {
// echo "<br>test: $col - $i $j - " . count($abc);
$i++; $j++;
echo '<td><input type="checkbox" name="ab_selected[' . $col . ']" value="True"'
. ($phpgw_info["user"]["preferences"]["addressbook"][$col]?" checked":"") . '>' . $descr
. '</option></td>';
if ($i ==3) {
if ($i == 3) {
echo "</tr>";
$i = 0;
}
@ -66,6 +67,12 @@
echo '<tr bgcolor="' . $tr_color . '">';
}
if ($j == count($abc)) {
if ($i == 1) {
echo "<td>&nbsp;</td><td>&nbsp;</td>";
}
if ($i == 2) {
echo "<td>&nbsp;</td>";
}
echo "</tr>";
}
}

View File

@ -19,6 +19,7 @@
- mcrypt should be working correctly now.
- Fixed problem with email's addressbook not retrieving records.
- Applied patch for accounts->listusers(). Thanks Mathieu van Loon <mathieu@playcollevtive.com>
- Fixed check for new version not working.
[0.9.2] - Fixed sorting bug in currentusers.php
- Cleaned up error reporting and form in newaccount.php

View File

@ -33,8 +33,17 @@
$phpgw->common->read_preferences($phpgw_info["user"]["userid"],"addressbook",True);
$phpgw->common->read_preferences($phpgw_info["user"]["userid"],"email",True);
$phpgw->common->read_preferences($phpgw_info["user"]["userid"],"calendar",True);
if ($phpgw_info["user"]["apps"]["admin"]) {
if ($phpgw_info["server"]["version"] > $phpgw_info["server"]["phpgroupware_api_version"]) {
echo "<p><b>" . lang("Your are running a newer version of phpGroupWare then your database is setup for")
. "<br>" . lang("It is recommend that you run setup to upgrade your tables to the current version")
. "</b>";
}
}
if ($phpgw_info["user"]["permissions"]["admin"] && $phpgw_info["server"]["checkfornewversion"]) {
if ($phpgw_info["user"]["apps"]["admin"] && $phpgw_info["server"]["checkfornewversion"]) {
$phpgw->network->set_addcrlf(False);
if ($phpgw->network->open_port("phpgroupware.org",80,30)) {
$phpgw->network->write_port("GET /currentversion HTTP/1.0\nHOST: www.phpgroupware.org\n\n");

View File

@ -223,8 +223,9 @@
PRIMARY KEY (message_id,app_name,lang)
)";
$db->query($sql);
$sql = "create table domains (
// I decied too hold off on this table until 0.9.4pre1 (jengo)
/* $sql = "create table domains (
domain_id int NOT NULL auto_increment,
domain_name varchar(255),
domain_database varchar(255),
@ -232,5 +233,6 @@
primary key(domain_id)
)";
$db->query($sql);
*/
?>

View File

@ -126,5 +126,6 @@
$db->query("insert into preferences (preference_owner, preference_name, preference_value, preference_appname) values ('demo','firstname','True','addressbook')");
$db->query("insert into preferences (preference_owner, preference_name, preference_value, preference_appname) values ('demo','lastname','True','addressbook')");
$db->query("insert into preferences (preference_owner, preference_name, preference_value, preference_appname) values ('demo','company','True','addressbook')");
$db->query("insert into config (config_name, config_value) values ('phpgroupware_api_version','" . $phpgw_info["server"]["version"] . "')");
?>

View File

@ -294,17 +294,19 @@
if ($currentver == "0.9.3pre4") {
$db->query("alter table config change config_name config_name varchar(255) NOT NULL");
$db->query("create table domains (domain_id int NOT NULL auto_increment, domain_name varchar(255),"
. "domain_database varchar(255),domain_status enum('Active,Disabled'),primary key(domain_id))");
// I decied too hold off on this table until 0.9.4pre1 (jengo)
// $db->query("create table domains (domain_id int NOT NULL auto_increment, domain_name varchar(255),"
// . "domain_database varchar(255),domain_status enum('Active,Disabled'),primary key(domain_id))");
$currentver = "0.9.3pre5";
update_version_table();
}
if ($currentver == "0.9.3pre5") {
$db->query("CREATE TABLE categories (
cat_id int(9) DEFAULT '0' NOT NULL auto_increment,
account_id int(11) DEFAULT '0' NOT NULL,
app_name varchar(25) NOT NULL,
cat_name varchar(150) NOT NULL,
cat_id int(9) DEFAULT '0' NOT NULL auto_increment,
account_id int(11) DEFAULT '0' NOT NULL,
app_name varchar(25) NOT NULL,
cat_name varchar(150) NOT NULL,
cat_description text NOT NULL,
PRIMARY KEY (cat_id))"
);
@ -330,6 +332,9 @@
v9072000to0_9_1();
v0_9_1to0_9_2();
v0_9_2to0_9_3();
$db->query("update config set config_value='" . $phpgw_info["server"]["version"] . "' where "
. "config_name='phpgroupware_api_version'");
if (!$tablechanges == True){
echo " <tr bgcolor=\"e6e6e6\">\n";

View File

@ -310,6 +310,10 @@
v0_9_2to0_9_3pre5();
$db->query("update applications set app_version='".$phpgw_info["server"]["version"]."' where (app_name='admin' or app_name='filemanager' or app_name='addressbook' or app_name='todo' or app_name='calendar' or app_name='email' or app_name='nntp' or app_name='cron_apps')");
$db->query("update config set config_value='" . $phpgw_info["server"]["version"] . "' where "
. "config_name='phpgroupware_api_version'");
if (!$didupgrade == True){
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>No table changes were needed. The script only updated your version setting.</td>\n";