| | |
| | | if ($col == 'ID' || $col == $this->primary_key) |
| | | { |
| | | $ids = !is_array($value) ? explode(',', $value) : $value; |
| | | $add_where[] = $this->primary_key.' IN ('.join(',', $ids).')'; |
| | | $add_where[] = 'c.' . $this->primary_key.' IN ('.join(',', $ids).')'; |
| | | } |
| | | else if ($strict) |
| | | $add_where[] = $this->db->quoteIdentifier($col).'='.$this->db->quote($value); |
| | |
| | | |
| | | $insert_id = $this->db->insert_id('contacts'); |
| | | } |
| | | |
| | | // also add the newly created contact to the active group |
| | | if ($insert_id && $this->group_id) |
| | | $this->add_to_group($this->group_id, $insert_id); |
| | | |
| | | return $insert_id; |
| | | } |
| | |
| | | if (is_array($ids)) |
| | | $ids = join(',', $ids); |
| | | |
| | | // delete all group members linked with these contacts |
| | | if ($this->groups) { |
| | | $this->db->query( |
| | | "DELETE FROM ".get_table_name('contactgroupmembers')." |
| | | WHERE contact_id IN (".$ids.")"); |
| | | } |
| | | |
| | | // flag record as deleted |
| | | $this->db->query( |
| | | "UPDATE ".$this->db_name." |
| | | SET del=1 |
| | | SET del=1, changed=".$this->db->now()." |
| | | WHERE user_id=? |
| | | AND contact_id IN (".$ids.")", |
| | | $this->user_id); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Delete the given group and all linked group members |
| | | * Delete the given group (and all linked group members) |
| | | * |
| | | * @param string Group identifier |
| | | * @return boolean True on success, false if no data was changed |
| | | */ |
| | | function delete_group($gid) |
| | | { |
| | | $sql_result = $this->db->query( |
| | | "DELETE FROM ".get_table_name('contactgroupmembers')." |
| | | WHERE contactgroup_id=?", |
| | | $gid); |
| | | |
| | | // flag group record as deleted |
| | | $sql_result = $this->db->query( |
| | | "UPDATE ".get_table_name('contactgroups')." |
| | | SET del=1, changed=".$this->db->now()." |