Make add() match sql class for input; BUG# 897792 - Fix filtering in read() to not

error when adding elements to string vs. array value for phpgwcontactowner;
This commit is contained in:
Miles Lott 2004-02-16 04:50:26 +00:00
parent bab57d221a
commit b7ae8accc8

View File

@ -243,8 +243,8 @@
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);
} }
@ -365,15 +365,14 @@
if(@is_array($this->grants)) if(@is_array($this->grants))
{ {
$filterfields['phpgwcontactowner'] = array();
/* this was not listing private entries when show all was selected */ /* this was not listing private entries when show all was selected */
/* $filterfields += array('phpgwcontactaccess' => 'public'); */ /* $filterfields += array('phpgwcontactaccess' => 'public'); */
$grants = $this->grants;
if($DEBUG) { echo '<br>DEBUG - My user id is: ' . $this->account_id; } if($DEBUG) { echo '<br>DEBUG - My user id is: ' . $this->account_id; }
while (list($user) = each($grants)) foreach($this->grants as $user => $right)
{ {
if($DEBUG) { echo '<br>DEBUG - Grant from owner: ' . $user; } if($DEBUG) { echo '<br>DEBUG - Grant from owner: ' . $user; }
/* I know this looks silly... */ $filterfields['phpgwcontactowner'][] = array('phpgwcontactowner' => $user);
@$filterfields['phpgwcontactowner'][] = array('phpgwcontactowner' => $user);
} }
} }
/* /*
@ -381,17 +380,13 @@
{ {
while(list($name,$value) = each($filterfields)) while(list($name,$value) = each($filterfields))
{ {
echo "<br>DEBUG - Filter strings: #".$name.",".$value."#"; echo '<br>DEBUG - Filter strings: #' . $name . ',' . $value . '#';
} }
} }
*/ */
if (!$sort) { $sort = 'ASC'; } $sort = $sort ? $sort : 'ASC';
$order = $order ? $order : 'n_family';
if (!$order)
{
$order = 'n_family';
}
if($DEBUG && $order) if($DEBUG && $order)
{ {
@ -623,13 +618,19 @@
return $fquery; return $fquery;
} }
function add($owner,$fields,$access='private',$cat_id='0',$tid='n') function add($owner,$fields,$access=NULL,$cat_id=NULL,$tid=NULL)
{ {
$tid = $fields['tid'] ? trim($fields['tid']) : $tid; // access, cat_id and tid can be in $fields now or as extra params
unset($fields['tid']); foreach(array('access','cat_id','tid') as $extra)
if(empty($tid))
{ {
$tid = 'n'; if(!is_null($$extra))
{
$fields[$extra] = $$extra;
}
}
if(empty($fields['tid']))
{
$fields['tid'] = 'n';
} }
if(!$GLOBALS['phpgw_info']['server']['ldap_contact_context']) if(!$GLOBALS['phpgw_info']['server']['ldap_contact_context'])
@ -673,11 +674,14 @@
$ldap_fields['uid'] = time().$time['usec'].':'.$ldap_fields['givenname']; $ldap_fields['uid'] = time().$time['usec'].':'.$ldap_fields['givenname'];
$dn = 'uid=' . $ldap_fields['uid'].',' . $GLOBALS['phpgw_info']['server']['ldap_contact_context']; $dn = 'uid=' . $ldap_fields['uid'].',' . $GLOBALS['phpgw_info']['server']['ldap_contact_context'];
$ldap_fields['phpgwcontacttypeid'] = $tid; $ldap_fields['phpgwcontacttypeid'] = $fields['tid'];
$ldap_fields['phpgwcontactowner'] = $owner; $ldap_fields['phpgwcontactowner'] = $owner;
if (!isset($access)) { $access = 'private'; } if(!isset($fields['access']))
$ldap_fields['phpgwcontactaccess'] = $access; {
$ldap_fields['phpgwcontactcatid'] = $cat_id ? $cat_id : '0'; $fields['access'] = 'private';
}
$ldap_fields['phpgwcontactaccess'] = $fields['access'];
$ldap_fields['phpgwcontactcatid'] = $fields['cat_id'] ? $fields['cat_id'] : '0';
$ldap_fields['uidnumber'] = $this->nextid; $ldap_fields['uidnumber'] = $this->nextid;
/* $ldap_fields['objectclass'][0] = 'person'; */ /* $ldap_fields['objectclass'][0] = 'person'; */
$ldap_fields['objectclass'][0] = 'organizationalPerson'; $ldap_fields['objectclass'][0] = 'organizationalPerson';