use foreach where possible vs. reset/while; Move extra loop in read() and read_single_entry() into the existing loop in sql/ldap classes.

This commit is contained in:
Miles Lott 2004-01-24 15:57:57 +00:00
parent 50581de1e1
commit f07775857e
3 changed files with 94 additions and 251 deletions

View File

@ -83,55 +83,6 @@
return $ret;
}
/*!
@function read_single_entry
@abstract reads one entry, reimplemented here to add the users rights / grants of the owner
@syntax read_single_entry($id,$fields='')
@param $id integer id of the contact
@param $fields array fields to read or False for all
*/
function read_single_entry($id,$fields='')
{
if(@is_array($fields))
{
$fields['owner'] = 'owner'; // we need the owner to set the rights
}
if ($entry = contacts_::read_single_entry($id,$fields))
{
$entry[0]['rights'] = (int)$this->grants[$entry[0]['owner']];
}
return $entry;
}
/*!
@function read_single_entry
@abstract reads/searches for entrys, reimplemented here to add the users rights / grants of the owner
@syntax read($start=0,$limit=0,$fields='',$query='',$filter='',$sort='',$order='', $lastmod=-1)
@param $start integer first entry to read
@param $limit integer number of entrys to read, 0 for all
@param $fields array fields to read or False for all
@param $query string free query pattern
@param $filter string eg. tid=n or access=public
@param $sort string after which column/field to sort
@param $order string sort-order DESC=descending, ASC=ascending
@param $lastmod integer get only fields modified since, -1=for all
*/
function read($start=0,$limit=0,$fields='',$query='',$filter='',$sort='',$order='', $lastmod=-1,$cquery='')
{
if(@is_array($fields))
{
$fields['owner'] = 'owner'; // we need the owner to set the rights
}
if($entries = contacts_::read($start,$limit,$fields,$query,$filter,$sort,$order,$lastmod,$cquery))
{
foreach($entries as $nr => $entry)
{
$entries[$nr]['rights'] = (int)$this->grants[$entry['owner']];
}
}
return $entries;
}
function split_stock_and_extras($fields)
{
settype($fields, 'array');
@ -292,99 +243,6 @@
return ($sortarray);
}
/* This function is deprecated, fortunately. */
function filter_ldap($ldap_fields,$filterfields,$DEBUG=0)
{
$match = 0;
if($DEBUG) { echo '<br>'; }
for($i=0;$i<count($ldap_fields);$i++)
{
$yes = True;
if ($ldap_fields[$i]['uidnumber'][0])
{
reset($filterfields);
while (list($col,$filt) = each($filterfields))
{
if ($col == 'phpgwcontactcatid')
{
$colarray = explode(',',$ldap_fields[$i][$col][0]);
if ($colarray[1])
{
while(list($key,$val) = each ($colarray))
{
if($DEBUG) { echo '&nbsp;&nbsp;Testing "'.$col.'" for "'.$val.'"'; }
if ($val == $filt)
{
if($DEBUG) { echo ', and number '.$ldap_fields[$i]['uidnumber'][0].' matched.'.'&nbsp;&nbsp;'; }
$yes &= True;
$match++;
break;
}
}
}
else
{
if($DEBUG) { echo '&nbsp;&nbsp;Testing "'.$col.'" for "'.$filt.'"'; }
if ($ldap_fields[$i][$col][0] == $filt)
{
if($DEBUG) { echo ', and number '.$ldap_fields[$i]['uidnumber'][0].' matched.'.'&nbsp;&nbsp;'; }
$yes &= True;
$match++;
}
else
{
if($DEBUG) { echo ', but number '.$ldap_fields[$i]['uidnumber'][0].' did not match.'.'&nbsp;&nbsp;'; }
$yes &= False;
$match--;
}
}
}
else
{
if($DEBUG) { echo '&nbsp;&nbsp;Testing "'.$col.'" for "'.$filt.'"'; }
if ($ldap_fields[$i][$col][0] == $filt)
{
if($DEBUG) { echo ', and number '.$ldap_fields[$i]['uidnumber'][0].' matched.'.'&nbsp;&nbsp;'; }
$yes &= True;
$match++;
}
else
{
if($DEBUG) { echo ', but number '.$ldap_fields[$i]['uidnumber'][0].' did not match.'.'&nbsp;&nbsp;'; }
$yes &= False;
$match--;
}
}
}
if ($yes)
{
if($DEBUG) { echo $ldap_fields[$i]['uidnumber'][0].' matched all!'.'<br>'; }
$new_ldap[] = $ldap_fields[$i];
}
else
{
if($DEBUG) { echo $ldap_fields[$i]['uidnumber'][0].' did not match all.'.'<br>'; }
}
}
}
if($DEBUG)
{
if($match)
{
echo '<br>'.$match.' total matches.'."\n";
}
else
{
echo '<br>No matches :('."\n";
}
}
$this->total_records = count($new_ldap);
return $new_ldap;
}
function formatted_address($id, $business = True, $afont = '', $asize = '2')
{
$t = CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir('addressbook'));
@ -489,8 +347,7 @@
$t = CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir('addressbook'));
$s = CreateObject('phpgwapi.sbox');
$fields = array
(
$fields = array(
'n_given' => 'n_given',
'n_family' => 'n_family',
'title' => 'title',
@ -520,14 +377,14 @@
$address[$k] = $GLOBALS['phpgw']->strip_html($val);
}
if ($address['title'])
if($address['title'])
{
$title = $address['title'] . '&nbsp;';
}
if ($business)
if($business)
{
if ($address['org_name'])
if($address['org_name'])
{
$company = $address['org_name'];
}
@ -556,12 +413,12 @@
$email = $address['email_home'];
}
if (! $country)
if(!$country)
{
$country = $GLOBALS['phpgw_info']['user']['preferences']['common']['country'];
}
if (file_exists(PHPGW_SERVER_ROOT . SEP . 'addressbook' . SEP . 'templates' . SEP .'default' . SEP . 'full_format_' . strtolower($country) . '.tpl'))
if(file_exists(PHPGW_SERVER_ROOT . SEP . 'addressbook' . SEP . 'templates' . SEP .'default' . SEP . 'full_format_' . strtolower($country) . '.tpl'))
{
$a = $t->set_file(array('address_format' => 'full_format_' . strtolower($country) . '.tpl'));
}
@ -570,7 +427,7 @@
$a = $t->set_file(array('address_format' => 'full_format_us.tpl'));
}
if (!$afont)
if(!$afont)
{
$afont = $GLOBALS['phpgw_info']['theme']['font'];
}
@ -592,7 +449,7 @@
$a .= $t->set_var('fax',$address['tel_fax']);
$a .= $t->set_var('url',$address['url']);
if ($country != $GLOBALS['phpgw_info']['user']['preferences']['common']['country'])
if($country != $GLOBALS['phpgw_info']['user']['preferences']['common']['country'])
{
$countryname = $s->get_full_name($country);
$a .= $t->set_var('country',lang($countryname));
@ -607,8 +464,7 @@
$t = CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir('addressbook'));
$s = CreateObject('phpgwapi.sbox');
$fields = array
(
$fields = array(
'n_given' => 'n_given',
'n_family' => 'n_family',
'title' => 'title',
@ -631,14 +487,14 @@
$address[$k] = $GLOBALS['phpgw']->strip_html($val);
}
if ($address['title'])
if($address['title'])
{
$title = $address['title'] . '&nbsp;';
}
if ($business)
if($business)
{
if ($address['org_name'])
if($address['org_name'])
{
$company = $address['org_name'];
}
@ -663,12 +519,12 @@
$country = $address['adr_two_countryname'];
}
if (! $country)
if(!$country)
{
$country = $GLOBALS['phpgw_info']['user']['preferences']['common']['country'];
}
if (file_exists(PHPGW_SERVER_ROOT . SEP . 'addressbook' . SEP . 'templates' . SEP .'default' . SEP . 'line_format_' . strtolower($country) . '.tpl'))
if(file_exists(PHPGW_SERVER_ROOT . SEP . 'addressbook' . SEP . 'templates' . SEP .'default' . SEP . 'line_format_' . strtolower($country) . '.tpl'))
{
$a = $t->set_file(array('address_format' => 'line_format_' . strtolower($country) . '.tpl'));
}
@ -677,7 +533,7 @@
$a = $t->set_file(array('address_format' => 'line_format_us.tpl'));
}
if (!$afont)
if(!$afont)
{
$afont = $GLOBALS['phpgw_info']['theme']['font'];
}
@ -690,7 +546,7 @@
$a .= $t->set_var('zip',$zip);
$a .= $t->set_var('state',$state);
if ($country != $GLOBALS['phpgw_info']['user']['preferences']['common']['country'])
if($country != $GLOBALS['phpgw_info']['user']['preferences']['common']['country'])
{
$countryname = $s->get_full_name($country);
$a .= $t->set_var('country','&nbsp;°&nbsp;' . lang($countryname));

View File

@ -168,16 +168,18 @@
}
/* send this the id and whatever fields you want to see */
function read_single_entry($id,$fields = '')
function read_single_entry($id,$fields='')
{
if (!$fields || empty($fields)) { $fields = $this->stock_contact_fields; }
list($stock_fields,$stock_fieldnames,$extra_fields) =
$this->split_stock_and_extras($fields);
if (count($stock_fieldnames))
if(!$fields || empty($fields))
{
$t_fields = "," . implode(",",$stock_fieldnames);
if ($t_fields == ",")
$fields = $this->stock_contact_fields;
}
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 == ',')
{
unset($t_fields);
}
@ -192,9 +194,10 @@
$return_fields[0]['owner'] = $ldap_fields[0]['phpgwcontactowner'][0];
$return_fields[0]['access'] = $ldap_fields[0]['phpgwcontactaccess'][0];
$return_fields[0]['cat_id'] = $ldap_fields[0]['phpgwcontactcatid'][0];
$return_fields[0]['rights'] = (int)$this->grants[$return_fields[0]['owner']];
if(@is_array($stock_fieldnames))
{
while(list($name,$value)=each($stock_fieldnames))
foreach($stock_fieldnames as $name => $value)
{
$return_fields[0][$name] = utf8_decode($ldap_fields[0][$value][0]);
}
@ -204,26 +207,24 @@
if ($return_fields[0]['adr_one_type'])
{
$one_type = $return_fields[0]['adr_one_type'];
reset($this->adr_types);
while (list($name,$val) = each($this->adr_types))
foreach($this->adr_types as $name => $val)
{
eval("if (strstr(\$one_type,\$name)) { \$return_fields[0][\"one_\$name\"] = \"on\"; }");
}
}
if ($return_fields[0]["adr_two_type"])
if($return_fields[0]['adr_two_type'])
{
$two_type = $return_fields[0]['adr_two_type'];
reset($this->adr_types);
while (list($name,$val) = each($this->adr_types))
foreach($this->adr_types as $name => $val)
{
eval("if (strstr(\$two_type,\$name)) { \$return_fields[0][\"two_\$name\"] = \"on\"; }");
}
}
$this->db->query("SELECT contact_name,contact_value FROM $this->ext_table WHERE contact_id='" . $id . "'",__LINE__,__FILE__);
while ($this->db->next_record())
while($this->db->next_record())
{
if ($extra_fields[$this->db->f('contact_name')])
if($extra_fields[$this->db->f('contact_name')])
{
$return_fields[0][$this->db->f('contact_name')] = $this->db->f('contact_value');
}
@ -233,9 +234,11 @@
function read_last_entry($fields = '')
{
if (!$fields || empty($fields)) { $fields = $this->stock_contact_fields; }
list($stock_fields,$stock_fieldnames,$extra_fields) =
$this->split_stock_and_extras($fields);
if (!$fields || empty($fields))
{
$fields = $this->stock_contact_fields;
}
list($stock_fields,$stock_fieldnames,$extra_fields) = $this->split_stock_and_extras($fields);
if (count($stock_fieldnames))
{
@ -258,39 +261,38 @@
$return_fields[0]['owner'] = $ldap_fields[0]['phpgwcontactowner'][0];
$return_fields[0]['access'] = $ldap_fields[0]['phpgwcontactaccess'][0];
$return_fields[0]['cat_id'] = $ldap_fields[0]['phpgwcontactcatid'][0];
$return_fields[0]['rights'] = (int)$this->grants[$return_fields[0]['owner']];
if(@is_array($stock_fieldnames))
{
while(list($name,$value)=each($stock_fieldnames))
foreach($stock_fieldnames as $name => $value)
{
$return_fields[0][$name] = utf8_decode($ldap_fields[0][$value][0]);
}
}
/* Setup address type fields */
if ($return_fields[0]['adr_one_type'])
if($return_fields[0]['adr_one_type'])
{
$one_type = $return_fields[0]['adr_one_type'];
reset($this->adr_types);
while (list($name,$val) = each($this->adr_types))
foreach($this->adr_types as $name => $val)
{
eval("if (strstr(\$one_type,\$name)) { \$return_fields[0][\"one_\$name\"] = \"on\"; }");
}
}
if ($return_fields[0]['adr_two_type'])
if($return_fields[0]['adr_two_type'])
{
$two_type = $return_fields[0]['adr_two_type'];
reset($this->adr_types);
while (list($name,$val) = each($this->adr_types))
foreach($this->adr_types as $name => $val)
{
eval("if (strstr(\$two_type,\$name)) { \$return_fields[0][\"two_\$name\"] = \"on\"; }");
}
}
$this->db->query("SELECT contact_name,contact_value FROM $this->ext_table WHERE contact_id='" . $id . "'",__LINE__,__FILE__);
while ($this->db->next_record())
while($this->db->next_record())
{
if ($extra_fields[$this->db->f('contact_name')])
if($extra_fields[$this->db->f('contact_name')])
{
$return_fields[0][$this->db->f('contact_name')] = $this->db->f('contact_value');
}
@ -305,7 +307,10 @@
if(!$limit) { $limit = 0; }
if(!$filter) { $filter = 'tid=n'; }
if (!$fields || empty($fields)) { $fields = $this->stock_contact_fields; }
if(!$fields || empty($fields))
{
$fields = $this->stock_contact_fields;
}
$DEBUG = 0;
list($stock_fields,$stock_fieldnames,$extra_fields) = $this->split_stock_and_extras($fields);
@ -345,16 +350,14 @@
if ($DEBUG) { echo "<br>DEBUG - Filter strings: #phpgwcontacttypeid=n#"; }
}
/*
/*
need some way of using the lastmod arg in the filter like this:
if($lastmod >= 0)
{
$filterfields += array('last_mod' => (int)$lastmod;
}
or maybe not like this - i am not sure what i am doing :)
*/
*/
if(@is_array($this->grants))
{
@ -404,7 +407,7 @@
$myfilter = $this->makefilter($filterfields,$search_filter,"$cquery*",$DEBUG);
}
elseif($query)
{
{
// the old code was searching about all fields
// this was very slow
#reset($this->stock_contact_fields);
@ -482,15 +485,14 @@
$return_fields[$j]['owner'] = $ldap_fields[$i]['phpgwcontactowner'][0];
$return_fields[$j]['access'] = $ldap_fields[$i]['phpgwcontactaccess'][0];
$return_fields[$j]['cat_id'] = $ldap_fields[$i]['phpgwcontactcatid'][0];
$return_fields[$j]['rights'] = (int)$this->grants[$return_fields[$j]['owner']];
if(@is_array($stock_fieldnames))
{
reset($stock_fieldnames);
while (list($f_name,$f_value) = each($stock_fieldnames))
foreach($stock_fieldnames as $f_name => $f_value)
{
$return_fields[$j][$f_name] = utf8_decode($ldap_fields[$i][$f_value][0]);
}
reset($stock_fieldnames);
}
$this->db->query("SELECT contact_name,contact_value FROM $this->ext_table WHERE contact_id='"
. (int)$ldap_fields[$i]['uidnumber'] . "'",__LINE__,__FILE__);
@ -518,8 +520,7 @@
if(@is_array($extra))
{
if($DEBUG) { echo '<br>Searching...'; }
reset($extra);
while(list($name,$value) = each($extra))
foreach($extra as $name => $value)
{
$qarray[] = array($value => $query);
}
@ -536,11 +537,11 @@
$oquery = '(|';
$hasor = False;
while(list($name,$value) = @each($qarray))
foreach($qarray as $name => $value)
{
if(@is_array($value))
{
while(list($x,$y) = each($value))
foreach($value as $x => $y)
{
if($y == '*')
{
@ -550,7 +551,7 @@
elseif(@is_array($y))
{
/* This was most likely created from acl grants in read() above */
while(list($a,$b) = each($y))
foreach($y as $a => $b)
{
$tmp .= '(' . $a . '=' . $b . ')';
}
@ -655,7 +656,7 @@
$ldap_fields = '';
if(@is_array($stock_fieldnames))
{
while(list($name,$value)=each($stock_fieldnames))
foreach($stock_fieldnames as $name => $value)
{
if ($stock_fields[$name] != '')
{
@ -694,7 +695,7 @@
if(count($extra_fields))
{
while (list($name,$value) = each($extra_fields))
foreach($extra_fields as $name => $value)
{
$this->db->query("INSERT INTO $this->ext_table VALUES ('".$this->nextid."','" . $this->account_id . "','"
. addslashes($name) . "','" . addslashes($value) . "')",__LINE__,__FILE__);
@ -885,20 +886,20 @@
/* OK, just mod the data already */
$allfields = $stock_fieldnames + $nonfields;
while ( list($fname,$fvalue) = each($allfields) )
foreach($allfields as $fname => $fvalue)
{
/* if ($ldap_fields[0][$fvalue]) */
if ($ldap_fields[0][$fvalue] && $stock_fields[$fname] && $ldap_fields[0][$fvalue][0] != $stock_fields[$fname] )
if($ldap_fields[0][$fvalue] && $stock_fields[$fname] && $ldap_fields[0][$fvalue][0] != $stock_fields[$fname] )
{
/* echo "<br>".$fname." => ".$fvalue." was there"; */
$err = ldap_modify($this->ldap,$dn,array($fvalue => utf8_encode($stock_fields[$fname])));
}
elseif (!$ldap_fields[0][$fvalue] && $stock_fields[$fname])
elseif(!$ldap_fields[0][$fvalue] && $stock_fields[$fname])
{
/* echo "<br>".$fname." not there - '".$fvalue."'"; */
$err = ldap_mod_add($this->ldap,$dn,array($fvalue => utf8_encode($stock_fields[$fname])));
}
elseif ($ldap_fields[0][$fvalue] && !$stock_fields[$fname])
elseif($ldap_fields[0][$fvalue] && !$stock_fields[$fname])
{
/*
echo "<br>".$fname." gone... deleting - '".$fvalue."'";
@ -914,19 +915,19 @@
//something here to update the last_mod from $GLOBALS['phpgw']->datetime->gmtnow
while (list($x_name,$x_value) = each($extra_fields))
foreach($extra_fields as $x_name => $x_value)
{
if ($this->field_exists($id,$x_name))
if($this->field_exists($id,$x_name))
{
if (! $x_value)
if(!$x_value)
{
$this->delete_single_extra_field($id,$x_name);
}
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__);
. "',contact_owner='$owner' WHERE contact_name='" . addslashes($x_name)
. "' AND contact_id='$id'",__LINE__,__FILE__);
}
}
else
@ -944,7 +945,7 @@
/* Used by admin to change ownership on account delete */
function change_owner($old_owner='',$new_owner='')
{
if (!($new_owner && $old_owner))
if(!($new_owner && $old_owner))
{
return False;
}
@ -953,9 +954,9 @@
$ldap_fields = ldap_get_entries($this->ldap, $sri);
$entry = '';
while (list($null,$entry) = each($ldap_fields))
foreach($ldap_fields as $nul => $entry)
{
$err = ldap_modify($this->ldap,$dn,array('phpgwcontactowner' => $new_owner));
$err = ldap_modify($this->ldap,$entry['dn'],array('phpgwcontactowner' => $new_owner));
}
$this->db->query("UPDATE $this->ext_table SET contact_owner='$new_owner' WHERE contact_owner=$owner",__LINE__,__FILE__);
@ -965,7 +966,7 @@
/* This is where the real work of delete() is done, shared class file contains calling function */
function delete_($id)
{
if (!$GLOBALS['phpgw_info']['server']['ldap_contact_context'])
if(!$GLOBALS['phpgw_info']['server']['ldap_contact_context'])
{
return False;
}
@ -978,7 +979,7 @@
$err = ldap_delete($this->ldap,$ldap_fields[0]['dn']);
$this->db->query("DELETE FROM $this->ext_table WHERE contact_id='$id' AND contact_owner='"
. $this->account_id . "'",__LINE__,__FILE__);
. $this->account_id . "'",__LINE__,__FILE__);
}
else
{
@ -1000,7 +1001,7 @@
$ldap_fields = ldap_get_entries($this->ldap, $sri);
$entry = '';
while (list($null,$entry) = each($ldap_fields))
foreach($ldap_fields as $nul => $entry)
{
$err = ldap_delete($this->ldap,$entry['dn']);
}

View File

@ -164,9 +164,11 @@
/* send this the id and whatever fields you want to see */
function read_single_entry($id,$fields='')
{
if (!$fields || empty($fields)) { $fields = $this->stock_contact_fields; }
list($stock_fields,$stock_fieldnames,$extra_fields) =
$this->split_stock_and_extras($fields);
if (!$fields || empty($fields))
{
$fields = $this->stock_contact_fields;
}
list($stock_fields,$stock_fieldnames,$extra_fields) = $this->split_stock_and_extras($fields);
if (count($stock_fieldnames))
{
@ -186,10 +188,10 @@
$return_fields[0]['owner'] = $this->db->f('owner');
$return_fields[0]['access'] = $this->db->f('access');
$return_fields[0]['cat_id'] = $this->db->f('cat_id');
$return_fields[0]['rights'] = (int)$this->grants[$this->db->f('owner')];
if(@is_array($stock_fieldnames))
{
// while (list($f_name) = each($stock_fieldnames))
foreach($stock_fieldnames as $f_name)
{
$return_fields[0][$f_name] = $this->db->f($f_name);
@ -200,8 +202,6 @@
if ($this->db->f('adr_one_type'))
{
$one_type = $this->db->f('adr_one_type');
// reset($this->adr_types);
// while (list($name,$val) = each($this->adr_types))
foreach($this->adr_types as $name => $val)
{
eval("if (strstr(\$one_type,\$name)) { \$return_fields[0][\"one_\$name\"] = \"on\"; }");
@ -210,8 +210,6 @@
if ($this->db->f('adr_two_type'))
{
$two_type = $this->db->f('adr_two_type');
// reset($this->adr_types);
// while (list($name,$val) = each($this->adr_types))
foreach($this->adr_types as $name => $val)
{
eval("if (strstr(\$two_type,\$name)) { \$return_fields[0][\"two_\$name\"] = \"on\"; }");
@ -258,10 +256,10 @@
$return_fields[0]['owner'] = $this->db->f('owner');
$return_fields[0]['access'] = $this->db->f('access');
$return_fields[0]['cat_id'] = $this->db->f('cat_id');
$return_fields[0]['rights'] = (int)$this->grants[$this->db->f('owner')];
if (@is_array($stock_fieldnames))
{
// while (list($f_name) = each($stock_fieldnames))
foreach($stock_fieldnames as $f_name)
{
$return_fields[0][$f_name] = $this->db->f($f_name);
@ -269,21 +267,17 @@
}
/* Setup address type fields for ui forms display */
if ($this->db->f('adr_one_type'))
if($this->db->f('adr_one_type'))
{
$one_type = $this->db->f('adr_one_type');
// reset($this->adr_types);
// while (list($name,$val) = each($this->adr_types))
foreach($this->adr_types as $name => $val)
{
eval("if (strstr(\$one_type,\$name)) { \$return_fields[0][\"one_\$name\"] = \"on\"; }");
}
}
if ($this->db->f('adr_two_type'))
if($this->db->f('adr_two_type'))
{
$two_type = $this->db->f('adr_two_type');
// reset($this->adr_types);
// while (list($name,$val) = each($this->adr_types))
foreach($this->adr_types as $name => $val)
{
eval("if (strstr(\$two_type,\$name)) { \$return_fields[0][\"two_\$name\"] = \"on\"; }");
@ -353,8 +347,6 @@
/* now check each element of the array and convert into SQL for queries below */
$i = 0;
// reset($filterfields);
// while (list($name,$value) = each($filterfields))
foreach($filterfields as $name => $value)
{
if ($DEBUG) { echo '<br>DEBUG - Filter intermediate strings 2: #'.$name.'# => #'.$value.'#'; }
@ -362,7 +354,6 @@
if ($name && empty($value))
{
if ($DEBUG) { echo '<br>DEBUG - filter field "'.$name.'" is empty (NULL)'; }
// while (list($fname,$fvalue)=each($check_stock))
foreach($check_stock as $fname => $fvalue)
{
if($fvalue == $name)
@ -375,8 +366,6 @@
}
elseif($name && $value)
{
// reset($check_stock);
// while (list($fname,$fvalue)=each($check_stock))
foreach($check_stock as $fname => $fvalue)
{
if($fvalue == $name)
@ -448,8 +437,7 @@
if(@is_array($this->grants))
{
$grants = $this->grants;
// while (list($user) = each($grants))
foreach($grants as $user)
foreach($grants as $user => $_right)
{
$public_user_list[] = $user;
}
@ -578,17 +566,17 @@
$i = 0;
while($this->db->next_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');
$return_fields[$i]['cat_id'] = $this->db->f('cat_id');
$return_fields[$i]['last_mod'] = $this->db->f('last_mod');
$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');
$return_fields[$i]['cat_id'] = $this->db->f('cat_id');
$return_fields[$i]['last_mod'] = $this->db->f('last_mod');
$return_fields[$i]['rights'] = (int)$this->grants[$this->db->f('owner')];
if(@is_array($stock_fieldnames))
{
// while(list($f_name) = each($stock_fieldnames))
foreach($stock_fieldnames as $f_name)
{
$return_fields[$i][$f_name] = $this->db->f($f_name);
@ -648,7 +636,6 @@
if(count($extra_fields))
{
// while (list($name,$value) = each($extra_fields))
foreach($extra_fields as $name => $value)
{
$this->db->query("INSERT INTO $this->ext_table VALUES ('$id','" . $owner . "','"
@ -719,7 +706,6 @@
$this->db->query($sql="UPDATE $this->std_table SET $fields_s WHERE "
. "id=$id",__LINE__,__FILE__);
}
// while (list($x_name,$x_value) = @each($extra_fields))
foreach($extra_fields as $x_name => $x_value)
{
if ($this->field_exists($id,$x_name))