mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
Now using limit_query, show_hits (.13 only); Change refs to $this to $contacts;
Cut down on duplicated strings for $sql
This commit is contained in:
parent
4f833d20d2
commit
09832b0496
@ -29,7 +29,7 @@
|
|||||||
$t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
|
$t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
|
||||||
$t->set_file(array('add' => 'add.tpl'));
|
$t->set_file(array('add' => 'add.tpl'));
|
||||||
|
|
||||||
$this = CreateObject('phpgwapi.contacts');
|
$contacts = CreateObject('phpgwapi.contacts');
|
||||||
|
|
||||||
// Read in user custom fields, if any
|
// Read in user custom fields, if any
|
||||||
$phpgw->preferences->read_repository();
|
$phpgw->preferences->read_repository();
|
||||||
@ -79,7 +79,7 @@
|
|||||||
'address2' => 'address2',
|
'address2' => 'address2',
|
||||||
'address3' => 'address3'
|
'address3' => 'address3'
|
||||||
);
|
);
|
||||||
$qfields = $this->stock_contact_fields + $extrafields + $customfields;
|
$qfields = $contacts->stock_contact_fields + $extrafields + $customfields;
|
||||||
$addnew = unserialize(rawurldecode($fields));
|
$addnew = unserialize(rawurldecode($fields));
|
||||||
$addnew['note'] .= "\nCopied from ".$phpgw->accounts->id2name($addnew['owner']).", record #".$addnew['id'].".";
|
$addnew['note'] .= "\nCopied from ".$phpgw->accounts->id2name($addnew['owner']).", record #".$addnew['id'].".";
|
||||||
$addnew['owner'] = $phpgw_info['user']['account_id'];
|
$addnew['owner'] = $phpgw_info['user']['account_id'];
|
||||||
@ -144,9 +144,9 @@
|
|||||||
$fields['adr_one_postalcode'] = $bzip;
|
$fields['adr_one_postalcode'] = $bzip;
|
||||||
$fields['adr_one_countryname'] = $bcountry;
|
$fields['adr_one_countryname'] = $bcountry;
|
||||||
|
|
||||||
reset($this->adr_types);
|
reset($contacts->adr_types);
|
||||||
$typed = '';
|
$typed = '';
|
||||||
while (list($type,$val) = each($this->adr_types))
|
while (list($type,$val) = each($contacts->adr_types))
|
||||||
{
|
{
|
||||||
$ftype = 'one_'.$type;
|
$ftype = 'one_'.$type;
|
||||||
eval("if (\$\$ftype=='on') { \$typed .= \$type . ';'; }");
|
eval("if (\$\$ftype=='on') { \$typed .= \$type . ';'; }");
|
||||||
@ -162,9 +162,9 @@
|
|||||||
$fields['adr_two_postalcode'] = $hzip;
|
$fields['adr_two_postalcode'] = $hzip;
|
||||||
$fields['adr_two_countryname'] = $hcountry;
|
$fields['adr_two_countryname'] = $hcountry;
|
||||||
|
|
||||||
reset($this->adr_types);
|
reset($contacts->adr_types);
|
||||||
$typed = '';
|
$typed = '';
|
||||||
while (list($type,$val) = each($this->adr_types))
|
while (list($type,$val) = each($contacts->adr_types))
|
||||||
{
|
{
|
||||||
$ftype = 'two_'.$type;
|
$ftype = 'two_'.$type;
|
||||||
eval("if (\$\$ftype=='on') { \$typed \.= \$type . ';'; }");
|
eval("if (\$\$ftype=='on') { \$typed \.= \$type . ';'; }");
|
||||||
|
@ -25,11 +25,11 @@
|
|||||||
Header('Location: ' . $phpgw->link('/addressbook/index.php'));
|
Header('Location: ' . $phpgw->link('/addressbook/index.php'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this = CreateObject('phpgwapi.contacts');
|
$contacts = CreateObject('phpgwapi.contacts');
|
||||||
$fields = $this->read_single_entry($ab_id,array('owner' => 'owner'));
|
$fields = $contacts->read_single_entry($ab_id,array('owner' => 'owner'));
|
||||||
//$record_owner = $fields[0]['owner'];
|
//$record_owner = $fields[0]['owner'];
|
||||||
|
|
||||||
if (! $this->check_perms($this->grants[$fields[0]['owner']],PHPGW_ACL_DELETE) && $fields[0]['owner'] != $phpgw_info['user']['account_id'])
|
if (! $contacts->check_perms($contacts->grants[$fields[0]['owner']],PHPGW_ACL_DELETE) && $fields[0]['owner'] != $phpgw_info['user']['account_id'])
|
||||||
{
|
{
|
||||||
Header('Location: '
|
Header('Location: '
|
||||||
. $phpgw->link('/addressbook/index.php',"cd=16&order=$order&sort=$sort&filter=$filter&start=$start&query=$query&cat_id=$cat_id"));
|
. $phpgw->link('/addressbook/index.php',"cd=16&order=$order&sort=$sort&filter=$filter&start=$start&query=$query&cat_id=$cat_id"));
|
||||||
@ -57,8 +57,8 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->account_id = $phpgw_info['user']['account_id'];
|
$contacts->account_id = $phpgw_info['user']['account_id'];
|
||||||
$this->delete($ab_id);
|
$contacts->delete($ab_id);
|
||||||
|
|
||||||
@Header('Location: ' . $phpgw->link('/addressbook/index.php',
|
@Header('Location: ' . $phpgw->link('/addressbook/index.php',
|
||||||
"cd=16&order=$order&sort=$sort&filter=$filter&start=$start&query=$query&cat_id=$cat_id"));
|
"cd=16&order=$order&sort=$sort&filter=$filter&start=$start&query=$query&cat_id=$cat_id"));
|
||||||
|
@ -23,12 +23,12 @@
|
|||||||
|
|
||||||
include('../header.inc.php');
|
include('../header.inc.php');
|
||||||
|
|
||||||
$this = CreateObject('phpgwapi.contacts');
|
$contacts = CreateObject('phpgwapi.contacts');
|
||||||
|
|
||||||
// First, make sure they have permission to this entry
|
// First, make sure they have permission to this entry
|
||||||
$check = addressbook_read_entry($ab_id,array('owner' => 'owner'));
|
$check = addressbook_read_entry($ab_id,array('owner' => 'owner'));
|
||||||
|
|
||||||
if ( !$this->check_perms($this->grants[$check[0]['owner']],PHPGW_ACL_EDIT) && ($check[0]['owner'] != $phpgw_info['user']['account_id']) )
|
if ( !$contacts->check_perms($contacts->grants[$check[0]['owner']],PHPGW_ACL_EDIT) && ($check[0]['owner'] != $phpgw_info['user']['account_id']) )
|
||||||
{
|
{
|
||||||
Header("Location: "
|
Header("Location: "
|
||||||
. $phpgw->link('/addressbook/index.php',"cd=16&order=$order&sort=$sort&filter=$filter&start=$start&query=$query&cat_id=$cat_id"));
|
. $phpgw->link('/addressbook/index.php',"cd=16&order=$order&sort=$sort&filter=$filter&start=$start&query=$query&cat_id=$cat_id"));
|
||||||
@ -69,7 +69,7 @@
|
|||||||
'address3' => 'address3'
|
'address3' => 'address3'
|
||||||
);
|
);
|
||||||
|
|
||||||
$qfields = $this->stock_contact_fields + $extrafields + $customfields;
|
$qfields = $contacts->stock_contact_fields + $extrafields + $customfields;
|
||||||
$fields = addressbook_read_entry($ab_id,$qfields);
|
$fields = addressbook_read_entry($ab_id,$qfields);
|
||||||
addressbook_form('edit','edit.php',lang('Edit'),$fields[0],$customfields);
|
addressbook_form('edit','edit.php',lang('Edit'),$fields[0],$customfields);
|
||||||
|
|
||||||
@ -91,7 +91,7 @@
|
|||||||
$t->set_var('lang_submit',lang('submit'));
|
$t->set_var('lang_submit',lang('submit'));
|
||||||
$t->set_var('cancel_link','<form method="POST" action="' . $phpgw->link("/addressbook/index.php") . '">');
|
$t->set_var('cancel_link','<form method="POST" action="' . $phpgw->link("/addressbook/index.php") . '">');
|
||||||
|
|
||||||
if (($this->grants[$check[0]['owner']] & PHPGW_ACL_DELETE) || $check[0]['owner'] == $phpgw_info['user']['account_id'])
|
if (($contacts->grants[$check[0]['owner']] & PHPGW_ACL_DELETE) || $check[0]['owner'] == $phpgw_info['user']['account_id'])
|
||||||
{
|
{
|
||||||
$t->set_var('delete_link','<form method="POST" action="'.$phpgw->link("/addressbook/delete.php") . '">');
|
$t->set_var('delete_link','<form method="POST" action="'.$phpgw->link("/addressbook/delete.php") . '">');
|
||||||
$t->set_var('delete_button','<input type="submit" name="delete" value="' . lang('Delete') . '">');
|
$t->set_var('delete_button','<input type="submit" name="delete" value="' . lang('Delete') . '">');
|
||||||
@ -153,9 +153,9 @@
|
|||||||
$fields['adr_one_postalcode'] = $bzip;
|
$fields['adr_one_postalcode'] = $bzip;
|
||||||
$fields['adr_one_countryname'] = $bcountry;
|
$fields['adr_one_countryname'] = $bcountry;
|
||||||
|
|
||||||
reset($this->adr_types);
|
reset($contacts->adr_types);
|
||||||
$typed = '';
|
$typed = '';
|
||||||
while (list($type,$val) = each($this->adr_types))
|
while (list($type,$val) = each($contacts->adr_types))
|
||||||
{
|
{
|
||||||
$ftype = 'one_'.$type;
|
$ftype = 'one_'.$type;
|
||||||
eval("if (\$\$ftype=='on') { \$typed .= \$type . ';'; }");
|
eval("if (\$\$ftype=='on') { \$typed .= \$type . ';'; }");
|
||||||
@ -171,9 +171,9 @@
|
|||||||
$fields['adr_two_postalcode'] = $hzip;
|
$fields['adr_two_postalcode'] = $hzip;
|
||||||
$fields['adr_two_countryname'] = $hcountry;
|
$fields['adr_two_countryname'] = $hcountry;
|
||||||
|
|
||||||
reset($this->adr_types);
|
reset($contacts->adr_types);
|
||||||
$typed = '';
|
$typed = '';
|
||||||
while (list($type,$val) = each($this->adr_types))
|
while (list($type,$val) = each($contacts->adr_types))
|
||||||
{
|
{
|
||||||
$ftype = 'two_'.$type;
|
$ftype = 'two_'.$type;
|
||||||
eval("if (\$\$ftype=='on') { \$typed .= \$type . ';'; }");
|
eval("if (\$\$ftype=='on') { \$typed .= \$type . ';'; }");
|
||||||
@ -214,7 +214,7 @@
|
|||||||
$fields['cat_id'] = $cat_id;
|
$fields['cat_id'] = $cat_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($this->grants[$check[0]['owner']] & PHPGW_ACL_EDIT) && $check[0]['owner'] != $phpgw_info['user']['account_id'])
|
if (($contacts->grants[$check[0]['owner']] & PHPGW_ACL_EDIT) && $check[0]['owner'] != $phpgw_info['user']['account_id'])
|
||||||
{
|
{
|
||||||
$userid = $check[0]['owner'];
|
$userid = $check[0]['owner'];
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@
|
|||||||
{
|
{
|
||||||
include (PHPGW_APP_ROOT . SEP . 'export' . SEP . $conv_type);
|
include (PHPGW_APP_ROOT . SEP . 'export' . SEP . $conv_type);
|
||||||
$buffer=array();
|
$buffer=array();
|
||||||
$this = new export_conv;
|
$contacts = new export_conv;
|
||||||
|
|
||||||
// Read in user custom fields, if any
|
// Read in user custom fields, if any
|
||||||
$customfields = array();
|
$customfields = array();
|
||||||
@ -115,32 +115,32 @@
|
|||||||
'address2' => 'address2',
|
'address2' => 'address2',
|
||||||
'address3' => 'address3'
|
'address3' => 'address3'
|
||||||
);
|
);
|
||||||
if ($this->type != 'vcard')
|
if ($contacts->type != 'vcard')
|
||||||
{
|
{
|
||||||
$this->qfields = $this->stock_contact_fields;# + $extrafields;# + $customfields;
|
$contacts->qfields = $contacts->stock_contact_fields;# + $extrafields;# + $customfields;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($cat_id))
|
if (!empty($cat_id))
|
||||||
{
|
{
|
||||||
$buffer = $this->export_start_file($buffer,$cat_id);
|
$buffer = $contacts->export_start_file($buffer,$cat_id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$buffer = $this->export_start_file($buffer);
|
$buffer = $contacts->export_start_file($buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($i=0;$i<count($this->ids);$i++)
|
for ($i=0;$i<count($contacts->ids);$i++)
|
||||||
{
|
{
|
||||||
$buffer = $this->export_start_record($buffer);
|
$buffer = $contacts->export_start_record($buffer);
|
||||||
while( list($name,$value) = each($this->currentrecord) )
|
while( list($name,$value) = each($contacts->currentrecord) )
|
||||||
{
|
{
|
||||||
$buffer = $this->export_new_attrib($buffer,$name,$value);
|
$buffer = $contacts->export_new_attrib($buffer,$name,$value);
|
||||||
}
|
}
|
||||||
$buffer = $this->export_end_record($buffer);
|
$buffer = $contacts->export_end_record($buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Here, buffer becomes a string suitable for printing
|
// Here, buffer becomes a string suitable for printing
|
||||||
$buffer = $this->export_end_file($buffer);
|
$buffer = $contacts->export_end_file($buffer);
|
||||||
|
|
||||||
$tsvfilename = $phpgw_info['server']['temp_dir'].$sep.$tsvfilename;
|
$tsvfilename = $phpgw_info['server']['temp_dir'].$sep.$tsvfilename;
|
||||||
}
|
}
|
||||||
|
@ -72,10 +72,10 @@
|
|||||||
if ($private == '') { $private = 'public'; }
|
if ($private == '') { $private = 'public'; }
|
||||||
$row=0;
|
$row=0;
|
||||||
$buffer=array();
|
$buffer=array();
|
||||||
$this = new import_conv;
|
$contacts = new import_conv;
|
||||||
$buffer = $this->import_start_file($buffer);
|
$buffer = $contacts->import_start_file($buffer);
|
||||||
$fp=fopen($tsvfile,'r');
|
$fp=fopen($tsvfile,'r');
|
||||||
if ($this->type == 'csv')
|
if ($contacts->type == 'csv')
|
||||||
{
|
{
|
||||||
while ($data = fgetcsv($fp,8000,','))
|
while ($data = fgetcsv($fp,8000,','))
|
||||||
{
|
{
|
||||||
@ -84,27 +84,27 @@
|
|||||||
if ($row == 1)
|
if ($row == 1)
|
||||||
{
|
{
|
||||||
// Changed here to ignore the header, set to our array
|
// Changed here to ignore the header, set to our array
|
||||||
while(list($lhs,$rhs) = each($this->import))
|
while(list($lhs,$rhs) = each($contacts->import))
|
||||||
{
|
{
|
||||||
$header[] = $lhs;
|
$header[] = $lhs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$buffer = $this->import_start_record($buffer);
|
$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
|
//Send name/value pairs along with the buffer
|
||||||
if ($this->import[$header[$c]] != '' && $data[$c] != '')
|
if ($contacts->import[$header[$c]] != '' && $data[$c] != '')
|
||||||
{
|
{
|
||||||
$buffer = $this->import_new_attrib($buffer, $this->import[$header[$c]],$data[$c]);
|
$buffer = $contacts->import_new_attrib($buffer, $contacts->import[$header[$c]],$data[$c]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$buffer = $this->import_end_record($buffer,$private);
|
$buffer = $contacts->import_end_record($buffer,$private);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($this->type == 'ldif')
|
elseif ($contacts->type == 'ldif')
|
||||||
{
|
{
|
||||||
while ($data = fgets($fp,8000))
|
while ($data = fgets($fp,8000))
|
||||||
{
|
{
|
||||||
@ -112,7 +112,7 @@
|
|||||||
list($name,$value,$extra) = split(':', $data);
|
list($name,$value,$extra) = split(':', $data);
|
||||||
if (substr($name,0,2) == 'dn')
|
if (substr($name,0,2) == 'dn')
|
||||||
{
|
{
|
||||||
$buffer = $this->import_start_record($buffer);
|
$buffer = $contacts->import_start_record($buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
$test = trim($value);
|
$test = trim($value);
|
||||||
@ -144,14 +144,14 @@
|
|||||||
$value = $url. ':' . $value;
|
$value = $url. ':' . $value;
|
||||||
}
|
}
|
||||||
//echo '<br>'.$j.': '.$name.' => '.$value;
|
//echo '<br>'.$j.': '.$name.' => '.$value;
|
||||||
if ($this->import[$name] != '' && $value != '')
|
if ($contacts->import[$name] != '' && $value != '')
|
||||||
{
|
{
|
||||||
$buffer = $this->import_new_attrib($buffer, $this->import[$name],$value);
|
$buffer = $contacts->import_new_attrib($buffer, $contacts->import[$name],$value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$buffer = $this->import_end_record($buffer,$private);
|
$buffer = $contacts->import_end_record($buffer,$private);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,28 +170,28 @@
|
|||||||
|
|
||||||
if (strtolower(substr($name,0,5)) == 'begin')
|
if (strtolower(substr($name,0,5)) == 'begin')
|
||||||
{
|
{
|
||||||
$buffer = $this->import_start_record($buffer);
|
$buffer = $contacts->import_start_record($buffer);
|
||||||
}
|
}
|
||||||
if ($name && $value)
|
if ($name && $value)
|
||||||
{
|
{
|
||||||
reset($this->import);
|
reset($contacts->import);
|
||||||
while ( list($fname,$fvalue) = each($this->import) )
|
while ( list($fname,$fvalue) = each($contacts->import) )
|
||||||
{
|
{
|
||||||
if ( strstr(strtolower($name), $this->import[$fname]) )
|
if ( strstr(strtolower($name), $contacts->import[$fname]) )
|
||||||
{
|
{
|
||||||
$buffer = $this->import_new_attrib($buffer,$name,$value);
|
$buffer = $contacts->import_new_attrib($buffer,$name,$value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$buffer = $this->import_end_record($buffer);
|
$buffer = $contacts->import_end_record($buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
$buffer = $this->import_end_file($buffer,$private,$cat_id);
|
$buffer = $contacts->import_end_file($buffer,$private,$cat_id);
|
||||||
|
|
||||||
if ($download == '')
|
if ($download == '')
|
||||||
{
|
{
|
||||||
|
@ -311,7 +311,7 @@
|
|||||||
|
|
||||||
// send this the range, query, sort, order and whatever fields you want to see
|
// send this the range, query, sort, order and whatever fields you want to see
|
||||||
// 'rights' and 'access' are unused at this time
|
// 'rights' and 'access' are unused at this time
|
||||||
function read($start=0,$offset=0,$fields="",$query="",$filter="",$sort="",$order="")
|
function read($start=0,$limit=0,$fields="",$query="",$filter="",$sort="",$order="")
|
||||||
{
|
{
|
||||||
global $phpgw,$phpgw_info;
|
global $phpgw,$phpgw_info;
|
||||||
|
|
||||||
@ -464,15 +464,22 @@
|
|||||||
// This logic allows you to limit rows, or not.
|
// This logic allows you to limit rows, or not.
|
||||||
// The export feature, for example, does not limit rows.
|
// The export feature, for example, does not limit rows.
|
||||||
// This way, it can retrieve all rows at once.
|
// This way, it can retrieve all rows at once.
|
||||||
if ($start && $offset) {
|
if ($start && $limit)
|
||||||
$limit = $start + $offset;;
|
{
|
||||||
} elseif ($start && !$offset) {
|
$limit = $start + $limit;
|
||||||
|
}
|
||||||
|
elseif ($start && !$limit)
|
||||||
|
{
|
||||||
$limit = $start;
|
$limit = $start;
|
||||||
} elseif(!$start && !$offset) {
|
}
|
||||||
|
elseif(!$start && !$limit)
|
||||||
|
{
|
||||||
$limit = $this->total_records;
|
$limit = $this->total_records;
|
||||||
} else { #(!$start && $offset) {
|
}
|
||||||
|
else
|
||||||
|
{ #(!$start && $limit) {
|
||||||
$start = 0;
|
$start = 0;
|
||||||
$limit = $offset;
|
$limit = $limit;
|
||||||
}
|
}
|
||||||
//echo '('.$start.','.$limit.')';
|
//echo '('.$start.','.$limit.')';
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
{
|
{
|
||||||
global $phpgw, $phpgw_info;
|
global $phpgw, $phpgw_info;
|
||||||
|
|
||||||
$this->db = $phpgw->db;
|
$this->db = $phpgw->db;
|
||||||
if($useacl)
|
if($useacl)
|
||||||
{
|
{
|
||||||
$this->grants = $phpgw->acl->get_grants('addressbook');
|
$this->grants = $phpgw->acl->get_grants('addressbook');
|
||||||
@ -183,7 +183,7 @@
|
|||||||
|
|
||||||
$this->db2 = $this->db;
|
$this->db2 = $this->db;
|
||||||
|
|
||||||
$this->db->query("select id,lid,tid,owner,access,cat_id $t_fields from $this->std_table WHERE id='$id'");
|
$this->db->query("SELECT id,lid,tid,owner,access,cat_id $t_fields FROM $this->std_table WHERE id='$id'");
|
||||||
$this->db->next_record();
|
$this->db->next_record();
|
||||||
|
|
||||||
$return_fields[0]['id'] = $this->db->f('id'); // unique id
|
$return_fields[0]['id'] = $this->db->f('id'); // unique id
|
||||||
@ -221,7 +221,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db2->query("SELECT contact_name,contact_value FROM $this->ext_table where contact_id='" . $this->db->f("id") . "'",__LINE__,__FILE__);
|
$this->db2->query("SELECT contact_name,contact_value FROM $this->ext_table where contact_id='" . $this->db->f('id') . "'",__LINE__,__FILE__);
|
||||||
while ($this->db2->next_record())
|
while ($this->db2->next_record())
|
||||||
{
|
{
|
||||||
// If its not in the list to be returned, don't return it.
|
// If its not in the list to be returned, don't return it.
|
||||||
@ -256,7 +256,7 @@
|
|||||||
|
|
||||||
$id = $this->db->f(0);
|
$id = $this->db->f(0);
|
||||||
|
|
||||||
$this->db->query("SELECT id,lid,tid,owner,access,cat_id $t_fields from $this->std_table WHERE id='$id'",__LINE__,__FILE__);
|
$this->db->query("SELECT id,lid,tid,owner,access,cat_id $t_fields FROM $this->std_table WHERE id='$id'",__LINE__,__FILE__);
|
||||||
$this->db->next_record();
|
$this->db->next_record();
|
||||||
|
|
||||||
$return_fields[0]['id'] = $this->db->f('id');
|
$return_fields[0]['id'] = $this->db->f('id');
|
||||||
@ -294,7 +294,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db2->query("select contact_name,contact_value from $this->ext_table where contact_id='" . $this->db->f("id") . "'",__LINE__,__FILE__);
|
$this->db2->query("SELECT contact_name,contact_value FROM $this->ext_table WHERE contact_id='" . $this->db->f('id') . "'",__LINE__,__FILE__);
|
||||||
while ($this->db2->next_record())
|
while ($this->db2->next_record())
|
||||||
{
|
{
|
||||||
// If its not in the list to be returned, don't return it.
|
// If its not in the list to be returned, don't return it.
|
||||||
@ -307,8 +307,8 @@
|
|||||||
return $return_fields;
|
return $return_fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send this the range, query, sort, order and whatever fields you want to see
|
/* send this the range, query, sort, order and whatever fields you want to see */
|
||||||
function read($start=0,$offset=0,$fields="",$query="",$filter="",$sort="",$order="")
|
function read($start=0,$limit=0,$fields="",$query="",$filter="",$sort="",$order="")
|
||||||
{
|
{
|
||||||
global $phpgw,$phpgw_info;
|
global $phpgw,$phpgw_info;
|
||||||
|
|
||||||
@ -318,24 +318,17 @@
|
|||||||
list($stock_fields,$stock_fieldnames,$extra_fields) = $this->split_stock_and_extras($fields);
|
list($stock_fields,$stock_fieldnames,$extra_fields) = $this->split_stock_and_extras($fields);
|
||||||
if (count($stock_fieldnames))
|
if (count($stock_fieldnames))
|
||||||
{
|
{
|
||||||
$t_fields = "," . implode(",",$stock_fieldnames);
|
$t_fields = ',' . implode(',',$stock_fieldnames);
|
||||||
if ($t_fields == ",")
|
if ($t_fields == ',')
|
||||||
{
|
{
|
||||||
unset($t_fields);
|
unset($t_fields);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// turn filter's a=b,c=d OR a=b into an array
|
/* turn filter's a=b,c=d OR a=b into an array */
|
||||||
if ($filter) {
|
if ($filter)
|
||||||
$extra_stock = array(
|
{
|
||||||
'id' => 'id',
|
$check_stock = $this->stock_contact_fields + $this->non_contact_fields;
|
||||||
'tid' => 'tid',
|
|
||||||
'lid' => 'lid',
|
|
||||||
'owner' => 'owner',
|
|
||||||
'access' => 'access',
|
|
||||||
'cat_id' => 'cat_id'
|
|
||||||
);
|
|
||||||
$check_stock = $this->stock_contact_fields + $extra_stock;
|
|
||||||
|
|
||||||
if ($DEBUG) { echo "DEBUG - Inbound filter is: #".$filter."#"; }
|
if ($DEBUG) { echo "DEBUG - Inbound filter is: #".$filter."#"; }
|
||||||
$filterarray = split(',',$filter);
|
$filterarray = split(',',$filter);
|
||||||
@ -344,7 +337,7 @@
|
|||||||
$i=0;
|
$i=0;
|
||||||
for ($i=0;$i<count($filterarray);$i++)
|
for ($i=0;$i<count($filterarray);$i++)
|
||||||
{
|
{
|
||||||
list($name,$value) = split("=",$filterarray[$i]);
|
list($name,$value) = split('=',$filterarray[$i]);
|
||||||
if ($name)
|
if ($name)
|
||||||
{
|
{
|
||||||
if ($DEBUG) { echo "<br>DEBUG - Filter intermediate strings 1: #".$name."# => #".$value."#"; }
|
if ($DEBUG) { echo "<br>DEBUG - Filter intermediate strings 1: #".$name."# => #".$value."#"; }
|
||||||
@ -357,28 +350,27 @@
|
|||||||
list($name,$value) = split('=',$filter);
|
list($name,$value) = split('=',$filter);
|
||||||
if ($DEBUG)
|
if ($DEBUG)
|
||||||
{
|
{
|
||||||
echo "<br>DEBUG - Filter intermediate strings 1: #".$name."# => #".$value."#";
|
echo '<br>DEBUG - Filter intermediate strings 1: #'.$name.'# => #'.$value.'#';
|
||||||
}
|
}
|
||||||
$filterfields = array($name => $value);
|
$filterfields = array($name => $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// now check each element of the array and convert into SQL for queries
|
/* now check each element of the array and convert into SQL for queries below */
|
||||||
// below
|
|
||||||
$i=0;
|
$i=0;
|
||||||
reset($filterfields);
|
reset($filterfields);
|
||||||
while (list($name,$value) = each($filterfields))
|
while (list($name,$value) = each($filterfields))
|
||||||
{
|
{
|
||||||
if ($DEBUG) { echo "<br>DEBUG - Filter intermediate strings 2: #".$name."# => #".$value."#"; }
|
if ($DEBUG) { echo '<br>DEBUG - Filter intermediate strings 2: #'.$name.'# => #'.$value.'#'; }
|
||||||
$isstd=0;
|
$isstd=0;
|
||||||
if ($name && empty($value))
|
if ($name && empty($value))
|
||||||
{
|
{
|
||||||
if ($DEBUG) { echo "<br>DEBUG - filter field '".$name."' is empty (NULL)"; }
|
if ($DEBUG) { echo '<br>DEBUG - filter field "'.$name.'" is empty (NULL)'; }
|
||||||
while (list($fname,$fvalue)=each($check_stock))
|
while (list($fname,$fvalue)=each($check_stock))
|
||||||
{
|
{
|
||||||
if ($fvalue==$name)
|
if ($fvalue==$name)
|
||||||
{
|
{
|
||||||
$filterlist .= $name.' is NULL,';
|
$filterlist .= $name.' is NULL,';
|
||||||
if ($DEBUG) { echo "<br>DEBUG - filter field '".$name."' is a stock field"; }
|
if ($DEBUG) { echo '<br>DEBUG - filter field "'.$name.'" is a stock field'; }
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -392,7 +384,6 @@
|
|||||||
{
|
{
|
||||||
if ($name == 'cat_id')
|
if ($name == 'cat_id')
|
||||||
{
|
{
|
||||||
// This is the alternative to CONCAT, since it is mysql-only
|
|
||||||
$filterlist .= "(" . $name . " LIKE '%," . $value . ",%' OR " . $name."='".$value."');";
|
$filterlist .= "(" . $name . " LIKE '%," . $value . ",%' OR " . $name."='".$value."');";
|
||||||
}
|
}
|
||||||
elseif (gettype($value) == "integer")
|
elseif (gettype($value) == "integer")
|
||||||
@ -412,11 +403,6 @@
|
|||||||
$filterlist = substr($filterlist,0,-1);
|
$filterlist = substr($filterlist,0,-1);
|
||||||
$filterlist = ereg_replace(";"," AND ",$filterlist);
|
$filterlist = ereg_replace(";"," AND ",$filterlist);
|
||||||
|
|
||||||
// echo "<p>contacts->read(): filterlist=\"$filterlist\" -->"; // allow multiple (','-separated) cat's per address
|
|
||||||
//$filterlist = ereg_replace('cat_id=[\']*([0-9]+)[\']*',"CONCAT(',',cat_id,',') LIKE '%,\\1,%'",$filterlist);
|
|
||||||
// echo "\"$filterlist\"</p>\n";
|
|
||||||
// Oops, CONCAT is mysql-only, this is now handled explicitly above for cat_id
|
|
||||||
|
|
||||||
if ($DEBUG)
|
if ($DEBUG)
|
||||||
{
|
{
|
||||||
echo "<br>DEBUG - Filter output string: #".$filterlist."#";
|
echo "<br>DEBUG - Filter output string: #".$filterlist."#";
|
||||||
@ -495,65 +481,50 @@
|
|||||||
|
|
||||||
$filtermethod = "";
|
$filtermethod = "";
|
||||||
|
|
||||||
// This logic allows you to limit rows, or not.
|
|
||||||
// The export feature, for example, does not limit rows.
|
|
||||||
// This way, it can retrieve all rows at once.
|
|
||||||
if ($start && $offset) {
|
|
||||||
$limit = $this->db->limit($start,$offset);
|
|
||||||
} elseif ($start && !$offset) {
|
|
||||||
$limit = "";
|
|
||||||
} elseif(!$start && !$offset) {
|
|
||||||
$limit = "";
|
|
||||||
} else { #(!$start && $offset) {
|
|
||||||
$start = 0;
|
|
||||||
$limit = $this->db->limit($start,$offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->db3 = $this->db2 = $this->db; // Create new result objects before our queries
|
|
||||||
|
|
||||||
if ($query)
|
if ($query)
|
||||||
{
|
{
|
||||||
$this->db3->query("SELECT * FROM $this->std_table WHERE (bday LIKE '%$query%' OR n_family LIKE '"
|
$sql = "SELECT * FROM $this->std_table WHERE (bday LIKE '%$query%' OR n_family LIKE '"
|
||||||
. "%$query%' OR n_given LIKE '%$query%' OR email LIKE '%$query%' OR "
|
. "%$query%' OR n_given LIKE '%$query%' OR email LIKE '%$query%' OR "
|
||||||
. "adr_one_street LIKE '%$query%' OR adr_one_locality LIKE '%$query%' OR adr_one_region LIKE '%$query%' OR "
|
. "adr_one_street LIKE '%$query%' OR adr_one_locality LIKE '%$query%' OR adr_one_region LIKE '%$query%' OR "
|
||||||
. "adr_one_postalcode LIKE '%$query%' OR adr_one_countryname LIKE '%$query%' OR "
|
. "adr_one_postalcode LIKE '%$query%' OR adr_one_countryname LIKE '%$query%' OR "
|
||||||
. "adr_two_street LIKE '%$query%' OR adr_two_locality LIKE '%$query%' OR adr_two_region LIKE '%$query%' OR "
|
. "adr_two_street LIKE '%$query%' OR adr_two_locality LIKE '%$query%' OR adr_two_region LIKE '%$query%' OR "
|
||||||
. "adr_two_postalcode LIKE '%$query%' OR adr_two_countryname LIKE '%$query%' OR "
|
. "adr_two_postalcode LIKE '%$query%' OR adr_two_countryname LIKE '%$query%' OR "
|
||||||
. "org_name LIKE '%$query%' OR org_unit LIKE '%$query%') " . $fand . $filtermethod . $ordermethod,__LINE__,__FILE__);
|
. "org_name LIKE '%$query%' OR org_unit LIKE '%$query%') " . $fand . $filtermethod . $ordermethod;
|
||||||
$this->total_records = $this->db3->num_rows();
|
|
||||||
|
|
||||||
$this->db->query("SELECT * FROM $this->std_table WHERE (bday LIKE '%$query%' OR n_family LIKE '"
|
|
||||||
. "%$query%' OR n_given LIKE '%$query%' OR email LIKE '%$query%' OR "
|
|
||||||
. "adr_one_street LIKE '%$query%' OR adr_one_locality LIKE '%$query%' OR adr_one_region LIKE '%$query%' OR "
|
|
||||||
. "adr_one_postalcode LIKE '%$query%' OR adr_one_countryname LIKE '%$query%' OR "
|
|
||||||
. "adr_two_street LIKE '%$query%' OR adr_two_locality LIKE '%$query%' OR adr_two_region LIKE '%$query%' OR "
|
|
||||||
. "adr_two_postalcode LIKE '%$query%' OR adr_two_countryname LIKE '%$query%' OR "
|
|
||||||
. "org_name LIKE '%$query%' OR org_unit LIKE '%$query%') " . $fand . $filtermethod . $ordermethod . " "
|
|
||||||
. $limit,__LINE__,__FILE__);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->db3->query("SELECT id,lid,tid,owner,access,cat_id $t_fields FROM $this->std_table " . $fwhere
|
$sql = "SELECT id,lid,tid,owner,access,cat_id $t_fields FROM $this->std_table " . $fwhere
|
||||||
. $filtermethod,__LINE__,__FILE__);
|
. $filtermethod . " " . $ordermethod;
|
||||||
$this->total_records = $this->db3->num_rows();
|
|
||||||
|
|
||||||
$this->db->query("SELECT id,lid,tid,owner,access,cat_id $t_fields FROM $this->std_table " . $fwhere
|
|
||||||
. $filtermethod . " " . $ordermethod . " " . $limit,__LINE__,__FILE__);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($DEBUG) { echo "<br>SELECT id,lid,tid,owner,access,cat_id $t_fields FROM $this->std_table " . $fwhere . $filtermethod; }
|
if ($DEBUG) { echo "<br>$sql"; }
|
||||||
|
|
||||||
|
$this->db2 = $this->db;
|
||||||
|
$this->db2->query($sql,__LINE__,__FILE__);
|
||||||
|
|
||||||
|
$this->total_records = $this->db2->num_rows();
|
||||||
|
|
||||||
|
if ($start && $limit)
|
||||||
|
{
|
||||||
|
$this->db->limit_query($sql,array($start,$limit),__LINE__,__FILE__);
|
||||||
|
}
|
||||||
|
elseif (!$limit)
|
||||||
|
{
|
||||||
|
$this->db->query($sql,__LINE__,__FILE__);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->limit_query($sql,$start,__LINE__,__FILE__);
|
||||||
|
}
|
||||||
|
|
||||||
$i=0;
|
$i=0;
|
||||||
while ($this->db->next_record())
|
while ($this->db->next_record())
|
||||||
{
|
{
|
||||||
// unique id, lid for group/account records,
|
|
||||||
// type id (g/u) for groups/accounts, and
|
|
||||||
// id of owner/parent for the record
|
|
||||||
$return_fields[$i]['id'] = $this->db->f('id');
|
$return_fields[$i]['id'] = $this->db->f('id');
|
||||||
$return_fields[$i]['lid'] = $this->db->f('lid');
|
$return_fields[$i]['lid'] = $this->db->f('lid');
|
||||||
$return_fields[$i]['tid'] = $this->db->f('tid');
|
$return_fields[$i]['tid'] = $this->db->f('tid');
|
||||||
$return_fields[$i]['owner'] = $this->db->f('owner');
|
$return_fields[$i]['owner'] = $this->db->f('owner');
|
||||||
$return_fields[$i]['access'] = $this->db->f('access'); // public/private
|
$return_fields[$i]['access'] = $this->db->f('access');
|
||||||
$return_fields[$i]['cat_id'] = $this->db->f('cat_id');
|
$return_fields[$i]['cat_id'] = $this->db->f('cat_id');
|
||||||
|
|
||||||
if (gettype($stock_fieldnames) == 'array')
|
if (gettype($stock_fieldnames) == 'array')
|
||||||
@ -565,11 +536,9 @@
|
|||||||
reset($stock_fieldnames);
|
reset($stock_fieldnames);
|
||||||
}
|
}
|
||||||
$this->db2->query("SELECT contact_name,contact_value FROM $this->ext_table WHERE contact_id='"
|
$this->db2->query("SELECT contact_name,contact_value FROM $this->ext_table WHERE contact_id='"
|
||||||
. $this->db->f("id") . "'" .$filterextra,__LINE__,__FILE__);
|
. $this->db->f('id') . "'" .$filterextra,__LINE__,__FILE__);
|
||||||
while ($this->db2->next_record())
|
while ($this->db2->next_record())
|
||||||
{
|
{
|
||||||
// If its not in the list to be returned, don't return it.
|
|
||||||
// This is still quicker then 5(+) separate queries
|
|
||||||
if ($extra_fields[$this->db2->f('contact_name')])
|
if ($extra_fields[$this->db2->f('contact_name')])
|
||||||
{
|
{
|
||||||
$return_fields[$i][$this->db2->f('contact_name')] = $this->db2->f('contact_value');
|
$return_fields[$i][$this->db2->f('contact_name')] = $this->db2->f('contact_value');
|
||||||
@ -584,26 +553,25 @@
|
|||||||
{
|
{
|
||||||
list($stock_fields,$stock_fieldnames,$extra_fields) = $this->split_stock_and_extras($fields);
|
list($stock_fields,$stock_fieldnames,$extra_fields) = $this->split_stock_and_extras($fields);
|
||||||
|
|
||||||
//$this->db->lock(array("contacts"));
|
|
||||||
if ($fields['lid'])
|
if ($fields['lid'])
|
||||||
{
|
{
|
||||||
$lid[0] = 'lid,';
|
$lid[0] = 'lid,';
|
||||||
$lid[1] = $fields['lid']."','";
|
$lid[1] = $fields['lid']."','";
|
||||||
}
|
}
|
||||||
$this->db->query("insert into $this->std_table (owner,access,cat_id,tid,".$lid[0]
|
$this->db->query("INSERT INTO $this->std_table (owner,access,cat_id,tid,".$lid[0]
|
||||||
. implode(",",$this->stock_contact_fields)
|
. implode(",",$this->stock_contact_fields)
|
||||||
. ") values ('$owner','$access','$cat_id','$tid','".$lid[1]
|
. ") VALUES ('$owner','$access','$cat_id','$tid','".$lid[1]
|
||||||
. implode("','",$this->loop_addslashes($stock_fields)) . "')",__LINE__,__FILE__);
|
. implode("','",$this->loop_addslashes($stock_fields)) . "')",__LINE__,__FILE__);
|
||||||
|
|
||||||
$this->db->query("select max(id) from $this->std_table ",__LINE__,__FILE__);
|
$this->db->query("SELECT max(id) FROM $this->std_table ",__LINE__,__FILE__);
|
||||||
$this->db->next_record();
|
$this->db->next_record();
|
||||||
$id = $this->db->f(0);
|
$id = $this->db->f(0);
|
||||||
//$this->db->unlock();
|
|
||||||
if (count($extra_fields))
|
if (count($extra_fields))
|
||||||
{
|
{
|
||||||
while (list($name,$value) = each($extra_fields))
|
while (list($name,$value) = each($extra_fields))
|
||||||
{
|
{
|
||||||
$this->db->query("insert into $this->ext_table values ('$id','" . $this->account_id . "','"
|
$this->db->query("INSERT INTO $this->ext_table VALUES ('$id','" . $this->account_id . "','"
|
||||||
. addslashes($name) . "','" . addslashes($value) . "')",__LINE__,__FILE__);
|
. addslashes($name) . "','" . addslashes($value) . "')",__LINE__,__FILE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -611,7 +579,7 @@
|
|||||||
|
|
||||||
function field_exists($id,$field_name)
|
function field_exists($id,$field_name)
|
||||||
{
|
{
|
||||||
$this->db->query("select count(*) from $this->ext_table where contact_id='$id' and contact_name='"
|
$this->db->query("SELECT COUNT(*) FROM $this->ext_table WHERE contact_id='$id' AND contact_name='"
|
||||||
. addslashes($field_name) . "'",__LINE__,__FILE__);
|
. addslashes($field_name) . "'",__LINE__,__FILE__);
|
||||||
$this->db->next_record();
|
$this->db->next_record();
|
||||||
return $this->db->f(0);
|
return $this->db->f(0);
|
||||||
@ -619,20 +587,20 @@
|
|||||||
|
|
||||||
function add_single_extra_field($id,$owner,$field_name,$field_value)
|
function add_single_extra_field($id,$owner,$field_name,$field_value)
|
||||||
{
|
{
|
||||||
$this->db->query("insert into $this->ext_table values ($id,'$owner','" . addslashes($field_name)
|
$this->db->query("INSERT INTO $this->ext_table VALUES ($id,'$owner','" . addslashes($field_name)
|
||||||
. "','" . addslashes($field_value) . "')",__LINE__,__FILE__);
|
. "','" . addslashes($field_value) . "')",__LINE__,__FILE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete_single_extra_field($id,$field_name)
|
function delete_single_extra_field($id,$field_name)
|
||||||
{
|
{
|
||||||
$this->db->query("delete from $this->ext_table where contact_id='$id' and contact_name='"
|
$this->db->query("DELETE FROM $this->ext_table WHERE contact_id='$id' AND contact_name='"
|
||||||
. addslashes($field_name) . "'",__LINE__,__FILE__);
|
. addslashes($field_name) . "'",__LINE__,__FILE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
function update($id,$owner,$fields,$access='',$cat_id='',$tid='n')
|
function update($id,$owner,$fields,$access='',$cat_id='',$tid='n')
|
||||||
{
|
{
|
||||||
// First make sure that id number exists
|
// First make sure that id number exists
|
||||||
$this->db->query("select count(*) from $this->std_table where id='$id'",__LINE__,__FILE__);
|
$this->db->query("SELECT COUNT(*) FROM $this->std_table WHERE id='$id'",__LINE__,__FILE__);
|
||||||
$this->db->next_record();
|
$this->db->next_record();
|
||||||
if (!$this->db->f(0))
|
if (!$this->db->f(0))
|
||||||
{
|
{
|
||||||
@ -651,7 +619,7 @@
|
|||||||
{
|
{
|
||||||
unset($field_s);
|
unset($field_s);
|
||||||
}
|
}
|
||||||
$this->db->query("update $this->std_table set access='$access',cat_id='$cat_id', tid='$tid' $fields_s where "
|
$this->db->query("UPDATE $this->std_table SET access='$access',cat_id='$cat_id', tid='$tid' $fields_s WHERE "
|
||||||
. "id='$id'",__LINE__,__FILE__);
|
. "id='$id'",__LINE__,__FILE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -665,9 +633,9 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->db->query("update $this->ext_table set contact_value='" . addslashes($x_value)
|
$this->db->query("UPDATE $this->ext_table SET contact_value='" . addslashes($x_value)
|
||||||
. "',contact_owner='$owner' where contact_name='" . addslashes($x_name)
|
. "',contact_owner='$owner' WHERE contact_name='" . addslashes($x_name)
|
||||||
. "' and contact_id='$id'",__LINE__,__FILE__);
|
. "' AND contact_id='$id'",__LINE__,__FILE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -685,8 +653,8 @@
|
|||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->query("update $this->std_table set owner='$new_owner' WHERE owner=$old_owner",__LINE__,__FILE__);
|
$this->db->query("UPDATE $this->std_table SET owner='$new_owner' WHERE owner=$old_owner",__LINE__,__FILE__);
|
||||||
$this->db->query("update $this->ext_table set contact_owner='$new_owner' WHERE contact_owner=$old_owner",__LINE__,__FILE__);
|
$this->db->query("UPDATE $this->ext_table SET contact_owner='$new_owner' WHERE contact_owner=$old_owner",__LINE__,__FILE__);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -694,8 +662,8 @@
|
|||||||
// This is where the real work of delete() is done, shared class file contains calling function
|
// This is where the real work of delete() is done, shared class file contains calling function
|
||||||
function delete_($id)
|
function delete_($id)
|
||||||
{
|
{
|
||||||
$this->db->query("delete from $this->std_table where id='$id'",__LINE__,__FILE__);
|
$this->db->query("DELETE FROM $this->std_table WHERE id='$id'",__LINE__,__FILE__);
|
||||||
$this->db->query("delete from $this->ext_table where contact_id='$id'",__LINE__,__FILE__);
|
$this->db->query("DELETE FROM $this->ext_table WHERE contact_id='$id'",__LINE__,__FILE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is for the admin script deleteaccount.php
|
// This is for the admin script deleteaccount.php
|
||||||
|
@ -113,8 +113,9 @@
|
|||||||
$phpgw->preferences->save_repository(1);
|
$phpgw->preferences->save_repository(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a select form element with the categories option dialog in it
|
/* Return a select form element with the categories option dialog in it */
|
||||||
function cat_option($cat_id='',$notall=False,$java=True,$multiple=False) {
|
function cat_option($cat_id='',$notall=False,$java=True,$multiple=False)
|
||||||
|
{
|
||||||
global $phpgw_info;
|
global $phpgw_info;
|
||||||
if ($java)
|
if ($java)
|
||||||
{
|
{
|
||||||
@ -132,38 +133,39 @@
|
|||||||
$cats_link .= '>'.lang("all").'</option>'."\n";
|
$cats_link .= '>'.lang("all").'</option>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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_link .= $cats->formated_list('select','all',$cat_id,True);
|
||||||
$cats_link .= '</select>'."\n";
|
$cats_link .= '</select>'."\n";
|
||||||
return $cats_link;
|
return $cats_link;
|
||||||
}
|
}
|
||||||
|
|
||||||
### SET THE FONT TO DEFAULT IF IT DOESNT EXISTS ###
|
/* SET THE FONT TO DEFAULT IF IT DOESNT EXISTS */
|
||||||
function set_font()
|
function set_font()
|
||||||
{
|
{
|
||||||
if($phpgw_info["user"]["preferences"]["notes"]["notes_font"] == "")
|
if($phpgw_info['user']['preferences']['notes']['notes_font'] == '')
|
||||||
{
|
{
|
||||||
$font = "Arial";
|
$font = "Arial";
|
||||||
return $font;
|
return $font;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$font = $phpgw_info["user"]["preferences"]["notes"]["notes_font"];
|
$font = $phpgw_info['user']['preferences']['notes']['notes_font'];
|
||||||
return $font;
|
return $font;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
### SET FONT SIZE ####
|
/* SET FONT SIZE */
|
||||||
function set_font_size()
|
function set_font_size()
|
||||||
{
|
{
|
||||||
if($phpgw_info["user"]["preferences"]["notes"]["notes_font_size"] == "") {
|
if($phpgw_info['user']['preferences']['notes']['notes_font_size'] == '')
|
||||||
|
{
|
||||||
$font_size = "3";
|
$font_size = "3";
|
||||||
return $font_size;
|
return $font_size;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$font_size = $phpgw_info["user"]["preferences"]["notes"]["notes_font_size"];
|
$font_size = $phpgw_info['user']['preferences']['notes']['notes_font_size'];
|
||||||
return $font_size;
|
return $font_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,7 +236,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addressbook_strip_html($dirty = "")
|
function addressbook_strip_html($dirty = '')
|
||||||
{
|
{
|
||||||
global $phpgw;
|
global $phpgw;
|
||||||
if ($dirty == ""){$dirty = array();}
|
if ($dirty == ""){$dirty = array();}
|
||||||
@ -247,81 +249,81 @@
|
|||||||
return $cleaned;
|
return $cleaned;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addressbook_read_entries($start,$offset,$qcols,$query,$qfilter,$sort,$order,$userid="")
|
function addressbook_read_entries($start,$offset,$qcols,$query,$qfilter,$sort,$order,$userid='')
|
||||||
{
|
{
|
||||||
global $this,$rights;
|
global $contacts,$rights;
|
||||||
$readrights = $rights & PHPGW_ACL_READ;
|
$readrights = $rights & PHPGW_ACL_READ;
|
||||||
$entries = $this->read($start,$offset,$qcols,$query,$qfilter,$sort,$order,$readrights);
|
$entries = $contacts->read($start,$offset,$qcols,$query,$qfilter,$sort,$order,$readrights);
|
||||||
$cleaned = addressbook_strip_html($entries);
|
$cleaned = addressbook_strip_html($entries);
|
||||||
return $cleaned;
|
return $cleaned;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addressbook_read_entry($id,$fields,$userid="")
|
function addressbook_read_entry($id,$fields,$userid='')
|
||||||
{
|
{
|
||||||
global $this,$rights;
|
global $contacts,$rights;
|
||||||
if ($rights & PHPGW_ACL_READ)
|
if ($rights & PHPGW_ACL_READ)
|
||||||
{
|
{
|
||||||
$entry = $this->read_single_entry($id,$fields);
|
$entry = $contacts->read_single_entry($id,$fields);
|
||||||
$cleaned = addressbook_strip_html($entry);
|
$cleaned = addressbook_strip_html($entry);
|
||||||
return $cleaned;
|
return $cleaned;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$rtrn = array("No access" => "No access");
|
$rtrn = array('No access' => 'No access');
|
||||||
return $rtrn;
|
return $rtrn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addressbook_read_last_entry($fields)
|
function addressbook_read_last_entry($fields)
|
||||||
{
|
{
|
||||||
global $this,$rights;
|
global $contacts,$rights;
|
||||||
if ($rights & PHPGW_ACL_READ)
|
if ($rights & PHPGW_ACL_READ)
|
||||||
{
|
{
|
||||||
$entry = $this->read_last_entry($fields);
|
$entry = $contacts->read_last_entry($fields);
|
||||||
$cleaned = addressbook_strip_html($entry);
|
$cleaned = addressbook_strip_html($entry);
|
||||||
return $cleaned;
|
return $cleaned;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$rtrn = array("No access" => "No access");
|
$rtrn = array('No access' => 'No access');
|
||||||
return $rtrn;
|
return $rtrn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addressbook_add_entry($userid,$fields,$access='',$cat_id='',$tid='n')
|
function addressbook_add_entry($userid,$fields,$access='',$cat_id='',$tid='n')
|
||||||
{
|
{
|
||||||
global $this,$rights;
|
global $contacts,$rights;
|
||||||
if ($rights & PHPGW_ACL_ADD)
|
if ($rights & PHPGW_ACL_ADD)
|
||||||
{
|
{
|
||||||
$this->add($userid,$fields,$access,$cat_id,$tid);
|
$contacts->add($userid,$fields,$access,$cat_id,$tid);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addressbook_get_lastid()
|
function addressbook_get_lastid()
|
||||||
{
|
{
|
||||||
global $this;
|
global $contacts;
|
||||||
$entry = $this->read_last_entry();
|
$entry = $contacts->read_last_entry();
|
||||||
$ab_id = $entry[0]["id"];
|
$ab_id = $entry[0]['id'];
|
||||||
return $ab_id;
|
return $ab_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addressbook_update_entry($id,$userid,$fields,$access,$cat_id)
|
function addressbook_update_entry($id,$userid,$fields,$access,$cat_id)
|
||||||
{
|
{
|
||||||
global $this,$rights;
|
global $contacts,$rights;
|
||||||
if ($rights & PHPGW_ACL_EDIT)
|
if ($rights & PHPGW_ACL_EDIT)
|
||||||
{
|
{
|
||||||
$this->update($id,$userid,$fields,$access,$cat_id);
|
$contacts->update($id,$userid,$fields,$access,$cat_id);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Folowing used for add/edit
|
// Folowing used for add/edit
|
||||||
function addressbook_form($format,$action,$title="",$fields="",$customfields="",$cat_id="")
|
function addressbook_form($format,$action,$title='',$fields='',$customfields='',$cat_id='')
|
||||||
{
|
{
|
||||||
global $phpgw,$phpgw_info,$referer;
|
global $phpgw,$phpgw_info,$referer;
|
||||||
|
|
||||||
$t = new Template(PHPGW_APP_TPL);
|
$t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
|
||||||
$t->set_file(array('form' => 'form.tpl'));
|
$t->set_file(array('form' => 'form.tpl'));
|
||||||
//$t->set_block('form','add','add');
|
//$t->set_block('form','add','add');
|
||||||
//$t->set_block('form','edit','edit');
|
//$t->set_block('form','edit','edit');
|
||||||
@ -422,14 +424,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this = CreateObject("phpgwapi.contacts");
|
$c = CreateObject("phpgwapi.contacts");
|
||||||
|
|
||||||
if ($format != "view")
|
if ($format != "view")
|
||||||
{
|
{
|
||||||
// Preferred phone number radio buttons
|
// Preferred phone number radio buttons
|
||||||
$pref[0] = "<font size=\"-2\">";
|
$pref[0] = "<font size=\"-2\">";
|
||||||
$pref[1] = "(".lang('pref').")</font>";
|
$pref[1] = "(".lang('pref').")</font>";
|
||||||
while (list($name,$val) = each($this->tel_types))
|
while (list($name,$val) = each($c->tel_types))
|
||||||
{
|
{
|
||||||
$str[$name] = "\n".' <input type="radio" name="tel_prefer" value="'.$name.'"';
|
$str[$name] = "\n".' <input type="radio" name="tel_prefer" value="'.$name.'"';
|
||||||
if ($name == $preferred)
|
if ($name == $preferred)
|
||||||
@ -504,7 +506,7 @@
|
|||||||
$time_zone .= "</select>\n";
|
$time_zone .= "</select>\n";
|
||||||
|
|
||||||
$email_type = '<select name=email_type>';
|
$email_type = '<select name=email_type>';
|
||||||
while ($type = each($this->email_types))
|
while ($type = each($c->email_types))
|
||||||
{
|
{
|
||||||
$email_type .= '<option value="'.$type[0].'"';
|
$email_type .= '<option value="'.$type[0].'"';
|
||||||
if ($type[0] == $emailtype) { $email_type .= ' selected'; }
|
if ($type[0] == $emailtype) { $email_type .= ' selected'; }
|
||||||
@ -512,9 +514,9 @@
|
|||||||
}
|
}
|
||||||
$email_type .= "</select>";
|
$email_type .= "</select>";
|
||||||
|
|
||||||
reset($this->email_types);
|
reset($c->email_types);
|
||||||
$hemail_type = '<select name=hemail_type>';
|
$hemail_type = '<select name=hemail_type>';
|
||||||
while ($type = each($this->email_types))
|
while ($type = each($c->email_types))
|
||||||
{
|
{
|
||||||
$hemail_type .= '<option value="'.$type[0].'"';
|
$hemail_type .= '<option value="'.$type[0].'"';
|
||||||
if ($type[0] == $hemailtype) { $hemail_type .= ' selected'; }
|
if ($type[0] == $hemailtype) { $hemail_type .= ' selected'; }
|
||||||
@ -522,8 +524,8 @@
|
|||||||
}
|
}
|
||||||
$hemail_type .= "</select>";
|
$hemail_type .= "</select>";
|
||||||
|
|
||||||
reset($this->adr_types);
|
reset($c->adr_types);
|
||||||
while (list($type,$val) = each($this->adr_types))
|
while (list($type,$val) = each($c->adr_types))
|
||||||
{
|
{
|
||||||
$badrtype .= "\n".'<INPUT type="checkbox" name="one_'.$type.'"';
|
$badrtype .= "\n".'<INPUT type="checkbox" name="one_'.$type.'"';
|
||||||
$ot = 'one_'.$type;
|
$ot = 'one_'.$type;
|
||||||
@ -535,8 +537,8 @@
|
|||||||
$badrtype .= '>'.$val;
|
$badrtype .= '>'.$val;
|
||||||
}
|
}
|
||||||
|
|
||||||
reset($this->adr_types);
|
reset($c->adr_types);
|
||||||
while (list($type,$val) = each($this->adr_types))
|
while (list($type,$val) = each($c->adr_types))
|
||||||
{
|
{
|
||||||
$hadrtype .= "\n".'<INPUT type="checkbox" name="two_'.$type.'"';
|
$hadrtype .= "\n".'<INPUT type="checkbox" name="two_'.$type.'"';
|
||||||
$tt = 'two_'.$type;
|
$tt = 'two_'.$type;
|
||||||
@ -718,12 +720,12 @@
|
|||||||
$t->pfp('out','form');
|
$t->pfp('out','form');
|
||||||
} //end form function
|
} //end form function
|
||||||
|
|
||||||
function parsevcard($filename,$access='')
|
function OLDparsevcard($filename,$access='')
|
||||||
{
|
{
|
||||||
global $phpgw;
|
global $phpgw;
|
||||||
global $phpgw_info;
|
global $phpgw_info;
|
||||||
|
|
||||||
$vcard = fopen($filename, "r");
|
$vcard = fopen($filename, 'r');
|
||||||
// Make sure we have a file to read.
|
// Make sure we have a file to read.
|
||||||
if (!$vcard) {
|
if (!$vcard) {
|
||||||
fclose($vcard);
|
fclose($vcard);
|
||||||
@ -1081,8 +1083,8 @@
|
|||||||
echo '<br>company: '.$fields["org_name"];
|
echo '<br>company: '.$fields["org_name"];
|
||||||
exit;
|
exit;
|
||||||
*/
|
*/
|
||||||
$this = CreateObject("phpgwapi.contacts");
|
$c = CreateObject("phpgwapi.contacts");
|
||||||
$this->add($phpgw_info["user"]["account_id"],$fields);
|
$c->add($phpgw_info["user"]["account_id"],$fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
/**************************************************************************\
|
/**************************************************************************\
|
||||||
* phpGroupWare - addressbook *
|
* phpGroupWare - Addressbook *
|
||||||
* http://www.phpgroupware.org *
|
* http://www.phpgroupware.org *
|
||||||
* Written by Joseph Engo <jengo@phpgroupware.org> *
|
* Written by Joseph Engo <jengo@phpgroupware.org> and *
|
||||||
* -------------------------------------------- *
|
* Miles Lott <miloschphpgroupware.org> *
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
* -------------------------------------------- *
|
||||||
* under the terms of the GNU General Public License as published by the *
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
* Free Software Foundation; either version 2 of the License, or (at your *
|
* under the terms of the GNU General Public License as published by the *
|
||||||
* option) any later version. *
|
* Free Software Foundation; either version 2 of the License, or (at your *
|
||||||
\**************************************************************************/
|
* option) any later version. *
|
||||||
|
\**************************************************************************/
|
||||||
|
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
$phpgw_info['flags'] = array(
|
$phpgw_info['flags'] = array(
|
||||||
'currentapp' => 'addressbook',
|
'currentapp' => 'addressbook',
|
||||||
@ -27,9 +28,8 @@
|
|||||||
$t->set_block('addressbook_list_t','row','row');
|
$t->set_block('addressbook_list_t','row','row');
|
||||||
$t->set_block('addressbook_list_t','addressbook_footer','addressbook_footer');
|
$t->set_block('addressbook_list_t','addressbook_footer','addressbook_footer');
|
||||||
|
|
||||||
$this = CreateObject('phpgwapi.contacts');
|
$contacts = CreateObject('phpgwapi.contacts');
|
||||||
//$this->delete_all($phpgw_info['user']['account_id']);
|
|
||||||
//exit;
|
|
||||||
$customfields = array();
|
$customfields = array();
|
||||||
while (list($col,$descr) = @each($phpgw_info['user']['preferences']['addressbook']))
|
while (list($col,$descr) = @each($phpgw_info['user']['preferences']['addressbook']))
|
||||||
{
|
{
|
||||||
@ -57,24 +57,24 @@
|
|||||||
'address2' => 'address2',
|
'address2' => 'address2',
|
||||||
'address3' => 'address3'
|
'address3' => 'address3'
|
||||||
);
|
);
|
||||||
$qfields = $this->stock_contact_fields + $extrafields + $customfields;
|
/* $qfields = $contacts->stock_contact_fields + $extrafields + $customfields; */
|
||||||
|
|
||||||
// create column list and the top row of the table based on user prefs
|
/* create column list and the top row of the table based on user prefs */
|
||||||
while ($column = each($this->stock_contact_fields))
|
while ($column = each($contacts->stock_contact_fields))
|
||||||
{
|
{
|
||||||
$test = strtolower($column[0]);
|
$test = strtolower($column[0]);
|
||||||
if (isset($phpgw_info['user']['preferences']['addressbook'][$test]) &&
|
if (isset($phpgw_info['user']['preferences']['addressbook'][$test]) &&
|
||||||
$phpgw_info['user']['preferences']['addressbook'][$test])
|
$phpgw_info['user']['preferences']['addressbook'][$test])
|
||||||
{
|
{
|
||||||
$showcol = display_name($column[0]);
|
$showcol = display_name($column[0]);
|
||||||
$cols .= " <td height=\"21\">\n";
|
$cols .= ' <td height="21">' . "\n";
|
||||||
$cols .= ' <font size="-1" face="Arial, Helvetica, sans-serif">';
|
$cols .= ' <font size="-1" face="Arial, Helvetica, sans-serif">';
|
||||||
$cols .= $phpgw->nextmatchs->show_sort_order($sort,
|
$cols .= $phpgw->nextmatchs->show_sort_order($sort,
|
||||||
$column[0],$order,"/addressbook/index.php",$showcol,"&cat_id=".$cat_id);
|
$column[0],$order,"/addressbook/index.php",$showcol,"&cat_id=".$cat_id);
|
||||||
$cols .= "</font>\n </td>";
|
$cols .= "</font>\n </td>";
|
||||||
$cols .= "\n";
|
$cols .= "\n";
|
||||||
|
|
||||||
// To be used when displaying the rows
|
/* To be used when displaying the rows */
|
||||||
$columns_to_display[$column[0]] = True;
|
$columns_to_display[$column[0]] = True;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,15 +87,15 @@
|
|||||||
$phpgw_info['user']['preferences']['addressbook'][$test])
|
$phpgw_info['user']['preferences']['addressbook'][$test])
|
||||||
{
|
{
|
||||||
$showcol = display_name($column[0]);
|
$showcol = display_name($column[0]);
|
||||||
// This must be a custom field
|
/* This must be a custom field */
|
||||||
if (!$showcol) { $showcol = $column[1]; }
|
if (!$showcol) { $showcol = $column[1]; }
|
||||||
$cols .= " <td height=\"21\">\n";
|
$cols .= ' <td height="21">' . "\n";
|
||||||
$cols .= ' <font size="-1" face="Arial, Helvetica, sans-serif">';
|
$cols .= ' <font size="-1" face="Arial, Helvetica, sans-serif">';
|
||||||
$cols .= $showcol;
|
$cols .= $showcol;
|
||||||
$cols .= "</font>\n </td>";
|
$cols .= "</font>\n </td>";
|
||||||
$cols .= "\n";
|
$cols .= "\n";
|
||||||
|
|
||||||
// To be used when displaying the rows
|
/* To be used when displaying the rows */
|
||||||
$columns_to_display[$column[0]] = True;
|
$columns_to_display[$column[0]] = True;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,11 +108,11 @@
|
|||||||
if($phpgw_info['user']['preferences']['common']['maxmatchs'] &&
|
if($phpgw_info['user']['preferences']['common']['maxmatchs'] &&
|
||||||
$phpgw_info['user']['preferences']['common']['maxmatchs'] > 0)
|
$phpgw_info['user']['preferences']['common']['maxmatchs'] > 0)
|
||||||
{
|
{
|
||||||
$offset = $phpgw_info['user']['preferences']['common']['maxmatchs'];
|
$limit = $phpgw_info['user']['preferences']['common']['maxmatchs'];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$offset = 30;
|
$limit = 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$filter)
|
if (!$filter)
|
||||||
@ -140,7 +140,7 @@
|
|||||||
case 'none':
|
case 'none':
|
||||||
break;
|
break;
|
||||||
case 'private':
|
case 'private':
|
||||||
$qfilter .= ',access=private'; // fall through
|
$qfilter .= ',access=private'; /* fall through */
|
||||||
case 'yours':
|
case 'yours':
|
||||||
$qfilter .= ',owner='.$phpgw_info['user']['account_id'];
|
$qfilter .= ',owner='.$phpgw_info['user']['account_id'];
|
||||||
break;
|
break;
|
||||||
@ -152,7 +152,7 @@
|
|||||||
$qfilter .= ',cat_id='.$cat_id;
|
$qfilter .= ',cat_id='.$cat_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if prefs were set, if not, create some defaults
|
/* Check if prefs were set, if not, create some defaults */
|
||||||
if (!$columns_to_display )
|
if (!$columns_to_display )
|
||||||
{
|
{
|
||||||
$columns_to_display = array(
|
$columns_to_display = array(
|
||||||
@ -161,13 +161,13 @@
|
|||||||
'org_name' => 'org_name'
|
'org_name' => 'org_name'
|
||||||
);
|
);
|
||||||
$columns_to_display = $columns_to_display + $customfields;
|
$columns_to_display = $columns_to_display + $customfields;
|
||||||
// No prefs,. so cols above may have been set to "" or a bunch of <td></td>
|
/* No prefs,. so cols above may have been set to "" or a bunch of <td></td> */
|
||||||
$cols="";
|
$cols="";
|
||||||
while ($column = each($columns_to_display))
|
while ($column = each($columns_to_display))
|
||||||
{
|
{
|
||||||
$showcol = display_name($column[0]);
|
$showcol = display_name($column[0]);
|
||||||
if (!$showcol) { $showcol = $column[1]; }
|
if (!$showcol) { $showcol = $column[1]; }
|
||||||
$cols .= " <td height=\"21\">\n";
|
$cols .= ' <td height="21">' . "\n";
|
||||||
$cols .= ' <font size="-1" face="Arial, Helvetica, sans-serif">';
|
$cols .= ' <font size="-1" face="Arial, Helvetica, sans-serif">';
|
||||||
$cols .= $phpgw->nextmatchs->show_sort_order($sort,
|
$cols .= $phpgw->nextmatchs->show_sort_order($sort,
|
||||||
$column[0],$order,"/addressbook/index.php",$showcol,"&cat_id=$cat_id");
|
$column[0],$order,"/addressbook/index.php",$showcol,"&cat_id=$cat_id");
|
||||||
@ -183,42 +183,27 @@
|
|||||||
if ($nosearch && !$query)
|
if ($nosearch && !$query)
|
||||||
{
|
{
|
||||||
$entries = array();
|
$entries = array();
|
||||||
$this->total_records = 0;
|
$contacts->total_records = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* read the entry list */
|
/* read the entry list */
|
||||||
$entries = addressbook_read_entries($start,$offset,$qcols,$query,$qfilter,$sort,$order,$userid);
|
$entries = addressbook_read_entries($start,$limit,$qcols,$query,$qfilter,$sort,$order,$userid);
|
||||||
}
|
}
|
||||||
|
|
||||||
$search_filter = $phpgw->nextmatchs->show_tpl('/addressbook/index.php',
|
$search_filter = $phpgw->nextmatchs->show_tpl('/addressbook/index.php',
|
||||||
$start, $this->total_records,"&order=$order&filter=$filter&sort=$sort&query=$query&cat_id=$cat_id","75%",
|
$start, $contacts->total_records,"&order=$order&filter=$filter&sort=$sort&query=$query&cat_id=$cat_id","75%",
|
||||||
$phpgw_info["theme"]["th_bg"],1,1,1,1);
|
$phpgw_info["theme"]["th_bg"],1,1,1,1);
|
||||||
|
|
||||||
if ($this->total_records > $phpgw_info['user']['preferences']['common']['maxmatchs'])
|
$lang_showing = $phpgw->nextmatchs->show_hits($contacts->total_records,$start);
|
||||||
{
|
|
||||||
if ($start + $phpgw_info['user']['preferences']['common']['maxmatchs'] > $this->total_records)
|
|
||||||
{
|
|
||||||
$end = $this->total_records;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$end = $start + $phpgw_info['user']['preferences']['common']['maxmatchs'];
|
|
||||||
}
|
|
||||||
$lang_showing=lang('showing x - x of x',($start + 1),$end,$this->total_records);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$lang_showing=lang('showing x',$this->total_records);
|
|
||||||
}
|
|
||||||
|
|
||||||
// set basic vars and parse the header
|
/* set basic vars and parse the header */
|
||||||
$t->set_var(font,$phpgw_info['theme']['font']);
|
$t->set_var(font,$phpgw_info['theme']['font']);
|
||||||
$t->set_var('lang_view',lang('View'));
|
$t->set_var('lang_view',lang('View'));
|
||||||
$t->set_var('lang_vcard',lang('VCard'));
|
$t->set_var('lang_vcard',lang('VCard'));
|
||||||
$t->set_var('lang_edit',lang('Edit'));
|
$t->set_var('lang_edit',lang('Edit'));
|
||||||
$t->set_var('lang_owner',lang('Owner'));
|
$t->set_var('lang_owner',lang('Owner'));
|
||||||
|
|
||||||
$t->set_var('searchreturn',$noprefs . ' ' . $searchreturn);
|
$t->set_var('searchreturn',$noprefs . ' ' . $searchreturn);
|
||||||
$t->set_var('lang_showing',$lang_showing);
|
$t->set_var('lang_showing',$lang_showing);
|
||||||
$t->set_var('search_filter',$search_filter);
|
$t->set_var('search_filter',$search_filter);
|
||||||
@ -251,11 +236,12 @@
|
|||||||
$t->set_var('start',$start);
|
$t->set_var('start',$start);
|
||||||
$t->set_var('filter',$filter);
|
$t->set_var('filter',$filter);
|
||||||
$t->set_var('cols',$cols);
|
$t->set_var('cols',$cols);
|
||||||
|
|
||||||
$t->pparse('out','addressbook_header');
|
$t->pparse('out','addressbook_header');
|
||||||
|
|
||||||
// Show the entries
|
/* Show the entries */
|
||||||
for ($i=0;$i<count($entries);$i++) // each entry
|
/* each entry */
|
||||||
|
for ($i=0;$i<count($entries);$i++)
|
||||||
{
|
{
|
||||||
$t->set_var('columns','');
|
$t->set_var('columns','');
|
||||||
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
|
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
|
||||||
@ -263,11 +249,12 @@
|
|||||||
$myid = $entries[$i]['id'];
|
$myid = $entries[$i]['id'];
|
||||||
$myowner = $entries[$i]['owner'];
|
$myowner = $entries[$i]['owner'];
|
||||||
|
|
||||||
while ($column = each($columns_to_display)) // each entry column
|
/* each entry column */
|
||||||
|
while ($column = each($columns_to_display))
|
||||||
{
|
{
|
||||||
$ref=$data="";
|
$ref = $data='';
|
||||||
$coldata = $entries[$i][$column[0]];
|
$coldata = $entries[$i][$column[0]];
|
||||||
// Some fields require special formatting.
|
/* Some fields require special formatting. */
|
||||||
if ($column[0] == 'url')
|
if ($column[0] == 'url')
|
||||||
{
|
{
|
||||||
if ( !empty($coldata) && (substr($coldata,0,7) != 'http://') ) { $coldata = 'http://' . $coldata; }
|
if ( !empty($coldata) && (substr($coldata,0,7) != 'http://') ) { $coldata = 'http://' . $coldata; }
|
||||||
@ -284,11 +271,11 @@
|
|||||||
{
|
{
|
||||||
$ref='<a href="mailto:'.$coldata.'">';
|
$ref='<a href="mailto:'.$coldata.'">';
|
||||||
}
|
}
|
||||||
$data=$coldata."</a>";
|
$data=$coldata . '</a>';
|
||||||
}
|
}
|
||||||
else // But these do not
|
else /* But these do not */
|
||||||
{
|
{
|
||||||
$ref=""; $data=$coldata;
|
$ref = ''; $data = $coldata;
|
||||||
}
|
}
|
||||||
$t->set_var('col_data',$ref.$data);
|
$t->set_var('col_data',$ref.$data);
|
||||||
$t->parse('columns','column',True);
|
$t->parse('columns','column',True);
|
||||||
@ -305,12 +292,12 @@
|
|||||||
$t->set_var('row_view_link','');
|
$t->set_var('row_view_link','');
|
||||||
$t->set_var('lang_view',lang('Private'));
|
$t->set_var('lang_view',lang('Private'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$t->set_var('row_vcard_link',$phpgw->link('/addressbook/vcardout.php',
|
$t->set_var('row_vcard_link',$phpgw->link('/addressbook/vcardout.php',
|
||||||
"ab_id=$myid&start=$start&sort=$sort&order=$order&filter="
|
"ab_id=$myid&start=$start&sort=$sort&order=$order&filter="
|
||||||
. "$filter&query=$query&sort=$sort&cat_id=$cat_id"));
|
. "$filter&query=$query&sort=$sort&cat_id=$cat_id"));
|
||||||
// echo '<br>: ' . $this->grants[$myowner] . ' - ' . $myowner;
|
/* echo '<br>: ' . $contacts->grants[$myowner] . ' - ' . $myowner; */
|
||||||
if ($this->check_perms($this->grants[$myowner],PHPGW_ACL_EDIT) || $myowner == $phpgw_info['user']['account_id'])
|
if ($contacts->check_perms($contacts->grants[$myowner],PHPGW_ACL_EDIT) || $myowner == $phpgw_info['user']['account_id'])
|
||||||
{
|
{
|
||||||
$t->set_var('row_edit','<a href="' . $phpgw->link("/addressbook/edit.php",
|
$t->set_var('row_edit','<a href="' . $phpgw->link("/addressbook/edit.php",
|
||||||
"ab_id=$myid&start=$start&sort=$sort&order=$order&filter="
|
"ab_id=$myid&start=$start&sort=$sort&order=$order&filter="
|
||||||
@ -320,12 +307,12 @@
|
|||||||
{
|
{
|
||||||
$t->set_var('row_edit',' ');
|
$t->set_var('row_edit',' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
$t->set_var('row_owner',$phpgw->accounts->id2name($myowner));
|
$t->set_var('row_owner',$phpgw->accounts->id2name($myowner));
|
||||||
|
|
||||||
$t->parse('rows','row',True);
|
$t->parse('rows','row',True);
|
||||||
$t->pparse('out','row');
|
$t->pparse('out','row');
|
||||||
reset($columns_to_display); // If we don't reset it, our inside while won't loop
|
reset($columns_to_display);
|
||||||
}
|
}
|
||||||
|
|
||||||
$t->pparse('out','addressbook_footer');
|
$t->pparse('out','addressbook_footer');
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
include('../header.inc.php');
|
include('../header.inc.php');
|
||||||
|
|
||||||
$this = CreateObject('phpgwapi.contacts');
|
$contacts = CreateObject('phpgwapi.contacts');
|
||||||
|
|
||||||
$extrafields = array(
|
$extrafields = array(
|
||||||
'ophone' => 'ophone',
|
'ophone' => 'ophone',
|
||||||
@ -45,7 +45,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$qfields = $this->stock_contact_fields + $extrafields + $customfields;
|
$qfields = $contacts->stock_contact_fields + $extrafields + $customfields;
|
||||||
|
|
||||||
if ($submit)
|
if ($submit)
|
||||||
{
|
{
|
||||||
|
@ -31,6 +31,6 @@
|
|||||||
/* Dependencies for this app to work */
|
/* Dependencies for this app to work */
|
||||||
$setup_info['addressbook']['depends'][] = array(
|
$setup_info['addressbook']['depends'][] = array(
|
||||||
'appname' => 'phpgwapi',
|
'appname' => 'phpgwapi',
|
||||||
'versions' => Array('0.9.10', '0.9.11' , '0.9.12', '0.9.13')
|
'versions' => Array('0.9.13', '0.9.14')
|
||||||
);
|
);
|
||||||
?>
|
?>
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
<td>{lang_Contact_application}:</td>
|
<td>{lang_Contact_application}:</td>
|
||||||
<td><input name="newsettings[contact_application]" value="{value_contact_application}"></td>
|
<td><input name="newsettings[contact_application]" value="{value_contact_application}"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr bgcolor="{row_off}">
|
||||||
|
<td align="center" colspan="2">{lang_WARNING!!_LDAP_is_valid_only_if_you_are_NOT_using_contacts_for_accounts_storage!}</td>
|
||||||
|
</tr>
|
||||||
<tr bgcolor="{row_off}">
|
<tr bgcolor="{row_off}">
|
||||||
<td>{lang_Select_where_you_want_to_store}/{lang_retrieve_contacts}.</td>
|
<td>{lang_Select_where_you_want_to_store}/{lang_retrieve_contacts}.</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -42,11 +42,11 @@
|
|||||||
$phpgw->common->phpgw_exit();
|
$phpgw->common->phpgw_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this = CreateObject('phpgwapi.contacts');
|
$contacts = CreateObject('phpgwapi.contacts');
|
||||||
|
|
||||||
// First, make sure they have permission to this entry
|
// First, make sure they have permission to this entry
|
||||||
$check = addressbook_read_entry($ab_id,array('owner' => 'owner'));
|
$check = addressbook_read_entry($ab_id,array('owner' => 'owner'));
|
||||||
$perms = $this->check_perms($this->grants[$check[0]['owner']],PHPGW_ACL_READ);
|
$perms = $contacts->check_perms($contacts->grants[$check[0]['owner']],PHPGW_ACL_READ);
|
||||||
|
|
||||||
if ( (!$perms) && ($check[0]['owner'] != $phpgw_info['user']['account_id']) )
|
if ( (!$perms) && ($check[0]['owner'] != $phpgw_info['user']['account_id']) )
|
||||||
{
|
{
|
||||||
@ -56,7 +56,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$extrafields = array('address2' => 'address2');
|
$extrafields = array('address2' => 'address2');
|
||||||
$qfields = $this->stock_contact_fields + $extrafields;
|
$qfields = $contacts->stock_contact_fields + $extrafields;
|
||||||
|
|
||||||
$fieldlist = addressbook_read_entry($ab_id,$qfields);
|
$fieldlist = addressbook_read_entry($ab_id,$qfields);
|
||||||
$fields = $fieldlist[0];
|
$fields = $fieldlist[0];
|
||||||
|
@ -22,11 +22,11 @@
|
|||||||
|
|
||||||
include('../header.inc.php');
|
include('../header.inc.php');
|
||||||
|
|
||||||
$this = CreateObject("phpgwapi.contacts");
|
$contacts = CreateObject("phpgwapi.contacts");
|
||||||
|
|
||||||
// First, make sure they have permission to this entry
|
// First, make sure they have permission to this entry
|
||||||
$check = addressbook_read_entry($ab_id,array('owner' => 'owner'));
|
$check = addressbook_read_entry($ab_id,array('owner' => 'owner'));
|
||||||
$perms = $this->check_perms($this->grants[$check[0]['owner']],PHPGW_ACL_READ);
|
$perms = $contacts->check_perms($contacts->grants[$check[0]['owner']],PHPGW_ACL_READ);
|
||||||
|
|
||||||
if ( (!$perms) && ($check[0]['owner'] != $phpgw_info['user']['account_id']) )
|
if ( (!$perms) && ($check[0]['owner'] != $phpgw_info['user']['account_id']) )
|
||||||
{
|
{
|
||||||
@ -63,7 +63,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while ($column = each($this->stock_contact_fields))
|
while ($column = each($contacts->stock_contact_fields))
|
||||||
{
|
{
|
||||||
if (isset($phpgw_info['user']['preferences']['addressbook'][$column[0]]) &&
|
if (isset($phpgw_info['user']['preferences']['addressbook'][$column[0]]) &&
|
||||||
$phpgw_info['user']['preferences']['addressbook'][$column[0]])
|
$phpgw_info['user']['preferences']['addressbook'][$column[0]])
|
||||||
@ -98,7 +98,7 @@
|
|||||||
'address2' => 'address2',
|
'address2' => 'address2',
|
||||||
'address3' => 'address3'
|
'address3' => 'address3'
|
||||||
);
|
);
|
||||||
$qfields = $this->stock_contact_fields + $extrafields + $customfields;
|
$qfields = $contacts->stock_contact_fields + $extrafields + $customfields;
|
||||||
|
|
||||||
$fields = addressbook_read_entry($ab_id,$qfields);
|
$fields = addressbook_read_entry($ab_id,$qfields);
|
||||||
|
|
||||||
@ -137,7 +137,7 @@
|
|||||||
$t->set_var('th_bg',$tr_color);
|
$t->set_var('th_bg',$tr_color);
|
||||||
$coldata = $fields[0][$column];
|
$coldata = $fields[0][$column];
|
||||||
// Some fields require special formatting.
|
// Some fields require special formatting.
|
||||||
if ( ($column == "note" || $column == "label" || $column == "pubkey") && $coldata )
|
if ( ($column == 'note' || $column == 'pubkey') && $coldata )
|
||||||
{
|
{
|
||||||
$datarray = explode ("\n",$coldata);
|
$datarray = explode ("\n",$coldata);
|
||||||
if ($datarray[1])
|
if ($datarray[1])
|
||||||
@ -160,6 +160,10 @@
|
|||||||
$data = $coldata;
|
$data = $coldata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elseif($column == 'label' && $coldata)
|
||||||
|
{
|
||||||
|
$data .= $contacts->formatted_address($fields[0]['id'],'',False);
|
||||||
|
}
|
||||||
elseif ($column == "url" && $coldata)
|
elseif ($column == "url" && $coldata)
|
||||||
{
|
{
|
||||||
$ref = '<a href="' . $coldata . '" target="_new">';
|
$ref = '<a href="' . $coldata . '" target="_new">';
|
||||||
@ -203,11 +207,11 @@
|
|||||||
$cats = explode(',',$fields[0]['cat_id']);
|
$cats = explode(',',$fields[0]['cat_id']);
|
||||||
if ($cats[1])
|
if ($cats[1])
|
||||||
{
|
{
|
||||||
while (list($key,$thiscat) = each($cats))
|
while (list($key,$contactscat) = each($cats))
|
||||||
{
|
{
|
||||||
if ($thiscat)
|
if ($contactscat)
|
||||||
{
|
{
|
||||||
$catinfo = $cat->return_single($thiscat);
|
$catinfo = $cat->return_single($contactscat);
|
||||||
$catname .= $catinfo[0]['name'] . '; ';
|
$catname .= $catinfo[0]['name'] . '; ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -285,7 +289,7 @@
|
|||||||
|
|
||||||
$common_vars = array('sort' => $sort,'order' => $order,'filter' => $filter,'start' => $start); // common vars for all buttons
|
$common_vars = array('sort' => $sort,'order' => $order,'filter' => $filter,'start' => $start); // common vars for all buttons
|
||||||
|
|
||||||
if (($this->grants[$record_owner] & PHPGW_ACL_EDIT) || ($record_owner == $phpgw_info['user']['account_id']))
|
if (($contacts->grants[$record_owner] & PHPGW_ACL_EDIT) || ($record_owner == $phpgw_info['user']['account_id']))
|
||||||
{
|
{
|
||||||
$extra_vars = array('cd' => 16,'query' => $query,'cat_id' => $cat_id);
|
$extra_vars = array('cd' => 16,'query' => $query,'cat_id' => $cat_id);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user