Add autosetting of cat_id on add if pref set for default

This commit is contained in:
Miles Lott 2001-03-25 09:07:58 +00:00
parent 23ec2bb2b1
commit 3c0832cab2
2 changed files with 16 additions and 11 deletions

View File

@ -39,15 +39,22 @@
} }
} }
if ($phpgw_info["user"]["preferences"]["addressbook"]["autosave_category"] && $cat_id) {
$phpgw->preferences->delete("addressbook","default_category");
$phpgw->preferences->add("addressbook","default_category",$cat_id);
$phpgw->preferences->save_repository();
}
if ($AddVcard){ if ($AddVcard){
Header("Location: " . $phpgw->link("/addressbook/vcardin.php")); Header("Location: " . $phpgw->link("/addressbook/vcardin.php"));
} else if ($add_email) { } else if ($add_email) {
list($fields["firstname"],$fields["lastname"]) = explode(" ", $name); list($fields["firstname"],$fields["lastname"]) = explode(" ", $name);
$fields["email"] = $add_email; $fields["email"] = $add_email;
addressbook_form("","add.php","Add",$fields); addressbook_form("","add.php","Add",$fields,'',$cat_id);
} else if (! $submit && ! $add_email) { } else if (! $submit && ! $add_email) {
// Default // Default
addressbook_form("","add.php","Add","",$customfields); addressbook_form("","add.php","Add","",$customfields,$cat_id);
} elseif ($submit && $fields) { } elseif ($submit && $fields) {
// This came from the view form, Copy entry // This came from the view form, Copy entry
$extrafields = array( $extrafields = array(

View File

@ -33,6 +33,7 @@
} }
} }
// Return a select form element with the categories options in it
function cat_option($cat_id='',$notall=False) { function cat_option($cat_id='',$notall=False) {
global $phpgw_info; global $phpgw_info;
// Setup all and none first // Setup all and none first
@ -53,12 +54,7 @@
// Get global and app-specific category listings // Get global and app-specific category listings
$cats = CreateObject('phpgwapi.categories'); $cats = CreateObject('phpgwapi.categories');
$cats_link .= $cats->formated_list('select','all',$cat_id,True);
$cats->categories($phpgw_info['user']['account_id'],'phpgw');
$cats_link .= $cats->formated_list('select','',$cat_id);
$cats->categories($phpgw_info['user']['account_id'],'addressbook');
$cats_link .= $cats->formated_list('select','',$cat_id);
$cats_link .= '</select>'; $cats_link .= '</select>';
return $cats_link; return $cats_link;
} }
@ -198,7 +194,7 @@
} }
// Folowing used for add/edit // Folowing used for add/edit
function addressbook_form($format,$action,$title="",$fields="",$customfields="") { function addressbook_form($format,$action,$title="",$fields="",$customfields="",$cat_id="") {
global $phpgw, $phpgw_info; global $phpgw, $phpgw_info;
$t = new Template($phpgw->common->get_tpl_dir("addressbook")); $t = new Template($phpgw->common->get_tpl_dir("addressbook"));
@ -258,7 +254,9 @@
$url = $fields["url"]; $url = $fields["url"];
$pubkey = $fields["pubkey"]; $pubkey = $fields["pubkey"];
$access = $fields["access"]; $access = $fields["access"];
if(!$cat_id) {
$cat_id = $fields["cat_id"]; $cat_id = $fields["cat_id"];
}
$cats_link = cat_option($cat_id,True); $cats_link = cat_option($cat_id,True);