From 8c9c2f09d0c6aa2796cb8cb178cb1949954fe427 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 24 Oct 2003 20:42:00 +0000 Subject: [PATCH] some more xmlrpc changes --- addressbook/inc/class.boaddressbook.inc.php | 18 ++++++++++++++++-- addressbook/inc/class.soaddressbook.inc.php | 11 +++-------- phpgwapi/inc/class.contacts_sql.inc.php | 15 +++++++++++---- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/addressbook/inc/class.boaddressbook.inc.php b/addressbook/inc/class.boaddressbook.inc.php index c61ffb92d7..515d97e4fd 100644 --- a/addressbook/inc/class.boaddressbook.inc.php +++ b/addressbook/inc/class.boaddressbook.inc.php @@ -384,7 +384,21 @@ function delete_entry($addr) { - $id = !is_array($addr) ? $addr : (isset($addr['id']) ? $addr['id'] : $addr['ab_id']); + if (!is_array($addr)) + { + $id = intval($addr); + } + else + { + if (is_numeric($addr[0])) // xmlrpc liefert array($id) + { + $id = intval($addr[0]); + } + else + { + $id = isset($addr['id']) ? $addr['id'] : $addr['ab_id']; + } + } if ($this->check_perms($id,PHPGW_ACL_DELETE)) { @@ -415,7 +429,7 @@ $owner = $addr['owner']; } //echo "

boaddressbook::check_perms(id='$id',rights=$rights): grant[owner='$owner']='".$this->grants[$owner]."' => ".(($this->grants[$owner] & 4) ? 'True':'False')."

\n"; - return !!($this->grants[$owner] & $rights); + return $owner && !!($this->grants[$owner] & $rights); } function save_preferences($prefs,$other,$qfields,$fcat_id) diff --git a/addressbook/inc/class.soaddressbook.inc.php b/addressbook/inc/class.soaddressbook.inc.php index fadf89bbbb..fe91a12791 100644 --- a/addressbook/inc/class.soaddressbook.inc.php +++ b/addressbook/inc/class.soaddressbook.inc.php @@ -78,18 +78,13 @@ function update_entry($fields) { - $ab_id = $fields['ab_id']; + $ab_id = isset($fields['ab_id']) ? $fields['ab_id'] : $fields['id']; $owner = $fields['owner']; - $access = $fields['access']; - $cat_id = $fields['cat_id']; - $tid = $fields['tid']; unset($fields['owner']); - unset($fields['access']); - unset($fields['cat_id']); unset($fields['ab_id']); - unset($fields['tid']); + unset($fields['id']); - return $this->contacts->update($ab_id,$owner,$fields,$access,$cat_id,$tid); + return $this->contacts->update($ab_id,$owner,$fields); } function delete_entry($id) diff --git a/phpgwapi/inc/class.contacts_sql.inc.php b/phpgwapi/inc/class.contacts_sql.inc.php index f835f6dcf4..4fd478731f 100644 --- a/phpgwapi/inc/class.contacts_sql.inc.php +++ b/phpgwapi/inc/class.contacts_sql.inc.php @@ -637,7 +637,7 @@ . $this->db->db_addslashes($field_name) . "'",__LINE__,__FILE__); } - function update($id,$owner,$fields,$access='',$cat_id='',$tid='n') + function update($id,$owner,$fields,$access=NULL,$cat_id=NULL,$tid=NULL) { /* First make sure that id number exists */ $this->db->query("SELECT COUNT(*) FROM $this->std_table WHERE id='$id'",__LINE__,__FILE__); @@ -647,6 +647,13 @@ return False; } + foreach(array('access','cat_id','tid') as $extra) + { + if (!is_null($$extra)) + { + $fields[$extra] = $$extra; + } + } list($stock_fields,$stock_fieldnames,$extra_fields) = $this->split_stock_and_extras($fields); if (count($stock_fields)) { @@ -654,13 +661,13 @@ { $ta[] = $stock_fieldname . "='" . $this->db->db_addslashes($stock_fields[$stock_fieldname]) . "'"; } - $ta[] = 'last_mod=' . $GLOBALS['phpgw']->datetime->gmtnow; - $fields_s = ',' . implode(',',$ta); + $ta[] = 'last_mod=' . $GLOBALS['phpgw']->datetime->gmtnow; + $fields_s = implode(',',$ta); if ($field_s == ',') { 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 $fields_s WHERE " . "id='$id'",__LINE__,__FILE__); }