diff -aburN --exclude='CVS*' phpgroupware_old/addressbook/inc/class.uiaddressbook.inc.php phpgroupware/addressbook/inc/class.uiaddressbook.inc.php --- phpgroupware_old/addressbook/inc/class.uiaddressbook.inc.php 2002-04-15 14:06:16.000000000 -0700 +++ phpgroupware/addressbook/inc/class.uiaddressbook.inc.php 2002-08-07 23:27:13.000000000 -0700 @@ -15,6 +15,7 @@ class uiaddressbook { + var $db = ''; var $template; var $contacts; var $bo; @@ -52,6 +53,7 @@ function uiaddressbook() { + $this->db = $GLOBALS['phpgw']->db; $GLOBALS['phpgw']->country = CreateObject('phpgwapi.country'); $GLOBALS['phpgw']->browser = CreateObject('phpgwapi.browser'); $GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs'); @@ -166,6 +168,7 @@ function display_name($column) { $abc = array( + 'id' => 'id', 'fn' => 'full name', 'sound' => 'Sound', 'org_name' => 'company name', @@ -578,9 +581,11 @@ { $addnew = $this->bo->read_entry(array('id' => $GLOBALS['ab_id'], 'fields' => $this->contacts->stock_contact_fields)); + $addnew[0]['id']=$this->next_id(); $addnew[0]['note'] .= "\nCopied from " . $GLOBALS['phpgw']->accounts->id2name($addnew[0]['owner']).", record #".$addnew[0]['id'].'.'; $addnew[0]['owner'] = $GLOBALS['phpgw_info']['user']['account_id']; - unset($addnew[0]['id']); + // unset($addnew[0]['id']); + unset($addnew[0]['choose']); $fields = $addnew[0]; $ab_id = $this->bo->add_entry($fields); @@ -588,8 +593,40 @@ Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.edit&ab_id=' . $ab_id)); } +// ----------------- from soprojects + function exists( $id = '') + { + + $this->db->query("select count(*) from phpgw_addressbook where id = $id ",__LINE__,__FILE__); + + $this->db->next_record(); + + if ($this->db->f(0)) + { + return True; + } + else + { + return False; + } + } + +// ----------------- end from soprojects + + function next_id() + { + $this->db->query("SELECT max(id) as maximum FROM phpgw_addressbook ",__LINE__,__FILE__); + $this->db->next_record(); + $next_id = $this->db->f('maximum')+1; + return "$next_id"; + + } + + function add() { + $this->template->set_var('choose','<input type="checkbox" name="entry[choose]" value="True" checked>'); + $this->template->set_var('lang_choose',lang('Generate Contact ID ?')); if ($GLOBALS['HTTP_POST_VARS']['submit']) { $fields = $this->get_form(); @@ -597,6 +634,45 @@ $referer = urlencode($fields['referer']); unset($fields['referer']); $fields['owner'] = $GLOBALS['phpgw_info']['user']['account_id']; +//------------------------ tilpassing + + if (! $fields['choose']) + { + if (! $fields['id']) + { + echo '<p><center>' . lang('Please enter an ID !') . '</center>'; + } + else + { + $exists = $this->exists($fields['id']); + + if ($exists) + { + echo '<p><center>' . lang('That ID has been used already !') . '</center>'; + } + else + { + $this->bo->add_entry($fields); + } + + } + + } + else + { + // $this->db->query("SELECT max(id) as maximum FROM phpgw_addressbook ",__LINE__,__FILE__); + // $this->db->next_record(); + // $next_id = $this->db->f('maximum')+1; + // $fields['id']="$next_id"; + $fields['id']=$this->next_id(); + + $this->bo->add_entry($fields); + } +//------------------------tilpassing + + if(!exists) + { + $this->bo->add_entry($fields); @@ -607,6 +683,8 @@ $GLOBALS['phpgw']->common->phpgw_exit(); } + } + $this->template->set_file(array('add' => 'add.tpl')); $GLOBALS['phpgw']->common->phpgw_header(); @@ -1177,7 +1255,9 @@ $fields['url'] = $entry['url'] == 'http://' ? '' : $entry['url']; + $fields['choose'] = $entry['choose']; $fields['org_name'] = $entry['company']; + $fields['id'] = $entry['id']; $fields['org_unit'] = $entry['department']; $fields['n_given'] = $entry['firstname']; $fields['n_family'] = $entry['lastname']; @@ -1309,6 +1389,7 @@ $countrylist = True; } + $id = $fields['id']; $email = $fields['email']; $emailtype = $fields['email_type']; $hemail = $fields['email_home']; @@ -1564,6 +1645,8 @@ $this->template->set_var('firstname',$firstname); $this->template->set_var('lang_middle',lang('Middle Name')); $this->template->set_var('middle',$middle); + $this->template->set_var('lang_id',lang('ID')); + $this->template->set_var('id',$id); $this->template->set_var('lang_prefix',lang('Prefix')); $this->template->set_var('prefix',$prefix); $this->template->set_var('lang_suffix',lang('Suffix')); diff -aburN --exclude='CVS*' phpgroupware_old/addressbook/templates/default/form.tpl phpgroupware/addressbook/templates/default/form.tpl --- phpgroupware_old/addressbook/templates/default/form.tpl 2002-02-06 16:08:42.000000000 -0800 +++ phpgroupware/addressbook/templates/default/form.tpl 2002-07-30 12:55:16.000000000 -0700 @@ -1,11 +1,24 @@ <!-- BEGIN addressbook entry form --> <table width="75%" border="0" align="center"> +{search} <tr bgcolor="{th_bg}"> <td colspan="5"><font color="{th_text}" face="">{lang_personal}:</font></td> </tr> <tr bgcolor="{row_on}"> <td>&nbsp;</td> + <td><font color="{row_text}" face="" size="-1">{lang_choose}:</font></td> + <td colspan="3">{choose}</td> + </tr> + <tr bgcolor="{row_off}"> + <td>&nbsp;</td> + <td><font color="{row_text}" face="" size="-1">{lang_id}:</font></td> + <td colspan="3"> + <font size="-1"><input size="10" name="entry[id]" value="{id}"></font> + </td> + </tr> + <tr bgcolor="{row_on}"> + <td>&nbsp;</td> <td><font color="{row_text}" face="" size="-1">{lang_prefix}:</font></td> <td colspan="3"> <font size="-1"><input size="10" name="entry[prefix]" value="{prefix}"></font> diff -aburN --exclude='CVS*' phpgroupware_old/addressbook/templates/default/preferences.tpl phpgroupware/addressbook/templates/default/preferences.tpl --- phpgroupware_old/addressbook/templates/default/preferences.tpl 2002-02-06 16:08:42.000000000 -0800 +++ phpgroupware/addressbook/templates/default/preferences.tpl 2002-07-30 12:49:54.000000000 -0700 @@ -9,6 +9,7 @@ <td colspan="6"><font color="#000000" face="">{lang_personal}:</font></td> </tr> <tr bgcolor="{row_off}"> + <td><input type="checkbox" name="prefs[id]"{id_checked}>{id}</option></td> <td><input type="checkbox" name="prefs[fn]"{fn_checked}>{fn}</option></td> <td><input type="checkbox" name="prefs[n_given]"{n_given_checked}>{n_given}</option></td> <td><input type="checkbox" name="prefs[n_family]"{n_family_checked}>{n_family}</option></td> diff -aburN --exclude='CVS*' phpgroupware_old/phpgwapi/inc/class.contacts_sql.inc.php phpgroupware/phpgwapi/inc/class.contacts_sql.inc.php --- phpgroupware_old/phpgwapi/inc/class.contacts_sql.inc.php 2002-02-06 16:07:42.000000000 -0800 +++ phpgroupware/phpgwapi/inc/class.contacts_sql.inc.php 2002-07-30 14:27:10.000000000 -0700 @@ -46,6 +46,7 @@ /* The left side are the array elements used throughout phpgw, right side are the db field names. */ var $stock_contact_fields = array( + 'id' => 'id', 'fn' => 'fn', 'n_given' => 'n_given', 'n_family' => 'n_family', @@ -559,15 +560,27 @@ list($stock_fields,$stock_fieldnames,$extra_fields) = $this->split_stock_and_extras($fields); +//----------Sigurd--------- + if ( $exists) + { + echo '<p><center>' . lang('That ID has been used already !') . '</center>'; + } + else + { + $this->db->query("INSERT INTO $this->std_table (owner,access,cat_id,tid,".$lid[0] . implode(",",$this->stock_contact_fields) . ") VALUES ('$owner','$access','$cat_id','$tid','".$lid[1] . implode("','",$this->loop_addslashes($stock_fields)) . "')",__LINE__,__FILE__); - $this->db->query("SELECT max(id) FROM $this->std_table ",__LINE__,__FILE__); - $this->db->next_record(); - $id = $this->db->f(0); + // $this->db->query("SELECT max(id) FROM $this->std_table ",__LINE__,__FILE__); + // $this->db->next_record(); + // $id = $this->db->f(0); + + $id = $stock_fields['id']; + } +//----------Sigurd--------- if (count($extra_fields)) { while (list($name,$value) = each($extra_fields))