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->set_file(array('add' => 'add.tpl'));
|
||||
|
||||
$this = CreateObject('phpgwapi.contacts');
|
||||
$contacts = CreateObject('phpgwapi.contacts');
|
||||
|
||||
// Read in user custom fields, if any
|
||||
$phpgw->preferences->read_repository();
|
||||
@ -79,7 +79,7 @@
|
||||
'address2' => 'address2',
|
||||
'address3' => 'address3'
|
||||
);
|
||||
$qfields = $this->stock_contact_fields + $extrafields + $customfields;
|
||||
$qfields = $contacts->stock_contact_fields + $extrafields + $customfields;
|
||||
$addnew = unserialize(rawurldecode($fields));
|
||||
$addnew['note'] .= "\nCopied from ".$phpgw->accounts->id2name($addnew['owner']).", record #".$addnew['id'].".";
|
||||
$addnew['owner'] = $phpgw_info['user']['account_id'];
|
||||
@ -144,9 +144,9 @@
|
||||
$fields['adr_one_postalcode'] = $bzip;
|
||||
$fields['adr_one_countryname'] = $bcountry;
|
||||
|
||||
reset($this->adr_types);
|
||||
reset($contacts->adr_types);
|
||||
$typed = '';
|
||||
while (list($type,$val) = each($this->adr_types))
|
||||
while (list($type,$val) = each($contacts->adr_types))
|
||||
{
|
||||
$ftype = 'one_'.$type;
|
||||
eval("if (\$\$ftype=='on') { \$typed .= \$type . ';'; }");
|
||||
@ -162,9 +162,9 @@
|
||||
$fields['adr_two_postalcode'] = $hzip;
|
||||
$fields['adr_two_countryname'] = $hcountry;
|
||||
|
||||
reset($this->adr_types);
|
||||
reset($contacts->adr_types);
|
||||
$typed = '';
|
||||
while (list($type,$val) = each($this->adr_types))
|
||||
while (list($type,$val) = each($contacts->adr_types))
|
||||
{
|
||||
$ftype = 'two_'.$type;
|
||||
eval("if (\$\$ftype=='on') { \$typed \.= \$type . ';'; }");
|
||||
|
@ -25,11 +25,11 @@
|
||||
Header('Location: ' . $phpgw->link('/addressbook/index.php'));
|
||||
}
|
||||
|
||||
$this = CreateObject('phpgwapi.contacts');
|
||||
$fields = $this->read_single_entry($ab_id,array('owner' => 'owner'));
|
||||
$contacts = CreateObject('phpgwapi.contacts');
|
||||
$fields = $contacts->read_single_entry($ab_id,array('owner' => '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: '
|
||||
. $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
|
||||
{
|
||||
$this->account_id = $phpgw_info['user']['account_id'];
|
||||
$this->delete($ab_id);
|
||||
$contacts->account_id = $phpgw_info['user']['account_id'];
|
||||
$contacts->delete($ab_id);
|
||||
|
||||
@Header('Location: ' . $phpgw->link('/addressbook/index.php',
|
||||
"cd=16&order=$order&sort=$sort&filter=$filter&start=$start&query=$query&cat_id=$cat_id"));
|
||||
|
@ -23,12 +23,12 @@
|
||||
|
||||
include('../header.inc.php');
|
||||
|
||||
$this = CreateObject('phpgwapi.contacts');
|
||||
$contacts = CreateObject('phpgwapi.contacts');
|
||||
|
||||
// First, make sure they have permission to this entry
|
||||
$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: "
|
||||
. $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'
|
||||
);
|
||||
|
||||
$qfields = $this->stock_contact_fields + $extrafields + $customfields;
|
||||
$qfields = $contacts->stock_contact_fields + $extrafields + $customfields;
|
||||
$fields = addressbook_read_entry($ab_id,$qfields);
|
||||
addressbook_form('edit','edit.php',lang('Edit'),$fields[0],$customfields);
|
||||
|
||||
@ -91,7 +91,7 @@
|
||||
$t->set_var('lang_submit',lang('submit'));
|
||||
$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_button','<input type="submit" name="delete" value="' . lang('Delete') . '">');
|
||||
@ -153,9 +153,9 @@
|
||||
$fields['adr_one_postalcode'] = $bzip;
|
||||
$fields['adr_one_countryname'] = $bcountry;
|
||||
|
||||
reset($this->adr_types);
|
||||
reset($contacts->adr_types);
|
||||
$typed = '';
|
||||
while (list($type,$val) = each($this->adr_types))
|
||||
while (list($type,$val) = each($contacts->adr_types))
|
||||
{
|
||||
$ftype = 'one_'.$type;
|
||||
eval("if (\$\$ftype=='on') { \$typed .= \$type . ';'; }");
|
||||
@ -171,9 +171,9 @@
|
||||
$fields['adr_two_postalcode'] = $hzip;
|
||||
$fields['adr_two_countryname'] = $hcountry;
|
||||
|
||||
reset($this->adr_types);
|
||||
reset($contacts->adr_types);
|
||||
$typed = '';
|
||||
while (list($type,$val) = each($this->adr_types))
|
||||
while (list($type,$val) = each($contacts->adr_types))
|
||||
{
|
||||
$ftype = 'two_'.$type;
|
||||
eval("if (\$\$ftype=='on') { \$typed .= \$type . ';'; }");
|
||||
@ -214,7 +214,7 @@
|
||||
$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'];
|
||||
}
|
||||
|
@ -97,7 +97,7 @@
|
||||
{
|
||||
include (PHPGW_APP_ROOT . SEP . 'export' . SEP . $conv_type);
|
||||
$buffer=array();
|
||||
$this = new export_conv;
|
||||
$contacts = new export_conv;
|
||||
|
||||
// Read in user custom fields, if any
|
||||
$customfields = array();
|
||||
@ -115,32 +115,32 @@
|
||||
'address2' => 'address2',
|
||||
'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))
|
||||
{
|
||||
$buffer = $this->export_start_file($buffer,$cat_id);
|
||||
$buffer = $contacts->export_start_file($buffer,$cat_id);
|
||||
}
|
||||
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);
|
||||
while( list($name,$value) = each($this->currentrecord) )
|
||||
$buffer = $contacts->export_start_record($buffer);
|
||||
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
|
||||
$buffer = $this->export_end_file($buffer);
|
||||
$buffer = $contacts->export_end_file($buffer);
|
||||
|
||||
$tsvfilename = $phpgw_info['server']['temp_dir'].$sep.$tsvfilename;
|
||||
}
|
||||
|
@ -72,10 +72,10 @@
|
||||
if ($private == '') { $private = 'public'; }
|
||||
$row=0;
|
||||
$buffer=array();
|
||||
$this = new import_conv;
|
||||
$buffer = $this->import_start_file($buffer);
|
||||
$contacts = new import_conv;
|
||||
$buffer = $contacts->import_start_file($buffer);
|
||||
$fp=fopen($tsvfile,'r');
|
||||
if ($this->type == 'csv')
|
||||
if ($contacts->type == 'csv')
|
||||
{
|
||||
while ($data = fgetcsv($fp,8000,','))
|
||||
{
|
||||
@ -84,27 +84,27 @@
|
||||
if ($row == 1)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$buffer = $this->import_start_record($buffer);
|
||||
$buffer = $contacts->import_start_record($buffer);
|
||||
for ($c=0; $c<$num; $c++ )
|
||||
{
|
||||
//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))
|
||||
{
|
||||
@ -112,7 +112,7 @@
|
||||
list($name,$value,$extra) = split(':', $data);
|
||||
if (substr($name,0,2) == 'dn')
|
||||
{
|
||||
$buffer = $this->import_start_record($buffer);
|
||||
$buffer = $contacts->import_start_record($buffer);
|
||||
}
|
||||
|
||||
$test = trim($value);
|
||||
@ -144,14 +144,14 @@
|
||||
$value = $url. ':' . $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
|
||||
{
|
||||
$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')
|
||||
{
|
||||
$buffer = $this->import_start_record($buffer);
|
||||
$buffer = $contacts->import_start_record($buffer);
|
||||
}
|
||||
if ($name && $value)
|
||||
{
|
||||
reset($this->import);
|
||||
while ( list($fname,$fvalue) = each($this->import) )
|
||||
reset($contacts->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
|
||||
{
|
||||
$buffer = $this->import_end_record($buffer);
|
||||
$buffer = $contacts->import_end_record($buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
$buffer = $this->import_end_file($buffer,$private,$cat_id);
|
||||
$buffer = $contacts->import_end_file($buffer,$private,$cat_id);
|
||||
|
||||
if ($download == '')
|
||||
{
|
||||
|
@ -311,7 +311,7 @@
|
||||
|
||||
// send this the range, query, sort, order and whatever fields you want to see
|
||||
// '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;
|
||||
|
||||
@ -464,15 +464,22 @@
|
||||
// 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 = $start + $offset;;
|
||||
} elseif ($start && !$offset) {
|
||||
if ($start && $limit)
|
||||
{
|
||||
$limit = $start + $limit;
|
||||
}
|
||||
elseif ($start && !$limit)
|
||||
{
|
||||
$limit = $start;
|
||||
} elseif(!$start && !$offset) {
|
||||
}
|
||||
elseif(!$start && !$limit)
|
||||
{
|
||||
$limit = $this->total_records;
|
||||
} else { #(!$start && $offset) {
|
||||
}
|
||||
else
|
||||
{ #(!$start && $limit) {
|
||||
$start = 0;
|
||||
$limit = $offset;
|
||||
$limit = $limit;
|
||||
}
|
||||
//echo '('.$start.','.$limit.')';
|
||||
|
||||
|
@ -183,7 +183,7 @@
|
||||
|
||||
$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();
|
||||
|
||||
$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())
|
||||
{
|
||||
// If its not in the list to be returned, don't return it.
|
||||
@ -256,7 +256,7 @@
|
||||
|
||||
$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();
|
||||
|
||||
$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())
|
||||
{
|
||||
// If its not in the list to be returned, don't return it.
|
||||
@ -307,8 +307,8 @@
|
||||
return $return_fields;
|
||||
}
|
||||
|
||||
// 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="")
|
||||
/* send this the range, query, sort, order and whatever fields you want to see */
|
||||
function read($start=0,$limit=0,$fields="",$query="",$filter="",$sort="",$order="")
|
||||
{
|
||||
global $phpgw,$phpgw_info;
|
||||
|
||||
@ -318,24 +318,17 @@
|
||||
list($stock_fields,$stock_fieldnames,$extra_fields) = $this->split_stock_and_extras($fields);
|
||||
if (count($stock_fieldnames))
|
||||
{
|
||||
$t_fields = "," . implode(",",$stock_fieldnames);
|
||||
if ($t_fields == ",")
|
||||
$t_fields = ',' . implode(',',$stock_fieldnames);
|
||||
if ($t_fields == ',')
|
||||
{
|
||||
unset($t_fields);
|
||||
}
|
||||
}
|
||||
|
||||
// turn filter's a=b,c=d OR a=b into an array
|
||||
if ($filter) {
|
||||
$extra_stock = array(
|
||||
'id' => 'id',
|
||||
'tid' => 'tid',
|
||||
'lid' => 'lid',
|
||||
'owner' => 'owner',
|
||||
'access' => 'access',
|
||||
'cat_id' => 'cat_id'
|
||||
);
|
||||
$check_stock = $this->stock_contact_fields + $extra_stock;
|
||||
/* turn filter's a=b,c=d OR a=b into an array */
|
||||
if ($filter)
|
||||
{
|
||||
$check_stock = $this->stock_contact_fields + $this->non_contact_fields;
|
||||
|
||||
if ($DEBUG) { echo "DEBUG - Inbound filter is: #".$filter."#"; }
|
||||
$filterarray = split(',',$filter);
|
||||
@ -344,7 +337,7 @@
|
||||
$i=0;
|
||||
for ($i=0;$i<count($filterarray);$i++)
|
||||
{
|
||||
list($name,$value) = split("=",$filterarray[$i]);
|
||||
list($name,$value) = split('=',$filterarray[$i]);
|
||||
if ($name)
|
||||
{
|
||||
if ($DEBUG) { echo "<br>DEBUG - Filter intermediate strings 1: #".$name."# => #".$value."#"; }
|
||||
@ -357,28 +350,27 @@
|
||||
list($name,$value) = split('=',$filter);
|
||||
if ($DEBUG)
|
||||
{
|
||||
echo "<br>DEBUG - Filter intermediate strings 1: #".$name."# => #".$value."#";
|
||||
echo '<br>DEBUG - Filter intermediate strings 1: #'.$name.'# => #'.$value.'#';
|
||||
}
|
||||
$filterfields = array($name => $value);
|
||||
}
|
||||
|
||||
// now check each element of the array and convert into SQL for queries
|
||||
// below
|
||||
/* now check each element of the array and convert into SQL for queries below */
|
||||
$i=0;
|
||||
reset($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;
|
||||
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))
|
||||
{
|
||||
if ($fvalue==$name)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
}
|
||||
@ -392,7 +384,6 @@
|
||||
{
|
||||
if ($name == 'cat_id')
|
||||
{
|
||||
// This is the alternative to CONCAT, since it is mysql-only
|
||||
$filterlist .= "(" . $name . " LIKE '%," . $value . ",%' OR " . $name."='".$value."');";
|
||||
}
|
||||
elseif (gettype($value) == "integer")
|
||||
@ -412,11 +403,6 @@
|
||||
$filterlist = substr($filterlist,0,-1);
|
||||
$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)
|
||||
{
|
||||
echo "<br>DEBUG - Filter output string: #".$filterlist."#";
|
||||
@ -495,65 +481,50 @@
|
||||
|
||||
$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)
|
||||
{
|
||||
$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 "
|
||||
. "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,__LINE__,__FILE__);
|
||||
$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__);
|
||||
. "org_name LIKE '%$query%' OR org_unit LIKE '%$query%') " . $fand . $filtermethod . $ordermethod;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db3->query("SELECT id,lid,tid,owner,access,cat_id $t_fields FROM $this->std_table " . $fwhere
|
||||
. $filtermethod,__LINE__,__FILE__);
|
||||
$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__);
|
||||
$sql = "SELECT id,lid,tid,owner,access,cat_id $t_fields FROM $this->std_table " . $fwhere
|
||||
. $filtermethod . " " . $ordermethod;
|
||||
}
|
||||
|
||||
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;
|
||||
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]['lid'] = $this->db->f('lid');
|
||||
$return_fields[$i]['tid'] = $this->db->f('tid');
|
||||
$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');
|
||||
|
||||
if (gettype($stock_fieldnames) == 'array')
|
||||
@ -565,11 +536,9 @@
|
||||
reset($stock_fieldnames);
|
||||
}
|
||||
$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())
|
||||
{
|
||||
// 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')])
|
||||
{
|
||||
$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);
|
||||
|
||||
//$this->db->lock(array("contacts"));
|
||||
if ($fields['lid'])
|
||||
{
|
||||
$lid[0] = '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)
|
||||
. ") values ('$owner','$access','$cat_id','$tid','".$lid[1]
|
||||
. ") VALUES ('$owner','$access','$cat_id','$tid','".$lid[1]
|
||||
. implode("','",$this->loop_addslashes($stock_fields)) . "')",__LINE__,__FILE__);
|
||||
|
||||
$this->db->query("select max(id) from $this->std_table ",__LINE__,__FILE__);
|
||||
$this->db->query("SELECT max(id) FROM $this->std_table ",__LINE__,__FILE__);
|
||||
$this->db->next_record();
|
||||
$id = $this->db->f(0);
|
||||
//$this->db->unlock();
|
||||
|
||||
if (count($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__);
|
||||
}
|
||||
}
|
||||
@ -611,7 +579,7 @@
|
||||
|
||||
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__);
|
||||
$this->db->next_record();
|
||||
return $this->db->f(0);
|
||||
@ -619,20 +587,20 @@
|
||||
|
||||
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__);
|
||||
}
|
||||
|
||||
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__);
|
||||
}
|
||||
|
||||
function update($id,$owner,$fields,$access='',$cat_id='',$tid='n')
|
||||
{
|
||||
// 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();
|
||||
if (!$this->db->f(0))
|
||||
{
|
||||
@ -651,7 +619,7 @@
|
||||
{
|
||||
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__);
|
||||
}
|
||||
|
||||
@ -665,9 +633,9 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->query("update $this->ext_table set contact_value='" . addslashes($x_value)
|
||||
. "',contact_owner='$owner' where contact_name='" . addslashes($x_name)
|
||||
. "' and contact_id='$id'",__LINE__,__FILE__);
|
||||
$this->db->query("UPDATE $this->ext_table SET contact_value='" . addslashes($x_value)
|
||||
. "',contact_owner='$owner' WHERE contact_name='" . addslashes($x_name)
|
||||
. "' AND contact_id='$id'",__LINE__,__FILE__);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -685,8 +653,8 @@
|
||||
return False;
|
||||
}
|
||||
|
||||
$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->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__);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -694,8 +662,8 @@
|
||||
// This is where the real work of delete() is done, shared class file contains calling function
|
||||
function delete_($id)
|
||||
{
|
||||
$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->std_table WHERE 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
|
||||
|
@ -113,8 +113,9 @@
|
||||
$phpgw->preferences->save_repository(1);
|
||||
}
|
||||
|
||||
// Return a select form element with the categories option dialog in it
|
||||
function cat_option($cat_id='',$notall=False,$java=True,$multiple=False) {
|
||||
/* Return a select form element with the categories option dialog in it */
|
||||
function cat_option($cat_id='',$notall=False,$java=True,$multiple=False)
|
||||
{
|
||||
global $phpgw_info;
|
||||
if ($java)
|
||||
{
|
||||
@ -132,38 +133,39 @@
|
||||
$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_link .= $cats->formated_list('select','all',$cat_id,True);
|
||||
$cats_link .= '</select>'."\n";
|
||||
return $cats_link;
|
||||
}
|
||||
|
||||
### SET THE FONT TO DEFAULT IF IT DOESNT EXISTS ###
|
||||
/* SET THE FONT TO DEFAULT IF IT DOESNT EXISTS */
|
||||
function set_font()
|
||||
{
|
||||
if($phpgw_info["user"]["preferences"]["notes"]["notes_font"] == "")
|
||||
if($phpgw_info['user']['preferences']['notes']['notes_font'] == '')
|
||||
{
|
||||
$font = "Arial";
|
||||
return $font;
|
||||
}
|
||||
else
|
||||
{
|
||||
$font = $phpgw_info["user"]["preferences"]["notes"]["notes_font"];
|
||||
$font = $phpgw_info['user']['preferences']['notes']['notes_font'];
|
||||
return $font;
|
||||
}
|
||||
}
|
||||
|
||||
### SET FONT SIZE ####
|
||||
/* 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";
|
||||
return $font_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
$font_size = $phpgw_info["user"]["preferences"]["notes"]["notes_font_size"];
|
||||
$font_size = $phpgw_info['user']['preferences']['notes']['notes_font_size'];
|
||||
return $font_size;
|
||||
}
|
||||
}
|
||||
@ -234,7 +236,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
function addressbook_strip_html($dirty = "")
|
||||
function addressbook_strip_html($dirty = '')
|
||||
{
|
||||
global $phpgw;
|
||||
if ($dirty == ""){$dirty = array();}
|
||||
@ -247,81 +249,81 @@
|
||||
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;
|
||||
$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);
|
||||
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)
|
||||
{
|
||||
$entry = $this->read_single_entry($id,$fields);
|
||||
$entry = $contacts->read_single_entry($id,$fields);
|
||||
$cleaned = addressbook_strip_html($entry);
|
||||
return $cleaned;
|
||||
}
|
||||
else
|
||||
{
|
||||
$rtrn = array("No access" => "No access");
|
||||
$rtrn = array('No access' => 'No access');
|
||||
return $rtrn;
|
||||
}
|
||||
}
|
||||
|
||||
function addressbook_read_last_entry($fields)
|
||||
{
|
||||
global $this,$rights;
|
||||
global $contacts,$rights;
|
||||
if ($rights & PHPGW_ACL_READ)
|
||||
{
|
||||
$entry = $this->read_last_entry($fields);
|
||||
$entry = $contacts->read_last_entry($fields);
|
||||
$cleaned = addressbook_strip_html($entry);
|
||||
return $cleaned;
|
||||
}
|
||||
else
|
||||
{
|
||||
$rtrn = array("No access" => "No access");
|
||||
$rtrn = array('No access' => 'No access');
|
||||
return $rtrn;
|
||||
}
|
||||
}
|
||||
|
||||
function addressbook_add_entry($userid,$fields,$access='',$cat_id='',$tid='n')
|
||||
{
|
||||
global $this,$rights;
|
||||
global $contacts,$rights;
|
||||
if ($rights & PHPGW_ACL_ADD)
|
||||
{
|
||||
$this->add($userid,$fields,$access,$cat_id,$tid);
|
||||
$contacts->add($userid,$fields,$access,$cat_id,$tid);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function addressbook_get_lastid()
|
||||
{
|
||||
global $this;
|
||||
$entry = $this->read_last_entry();
|
||||
$ab_id = $entry[0]["id"];
|
||||
global $contacts;
|
||||
$entry = $contacts->read_last_entry();
|
||||
$ab_id = $entry[0]['id'];
|
||||
return $ab_id;
|
||||
}
|
||||
|
||||
function addressbook_update_entry($id,$userid,$fields,$access,$cat_id)
|
||||
{
|
||||
global $this,$rights;
|
||||
global $contacts,$rights;
|
||||
if ($rights & PHPGW_ACL_EDIT)
|
||||
{
|
||||
$this->update($id,$userid,$fields,$access,$cat_id);
|
||||
$contacts->update($id,$userid,$fields,$access,$cat_id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
$t = new Template(PHPGW_APP_TPL);
|
||||
$t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
|
||||
$t->set_file(array('form' => 'form.tpl'));
|
||||
//$t->set_block('form','add','add');
|
||||
//$t->set_block('form','edit','edit');
|
||||
@ -422,14 +424,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
$this = CreateObject("phpgwapi.contacts");
|
||||
$c = CreateObject("phpgwapi.contacts");
|
||||
|
||||
if ($format != "view")
|
||||
{
|
||||
// Preferred phone number radio buttons
|
||||
$pref[0] = "<font size=\"-2\">";
|
||||
$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.'"';
|
||||
if ($name == $preferred)
|
||||
@ -504,7 +506,7 @@
|
||||
$time_zone .= "</select>\n";
|
||||
|
||||
$email_type = '<select name=email_type>';
|
||||
while ($type = each($this->email_types))
|
||||
while ($type = each($c->email_types))
|
||||
{
|
||||
$email_type .= '<option value="'.$type[0].'"';
|
||||
if ($type[0] == $emailtype) { $email_type .= ' selected'; }
|
||||
@ -512,9 +514,9 @@
|
||||
}
|
||||
$email_type .= "</select>";
|
||||
|
||||
reset($this->email_types);
|
||||
reset($c->email_types);
|
||||
$hemail_type = '<select name=hemail_type>';
|
||||
while ($type = each($this->email_types))
|
||||
while ($type = each($c->email_types))
|
||||
{
|
||||
$hemail_type .= '<option value="'.$type[0].'"';
|
||||
if ($type[0] == $hemailtype) { $hemail_type .= ' selected'; }
|
||||
@ -522,8 +524,8 @@
|
||||
}
|
||||
$hemail_type .= "</select>";
|
||||
|
||||
reset($this->adr_types);
|
||||
while (list($type,$val) = each($this->adr_types))
|
||||
reset($c->adr_types);
|
||||
while (list($type,$val) = each($c->adr_types))
|
||||
{
|
||||
$badrtype .= "\n".'<INPUT type="checkbox" name="one_'.$type.'"';
|
||||
$ot = 'one_'.$type;
|
||||
@ -535,8 +537,8 @@
|
||||
$badrtype .= '>'.$val;
|
||||
}
|
||||
|
||||
reset($this->adr_types);
|
||||
while (list($type,$val) = each($this->adr_types))
|
||||
reset($c->adr_types);
|
||||
while (list($type,$val) = each($c->adr_types))
|
||||
{
|
||||
$hadrtype .= "\n".'<INPUT type="checkbox" name="two_'.$type.'"';
|
||||
$tt = 'two_'.$type;
|
||||
@ -718,12 +720,12 @@
|
||||
$t->pfp('out','form');
|
||||
} //end form function
|
||||
|
||||
function parsevcard($filename,$access='')
|
||||
function OLDparsevcard($filename,$access='')
|
||||
{
|
||||
global $phpgw;
|
||||
global $phpgw_info;
|
||||
|
||||
$vcard = fopen($filename, "r");
|
||||
$vcard = fopen($filename, 'r');
|
||||
// Make sure we have a file to read.
|
||||
if (!$vcard) {
|
||||
fclose($vcard);
|
||||
@ -1081,8 +1083,8 @@
|
||||
echo '<br>company: '.$fields["org_name"];
|
||||
exit;
|
||||
*/
|
||||
$this = CreateObject("phpgwapi.contacts");
|
||||
$this->add($phpgw_info["user"]["account_id"],$fields);
|
||||
$c = CreateObject("phpgwapi.contacts");
|
||||
$c->add($phpgw_info["user"]["account_id"],$fields);
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -1,8 +1,9 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare - addressbook *
|
||||
* phpGroupWare - Addressbook *
|
||||
* 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 *
|
||||
@ -27,9 +28,8 @@
|
||||
$t->set_block('addressbook_list_t','row','row');
|
||||
$t->set_block('addressbook_list_t','addressbook_footer','addressbook_footer');
|
||||
|
||||
$this = CreateObject('phpgwapi.contacts');
|
||||
//$this->delete_all($phpgw_info['user']['account_id']);
|
||||
//exit;
|
||||
$contacts = CreateObject('phpgwapi.contacts');
|
||||
|
||||
$customfields = array();
|
||||
while (list($col,$descr) = @each($phpgw_info['user']['preferences']['addressbook']))
|
||||
{
|
||||
@ -57,24 +57,24 @@
|
||||
'address2' => 'address2',
|
||||
'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
|
||||
while ($column = each($this->stock_contact_fields))
|
||||
/* create column list and the top row of the table based on user prefs */
|
||||
while ($column = each($contacts->stock_contact_fields))
|
||||
{
|
||||
$test = strtolower($column[0]);
|
||||
if (isset($phpgw_info['user']['preferences']['addressbook'][$test]) &&
|
||||
$phpgw_info['user']['preferences']['addressbook'][$test])
|
||||
{
|
||||
$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 .= $phpgw->nextmatchs->show_sort_order($sort,
|
||||
$column[0],$order,"/addressbook/index.php",$showcol,"&cat_id=".$cat_id);
|
||||
$cols .= "</font>\n </td>";
|
||||
$cols .= "\n";
|
||||
|
||||
// To be used when displaying the rows
|
||||
/* To be used when displaying the rows */
|
||||
$columns_to_display[$column[0]] = True;
|
||||
}
|
||||
}
|
||||
@ -87,15 +87,15 @@
|
||||
$phpgw_info['user']['preferences']['addressbook'][$test])
|
||||
{
|
||||
$showcol = display_name($column[0]);
|
||||
// This must be a custom field
|
||||
/* This must be a custom field */
|
||||
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 .= $showcol;
|
||||
$cols .= "</font>\n </td>";
|
||||
$cols .= "\n";
|
||||
|
||||
// To be used when displaying the rows
|
||||
/* To be used when displaying the rows */
|
||||
$columns_to_display[$column[0]] = True;
|
||||
}
|
||||
}
|
||||
@ -108,11 +108,11 @@
|
||||
if($phpgw_info['user']['preferences']['common']['maxmatchs'] &&
|
||||
$phpgw_info['user']['preferences']['common']['maxmatchs'] > 0)
|
||||
{
|
||||
$offset = $phpgw_info['user']['preferences']['common']['maxmatchs'];
|
||||
$limit = $phpgw_info['user']['preferences']['common']['maxmatchs'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$offset = 30;
|
||||
$limit = 30;
|
||||
}
|
||||
|
||||
if (!$filter)
|
||||
@ -140,7 +140,7 @@
|
||||
case 'none':
|
||||
break;
|
||||
case 'private':
|
||||
$qfilter .= ',access=private'; // fall through
|
||||
$qfilter .= ',access=private'; /* fall through */
|
||||
case 'yours':
|
||||
$qfilter .= ',owner='.$phpgw_info['user']['account_id'];
|
||||
break;
|
||||
@ -152,7 +152,7 @@
|
||||
$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 )
|
||||
{
|
||||
$columns_to_display = array(
|
||||
@ -161,13 +161,13 @@
|
||||
'org_name' => 'org_name'
|
||||
);
|
||||
$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="";
|
||||
while ($column = each($columns_to_display))
|
||||
{
|
||||
$showcol = display_name($column[0]);
|
||||
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 .= $phpgw->nextmatchs->show_sort_order($sort,
|
||||
$column[0],$order,"/addressbook/index.php",$showcol,"&cat_id=$cat_id");
|
||||
@ -183,36 +183,21 @@
|
||||
if ($nosearch && !$query)
|
||||
{
|
||||
$entries = array();
|
||||
$this->total_records = 0;
|
||||
$contacts->total_records = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 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',
|
||||
$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);
|
||||
|
||||
if ($this->total_records > $phpgw_info['user']['preferences']['common']['maxmatchs'])
|
||||
{
|
||||
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);
|
||||
}
|
||||
$lang_showing = $phpgw->nextmatchs->show_hits($contacts->total_records,$start);
|
||||
|
||||
// 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('lang_view',lang('View'));
|
||||
$t->set_var('lang_vcard',lang('VCard'));
|
||||
@ -254,8 +239,9 @@
|
||||
|
||||
$t->pparse('out','addressbook_header');
|
||||
|
||||
// Show the entries
|
||||
for ($i=0;$i<count($entries);$i++) // each entry
|
||||
/* Show the entries */
|
||||
/* each entry */
|
||||
for ($i=0;$i<count($entries);$i++)
|
||||
{
|
||||
$t->set_var('columns','');
|
||||
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
|
||||
@ -263,11 +249,12 @@
|
||||
$myid = $entries[$i]['id'];
|
||||
$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]];
|
||||
// Some fields require special formatting.
|
||||
/* Some fields require special formatting. */
|
||||
if ($column[0] == 'url')
|
||||
{
|
||||
if ( !empty($coldata) && (substr($coldata,0,7) != 'http://') ) { $coldata = 'http://' . $coldata; }
|
||||
@ -284,11 +271,11 @@
|
||||
{
|
||||
$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->parse('columns','column',True);
|
||||
@ -309,8 +296,8 @@
|
||||
$t->set_var('row_vcard_link',$phpgw->link('/addressbook/vcardout.php',
|
||||
"ab_id=$myid&start=$start&sort=$sort&order=$order&filter="
|
||||
. "$filter&query=$query&sort=$sort&cat_id=$cat_id"));
|
||||
// echo '<br>: ' . $this->grants[$myowner] . ' - ' . $myowner;
|
||||
if ($this->check_perms($this->grants[$myowner],PHPGW_ACL_EDIT) || $myowner == $phpgw_info['user']['account_id'])
|
||||
/* echo '<br>: ' . $contacts->grants[$myowner] . ' - ' . $myowner; */
|
||||
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",
|
||||
"ab_id=$myid&start=$start&sort=$sort&order=$order&filter="
|
||||
@ -325,7 +312,7 @@
|
||||
|
||||
$t->parse('rows','row',True);
|
||||
$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');
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
include('../header.inc.php');
|
||||
|
||||
$this = CreateObject('phpgwapi.contacts');
|
||||
$contacts = CreateObject('phpgwapi.contacts');
|
||||
|
||||
$extrafields = array(
|
||||
'ophone' => 'ophone',
|
||||
@ -45,7 +45,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
$qfields = $this->stock_contact_fields + $extrafields + $customfields;
|
||||
$qfields = $contacts->stock_contact_fields + $extrafields + $customfields;
|
||||
|
||||
if ($submit)
|
||||
{
|
||||
|
@ -31,6 +31,6 @@
|
||||
/* Dependencies for this app to work */
|
||||
$setup_info['addressbook']['depends'][] = array(
|
||||
'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><input name="newsettings[contact_application]" value="{value_contact_application}"></td>
|
||||
</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}">
|
||||
<td>{lang_Select_where_you_want_to_store}/{lang_retrieve_contacts}.</td>
|
||||
<td>
|
||||
|
@ -42,11 +42,11 @@
|
||||
$phpgw->common->phpgw_exit();
|
||||
}
|
||||
|
||||
$this = CreateObject('phpgwapi.contacts');
|
||||
$contacts = CreateObject('phpgwapi.contacts');
|
||||
|
||||
// First, make sure they have permission to this entry
|
||||
$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']) )
|
||||
{
|
||||
@ -56,7 +56,7 @@
|
||||
}
|
||||
|
||||
$extrafields = array('address2' => 'address2');
|
||||
$qfields = $this->stock_contact_fields + $extrafields;
|
||||
$qfields = $contacts->stock_contact_fields + $extrafields;
|
||||
|
||||
$fieldlist = addressbook_read_entry($ab_id,$qfields);
|
||||
$fields = $fieldlist[0];
|
||||
|
@ -22,11 +22,11 @@
|
||||
|
||||
include('../header.inc.php');
|
||||
|
||||
$this = CreateObject("phpgwapi.contacts");
|
||||
$contacts = CreateObject("phpgwapi.contacts");
|
||||
|
||||
// First, make sure they have permission to this entry
|
||||
$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']) )
|
||||
{
|
||||
@ -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]]) &&
|
||||
$phpgw_info['user']['preferences']['addressbook'][$column[0]])
|
||||
@ -98,7 +98,7 @@
|
||||
'address2' => 'address2',
|
||||
'address3' => 'address3'
|
||||
);
|
||||
$qfields = $this->stock_contact_fields + $extrafields + $customfields;
|
||||
$qfields = $contacts->stock_contact_fields + $extrafields + $customfields;
|
||||
|
||||
$fields = addressbook_read_entry($ab_id,$qfields);
|
||||
|
||||
@ -137,7 +137,7 @@
|
||||
$t->set_var('th_bg',$tr_color);
|
||||
$coldata = $fields[0][$column];
|
||||
// Some fields require special formatting.
|
||||
if ( ($column == "note" || $column == "label" || $column == "pubkey") && $coldata )
|
||||
if ( ($column == 'note' || $column == 'pubkey') && $coldata )
|
||||
{
|
||||
$datarray = explode ("\n",$coldata);
|
||||
if ($datarray[1])
|
||||
@ -160,6 +160,10 @@
|
||||
$data = $coldata;
|
||||
}
|
||||
}
|
||||
elseif($column == 'label' && $coldata)
|
||||
{
|
||||
$data .= $contacts->formatted_address($fields[0]['id'],'',False);
|
||||
}
|
||||
elseif ($column == "url" && $coldata)
|
||||
{
|
||||
$ref = '<a href="' . $coldata . '" target="_new">';
|
||||
@ -203,11 +207,11 @@
|
||||
$cats = explode(',',$fields[0]['cat_id']);
|
||||
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'] . '; ';
|
||||
}
|
||||
}
|
||||
@ -285,7 +289,7 @@
|
||||
|
||||
$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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user