db_name = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_name']; $this->db_host = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_host']; $this->db_port = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_port']; $this->db_user = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_user']; $this->db_pass = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_pass']; $this->db_type = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_type']; $this->user_id = $_SESSION['phpgw_info']['jabberit_messenger']['user_id']; } private final function connectDB() { $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); } public final function getApplicationsEnabled() { $this->connectDB(); $this->db->query("SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' and config_name ='apps_jabberit'"); if($this->db->num_rows()) { $tmp = ""; while($this->db->next_record()) { $tmp[]= $this->db->row(); } return $tmp[0]['config_value']; } return false; } public final function getApplicationsList() { $this->connectDB(); $this->db->query("SELECT * FROM phpgw_applications WHERE app_enabled = '1' order by app_name"); if($this->db->num_rows()) { while ($this->db->next_record()) { $app = $this->db->f('app_name'); $title = @$GLOBALS['phpgw_info']['apps'][$app]['title']; if (empty($title)) { $title = lang($app) == $app.'*' ? $app : lang($app); } $apps[$app] = array( 'title' => $title, 'name' => $app, 'status' => $this->db->f('app_enabled') ); } } return $apps; } public final function get_accounts_acl() { $this->connectDB(); $query = "select acl_account from phpgw_acl where acl_location in (select acl_account from phpgw_acl where acl_appname = 'jabberit_messenger') "; $query .= "union select acl_account from phpgw_acl where acl_appname = 'jabberit_messenger'"; if( $this->db->query($query) ) { $users = array(); $new_users = array(); while($this->db->next_record()) $users[] = $this->db->row(); if(is_array($users)) foreach($users as $tmp) $new_users[] = $tmp['acl_account']; return $new_users; } return false; } public final function getPreferences() { $this->connectDB(); $result = array(); $query = "select * from phpgw_preferences where preference_owner = '".$this->user_id."' and preference_app = 'jabberit_messenger'"; if ( $this->db->query($query) ) { while($this->db->next_record()) $result[] = $this->db->row(); if(count($result) > 0) return unserialize($result[0]['preference_value']); } return "openWindowJabberit:true"; } public final function setPreferences($pParam) { $this->connectDB(); $preferences = $pParam['preferences']; $user_id = $this->user_id; $query = "insert into phpgw_preferences values('".$user_id."','jabberit_messenger','".serialize($preferences)."')"; if($this->db->query($query)) { return "true"; } else { $query = "update phpgw_preferences set preference_value = '".serialize($preferences)."' where preference_app='jabberit_messenger' and preference_owner='".$user_id."'"; if($this->db->query($query)) return "true"; else return "false"; } } public final function setApplications($pApplications) { $this->connectDB(); $apps = serialize($pApplications); if( $this->db ) { $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' and config_name ='apps_jabberit'"; $this->db->query($query); if(!$this->db->next_record()) { $query = "INSERT INTO phpgw_config(config_app,config_name,config_value) VALUES('phpgwapi','apps_jabberit','".$apps."')"; $this->db->query($query); return true; } else { $query = "UPDATE phpgw_config SET config_value = '".$apps."' WHERE config_app = 'phpgwapi' AND config_name = 'apps_jabberit'"; $this->db->query($query); return true; } } return false; } } ?>