Ignore:
Timestamp:
09/12/08 11:41:46 (16 years ago)
Author:
niltonneto
Message:

Vide changelog do módulo.
http://www.expressolivre.org/dev/wiki/jabberit/changelog
Alterações feitas por Alexandre Correia
email: alexandrecorreia@…

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/jabberit_messenger/inc/class.db_im.inc.php

    r382 r417  
    11<?php 
     2  /***************************************************************************\ 
     3  *  Expresso - Expresso Messenger                                            * 
     4  *     - Alexandre Correia / Rodrigo Souza                                                               * 
     5  *     - JETI - http://jeti-im.org/                                                                              * 
     6  * ------------------------------------------------------------------------- * 
     7  *  This program is free software; you can redistribute it and/or modify it  * 
     8  *  under the terms of the GNU General Public License as published by the    * 
     9  *  Free Software Foundation; either version 2 of the License, or (at your   * 
     10  *  option) any later version.                                               * 
     11  \***************************************************************************/ 
    212 
    313define('PHPGW_INCLUDE_ROOT','../');      
     
    717class db_im 
    818{        
    9          
    1019        private $db; 
    1120        private $db_name; 
     
    2837        } 
    2938 
     39        private final function connectDB() 
     40        { 
     41                $this->db = new db(); 
     42                $this->db->connect($this->db_name,$this->db_host,$this->db_port,$this->db_user,$this->db_pass,$this->db_type);           
     43        }        
     44 
     45        public final function getApplicationsEnabled() 
     46        { 
     47                $this->connectDB(); 
     48                $this->db->query("SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' and config_name ='apps_jabberit'"); 
     49                if($this->db->num_rows()) 
     50                { 
     51                        $tmp = ""; 
     52                        while($this->db->next_record()) 
     53                        { 
     54                                $tmp[]= $this->db->row(); 
     55                        } 
     56                        return $tmp[0]['config_value']; 
     57                } 
     58                return false; 
     59        } 
     60         
     61        public final function getApplicationsList() 
     62        { 
     63                $this->connectDB(); 
     64                $this->db->query("SELECT * FROM phpgw_applications WHERE app_enabled = '1' order by app_name"); 
     65                if($this->db->num_rows()) 
     66                { 
     67                        while ($this->db->next_record()) 
     68                        { 
     69                                $app = $this->db->f('app_name'); 
     70                                $title = @$GLOBALS['phpgw_info']['apps'][$app]['title']; 
     71                                if (empty($title)) 
     72                                { 
     73                                        $title = lang($app) == $app.'*' ? $app : lang($app); 
     74                                } 
     75                                $apps[$app] = array( 
     76                                        'title'  => $title, 
     77                                        'name'   => $app, 
     78                                        'status' => $this->db->f('app_enabled') 
     79                                ); 
     80                        } 
     81                } 
     82                return $apps; 
     83        } 
     84 
    3085        public final function get_accounts_acl() 
    3186        { 
    32                          
    33                 $this->db = new db(); 
    34                 $this->db->connect($this->db_name,$this->db_host,$this->db_port,$this->db_user,$this->db_pass,$this->db_type);           
     87                $this->connectDB();                      
    3588                 
    3689                $query  = "select acl_account from phpgw_acl where acl_location in (select acl_account from phpgw_acl where acl_appname = 'jabberit_messenger') "; 
     
    54107        } 
    55108         
    56         private final function query_db($pQuery) 
     109        public final function getPreferences() 
    57110        { 
    58                 if (!$this->db->query($pQuery)) 
    59                 return false; 
     111                $this->connectDB(); 
     112                 
     113                $result = array(); 
     114                $query = "select * from phpgw_preferences where preference_owner = '".$this->user_id."' and preference_app = 'jabberit_messenger'"; 
     115                 
     116                if ( $this->db->query($query) ) 
     117                {        
     118                        while($this->db->next_record()) 
     119                                $result[] = $this->db->row(); 
     120         
     121                        if(count($result) > 0) 
     122                                return unserialize($result[0]['preference_value']); 
     123                } 
     124 
     125                return "openWindowJabberit:true"; 
     126        } 
     127 
     128        public final function setPreferences($pParam) 
     129        { 
     130                $this->connectDB(); 
     131                $preferences = $pParam['preferences']; 
     132                $user_id  = $this->user_id; 
     133                 
     134                $query = "insert into phpgw_preferences values('".$user_id."','jabberit_messenger','".serialize($preferences)."')"; 
     135                                 
     136                if($this->db->query($query)) 
     137                {  
     138                        return "true"; 
     139                } 
    60140                else 
    61                         return true; 
     141                { 
     142                        $query = "update phpgw_preferences set preference_value = '".serialize($preferences)."' where preference_app='jabberit_messenger' and preference_owner='".$user_id."'"; 
     143 
     144                        if($this->db->query($query)) 
     145                                return "true"; 
     146                        else 
     147                                return "false";                  
     148                }                
     149        } 
     150         
     151        public final function setApplications($pApplications) 
     152        { 
     153                $this->connectDB(); 
     154                $apps = serialize($pApplications); 
     155                 
     156                if( $this->db ) 
     157                { 
     158                        $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' and config_name ='apps_jabberit'"; 
     159                                 
     160                        $this->db->query($query); 
     161                                         
     162                        if(!$this->db->next_record()) 
     163                        { 
     164                                $query = "INSERT INTO phpgw_config(config_app,config_name,config_value) VALUES('phpgwapi','apps_jabberit','".$apps."')"; 
     165                                $this->db->query($query); 
     166                                return true; 
     167                        } 
     168                        else 
     169                        { 
     170                                $query = "UPDATE phpgw_config SET config_value = '".$apps."' WHERE config_app = 'phpgwapi' AND config_name = 'apps_jabberit'"; 
     171                                $this->db->query($query); 
     172                                return true; 
     173                        } 
     174                } 
     175                return false;    
    62176        } 
    63177} 
    64  
    65178?> 
Note: See TracChangeset for help on using the changeset viewer.