Ignore:
Timestamp:
08/19/11 10:46:17 (13 years ago)
Author:
alexandrecorreia
Message:

Ticket #2083 - Corrigido para que a add de novos RSS é feito apenas pelo administrador

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/expressoMail1_2/inc/class.rss.inc.php

    r4688 r4957  
    11<?php 
     2 
     3include('../header.inc.php'); 
    24 
    35class rss 
    46{ 
    5  
    6         function rss (){ 
    7         } 
    87        // BEGIN of functions. 
    9         function getContent($param){ 
     8        function getContent($param) 
     9        { 
    1010                $daurl=$param['url']; 
     11                 
    1112                if (preg_match('/http(s)?:\/\//i',$daurl,$matches) == 0) 
    1213                        $daurl = 'http://'.$daurl; 
     
    3435        } 
    3536 
    36         private function createTableRSS() 
    37         { 
    38                 $query = 'CREATE TABLE phpgw_userrss( uid INT NOT NULL,rss_url VARCHAR(1000),name varchar(50), PRIMARY KEY (uid,rss_url) );'; 
    39                  
    40                 $GLOBALS['phpgw']->db->query($query); 
    41                  
    42                 if ( $GLOBALS['phpgw']->db->Error ) 
    43                         return false; 
    44                 else 
    45                         return true; 
    46         } 
    47          
    4837        function getChannels() 
    4938        { 
    50                 include('../header.inc.php'); 
     39                $query  = "SELECT config_value FROM phpgw_config WHERE config_name = 'expressoMail_enabled_read_rss';"; 
    5140                 
    52                 $flag           = false; 
    53                 $tableQuery = "select relname from pg_stat_user_tables order by relname;"; 
    54                  
    55                 if( $GLOBALS['phpgw']->db->query( $tableQuery ) ) 
     41                if( $GLOBALS['phpgw']->db->query( $query ) ) 
    5642                { 
    5743                        while( $GLOBALS['phpgw']->db->next_record() ) 
    5844                        { 
    59                                 $tables[] = $GLOBALS['phpgw']->db->row(); 
    60                         } 
    61                          
    62                         foreach( $tables as $tableName ) 
    63                         { 
    64                                 if( strtolower( $tableName['relname'] ) === 'phpgw_userrss' ) 
    65                                 { 
    66                                         $flag = true; 
    67                                 } 
     45                                $result = $GLOBALS['phpgw']->db->row(); 
    6846                        } 
    6947                } 
    7048                 
    71                 if( !$flag ) 
     49                if( $result['config_value'] === 'true' ) 
    7250                { 
    73                         $flag = $this->createTableRSS(); 
     51                        $query = "SELECT * FROM phpgw_config WHERE config_name = 'expressoMail_list_rss';"; 
     52                         
     53                        if( $GLOBALS['phpgw']->db->query($query) )  
     54                        { 
     55                                while( $GLOBALS['phpgw']->db->next_record() ) 
     56                                { 
     57                                        $result = $GLOBALS['phpgw']->db->row(); 
     58                                } 
     59                        } 
     60         
     61                        if( $result['config_value'] ) 
     62                        { 
     63                                $i              = 0; 
     64                                $rss    = unserialize($result['config_value']); 
     65                                 
     66                                foreach( $rss as $item ) 
     67                                { 
     68                                        $tmp = explode( "|", $item ); 
     69                                        $return[$i]['rss_url']  = $tmp[0]; 
     70                                        $return[$i++]['name']   = $tmp[1]; 
     71                                } 
     72         
     73                                return $return; 
     74                        } 
     75                        else 
     76                                return ""; 
    7477                } 
    75                  
    76                 $query = 'SELECT rss_url,name FROM phpgw_userrss WHERE uid = '.$_SESSION['phpgw_session']['account_id'];                 
    77                  
    78                 if( $GLOBALS['phpgw']->db->query($query) )  
    79                 { 
    80                         while( $GLOBALS['phpgw']->db->next_record() ) 
    81                         { 
    82                                 $return[] = $GLOBALS['phpgw']->db->row(); 
    83                         } 
    84                 } 
    85  
    86                 if( count($return) > 0 ) 
    87                         return $return; 
    88                 else 
    89                         return ""; 
    9078        } 
    9179         
    92         function addChannel($param) 
     80        /*function addChannel($param) 
    9381        { 
    94                 include('../header.inc.php'); 
    95                 $name = $GLOBALS['phpgw']->db->db_addslashes(htmlentities($param['name'])); 
    96                 $url = $GLOBALS['phpgw']->db->db_addslashes($param['url']); 
    97                 $GLOBALS['phpgw']->db->query('INSERT INTO phpgw_userrss values('.$_SESSION['phpgw_session']['account_id'].',\''.$url.'\',\''.$name.'\');',__LINE__,__FILE__); 
     82 
     83                $name   = $GLOBALS['phpgw']->db->db_addslashes(htmlentities($param['name'])); 
     84                $url    = $GLOBALS['phpgw']->db->db_addslashes($param['url']); 
     85                $query  = 'INSERT INTO phpgw_userrss values('.$_SESSION['phpgw_session']['account_id'].',\''.$url.'\',\''.$name.'\');'; 
     86                 
     87                error_log( print_r( $query, true ), 3, "/tmp/log" ); 
     88                 
     89                $GLOBALS['phpgw']->db->query( $query ,__LINE__,__FILE__ ); 
    9890                if ($GLOBALS['phpgw']->db->Error) 
    99                             return "Error"; 
     91                        return "Error"; 
    10092                else 
    101                             return "Success"; 
     93                        return "Success"; 
    10294 
    10395        } 
     
    10597        function removeChannel($param) 
    10698        { 
    107                 include('../header.inc.php'); 
    10899                $url = $GLOBALS['phpgw']->db->db_addslashes($param['url']); 
    109100                $GLOBALS['phpgw']->db->query('DELETE FROM phpgw_userrss where rss_url = \''.$url.'\';',__LINE__,__FILE__); 
     
    112103                else 
    113104                            return "Success"; 
    114         } 
     105        }*/ 
    115106 
    116107} 
Note: See TracChangeset for help on using the changeset viewer.