Add saving of cat_id into new phpgwcatid attribute - filters pending

This commit is contained in:
Miles Lott 2001-03-26 13:33:50 +00:00
parent df41f9fefe
commit e6d9173490

View File

@ -183,6 +183,7 @@
$return_fields[0]["tid"] = $ldap_fields[0]["phpgwcontacttype"][0];
$return_fields[0]["owner"] = $ldap_fields[0]["phpgwowner"][0];
$return_fields[0]["access"] = $ldap_fields[0]["phpgwaccess"][0];
$return_fields[0]["cat_id"] = $ldap_fields[0]["phpgwcatid"][0];
if (gettype($stock_fieldnames) == "array") {
while(list($name,$value)=each($stock_fieldnames)) {
@ -243,6 +244,7 @@
$return_fields[0]["tid"] = $ldap_fields[0]["phpgwcontacttype"][0];
$return_fields[0]["owner"] = $ldap_fields[0]["phpgwowner"][0];
$return_fields[0]["access"] = $ldap_fields[0]["phpgwaccess"][0];
$return_fields[0]["cat_id"] = $ldap_fields[0]["phpgwcatid"][0];
if (gettype($stock_fieldnames) == "array") {
while(list($name,$value)=each($stock_fieldnames)) {
@ -379,7 +381,7 @@
$total = $total + ldap_count_entries($this->ldap, $sri);
}
echo '<br>first total="'.$total.'"';
//echo '<br>first total="'.$total.'"';
// Now, remove duplicate rows
//$tmp = array_unique($ldap_fields); PHP 4.X only
@ -404,7 +406,7 @@
}
$this->total_records = count($ldap_fields);
echo '<br>total="'.$this->total_records.'"';
//echo '<br>total="'.$this->total_records.'"';
} else {
$sri = ldap_search($this->ldap, $phpgw_info["server"]["ldap_contact_context"], "phpgwowner=*");
$ldap_fields = ldap_get_entries($this->ldap, $sri);
@ -446,6 +448,7 @@
$return_fields[$j]["tid"] = $ldap_fields[$i]["phpgwcontacttype"][0];
$return_fields[$j]["owner"] = $ldap_fields[$i]["phpgwowner"][0];
$return_fields[$j]["access"] = $ldap_fields[$i]["phpgwaccess"][0];
$return_fields[$j]["cat_id"] = $ldap_fields[$i]["phpgwcatid"][0];
if (gettype($stock_fieldnames) == "array") {
reset($stock_fieldnames);
@ -469,7 +472,7 @@
return $return_fields;
}
function add($owner,$fields,$access='')
function add($owner,$fields,$access='',$cat_id='')
{
global $phpgw,$phpgw_info;
@ -506,6 +509,7 @@
$dn = 'uid=' . $ldap_fields['uid'].',' . $phpgw_info["server"]["ldap_contact_context"];
$ldap_fields['phpgwowner'] = $owner;
$ldap_fields['phpgwaccess'] = $access;
$ldap_fields["cat_id"] = $cat_id;
$ldap_fields['uidnumber'] = $this->nextid;
$ldap_fields['objectclass'][0] = 'person';
$ldap_fields['objectclass'][1] = 'organizationalPerson';
@ -549,7 +553,7 @@
. addslashes($field_name) . "'",__LINE__,__FILE__);
}
function update($id,$owner,$fields,$access='')
function update($id,$owner,$fields,$access='',$cat_id='')
{
global $phpgw_info;
@ -608,6 +612,15 @@
$err = ldap_mod_add($this->ldap,$dn,array('phpgwaccess' => $stock_fields['phpgwaccess']));
}
// Verify cat_id
if (empty($ldap_fields[0]['phpgwcatid'])) {
$stock_fields['phpgwcatid'] = $cat_id;
$err = ldap_modify($this->ldap,$dn,array('phpgwcatid' => $stock_fields['phpgwcatid']));
} elseif (!$ldap_fields[0]['phpgwcatid']) {
$stock_fields['phpgwcatid'] = $cat_id;
$err = ldap_mod_add($this->ldap,$dn,array('phpgwcatid' => $stock_fields['phpgwcatid']));
}
// Verify objectclasses are there
if (empty($ldap_fields[0]['objectclass'])) {
$stock_fields['objectclass'][0] = 'person';