+ // Remove the user identified by $alias from backend $bnum
+ // If $alias is an array, all users in the array are removed.
+ function remove($alias, $bnum) {
+
+ // Check input
+ if(empty($alias))
+ return true;
+
+ // Convert string to single element array
+ if(!is_array($alias))
+ $alias = array(0 => $alias);
+
+ // Check that specified backend is writable
+ if(!$this->backends[$bnum]->writeable) {
+ $this->error = _("Addressbook is read-only");
+ return false;
+ }
+
+ // Remove user from backend
+ $res = $this->backends[$bnum]->remove($alias);
+ if($res) {
+ return $bnum;
+ } else {
+ $this->error = $this->backends[$bnum]->error;
+ return false;
+ }
+
+ return false; // Not reached
+ } // end of remove()
+
+
+ // Remove the user identified by $alias from backend $bnum
+ // If $alias is an array, all users in the array are removed.
+ function modify($alias, $userdata, $bnum) {
+
+ // Check input
+ if(empty($alias) || !is_string($alias))
+ return true;
+
+ // Validate data
+ if(!is_array($userdata)) {
+ $this->error = _("Invalid input data");
+ return false;
+ }
+ if(empty($userdata['firstname']) &&
+ empty($userdata['lastname'])) {
+ $this->error = _("Name is missing");
+ return false;
+ }
+ if(empty($userdata['email'])) {
+ $this->error = _("E-mail address is missing");
+ return false;
+ }
+
+ if(eregi('[\\: \\|\\#"\\!]', $userdata['nickname'])) {
+ $this->error = _("Nickname contains illegal characters");
+ return false;
+ }
+
+ if(empty($userdata['nickname'])) {
+ $userdata['nickname'] = $userdata['email'];
+ }
+
+ // Check that specified backend is writable
+ if(!$this->backends[$bnum]->writeable) {
+ $this->error = _("Addressbook is read-only");;
+ return false;
+ }
+
+ // Modify user in backend
+ $res = $this->backends[$bnum]->modify($alias, $userdata);
+ if($res) {
+ return $bnum;
+ } else {
+ $this->error = $this->backends[$bnum]->error;
+ return false;
+ }
+
+ return false; // Not reached
+ } // end of modify()
+
+
+ } // End of class Addressbook