db_name = $_SESSION['phpgw_info']['instant_messenger']['server']['db_name']; $this->db_host = $_SESSION['phpgw_info']['instant_messenger']['server']['db_host']; $this->db_port = $_SESSION['phpgw_info']['instant_messenger']['server']['db_port']; $this->db_user = $_SESSION['phpgw_info']['instant_messenger']['server']['db_user']; $this->db_pass = $_SESSION['phpgw_info']['instant_messenger']['server']['db_pass']; $this->db_type = $_SESSION['phpgw_info']['instant_messenger']['server']['db_type']; $this->user_id = $_SESSION['phpgw_info']['instant_messenger']['user_id']; session_write_close(); $this->db = new db(); $this->db->connect($this->db_name,$this->db_host,$this->db_port,$this->db_user,$this->db_pass,$this->db_type); } function get_accounts_acl() { $result = array(); $query = "select acl_appname, acl_account from phpgw_acl where acl_appname = 'instant_messenger' order by acl_account"; if (!$this->db->query($query)) return null; while($this->db->next_record()) $result[] = $this->db->row(); return $result; } function query_db($pQuery) { if (!$this->db->query($pQuery)) return false; else return true; } function set_preferences($param) { $preferences = $param['preferences']; $user_id = $this->user_id; $app_name = $this->name_app(); $query = "insert into phpgw_preferences values('".$user_id."','".$app_name."','".serialize($preferences)."')"; if($this->query_db($query)) { return "true"; } else { $query = "update phpgw_preferences set preference_value = '".serialize($preferences)."' where preference_app='".$app_name."' and preference_owner='".$user_id."'"; if($this->query_db($query)) return "true"; else return "false"; } } function get_preferences() { $result = array(); $user_id = $this->user_id; $app_name = $this->name_app(); $query = "select * from phpgw_preferences where preference_owner = '".$user_id."' and preference_app = '".$app_name."'"; if (!$this->db->query($query)) return NULL; while($this->db->next_record()) $result[] = $this->db->row(); if(count($result) > 0) return unserialize($result[0]['preference_value']); else return "ch_offline:true;time_xa_im:1;rd_nm:true;rd_ch:false"; } function name_app() { return "instant_messenger"; } } ?>