Fix email link; Formatting;

This commit is contained in:
Miles Lott 2002-01-17 03:52:56 +00:00
parent 4b26993512
commit 2421cc1afa
7 changed files with 306 additions and 256 deletions

View File

@ -75,7 +75,10 @@
function read_sessiondata()
{
$data = $GLOBALS['phpgw']->session->appsession('session_data','addressbook');
if($this->debug) { echo '<br>Read:'; _debug_array($data); }
if($this->debug)
{
echo '<br>Read:'; _debug_array($data);
}
$this->start = $data['start'];
$this->limit = $data['limit'];
@ -90,20 +93,23 @@
{
include (PHPGW_APP_INC . '/import/' . $conv_type);
if ($private == '') { $private = 'public'; }
if($private == '')
{
$private = 'public';
}
$row = 0;
$buffer = array();
$contacts = new import_conv;
$buffer = $contacts->import_start_file($buffer);
$fp = fopen($tsvfile,'r');
if ($contacts->type == 'csv')
if($contacts->type == 'csv')
{
while ($data = fgetcsv($fp,8000,','))
while($data = fgetcsv($fp,8000,','))
{
$num = count($data);
$row++;
if ($row == 1)
if($row == 1)
{
$header = $data;
/* Changed here to ignore the header, set to our array
@ -116,10 +122,10 @@
else
{
$buffer = $contacts->import_start_record($buffer);
for ($c=0; $c<$num; $c++ )
for($c=0; $c<$num; $c++)
{
//Send name/value pairs along with the buffer
if ($contacts->import[$header[$c]] != '' && $data[$c] != '')
if($contacts->import[$header[$c]] != '' && $data[$c] != '')
{
$buffer = $contacts->import_new_attrib($buffer, $contacts->import[$header[$c]],$data[$c]);
}
@ -128,25 +134,25 @@
}
}
}
elseif ($contacts->type == 'ldif')
elseif($contacts->type == 'ldif')
{
while ($data = fgets($fp,8000))
while($data = fgets($fp,8000))
{
$url = "";
list($name,$value,$extra) = split(':', $data);
if (substr($name,0,2) == 'dn')
if(substr($name,0,2) == 'dn')
{
$buffer = $contacts->import_start_record($buffer);
}
$test = trim($value);
if ($name && !empty($test) && $extra)
if($name && !empty($test) && $extra)
{
// Probable url string
$url = $test;
$value = $extra;
}
elseif ($name && empty($test) && $extra)
elseif($name && empty($test) && $extra)
{
// Probable multiline encoding
$newval = base64_decode(trim($extra));
@ -154,15 +160,15 @@
//echo $name.':'.$value;
}
if ($name && $value)
if($name && $value)
{
$test = split(',mail=',$value);
if ($test[1])
if($test[1])
{
$name = "mail";
$value = $test[1];
}
if ($url)
if($url)
{
$name = "homeurl";
$value = $url. ':' . $value;
@ -181,32 +187,32 @@
}
else
{
while ($data = fgets($fp,8000))
while($data = fgets($fp,8000))
{
$data = trim($data);
// RB 2001/05/07 added for Lotus Organizer
while (substr($data,-1) == '=')
while(substr($data,-1) == '=')
{
// '=' at end-of-line --> line to be continued with next line
$data = substr($data,0,-1) . trim(fgets($fp,8000));
}
if (strstr($data,';ENCODING=QUOTED-PRINTABLE'))
if(strstr($data,';ENCODING=QUOTED-PRINTABLE'))
{
// RB 2001/05/07 added for Lotus Organizer
$data = quoted_printable_decode(str_replace(';ENCODING=QUOTED-PRINTABLE','',$data));
}
list($name,$value) = explode(':', $data,2); // RB 2001/05/09 to allow ':' in Values (not only in URL's)
if (strtolower(substr($name,0,5)) == 'begin')
if(strtolower(substr($name,0,5)) == 'begin')
{
$buffer = $contacts->import_start_record($buffer);
}
if ($name && $value)
if($name && $value)
{
reset($contacts->import);
while ( list($fname,$fvalue) = each($contacts->import) )
while(list($fname,$fvalue) = each($contacts->import))
{
if ( strstr(strtolower($name), $contacts->import[$fname]) )
if(strstr(strtolower($name), $contacts->import[$fname]))
{
$buffer = $contacts->import_new_attrib($buffer,$name,$value);
}
@ -227,14 +233,14 @@
function export($conv_type,$cat_id='')
{
include (PHPGW_APP_INC . '/export/' . $conv_type);
$buffer=array();
$buffer = array();
$contacts = new export_conv;
// Read in user custom fields, if any
$customfields = array();
while (list($col,$descr) = @each($GLOBALS['phpgw_info']['user']['preferences']['addressbook']))
while(list($col,$descr) = @each($GLOBALS['phpgw_info']['user']['preferences']['addressbook']))
{
if ( substr($col,0,6) == 'extra_' )
if(substr($col,0,6) == 'extra_')
{
$field = ereg_replace('extra_','',$col);
$field = ereg_replace(' ','_',$field);
@ -246,12 +252,12 @@
'address2' => 'address2',
'address3' => 'address3'
);
if ($contacts->type != 'vcard')
if($contacts->type != 'vcard')
{
$contacts->qfields = $contacts->stock_contact_fields;# + $extrafields;# + $customfields;
}
if (!empty($cat_id))
if(!empty($cat_id))
{
$buffer = $contacts->export_start_file($buffer,$cat_id);
}
@ -260,10 +266,10 @@
$buffer = $contacts->export_start_file($buffer);
}
for ($i=0;$i<count($contacts->ids);$i++)
for($i=0;$i<count($contacts->ids);$i++)
{
$buffer = $contacts->export_start_record($buffer);
while( list($name,$value) = each($contacts->currentrecord) )
while(list($name,$value) = each($contacts->currentrecord))
{
$buffer = $contacts->export_new_attrib($buffer,$name,$value);
}

View File

@ -125,7 +125,10 @@
$this->filter = $_filter;
}
if($this->debug) { $this->_debug_sqsof(); }
if($this->debug)
{
$this->_debug_sqsof();
}
}
function _debug_sqsof()
@ -150,7 +153,7 @@
in which case the input might be an array. The server always calls
this function to fill the server dispatch map using a string.
*/
if (is_array($_type))
if(is_array($_type))
{
$_type = $_type['type'] ? $_type['type'] : $_type[0];
}
@ -202,9 +205,12 @@
function save_sessiondata($data)
{
if ($this->use_session)
if($this->use_session)
{
if($this->debug) { echo '<br>Save:'; _debug_array($data); }
if($this->debug)
{
echo '<br>Save:'; _debug_array($data);
}
$GLOBALS['phpgw']->session->appsession('session_data','addressbook',$data);
}
}
@ -212,7 +218,10 @@
function read_sessiondata()
{
$data = $GLOBALS['phpgw']->session->appsession('session_data','addressbook');
if($this->debug) { echo '<br>Read:'; _debug_array($data); }
if($this->debug)
{
echo '<br>Read:'; _debug_array($data);
}
$this->start = $data['start'];
$this->limit = $data['limit'];
@ -226,7 +235,7 @@
function strip_html($dirty = '')
{
if ($dirty == '')
if($dirty == '')
{
$dirty = array();
}
@ -234,7 +243,7 @@
{
if(gettype($dirty[$i]) == 'array')
{
while (list($name,$value) = @each($dirty[$i]))
while(list($name,$value) = @each($dirty[$i]))
{
$cleaned[$i][$name] = $GLOBALS['phpgw']->strip_html($dirty[$i][$name]);
}
@ -251,7 +260,10 @@
{
$entries = $this->so->read_entries($data);
$this->total = $this->so->contacts->total_records;
if($this->debug) { echo '<br>Total records="' . $this->total . '"'; }
if($this->debug)
{
echo '<br>Total records="' . $this->total . '"';
}
return $this->strip_html($entries);
}
@ -313,8 +325,11 @@
global $name,$referer;
$named = explode(' ', $name);
for ($i=count($named);$i>=0;$i--) { $names[$i] = $named[$i]; }
if ($names[2])
for($i=count($named);$i>=0;$i--)
{
$names[$i] = $named[$i];
}
if($names[2])
{
$fields['n_given'] = $names[0];
$fields['n_middle'] = $names[1];
@ -358,13 +373,13 @@
function save_preferences($prefs,$other,$qfields,$fcat_id)
{
$GLOBALS['phpgw']->preferences->read_repository();
if (is_array($prefs))
if(is_array($prefs))
{
/* _debug_array($prefs);exit; */
while (list($pref,$x) = each($qfields))
while(list($pref,$x) = each($qfields))
{
/* echo '<br>checking: ' . $pref . '=' . $prefs[$pref]; */
if ($prefs[$pref] == 'on')
if($prefs[$pref] == 'on')
{
$GLOBALS['phpgw']->preferences->add('addressbook',$pref,'addressbook_on');
}
@ -378,19 +393,19 @@
if(is_array($other))
{
$GLOBALS['phpgw']->preferences->delete('addressbook','mainscreen_showbirthdays');
if ($other['mainscreen_showbirthdays'])
if($other['mainscreen_showbirthdays'])
{
$GLOBALS['phpgw']->preferences->add('addressbook','mainscreen_showbirthdays',True);
}
$GLOBALS['phpgw']->preferences->delete('addressbook','default_filter');
if ($other['default_filter'])
if($other['default_filter'])
{
$GLOBALS['phpgw']->preferences->add('addressbook','default_filter',True);
}
$GLOBALS['phpgw']->preferences->delete('addressbook','autosave_category');
if ($other['autosave_category'])
if($other['autosave_category'])
{
$GLOBALS['phpgw']->preferences->add('addressbook','autosave_category',True);
}

View File

@ -71,7 +71,7 @@
function read_entry($id,$fields)
{
if ($this->rights & PHPGW_ACL_READ)
if($this->rights & PHPGW_ACL_READ)
{
return $this->contacts->read_single_entry($id,$fields);
}
@ -84,7 +84,7 @@
function read_last_entry($fields)
{
if ($this->rights & PHPGW_ACL_READ)
if($this->rights & PHPGW_ACL_READ)
{
return $this->contacts->read_last_entry($fields);
}
@ -102,7 +102,7 @@
{
$fields['tid'] = 'n';
}
if ($this->rights & PHPGW_ACL_ADD)
if($this->rights & PHPGW_ACL_ADD)
{
$ab_id = $fields['ab_id'];
$owner = $fields['owner'];
@ -129,7 +129,7 @@
function update_entry($fields)
{
if ($this->rights & PHPGW_ACL_EDIT)
if($this->rights & PHPGW_ACL_EDIT)
{
$ab_id = $fields['ab_id'];
$owner = $fields['owner'];
@ -148,7 +148,7 @@
function delete_entry($data)
{
if ($this->rights & PHPGW_ACL_DELETE)
if($this->rights & PHPGW_ACL_DELETE)
{
$this->contacts->delete($data['id']);
}

View File

@ -49,16 +49,16 @@
/* Return a select form element with the categories option dialog in it */
function cat_option($cat_id='',$notall=False,$java=True,$multiple=False)
{
if ($java)
if($java)
{
$jselect = ' onChange="this.form.submit();"';
}
/* Setup all and none first */
$cats_link = "\n" .'<select name="fcat_id'.($multiple?'[]':'').'"' .$jselect . ($multiple ? 'multiple size="3"' : '') . ">\n";
if (!$notall)
if(!$notall)
{
$cats_link .= '<option value=""';
if ($cat_id=='all')
if($cat_id=='all')
{
$cats_link .= ' selected';
}
@ -75,11 +75,11 @@
{
global $convert,$download,$tsvfile,$private,$conv_type,$fcat_id;
if ($convert)
if($convert)
{
$buffer = $this->bo->import($tsvfile,$conv_type,$private,$fcat_id);
if ($download == '')
if($download == '')
{
if($conv_type == 'Debug LDAP' || $conv_type == 'Debug SQL' )
{
@ -115,9 +115,9 @@
$dir_handle = opendir(PHPGW_APP_INC . SEP . 'import');
$i=0; $myfilearray = '';
while ($file = readdir($dir_handle))
while($file = readdir($dir_handle))
{
if ((substr($file, 0, 1) != '.') && is_file(PHPGW_APP_INC . SEP . 'import' . SEP . $file) )
if((substr($file, 0, 1) != '.') && is_file(PHPGW_APP_INC . SEP . 'import' . SEP . $file) )
{
$myfilearray[$i] = $file;
$i++;
@ -125,7 +125,7 @@
}
closedir($dir_handle);
sort($myfilearray);
for ($i=0;$i<count($myfilearray);$i++)
for($i=0;$i<count($myfilearray);$i++)
{
$fname = ereg_replace('_',' ',$myfilearray[$i]);
$conv .= '<OPTION VALUE="' . $myfilearray[$i].'">' . $fname . '</OPTION>';
@ -166,11 +166,11 @@
{
global $convert,$tsvfilename,$cat_id,$download,$conv_type;
if ($convert)
if($convert)
{
$buffer = $this->bo->export($conv_type,$cat_id);
if ($conv_type == 'none')
if($conv_type == 'none')
{
$GLOBALS['phpgw_info']['flags']['noheader'] = False;
$GLOBALS['phpgw_info']['flags']['noheader'] = True;
@ -182,7 +182,7 @@
$GLOBALS['phpgw']->common->phpgw_exit();
}
if ( ($download == 'on') || ($o->type == 'pdb') )
if(($download == 'on') || ($o->type == 'pdb'))
{
// filename, default application/octet-stream, length of file, default nocache True
$this->browser->content_header($tsvfilename,'application/octet-stream',strlen($buffer));
@ -208,9 +208,9 @@
$dir_handle = opendir(PHPGW_APP_INC. SEP . 'export');
$i=0; $myfilearray = '';
while ($file = readdir($dir_handle))
while($file = readdir($dir_handle))
{
if ((substr($file, 0, 1) != '.') && is_file(PHPGW_APP_INC . SEP . 'export' . SEP . $file) )
if((substr($file, 0, 1) != '.') && is_file(PHPGW_APP_INC . SEP . 'export' . SEP . $file) )
{
$myfilearray[$i] = $file;
$i++;
@ -218,7 +218,7 @@
}
closedir($dir_handle);
sort($myfilearray);
for ($i=0;$i<count($myfilearray);$i++)
for($i=0;$i<count($myfilearray);$i++)
{
$fname = ereg_replace('_',' ',$myfilearray[$i]);
$conv .= ' <option value="'.$myfilearray[$i].'">'.$fname.'</option>'."\n";

View File

@ -75,7 +75,10 @@
$this->order = $this->bo->order;
$this->filter = $this->bo->filter;
$this->cat_id = $this->bo->cat_id;
if($this->debug) { $this->_debug_sqsof(); }
if($this->debug)
{
$this->_debug_sqsof();
}
}
function _debug_sqsof()
@ -110,7 +113,7 @@
function formatted_list($name,$list,$id='',$default=False,$java=False)
{
if ($java)
if($java)
{
$jselect = ' onChange="this.form.submit();"';
}
@ -120,10 +123,10 @@
{
$select .= '<option value="">' . lang('Please Select') . '</option>'."\n";
}
while (list($key,$val) = each($list))
while(list($key,$val) = each($list))
{
$select .= '<option value="' . $key . '"';
if ($key == $id && $id != '')
if($key == $id && $id != '')
{
$select .= ' selected';
}
@ -140,10 +143,10 @@
{
$fields = array();
@reset($this->prefs);
while (list($col,$descr) = @each($this->prefs))
while(list($col,$descr) = @each($this->prefs))
{
$tmp = '';
if ( substr($col,0,6) == 'extra_' )
if(substr($col,0,6) == 'extra_')
{
$tmp = ereg_replace('extra_','',$col);
$tmp = ereg_replace(' ','_',$tmp);
@ -157,7 +160,7 @@
function save_custom_field($old='',$new='')
{
$GLOBALS['phpgw']->preferences->read_repository($GLOBALS['phpgw_info']['user']['account_id']);
if ($old)
if($old)
{
$GLOBALS['phpgw']->preferences->delete('addressbook','extra_' . $old);
}
@ -171,25 +174,25 @@
/* Return a select form element with the categories option dialog in it */
function cat_option($cat_id='',$notall=False,$java=True,$multiple=False)
{
if ($java)
if($java)
{
$jselect = ' onChange="this.form.submit();"';
}
/* Setup all and none first */
$cats_link = "\n" .'<select name="fcat_id'.($multiple?'[]':'').'"' .$jselect . ($multiple ? 'multiple size="3"' : '') . ">\n";
if (!$notall)
$cats_link = "\n" . '<select name="fcat_id' . ($multiple?'[]':'') . '"' . $jselect . ($multiple ? 'multiple size="3"' : '') . ">\n";
if(!$notall)
{
$cats_link .= '<option value=""';
if ($cat_id=="all")
if($cat_id == 'all')
{
$cats_link .= ' selected';
}
$cats_link .= '>'.lang("all").'</option>'."\n";
$cats_link .= '>' . lang("all") . '</option>'."\n";
}
/* Get global and app-specific category listings */
$cats_link .= $this->cat->formated_list('select','all',$cat_id,True);
$cats_link .= '</select>'."\n";
$cats_link .= '</select>' . "\n";
return $cats_link;
}
@ -248,7 +251,7 @@
'note' => 'notes'
);
if ($abc[$column])
if($abc[$column])
{
return lang($abc[$column]);
}
@ -271,11 +274,11 @@
$customfields = $this->read_custom_fields();
if (!isset($this->cat_id))
if(!isset($this->cat_id))
{
$this->cat_id = $this->prefs['default_category'];
}
if ($this->prefs['autosave_category'])
if($this->prefs['autosave_category'])
{
$GLOBALS['phpgw']->preferences->read_repository();
$GLOBALS['phpgw']->preferences->delete('addressbook','default_category');
@ -285,10 +288,10 @@
/* $qfields = $contacts->stock_contact_fields + $extrafields + $customfields; */
/* create column list and the top row of the table based on user prefs */
while ($column = each($this->contacts->stock_contact_fields))
while($column = each($this->contacts->stock_contact_fields))
{
$test = strtolower($column[0]);
if (isset($this->prefs[$test]) && $this->prefs[$test])
if(isset($this->prefs[$test]) && $this->prefs[$test])
{
$showcol = $this->display_name($column[0]);
$cols .= ' <td height="21">' . "\n";
@ -304,14 +307,17 @@
}
/* Setup the columns for non-standard fields, since we don't allow sorting */
$nonstd = $this->extrafields + $customfields;
while ($column = each($nonstd))
while($column = each($nonstd))
{
$test = strtolower($column[1]);
if (isset($this->prefs[$test]) && $this->prefs[$test])
if(isset($this->prefs[$test]) && $this->prefs[$test])
{
$showcol = $this->display_name($column[0]);
/* This must be a custom field */
if (!$showcol) { $showcol = $column[1]; }
if(!$showcol)
{
$showcol = $column[1];
}
$cols .= ' <td height="21">' . "\n";
$cols .= ' <font size="-1" face="Arial, Helvetica, sans-serif">';
$cols .= $showcol;
@ -323,7 +329,7 @@
}
}
/* Check if prefs were set, if not, create some defaults */
if (!$columns_to_display )
if(!$columns_to_display )
{
$columns_to_display = array(
'n_given' => 'n_given',
@ -333,10 +339,13 @@
$columns_to_display = $columns_to_display + $customfields;
/* No prefs,. so cols above may have been set to '' or a bunch of <td></td> */
$cols='';
while ($column = each($columns_to_display))
while($column = each($columns_to_display))
{
$showcol = $this->display_name($column[0]);
if (!$showcol) { $showcol = $column[1]; }
if(!$showcol)
{
$showcol = $column[1];
}
$cols .= ' <td height="21">' . "\n";
$cols .= ' <font size="-1" face="Arial, Helvetica, sans-serif">';
$cols .= $GLOBALS['phpgw']->nextmatchs->show_sort_order($this->sort,
@ -347,7 +356,7 @@
$noprefs=lang('Please set your preferences for this application');
}
if (!$this->start)
if(!$this->start)
{
$this->start = 0;
}
@ -363,7 +372,7 @@
}
/*global $filter; */
if (empty($this->filter) || !isset($this->filter))
if(empty($this->filter) || !isset($this->filter))
{
if($this->prefs['default_filter'])
{
@ -381,7 +390,7 @@
else they may be accounts, etc.
*/
$qfilter = 'tid=n';
switch ($this->filter)
switch($this->filter)
{
case 'blank':
$nosearch = True;
@ -396,17 +405,17 @@
default:
$qfilter .= ',owner=' . $this->filter;
}
if ($this->cat_id)
if($this->cat_id)
{
$qfilter .= ',cat_id='.$this->cat_id;
}
if (!$userid)
if(!$userid)
{
$userid = $GLOBALS['phpgw_info']['user']['account_id'];
}
if ($nosearch && !$this->query)
if($nosearch && !$this->query)
{
$entries = array();
$total_records = 0;
@ -480,7 +489,7 @@
/* Show the entries */
/* each entry */
for ($i=0;$i<count($entries);$i++)
for($i=0;$i<count($entries);$i++)
{
$this->template->set_var('columns','');
$tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
@ -490,42 +499,46 @@
/* each entry column */
@reset($columns_to_display);
while ($column = @each($columns_to_display))
while($column = @each($columns_to_display))
{
$ref = $data='';
$ref = $data = '';
$coldata = $entries[$i][$column[0]];
/* echo '<br>coldata="' . $coldata . '"'; */
/* Some fields require special formatting. */
if ($column[0] == 'url')
if($column[0] == 'url')
{
if ( !empty($coldata) && (substr($coldata,0,7) != 'http://') ) { $coldata = 'http://' . $coldata; }
$ref='<a href="'.$coldata.'" target="_new">';
$data=$coldata.'</a>';
}
elseif ( ($column[0] == 'email') || ($column[0] == 'email_home') )
{
if ($GLOBALS['phpgw_info']['user']['apps']['email'])
if(!empty($coldata) && (substr($coldata,0,7) != 'http://'))
{
$ref='<a href="'.$GLOBALS['phpgw']->link("/email/compose.php","to=" . urlencode($coldata)).'" target="_new">';
$coldata = 'http://' . $coldata;
}
$ref = '<a href="' . $coldata . '" target="_new">';
$data = $coldata . '</a>';
}
elseif(($column[0] == 'email') || ($column[0] == 'email_home'))
{
if($GLOBALS['phpgw_info']['user']['apps']['email'])
{
$ref = '<a href="' . $GLOBALS['phpgw']->link('/index.php','menuaction=email.uicompose.compose&to=' . urlencode($coldata)) . '" target="_new">';
}
else
{
$ref='<a href="mailto:'.$coldata.'">';
$ref = '<a href="mailto:'.$coldata.'">';
}
$data=$coldata . '</a>';
$data = $coldata . '</a>';
}
else /* But these do not */
{
$ref = ''; $data = $coldata;
$ref = '';
$data = $coldata;
}
$this->template->set_var('col_data',$ref.$data);
$this->template->set_var('col_data',$ref . $data);
$this->template->parse('columns','column',True);
}
if (1)
if(1)
{
$this->template->set_var('row_view_link',$GLOBALS['phpgw']->link('/index.php',
'menuaction=addressbook.uiaddressbook.view&ab_id='.$entries[$i]['id']));
'menuaction=addressbook.uiaddressbook.view&ab_id=' . $entries[$i]['id']));
}
else
{
@ -535,8 +548,10 @@
$this->template->set_var('row_vcard_link',$GLOBALS['phpgw']->link('/index.php',
'menuaction=addressbook.uivcard.out&ab_id='.$entries[$i]['id']));
/* echo '<br>: ' . $contacts->grants[$myowner] . ' - ' . $myowner; */
if ($this->contacts->check_perms($this->contacts->grants[$myowner],PHPGW_ACL_EDIT) || $myowner == $GLOBALS['phpgw_info']['user']['account_id'])
if($this->contacts->check_perms($this->contacts->grants[$myowner],PHPGW_ACL_EDIT) ||
$myowner == $GLOBALS['phpgw_info']['user']['account_id'])
{
$this->template->set_var('row_edit','<a href="' . $GLOBALS['phpgw']->link('/index.php',
'menuaction=addressbook.uiaddressbook.edit&ab_id='.$entries[$i]['id']) . '">' . lang('Edit') . '</a>');
@ -565,11 +580,11 @@
$add_email = $GLOBALS['HTTP_POST_VARS']['add_email'] ? $GLOBALS['HTTP_POST_VARS']['add_email'] : $GLOBALS['HTTP_GET_VARS']['add_email'];
$named = explode(' ', $name);
for ($i=count($named);$i>=0;$i--)
for($i=count($named);$i>=0;$i--)
{
$names[$i] = $named[$i];
}
if ($names[2])
if($names[2])
{
$fields['n_given'] = $names[0];
$fields['n_middle'] = $names[1];
@ -613,7 +628,7 @@
function add()
{
if ($GLOBALS['HTTP_POST_VARS']['submit'])
if($GLOBALS['HTTP_POST_VARS']['submit'])
{
$fields = $this->get_form();
@ -647,13 +662,14 @@
function edit()
{
if ($GLOBALS['HTTP_POST_VARS']['submit'])
if($GLOBALS['HTTP_POST_VARS']['submit'])
{
$_fields = $this->get_form();
/* _debug_array($_fields);exit; */
$check = $this->bo->read_entry(array('id' => $_fields['ab_id'], 'fields' => array('owner' => 'owner','tid' => 'tid')));
if (($this->contacts->grants[$check[0]['owner']] & PHPGW_ACL_EDIT) && $check[0]['owner'] != $GLOBALS['phpgw_info']['user']['account_id'])
if(($this->contacts->grants[$check[0]['owner']] & PHPGW_ACL_EDIT) &&
$check[0]['owner'] != $GLOBALS['phpgw_info']['user']['account_id'])
{
$userid = $check[0]['owner'];
}
@ -677,8 +693,8 @@
/* First, make sure they have permission to this entry */
$check = $this->bo->read_entry(array('id' => $GLOBALS['HTTP_GET_VARS']['ab_id'], 'fields' => array('owner' => 'owner','tid' => 'tid')));
if ( !$this->contacts->check_perms($this->contacts->grants[$check[0]['owner']],PHPGW_ACL_EDIT) &&
($check[0]['owner'] != $GLOBALS['phpgw_info']['user']['account_id']) )
if(!$this->contacts->check_perms($this->contacts->grants[$check[0]['owner']],PHPGW_ACL_EDIT) &&
($check[0]['owner'] != $GLOBALS['phpgw_info']['user']['account_id']))
{
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
$GLOBALS['phpgw']->common->phpgw_exit();
@ -708,7 +724,8 @@
$this->template->set_var('cancel_link','<form method="POST" action="'
. $GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index') . '">');
if (($this->contacts->grants[$check[0]['owner']] & PHPGW_ACL_DELETE) || $check[0]['owner'] == $GLOBALS['phpgw_info']['user']['account_id'])
if(($this->contacts->grants[$check[0]['owner']] & PHPGW_ACL_DELETE) ||
$check[0]['owner'] == $GLOBALS['phpgw_info']['user']['account_id'])
{
$this->template->set_var('delete_link','<form method="POST" action="'.$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.delete') . '">');
$this->template->set_var('delete_button','<input type="submit" name="delete" value="' . lang('Delete') . '">');
@ -721,18 +738,19 @@
{
$ab_id = $GLOBALS['HTTP_POST_VARS']['entry']['ab_id'] ? $GLOBALS['HTTP_POST_VARS']['entry']['ab_id'] : $GLOBALS['HTTP_POST_VARS']['ab_id'];
$confirm = $GLOBALS['HTTP_GET_VARS']['confirm'] ? $GLOBALS['HTTP_GET_VARS']['confirm'] :$GLOBALS['HTTP_POST_VARS']['confirm'];
if (!$ab_id)
if(!$ab_id)
{
$ab_id = $GLOBALS['HTTP_GET_VARS']['ab_id']; // else plain Link in delete does not work
}
if (!$ab_id)
if(!$ab_id)
{
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
}
$check = $this->bo->read_entry(array('id' => $ab_id, 'fields' => array('owner' => 'owner','tid' => 'tid')));
if (!(($this->contacts->grants[$check[0]['owner']] & PHPGW_ACL_DELETE) || $check[0]['owner'] == $GLOBALS['phpgw_info']['user']['account_id']))
if(!(($this->contacts->grants[$check[0]['owner']] & PHPGW_ACL_DELETE) ||
$check[0]['owner'] == $GLOBALS['phpgw_info']['user']['account_id']))
{
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
$GLOBALS['phpgw']->common->phpgw_exit();
@ -740,7 +758,7 @@
$this->template->set_file(array('delete' => 'delete.tpl'));
if ($confirm != 'true')
if($confirm != 'true')
{
$GLOBALS['phpgw']->common->phpgw_header();
echo parse_navbar();
@ -772,18 +790,18 @@
$tmp = $check[0]['owner'];
$perms = $this->contacts->check_perms($this->contacts->grants[$tmp],PHPGW_ACL_READ);
if ( (!$perms) && ($check[0]['owner'] != $GLOBALS['phpgw_info']['user']['account_id']) )
if((!$perms) && ($check[0]['owner'] != $GLOBALS['phpgw_info']['user']['account_id']))
{
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
$GLOBALS['phpgw']->common->phpgw_exit();
}
if (!$ab_id)
if(!$ab_id)
{
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
$GLOBALS['phpgw']->common->phpgw_exit();
}
elseif (!$submit && $ab_id)
elseif(!$submit && $ab_id)
{
$GLOBALS['phpgw']->common->phpgw_header();
echo parse_navbar();
@ -797,9 +815,9 @@
$customfields = $this->read_custom_fields();
/* _debug_array($this->prefs); */
while (list($column,$x) = each($this->contacts->stock_contact_fields))
while(list($column,$x) = each($this->contacts->stock_contact_fields))
{
if (isset($this->prefs[$column]) && $this->prefs[$column])
if(isset($this->prefs[$column]) && $this->prefs[$column])
{
$columns_to_display[$column] = True;
$colname[$column] = $column;
@ -807,7 +825,7 @@
}
/* No prefs? */
if (!$columns_to_display )
if(!$columns_to_display )
{
$columns_to_display = array(
'n_given' => 'n_given',
@ -818,7 +836,7 @@
'email' => 'email',
'email_home' => 'email_home'
);
while ($column = each($columns_to_display))
while($column = each($columns_to_display))
{
$colname[$column[0]] = $column[1];
}
@ -832,7 +850,7 @@
$record_owner = $fields[0]['owner'];
if ($fields[0]['access'] == 'private')
if($fields[0]['access'] == 'private')
{
$access_check = lang('private');
}
@ -844,7 +862,7 @@
$this->template->set_var('lang_viewpref',lang('Address book - view') . $noprefs);
@reset($qfields);
while (list($column,$null) = @each($qfields))
while(list($column,$null) = @each($qfields))
{
if($this->display_name($colname[$column]))
{
@ -859,20 +877,20 @@
$this->template->set_var('display_col',ucfirst($column));
}
$ref = $data = '';
if ($fields[0][$column])
if($fields[0][$column])
{
$tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
$this->template->set_var('th_bg',$tr_color);
$coldata = $fields[0][$column];
/* Some fields require special formatting. */
if ( ($column == 'note' || $column == 'pubkey') && $coldata )
if(($column == 'note' || $column == 'pubkey') && $coldata)
{
$datarray = explode ("\n",$coldata);
if ($datarray[1])
if($datarray[1])
{
while (list($key,$info) = each ($datarray))
while(list($key,$info) = each ($datarray))
{
if ($key)
if($key)
{
$data .= '</td></tr><tr bgcolor="'.$tr_color.'"><td width="30%">&nbsp;</td><td width="70%">' .$info;
}
@ -893,14 +911,14 @@
{
$data .= $this->contacts->formatted_address($fields[0]['id'],'',False);
}
elseif ($column == 'url' && $coldata)
elseif($column == 'url' && $coldata)
{
$ref = '<a href="' . $coldata . '" target="_new">';
$data = $coldata . '</a>';
}
elseif ( (($column == 'email') || ($column == 'email_home')) && $coldata)
elseif((($column == 'email') || ($column == 'email_home')) && $coldata)
{
if ($GLOBALS['phpgw_info']['user']['apps']['email'])
if($GLOBALS['phpgw_info']['user']['apps']['email'])
{
$ref='<a href="' . $GLOBALS['phpgw']->link('/email/compose.php','to='
. urlencode($coldata)) . '" target="_new">';
@ -917,7 +935,7 @@
$ref = ''; $data = $coldata;
}
if (!$data)
if(!$data)
{
$this->template->set_var('ref_data','&nbsp;');
}
@ -934,17 +952,17 @@
$fields['cat_id'] = is_array($this->cat_id) ? implode(',',$this->cat_id) : $this->cat_id;
$cats = explode(',',$fields[0]['cat_id']);
if ($cats[1])
if($cats[1])
{
while (list($key,$contactscat) = each($cats))
while(list($key,$contactscat) = each($cats))
{
if ($contactscat)
if($contactscat)
{
$catinfo = $this->cat->return_single(intval($contactscat));
$catname .= $catinfo[0]['name'] . '; ';
}
}
if (!$this->cat_id)
if(!$this->cat_id)
{
$this->cat_id = $cats[0];
}
@ -954,13 +972,16 @@
$fields[0]['cat_id'] = ereg_replace(',','',$fields[0]['cat_id']);
$catinfo = $this->cat->return_single(intval($fields[0]['cat_id']));
$catname = $catinfo[0]['name'];
if (!$this->cat_id)
if(!$this->cat_id)
{
$this->cat_id = $fields[0]['cat_id'];
}
}
if (!$catname) { $catname = lang('none'); }
if(!$catname)
{
$catname = lang('none');
}
/* These are in the footer */
$this->template->set_var('lang_owner',lang('Record owner'));
@ -970,11 +991,12 @@
$this->template->set_var('lang_category',lang('Category'));
$this->template->set_var('catname',$catname);
if (($this->contacts->grants[$record_owner] & PHPGW_ACL_EDIT) || ($record_owner == $GLOBALS['phpgw_info']['user']['account_id']))
if(($this->contacts->grants[$record_owner] & PHPGW_ACL_EDIT) ||
($record_owner == $GLOBALS['phpgw_info']['user']['account_id']))
{
$extra_vars = array('cd' => 16,'query' => $this->query,'cat_id' => $this->cat_id);
if ($referer)
if($referer)
{
$extra_vars += array('referer' => urlencode($referer));
}
@ -985,7 +1007,7 @@
$this->template->set_var('copy_button',$this->html_1button_form('submit','copy',
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.copy&ab_id=' . $fields[0]['id'])));
if ($fields[0]['n_family'] && $fields[0]['n_given'])
if($fields[0]['n_family'] && $fields[0]['n_given'])
{
$this->template->set_var('vcard_button',$this->html_1button_form('VCardForm','VCard',
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uivcard.out&ab_id=' .$ab_id)));
@ -1024,14 +1046,14 @@
$qfields = $this->contacts->stock_contact_fields + $this->extrafields + $customfields;
if ($submit)
if($submit)
{
$totalerrors = 0;
if (!count($prefs))
if(!count($prefs))
{
$errors[$totalerrors++] = lang('You must select at least 1 column to display');
}
if (!$totalerrors)
if(!$totalerrors)
{
@reset($qfields);
$this->bo->save_preferences($prefs,$other,$qfields,$fcat_id);
@ -1041,7 +1063,7 @@
$GLOBALS['phpgw']->common->phpgw_header();
echo parse_navbar();
if ($totalerrors)
if($totalerrors)
{
echo '<p><center>' . $GLOBALS['phpgw']->common->error_list($errors) . '</center>';
}
@ -1053,18 +1075,21 @@
$i = 0; $j = 0;
$tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
while (list($col, $descr) = each($qfields))
while(list($col, $descr) = each($qfields))
{
/* echo '<br>test: $col - $i $j - ' . count($abc); */
$i++; $j++;
$showcol = $this->display_name($col);
if (!$showcol) { $showcol = $col; }
if(!$showcol)
{
$showcol = $col;
}
/* yank the *'s prior to testing for a valid column description */
$coltest = ereg_replace('\*','',$showcol);
if ($coltest)
if($coltest)
{
$this->template->set_var($col,$showcol);
if ($GLOBALS['phpgw_info']['user']['preferences']['addressbook'][$col])
if($GLOBALS['phpgw_info']['user']['preferences']['addressbook'][$col])
{
$this->template->set_var($col.'_checked',' checked');
}
@ -1075,7 +1100,7 @@
}
}
if ($customfields)
if($customfields)
{
$custom_var = '
<tr>
@ -1084,7 +1109,7 @@
<td></td>
</tr>
';
while( list($cf) = each($customfields) )
while(list($cf) = each($customfields))
{
$tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
$custom_var .= "\n" . '<tr bgcolor="' . $tr_color . '">' . "\n";
@ -1105,7 +1130,7 @@
$this->template->set_var(tr_color,$tr_color);
$this->template->set_var('lang_showbirthday',lang('show birthday reminders on main screen'));
if ($this->prefs['mainscreen_showbirthdays'])
if($this->prefs['mainscreen_showbirthdays'])
{
$this->template->set_var('show_birthday',' checked');
}
@ -1123,7 +1148,7 @@
$this->template->set_var('filter_select',$this->formatted_list('other[default_filter]',$list,$this->prefs['default_filter']));
$this->template->set_var('lang_autosave',lang('Autosave default category'));
if ($this->prefs['autosave_category'])
if($this->prefs['autosave_category'])
{
$this->template->set_var('autosave',' checked');
}
@ -1162,14 +1187,14 @@
}
/* _debug_array($entry); exit; */
if (!$entry['bday_month'] && !$entry['bday_day'] && !$entry['bday_year'])
if(!$entry['bday_month'] && !$entry['bday_day'] && !$entry['bday_year'])
{
$fields['bday'] = '';
}
else
{
$bday_day = $entry['bday_day'];
if (strlen($bday_day) == 1)
if(strlen($bday_day) == 1)
{
$bday_day = '0' . $entry['bday_day'];
}
@ -1186,9 +1211,9 @@
$fields['n_middle'] = $entry['middle'];
$fields['n_prefix'] = $entry['prefix'];
$fields['n_suffix'] = $entry['suffix'];
if ($entry['prefix']) { $pspc = ' '; }
if ($entry['middle']) { $mspc = ' '; } else { $nspc = ' '; }
if ($entry['suffix']) { $sspc = ' '; }
if($entry['prefix']) { $pspc = ' '; }
if($entry['middle']) { $mspc = ' '; } else { $nspc = ' '; }
if($entry['suffix']) { $sspc = ' '; }
$fields['fn'] = $entry['prefix'].$pspc.$entry['firstname'].$nspc.$mspc.$entry['middle'].$mspc.$entry['lastname'].$sspc.$entry['suffix'];
$fields['email'] = $entry['email'];
$fields['email_type'] = $entry['email_type'];
@ -1256,7 +1281,7 @@
$fields['adr_two_type'] = substr($typeb,0,-1);
$custom = $this->read_custom_fields();
while (list($name,$val) = @each($custom))
while(list($name,$val) = @each($custom))
{
$fields[$name] = $entry[$val];
}
@ -1267,7 +1292,7 @@
$fields['note'] = $entry['notes'];
$fields['label'] = $entry['label'];
if ($entry['access'] == True)
if($entry['access'] == True)
{
$fields['access'] = 'private';
}
@ -1276,7 +1301,7 @@
$fields['access'] = 'public';
}
if (is_array($fcat_id))
if(is_array($fcat_id))
{
$fields['cat_id'] = count($fcat_id) > 1 ? ','.implode(',',$fcat_id).',' : $fcat_id[0];
}
@ -1287,7 +1312,7 @@
$fields['ab_id'] = $entry['ab_id'];
$fields['tid'] = $entry['tid'];
if (!$fields['tid'])
if(!$fields['tid'])
{
$fields['tid'] = 'n';
}
@ -1304,7 +1329,7 @@
$this->template->set_file(array('form' => 'form.tpl'));
if ( ($GLOBALS['phpgw_info']['server']['countrylist'] == 'user_choice' &&
if(($GLOBALS['phpgw_info']['server']['countrylist'] == 'user_choice' &&
$GLOBALS['phpgw_info']['user']['preferences']['common']['countrylist'] == 'use_select') ||
($GLOBALS['phpgw_info']['server']['countrylist'] == 'force_select'))
{
@ -1371,7 +1396,7 @@
}
$cats_link = $this->cat_option($cat_id,True,False,True);
if ($access == 'private')
if($access == 'private')
{
$access_check = ' checked';
}
@ -1380,7 +1405,7 @@
$access_check = '';
}
if ($customfields)
if($customfields)
{
while(list($name,$value) = each($customfields))
{
@ -1395,15 +1420,15 @@
}
}
if ($format != "view")
if($format != "view")
{
/* Preferred phone number radio buttons */
$pref[0] = '<font size="-2">';
$pref[1] = '(' . lang('pref') . ')</font>';
while (list($name,$val) = each($this->contacts->tel_types))
while(list($name,$val) = each($this->contacts->tel_types))
{
$str[$name] = "\n".' <input type="radio" name="entry[tel_prefer]" value="'.$name.'"';
if ($name == $preferred)
if($name == $preferred)
{
$str[$name] .= ' checked';
}
@ -1412,7 +1437,7 @@
$this->template->set_var("pref_".$name,$str[$name]);
}
if (strlen($bday) > 2)
if(strlen($bday) > 2)
{
list( $month, $day, $year ) = split( '/', $bday );
$temp_month[$month] = ' selected';
@ -1456,14 +1481,14 @@
}
$time_zone = '<select name="entry[timezone]">' . "\n";
for ($i = -23; $i<24; $i++)
for($i = -23; $i<24; $i++)
{
$time_zone .= '<option value="' . $i . '"';
if ($i == $timezone)
if($i == $timezone)
{
$time_zone .= ' selected';
}
if ($i < 1)
if($i < 1)
{
$time_zone .= '>' . $i . '</option>' . "\n";
}
@ -1475,26 +1500,32 @@
$time_zone .= '</select>' . "\n";
$email_type = '<select name=entry[email_type]>';
while ($type = each($this->contacts->email_types))
while($type = each($this->contacts->email_types))
{
$email_type .= '<option value="' . $type[0] . '"';
if ($type[0] == $emailtype) { $email_type .= ' selected'; }
if($type[0] == $emailtype)
{
$email_type .= ' selected';
}
$email_type .= '>' . $type[1] . '</option>';
}
$email_type .= '</select>';
reset($this->contacts->email_types);
$hemail_type = '<select name=entry[hemail_type]>';
while ($type = each($this->contacts->email_types))
while($type = each($this->contacts->email_types))
{
$hemail_type .= '<option value="' . $type[0] . '"';
if ($type[0] == $hemailtype) { $hemail_type .= ' selected'; }
if($type[0] == $hemailtype)
{
$hemail_type .= ' selected';
}
$hemail_type .= '>' . $type[1] . '</option>';
}
$hemail_type .= '</select>';
reset($this->contacts->adr_types);
while (list($type,$val) = each($this->contacts->adr_types))
while(list($type,$val) = each($this->contacts->adr_types))
{
$badrtype .= "\n".'<INPUT type="checkbox" name="entry[one_'.$type.']"';
$ot = 'one_'.$type;
@ -1507,7 +1538,7 @@
}
reset($this->contacts->adr_types);
while (list($type,$val) = each($this->contacts->adr_types))
while(list($type,$val) = each($this->contacts->adr_types))
{
$hadrtype .= "\n".'<INPUT type="checkbox" name="entry[two_'.$type.']"';
$tt = 'two_'.$type;
@ -1527,25 +1558,25 @@
{
$notes = '<form><TEXTAREA cols="60" name="entry[notes]" rows="4">'
. $notes . '</TEXTAREA></form>';
if ($bday == '//')
if($bday == '//')
{
$bday = '';
}
}
if ($action)
if($action)
{
echo '<FORM action="' . $GLOBALS['phpgw']->link('/index.php', $action . '&referer='.urlencode($referer)).'" method="post">';
}
if (!ereg('^http://',$url))
if(!ereg('^http://',$url))
{
$url = 'http://' . $url;
}
$birthday = $GLOBALS['phpgw']->common->dateformatorder($bday_year,$bday_month,$bday_day)
. '<font face="'.$theme["font"].'" size="-2">(e.g. 1969)</font>';
if ($format == 'edit')
if($format == 'edit')
{
$create .= '<tr bgcolor="' . $GLOBALS['phpgw_info']['theme']['th_bg'] . '"><td colspan="2"><font size="-1">' . lang("Created by") . ':</font></td>'
. '<td colspan="3"><font size="-1">'
@ -1620,7 +1651,7 @@
$this->template->set_var('bzip',$bzip);
$this->template->set_var('lang_bcountry',lang('Business Country'));
$this->template->set_var('bcountry',$bcountry);
if ($countrylist)
if($countrylist)
{
$this->template->set_var('bcountry',$GLOBALS['phpgw']->country->form_select($bcountry,'entry[bcountry]'));
}
@ -1646,7 +1677,7 @@
$this->template->set_var('lang_hzip',lang('Home Zip Code'));
$this->template->set_var('hzip',$hzip);
$this->template->set_var('lang_hcountry',lang('Home Country'));
if ($countrylist)
if($countrylist)
{
$this->template->set_var('hcountry',$GLOBALS['phpgw']->country->form_select($hcountry,'entry[hcountry]'));
}
@ -1670,7 +1701,7 @@
$this->template->set_var('lang_cats',lang('Category'));
$this->template->set_var('cats_link',$cats_link);
if ($customfields)
if($customfields)
{
$this->template->set_var('lang_custom',lang('Custom Fields').':');
$this->template->set_var('custom',$custom);

View File

@ -66,12 +66,12 @@
$GLOBALS['phpgw']->template->set_var('lang_done',lang('Done'));
$GLOBALS['phpgw']->template->set_var('doneurl',$GLOBALS['phpgw']->link('/admin/index.php'));
if (!$start)
if(!$start)
{
$start = 0;
}
if (!$sort)
if(!$sort)
{
$sort = 'ASC';
}
@ -92,7 +92,7 @@
$GLOBALS['phpgw']->template->set_var('lang_edit',lang('Edit'));
$GLOBALS['phpgw']->template->set_var('lang_delete',lang('Delete'));
for ($i=0;$i<count($fields);$i++)
for($i=0;$i<count($fields);$i++)
{
$tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
$GLOBALS['phpgw']->template->set_var(tr_color,$tr_color);
@ -136,22 +136,22 @@
$GLOBALS['phpgw']->template->set_block('form','add','addhandle');
$GLOBALS['phpgw']->template->set_block('form','edit','edithandle');
if ($GLOBALS['HTTP_POST_VARS']['submit'])
if($GLOBALS['HTTP_POST_VARS']['submit'])
{
$errorcount = 0;
if (!$field_name)
if(!$field_name)
{
$error[$errorcount++] = lang('Please enter a name for that field !');
}
$fields = $this->read_custom_fields($start,$limit,$field_name);
if ($fields[0]['name'])
if($fields[0]['name'])
{
$error[$errorcount++] = lang('That field name has been used already !');
}
if (! $error)
if(!$error)
{
$field_name = addslashes($field_name);
$this->save_custom_field($field,$field_name);
@ -161,15 +161,15 @@
$GLOBALS['phpgw']->common->phpgw_header();
echo parse_navbar();
if ($errorcount)
if($errorcount)
{
$GLOBALS['phpgw']->template->set_var('message',$GLOBALS['phpgw']->common->error_list($error));
}
if (($submit) && (! $error) && (! $errorcount))
if(($submit) && (! $error) && (! $errorcount))
{
$GLOBALS['phpgw']->template->set_var('message',lang('Field x has been added !', $field_name));
}
if ((! $submit) && (! $error) && (! $errorcount))
if((! $submit) && (! $error) && (! $errorcount))
{
$GLOBALS['phpgw']->template->set_var('message','');
}
@ -202,7 +202,6 @@
echo lang('access not permitted');
$GLOBALS['phpgw']->common->phpgw_footer();
$GLOBALS['phpgw']->common->phpgw_exit();
}
$field = $GLOBALS['HTTP_POST_VARS']['field'] ? $GLOBALS['HTTP_POST_VARS']['field'] : $GLOBALS['HTTP_GET_VARS']['field'];
@ -212,7 +211,7 @@
$sort = $GLOBALS['HTTP_POST_VARS']['sort'] ? $GLOBALS['HTTP_POST_VARS']['sort'] : $GLOBALS['HTTP_GET_VARS']['sort'];
$submit = $GLOBALS['HTTP_POST_VARS']['submit'];
if (!$field)
if(!$field)
{
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',"menuaction=addressbook.uifields.index&sort=$sort&query=$query&start=$start"));
}
@ -226,14 +225,17 @@
. '<input type="hidden" name="start" value="' . $start . '">' . "\n"
. '<input type="hidden" name="field" value="' . $field . '">' . "\n";
if ($submit)
if($submit)
{
$errorcount = 0;
if (!$field_name) { $error[$errorcount++] = lang('Please enter a name for that field!'); }
if(!$field_name)
{
$error[$errorcount++] = lang('Please enter a name for that field!');
}
$field_name = addslashes($field_name);
if (! $error)
if(!$error)
{
$this->save_custom_field($field,$field_name);
}
@ -242,20 +244,20 @@
$GLOBALS['phpgw']->common->phpgw_header();
echo parse_navbar();
if ($errorcount)
if($errorcount)
{
$GLOBALS['phpgw']->template->set_var('message',$GLOBALS['phpgw']->common->error_list($error));
}
if (($submit) && (! $error) && (! $errorcount))
if(($submit) && (! $error) && (! $errorcount))
{
$GLOBALS['phpgw']->template->set_var('message',lang('Field x has been updated !', $field_name));
}
if ((! $submit) && (! $error) && (! $errorcount))
if((!$submit) && (! $error) && (! $errorcount))
{
$GLOBALS['phpgw']->template->set_var('message','');
}
if ($submit)
if($submit)
{
$field = $field_name;
}
@ -294,12 +296,12 @@
$query = $GLOBALS['HTTP_POST_VARS']['query'] ? $GLOBALS['HTTP_POST_VARS']['query'] : $GLOBALS['HTTP_GET_VARS']['query'];
$sort = $GLOBALS['HTTP_POST_VARS']['sort'] ? $GLOBALS['HTTP_POST_VARS']['sort'] : $GLOBALS['HTTP_GET_VARS']['sort'];
if (!$field)
if(!$field)
{
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uifields.index'));
}
if ($GLOBALS['HTTP_POST_VARS']['confirm'])
if($GLOBALS['HTTP_POST_VARS']['confirm'])
{
$this->save_custom_field($field);
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',"menuaction=addressbook.uifields.index&start=$start&query=$query&sort=$sort"));
@ -343,15 +345,15 @@
$i = 0; $j = 0;
$fields = array();
@reset($GLOBALS['phpgw_info']['user']['preferences']['addressbook']);
while (list($col,$descr) = @each($GLOBALS['phpgw_info']['user']['preferences']['addressbook']))
while(list($col,$descr) = @each($GLOBALS['phpgw_info']['user']['preferences']['addressbook']))
{
if ( substr($col,0,6) == 'extra_' )
if(substr($col,0,6) == 'extra_')
{
$fields[$j]['name'] = ereg_replace('extra_','',$col);
$fields[$j]['name'] = ereg_replace(' ','_',$fields[$j]['name']);
$fields[$j]['id'] = $i;
if ($query && ($fields[$j]['name'] != $query))
if($query && ($fields[$j]['name'] != $query))
{
unset($fields[$j]['name']);
unset($fields[$j]['id']);
@ -371,7 +373,7 @@
function save_custom_field($old='',$new='')
{
$GLOBALS['phpgw']->preferences->read_repository($GLOBALS['phpgw_info']['user']['account_id']);
if ($old)
if($old)
{
$GLOBALS['phpgw']->preferences->delete("addressbook","extra_".$old);
}

View File

@ -26,7 +26,7 @@
'out' => True
);
var $extrafields = array(
var $extrafields = array(
'ophone' => 'ophone',
'address2' => 'address2',
'address3' => 'address3'
@ -34,9 +34,7 @@
function uivcard()
{
global $phpgw;
$this->template = $phpgw->template;
$this->template = $GLOBALS['phpgw']->template;
$this->contacts = CreateObject('phpgwapi.contacts');
$this->browser = CreateObject('phpgwapi.browser');
$this->vcard = CreateObject('phpgwapi.vcard');
@ -45,14 +43,14 @@
function in()
{
global $phpgw,$phpgw_info,$action;
$action = $GLOBALS['HTTP_POST_VARS']['action'];
$phpgw->common->phpgw_header();
$GLOBALS['phpgw']->common->phpgw_header();
echo parse_navbar();
echo '<body bgcolor="' . $phpgw_info['theme']['bg_color'] . '">';
echo '<body bgcolor="' . $GLOBALS['phpgw_info']['theme']['bg_color'] . '">';
if ($action == 'GetFile')
if($action == 'GetFile')
{
echo '<b><center>' . lang('You must select a vcard. (*.vcf)') . '</b></center><br><br>';
}
@ -60,7 +58,7 @@
$this->template->set_file(array('vcardin' => 'vcardin.tpl'));
$this->template->set_var('vcard_header','<p>&nbsp;<b>' . lang('Address book - VCard in') . '</b><hr><p>');
$this->template->set_var('action_url',$phpgw->link('/index.php','menuaction=addressbook.boaddressbook.add_vcard'));
$this->template->set_var('action_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.boaddressbook.add_vcard'));
$this->template->set_var('lang_access',lang('Access'));
$this->template->set_var('lang_groups',lang('Which groups'));
$this->template->set_var('access_option',$access_option);
@ -68,36 +66,36 @@
$this->template->pparse('out','vcardin');
$phpgw->common->phpgw_footer();
$GLOBALS['phpgw']->common->phpgw_footer();
}
function out()
{
global $phpgw,$phpgw_info,$ab_id,$nolname,$nofname;
global $ab_id,$nolname,$nofname;
if ($nolname || $nofname)
if($nolname || $nofname)
{
$phpgw->common->phpgw_header();
$GLOBALS['phpgw']->common->phpgw_header();
echo parse_navbar();
}
if (!$ab_id)
if(!$ab_id)
{
Header('Location: ' . $phpgw->link('/addressbook/index.php'));
$phpgw->common->phpgw_exit();
Header('Location: ' . $GLOBALS['phpgw']->link('/addressbook/index.php'));
$GLOBALS['phpgw']->common->phpgw_exit();
}
// First, make sure they have permission to this entry
$check = $this->bo->read_entry(array('id' => $ab_id, 'fields' => array('owner' => 'owner')));
$perms = $this->contacts->check_perms($this->contacts->grants[$check[0]['owner']],PHPGW_ACL_READ);
if ( (!$perms) && ($check[0]['owner'] != $phpgw_info['user']['account_id']) )
if((!$perms) && ($check[0]['owner'] != $GLOBALS['phpgw_info']['user']['account_id']))
{
Header("Location: " . $phpgw->link('/index.php','menuaction=addressbook.uiaddressbook.get_list'));
$phpgw->common->phpgw_exit();
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.get_list'));
$GLOBALS['phpgw']->common->phpgw_exit();
}
$extrafields = array('address2' => 'address2');
$extrafields = array('address2' => 'address2');
$qfields = $this->contacts->stock_contact_fields + $extrafields;
$fieldlist = $this->bo->read_entry(array('id' => $ab_id, 'fields' => $qfields));
@ -124,49 +122,49 @@
if($lastname == '')
{
/* Run away here. */
Header('Location: ' . $phpgw->link('/index.php',"menuaction=addressbook.uivcard.out&nolname=1&ab_id=$ab_id"));
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uivcard.out&nolname=1&ab_id=' . $ab_id));
}
if($firstname == '')
{
Header('Location: ' . $phpgw->link('/index.php',"menuaction=addressbook.uivcard.out&nofname=1&ab_id=$ab_id"));
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uivcard.out&nofname=1&ab_id=' . $ab_id));
}
if ($email)
{
$fn = explode('@',$email);
$filename = sprintf("%s.vcf", $fn[0]);
$filename = sprintf('%s.vcf', $fn[0]);
}
elseif ($hemail)
{
$fn = explode('@',$hemail);
$filename = sprintf("%s.vcf", $fn[0]);
$filename = sprintf('%s.vcf', $fn[0]);
}
else
{
$fn = strtolower($firstname);
$filename = sprintf("%s.vcf", $fn);
$filename = sprintf('%s.vcf', $fn);
}
// set translation variable
$myexport = $this->vcard->export;
// check that each $fields exists in the export array and
// set a new array to equal the translation and original value
while( list($name,$value) = each($fields) )
while(list($name,$value) = each($fields))
{
if ($myexport[$name] && ($value != "") )
if($myexport[$name] && ($value != ''))
{
//echo '<br>'.$name."=".$fields[$name]."\n";
//echo '<br>'.$name.'='.$fields[$name]."\n";
$buffer[$myexport[$name]] = $value;
}
}
// create a vcard from this translated array
$entry = $this->vcard->out($buffer);
$entry = $this->vcard->out($buffer);
// print it using browser class for headers
// filename, mimetype, no length, default nocache True
$this->browser->content_header($filename,'text/x-vcard');
echo $entry;
$phpgw->common->exit;
$GLOBALS['phpgw']->common->exit;
} /* !nolname && !nofname */
if($nofname)
@ -174,8 +172,7 @@
echo '<br><br><center>';
echo lang("This person's first name was not in the address book.") .'<br>';
echo lang('Vcards require a first name entry.') . '<br><br>';
echo '<a href="' . $phpgw->link('/addressbook/index.php',
"order=$order&start=$start&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id") . '">' . lang('OK') . '</a>';
echo '<a href="' . $GLOBALS['phpgw']->link('/addressbook/index.php') . '">' . lang('OK') . '</a>';
echo '</center>';
}
@ -184,14 +181,13 @@
echo '<br><br><center>';
echo lang("This person's last name was not in the address book.") . '<br>';
echo lang('Vcards require a last name entry.') . '<br><br>';
echo '<a href="' . $phpgw->link('/addressbook/index.php',
"order=$order&start=$start&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id") . '">' . lang('OK') . '</a>';
echo '<a href="' . $GLOBALS['phpgw']->link('/addressbook/index.php') . '">' . lang('OK') . '</a>';
echo '</center>';
}
if($nolname || $nofname)
{
$phpgw->common->phpgw_footer();
$GLOBALS['phpgw']->common->phpgw_footer();
}
}
}