mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-04 04:19:41 +01:00
Add return of access field, modify read_single/last to return these explicitly
This commit is contained in:
parent
12e24d7284
commit
a7742b1685
@ -59,10 +59,11 @@
|
||||
|
||||
// The left side are the array elements used throughout phpgw, right side are the ldap attributes
|
||||
$this->stock_contact_fields = array(
|
||||
"id" => "uidnumber",
|
||||
"lid" => "uid",
|
||||
"tid" => "phpgwcontacttype",
|
||||
"owner" => "phpgwowner",
|
||||
// "id" => "uidnumber",
|
||||
// "lid" => "uid",
|
||||
// "tid" => "phpgwcontacttype",
|
||||
// "owner" => "phpgwowner",
|
||||
// "access" => "phpgwaccess",
|
||||
"fn" => "cn", // 'prefix given middle family suffix'
|
||||
"n_given" => "givenname", // firstname
|
||||
"n_family" => "sn", // lastname
|
||||
@ -180,6 +181,12 @@
|
||||
$sri = ldap_search($this->ldap, $phpgw_info["server"]["ldap_contact_context"], "uidnumber=".$id);
|
||||
$ldap_fields = ldap_get_entries($this->ldap, $sri);
|
||||
|
||||
$return_fields[0]["id"] = $ldap_fields[0]["uidnumber"][0];
|
||||
$return_fields[0]["lid"] = $ldap_fields[0]["uid"][0];
|
||||
$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];
|
||||
|
||||
if (gettype($stock_fieldnames) == "array") {
|
||||
while(list($name,$value)=each($stock_fieldnames)) {
|
||||
$return_fields[0][$name] = $ldap_fields[0][$value][0];
|
||||
@ -234,6 +241,12 @@
|
||||
$sri = ldap_search($this->ldap, $phpgw_info["server"]["ldap_contact_context"], "uidnumber=".$id);
|
||||
$ldap_fields = ldap_get_entries($this->ldap, $sri);
|
||||
|
||||
$return_fields[0]["id"] = $ldap_fields[0]["uidnumber"][0];
|
||||
$return_fields[0]["lid"] = $ldap_fields[0]["uid"][0];
|
||||
$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];
|
||||
|
||||
if (gettype($stock_fieldnames) == "array") {
|
||||
while(list($name,$value)=each($stock_fieldnames)) {
|
||||
$return_fields[0][$name] = $ldap_fields[0][$value][0];
|
||||
@ -268,8 +281,8 @@
|
||||
}
|
||||
|
||||
// send this the range, query, sort, order and whatever fields you want to see
|
||||
// 'rights' is unused at this time
|
||||
function read($start=0,$offset=0,$fields="",$query="",$filter="",$sort="",$order="",$rights="")
|
||||
// 'rights' and 'access' are unused at this time
|
||||
function read($start=0,$offset=0,$fields="",$query="",$filter="",$sort="",$order="",$rights="",$access="")
|
||||
{
|
||||
global $phpgw,$phpgw_info;
|
||||
|
||||
@ -372,27 +385,27 @@
|
||||
echo '<br>first total="'.$total.'"';
|
||||
|
||||
// Now, remove duplicate rows
|
||||
$tmp = array_unique($ldap_fields);
|
||||
$ldap_fields = $tmp;
|
||||
/*
|
||||
//$tmp = array_unique($ldap_fields); PHP 4.X only
|
||||
//$ldap_fields = $tmp;
|
||||
|
||||
$ldap_fields = $this->asortbyindex($ldap_fields,'uidnumber');
|
||||
reset($ldap_fields);
|
||||
if (count($ldap_fields) > 0) {
|
||||
for ($a = 0; $a < count($ldap_fields); $a++) {
|
||||
if ($ldap_fields[$a]) {
|
||||
echo '<br>comparing "'.$ldap_fields[$a]['uidnumber'][0]
|
||||
.'" to "'.$ldap_fields[$a - 1]['uidnumber'][0].'"';
|
||||
//echo '<br>comparing "'.$ldap_fields[$a]['uidnumber'][0]
|
||||
// .'" to "'.$ldap_fields[$a - 1]['uidnumber'][0].'"';
|
||||
if (($ldap_fields[$a]['uidnumber'][0] <> $ldap_fields[$a - 1]['uidnumber'][0])
|
||||
) {
|
||||
$uniquearray[$a] = $ldap_fields[$a];
|
||||
} else {
|
||||
echo '<br>deleting "'.$ldap_fields[$a -1 ]['uidnumber'][0];
|
||||
//echo '<br>deleting "'.$ldap_fields[$a -1 ]['uidnumber'][0];
|
||||
}
|
||||
}
|
||||
}
|
||||
$ldap_fields = $uniquearray;
|
||||
}
|
||||
*/
|
||||
|
||||
$this->total_records = count($ldap_fields);
|
||||
echo '<br>total="'.$this->total_records.'"';
|
||||
} else {
|
||||
@ -435,6 +448,7 @@
|
||||
$return_fields[$j]["lid"] = $ldap_fields[$i]["uid"][0];
|
||||
$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];
|
||||
|
||||
if (gettype($stock_fieldnames) == "array") {
|
||||
reset($stock_fieldnames);
|
||||
@ -458,7 +472,7 @@
|
||||
return $return_fields;
|
||||
}
|
||||
|
||||
function add($owner,$fields)
|
||||
function add($owner,$fields,$access='')
|
||||
{
|
||||
global $phpgw,$phpgw_info;
|
||||
|
||||
@ -494,6 +508,7 @@
|
||||
|
||||
$dn = 'uid=' . $ldap_fields['uid'].',' . $phpgw_info["server"]["ldap_contact_context"];
|
||||
$ldap_fields['phpgwowner'] = $owner;
|
||||
$ldap_fields['phpgwaccess'] = $access;
|
||||
$ldap_fields['uidnumber'] = $this->nextid;
|
||||
$ldap_fields['objectclass'][0] = 'person';
|
||||
$ldap_fields['objectclass'][1] = 'organizationalPerson';
|
||||
@ -537,7 +552,7 @@
|
||||
. addslashes($field_name) . "'",__LINE__,__FILE__);
|
||||
}
|
||||
|
||||
function update($id,$owner,$fields)
|
||||
function update($id,$owner,$fields,$access='')
|
||||
{
|
||||
global $phpgw_info;
|
||||
|
||||
@ -554,6 +569,7 @@
|
||||
list($stock_fields,$stock_fieldnames,$extra_fields) = $this->split_stock_and_extras($fields);
|
||||
if (gettype($stock_fieldnames) == "array") {
|
||||
$stock_fields['phpgwowner'] = $owner;
|
||||
if ($access) { $stock_fields['phpgwaccess'] = $access; }
|
||||
// Check each value, add our extra attributes if they are missing, and
|
||||
// otherwise fix the entry while we can.
|
||||
//
|
||||
@ -578,12 +594,21 @@
|
||||
}
|
||||
|
||||
// Verify owner
|
||||
if (empty($ldap_fields[0]['owner'])) {
|
||||
if (empty($ldap_fields[0]['phpgwowner'])) {
|
||||
$stock_fields['phpgwowner'] = $owner;
|
||||
$err = ldap_modify($this->ldap,$dn,array('owner' => $stock_fields['phpgwowner']));
|
||||
$err = ldap_modify($this->ldap,$dn,array('phpgwowner' => $stock_fields['phpgwowner']));
|
||||
} elseif (!$ldap_fields[0]['owner']) {
|
||||
$stock_fields['phpgwowner'] = $owner;
|
||||
$err = ldap_mod_add($this->ldap,$dn,array('owner' => $stock_fields['phpgwowner']));
|
||||
$err = ldap_mod_add($this->ldap,$dn,array('phpgwowner' => $stock_fields['phpgwowner']));
|
||||
}
|
||||
|
||||
// Verify access
|
||||
if (empty($ldap_fields[0]['phpgwaccess'])) {
|
||||
$stock_fields['phpgwaccess'] = $access;
|
||||
$err = ldap_modify($this->ldap,$dn,array('phpgwaccess' => $stock_fields['phpgwaccess']));
|
||||
} elseif (!$ldap_fields[0]['owner']) {
|
||||
$stock_fields['phpgwaccess'] = $access;
|
||||
$err = ldap_mod_add($this->ldap,$dn,array('phpgwaccess' => $stock_fields['phpgwaccess']));
|
||||
}
|
||||
|
||||
// Verify objectclasses are there
|
||||
|
@ -174,6 +174,7 @@
|
||||
$return_fields[0]["lid"] = $this->db->f("lid"); // lid for group/account records
|
||||
$return_fields[0]["tid"] = $this->db->f("tid"); // type id (g/u) for groups/accounts
|
||||
$return_fields[0]["owner"] = $this->db->f("owner"); // id of owner/parent for the record
|
||||
$return_fields[0]["access"] = $this->db->f("access"); // public/private
|
||||
|
||||
if (gettype($stock_fieldnames) == "array") {
|
||||
while (list($f_name) = each($stock_fieldnames)) {
|
||||
@ -235,6 +236,7 @@
|
||||
$return_fields[0]["lid"] = $this->db->f("lid");
|
||||
$return_fields[0]["tid"] = $this->db->f("tid");
|
||||
$return_fields[0]["owner"] = $this->db->f("owner");
|
||||
$return_fields[0]["access"] = $this->db->f("access"); // public/private
|
||||
|
||||
if (gettype($stock_fieldnames) == "array") {
|
||||
while (list($f_name) = each($stock_fieldnames)) {
|
||||
@ -269,10 +271,9 @@
|
||||
return $return_fields;
|
||||
}
|
||||
|
||||
|
||||
// send this the range, query, sort, order and whatever fields you want to see
|
||||
// 'rights' is unused at this time
|
||||
function read($start=0,$offset=0,$fields="",$query="",$filter="",$sort="",$order="",$rights="")
|
||||
// 'rights' and 'access' are unused at this time
|
||||
function read($start=0,$offset=0,$fields="",$query="",$filter="",$sort="",$order="",$rights="",$access="")
|
||||
{
|
||||
global $phpgw,$phpgw_info;
|
||||
|
||||
@ -418,6 +419,7 @@
|
||||
$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
|
||||
|
||||
if (gettype($stock_fieldnames) == "array") {
|
||||
while (list($f_name) = each($stock_fieldnames)) {
|
||||
@ -439,14 +441,14 @@
|
||||
return $return_fields;
|
||||
}
|
||||
|
||||
function add($owner,$fields)
|
||||
function add($owner,$fields,$access='')
|
||||
{
|
||||
list($stock_fields,$stock_fieldnames,$extra_fields) = $this->split_stock_and_extras($fields);
|
||||
|
||||
//$this->db->lock(array("contacts"));
|
||||
$this->db->query("insert into $this->std_table (owner,"
|
||||
$this->db->query("insert into $this->std_table (owner,access,"
|
||||
. implode(",",$this->stock_contact_fields)
|
||||
. ") values ('$owner','"
|
||||
. ") values ('$owner','$access','"
|
||||
. implode("','",$this->loop_addslashes($stock_fields)) . "')",__LINE__,__FILE__);
|
||||
|
||||
$this->db->query("select max(id) from $this->std_table ",__LINE__,__FILE__);
|
||||
@ -481,7 +483,7 @@
|
||||
. addslashes($field_name) . "'",__LINE__,__FILE__);
|
||||
}
|
||||
|
||||
function update($id,$owner,$fields)
|
||||
function update($id,$owner,$fields,$access='')
|
||||
{
|
||||
// First make sure that id number exists
|
||||
$this->db->query("select count(*) from $this->std_table where id='$id'",__LINE__,__FILE__);
|
||||
@ -499,7 +501,7 @@
|
||||
if ($field_s == ",") {
|
||||
unset($field_s);
|
||||
}
|
||||
$this->db->query("update $this->std_table set owner='$owner' $fields_s where "
|
||||
$this->db->query("update $this->std_table set owner='$owner', access='$access' $fields_s where "
|
||||
. "id='$id'",__LINE__,__FILE__);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user