phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: stocks/inc class.bo.inc.php,1.4,1.5 class.so.inc


From: Bettina Gille <address@hidden>
Subject: [Phpgroupware-cvs] CVS: stocks/inc class.bo.inc.php,1.4,1.5 class.so.inc.php,1.3,1.4 class.ui.inc.php,1.5,1.6
Date: Tue, 22 Jan 2002 19:42:49 -0500

Update of /cvsroot/phpgroupware/stocks/inc
In directory subversions:/tmp/cvs-serv5083/inc

Modified Files:
        class.bo.inc.php class.so.inc.php class.ui.inc.php 
Log Message:
added some country selection

Index: class.bo.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/stocks/inc/class.bo.inc.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** class.bo.inc.php    22 Jan 2002 01:43:25 -0000      1.4
--- class.bo.inc.php    23 Jan 2002 00:42:47 -0000      1.5
***************
*** 34,37 ****
--- 34,71 ----
                        $this->so               = CreateObject('stocks.so');
                        $this->network  = CreateObject('phpgwapi.network');
+ 
+                       $this->read_sessiondata();
+ 
+                       $country = $GLOBALS['HTTP_POST_VARS']['country']  ? 
$GLOBALS['HTTP_POST_VARS']['country'] : $GLOBALS['HTTP_GET_VARS']['country'];
+ 
+                       if (isset($country) && !empty($country))
+                       {
+                               $this->country = $country;
+                       }
+ 
+                       if($country == '')
+                       {
+                               $prefs = $this->read_prefs();
+                               if ($prefs['country'])
+                               {
+                                       $this->country = $prefs['country'];
+                               }
+                               else
+                               {
+                                       $this->country = 'US';
+                               }
+                       }
+               }
+ 
+               function save_sessiondata($data)
+               {
+                       
$GLOBALS['phpgw']->session->appsession('session_data','stocks',$data);
+               }
+ 
+               function read_sessiondata()
+               {
+                       $data = 
$GLOBALS['phpgw']->session->appsession('session_data','stocks');
+ 
+                       $this->country  = $data['country'];
                }
  
***************
*** 42,47 ****
--- 76,99 ----
                }
  
+               function get_url()
+               {
+                       switch($this->country)
+                       {
+                               case 'US':      $url = 
'http://finance.yahoo.com/d/quotes.csv?f=sl1d1t1c1ohgv&e=.csv&s='; break;
+                               case 'DE':      $url = 
'http://de.finance.yahoo.com/d/quotes_de.csv?f=sl1d1t1c1ohgv&e=.csv&s='; break;
+                               default :       $url = 
'http://finance.yahoo.com/d/quotes.csv?f=sl1d1t1c1ohgv&e=.csv&s='; break;
+                       }
+                       return $url;
+               }
+ 
                function get_quotes($stocklist)
                {
+                       switch($this->country)
+                       {
+                               case 'US':      $sep = ','; break;
+                               case 'DE':      $sep = ';'; break;
+                               default :       $sep = ','; break;
+                       }
+ 
                        if (! $stocklist)
                        {
***************
*** 63,67 ****
                        $regexp_stocks = '/(' . implode('|',$symbollist) . ')/';
  
!                       $url = 
'http://finance.yahoo.com/d/quotes.csv?f=sl1d1t1c1ohgv&e=.csv&s=' . $symbolstr;
                        $lines = $this->http_fetch($url,false,80,'');
  
--- 115,119 ----
                        $regexp_stocks = '/(' . implode('|',$symbollist) . ')/';
  
!                       $url = $this->get_url($this->country) . $symbolstr;
                        $lines = $this->http_fetch($url,false,80,'');
  
***************
*** 78,82 ****
                                        {
                                                $line = 
ereg_replace('"','',$line);
!                                               
list($symbol,$price0,$date,$time,$dchange,$price1,$price2) = split(',',$line);
  
                                                if ($price1>0 && $dchange!=0)
--- 130,134 ----
                                        {
                                                $line = 
ereg_replace('"','',$line);
!                                               
list($symbol,$price0,$date,$time,$dchange,$price1,$price2) = split($sep,$line);
  
                                                if ($price1>0 && $dchange!=0)
***************
*** 129,136 ****
--- 181,190 ----
                        {
                                $prefs['mainscreen']    = 
$GLOBALS['phpgw_info']['user']['preferences']['stocks']['mainscreen'];
+                               $prefs['country']               = 
$GLOBALS['phpgw_info']['user']['preferences']['stocks']['country'];
                        }
                        else
                        {
                                $prefs['mainscreen']    = 'disabled';
+                               $prefs['country']               = 'us';
                        }
                        return $prefs;
***************
*** 140,144 ****
                {
                        $def = array();
!                       $def['LNUX']    = 'VA%20Linux';
                        $def['RHAT']    = 'Redhat';
                        return $def;
--- 194,198 ----
                {
                        $def = array();
!                       $def['LNUX']    = 'VA Linux';
                        $def['RHAT']    = 'Redhat';
                        return $def;
***************
*** 147,151 ****
                function read_stocks()
                {
!                       return $this->so->read_stocks();
                }
  
--- 201,205 ----
                function read_stocks()
                {
!                       return $this->so->read_stocks($this->country);
                }
  
***************
*** 162,167 ****
                        }
  
!                       $values['sysmbol']      = 
urlencode(strtoupper($values['symbol']));
!                       $values['name']         = urlencode($values['name']);
  
                        if ($values['id'] && $values['id'] != 0)
--- 216,220 ----
                        }
  
!                       $values['symbol']       = strtoupper($values['symbol']);
  
                        if ($values['id'] && $values['id'] != 0)
***************
*** 188,193 ****
                                while (list($null,$stock) = each($stocks))
                                {
!                                       $symbol = 
rawurldecode($stock['symbol']);
!                                       $name   = rawurldecode($stock['name']);
  
                                        if ($symbol)
--- 241,246 ----
                                while (list($null,$stock) = each($stocks))
                                {
!                                       $symbol = 
$GLOBALS['phpgw']->strip_html($stock['symbol']);
!                                       $name   = 
$GLOBALS['phpgw']->strip_html($stock['name']);
  
                                        if ($symbol)
***************
*** 204,209 ****
                        {
                                $def = $this->get_default();
!                               $stocklist['LNUX'] = rawurldecode($def['LNUX']);
!                               $stocklist['RHAT'] = rawurldecode($def['RHAT']);
                        }
                        return $stocklist;
--- 257,262 ----
                        {
                                $def = $this->get_default();
!                               $stocklist['LNUX'] = $def['LNUX'];
!                               $stocklist['RHAT'] = $def['RHAT'];
                        }
                        return $stocklist;

Index: class.so.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/stocks/inc/class.so.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** class.so.inc.php    21 Jan 2002 00:38:28 -0000      1.3
--- class.so.inc.php    23 Jan 2002 00:42:47 -0000      1.4
***************
*** 36,42 ****
                }
  
!               function read_stocks()
                {
!                       $this->db->query("SELECT * from phpgw_stocks where 
stock_owner='" . $this->account . "'",__LINE__,__FILE__);
  
                        while($this->db->next_record())
--- 36,47 ----
                }
  
!               function read_stocks($country = '')
                {
!                       if ($country)
!                       {
!                               $countrysel = " AND stock_country='" . $country 
. "'";
!                       }
! 
!                       $this->db->query("SELECT * from phpgw_stocks where 
stock_owner='" . $this->account . "'" . $countrysel,__LINE__,__FILE__);
  
                        while($this->db->next_record())
***************
*** 48,52 ****
                                        'access'        => 
$this->db->f('stock_access'),
                                        'name'          => 
$this->db->f('stock_name'),
!                                       'symbol'        => 
$this->db->f('stock_symbol')
                                );
                        }
--- 53,58 ----
                                        'access'        => 
$this->db->f('stock_access'),
                                        'name'          => 
$this->db->f('stock_name'),
!                                       'symbol'        => 
$this->db->f('stock_symbol'),
!                                       'country'       => 
$this->db->f('stock_country'),
                                );
                        }
***************
*** 65,68 ****
--- 71,75 ----
                                $stock['name']          = 
$this->db->f('stock_name');
                                $stock['symbol']        = 
$this->db->f('stock_symbol');
+                               $stock['country']       = 
$this->db->f('stock_country');
                        }
                        return $stock;
***************
*** 71,77 ****
                function add_stock($values)
                {
!                       $this->db->query("INSERT into phpgw_stocks 
(stock_owner,stock_access,stock_name,stock_symbol) values('"
                                                        . $this->account . 
"','" . $values['access'] . "','" . $values['name'] . "','" . $values['symbol']
!                                                       . 
"')",__LINE__,__FILE__);
                }
  
--- 78,87 ----
                function add_stock($values)
                {
!                       $values['symbol']       = 
$this->db->db_addslashes($values['symbol']);
!                       $values['name']         = 
$this->db->db_addslashes($values['name']);
! 
!                       $this->db->query("INSERT into phpgw_stocks 
(stock_owner,stock_access,stock_name,stock_symbol,stock_country) values('"
                                                        . $this->account . 
"','" . $values['access'] . "','" . $values['name'] . "','" . $values['symbol']
!                                                       . "','" . 
$values['country'] . "')",__LINE__,__FILE__);
                }
  
***************
*** 83,88 ****
                function edit_stock($values)
                {
                        $this->db->query("UPDATE phpgw_stocks set stock_name='" 
. $values['name'] . "', stock_symbol='" . $values['symbol']
!                                                       . "' where stock_id='" 
. $values['id'] . "'",__LINE__,__FILE__);
                }
        }
--- 93,101 ----
                function edit_stock($values)
                {
+                       $values['symbol']       = 
$this->db->db_addslashes($values['symbol']);
+                       $values['name']         = 
$this->db->db_addslashes($values['name']);
+ 
                        $this->db->query("UPDATE phpgw_stocks set stock_name='" 
. $values['name'] . "', stock_symbol='" . $values['symbol']
!                                                       . "', stock_country='" 
. $values['country'] . "' where stock_id='" . $values['id'] . 
"'",__LINE__,__FILE__);
                }
        }

Index: class.ui.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/stocks/inc/class.ui.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** class.ui.inc.php    22 Jan 2002 01:43:26 -0000      1.5
--- class.ui.inc.php    23 Jan 2002 00:42:47 -0000      1.6
***************
*** 43,47 ****
--- 43,58 ----
                        $this->bo                       = 
CreateObject('stocks.bo');
                        $this->t                        = 
$GLOBALS['phpgw']->template;
+                       $this->sbox                     = 
CreateObject('phpgwapi.sbox');
                        $this->nextmatchs       = 
CreateObject('phpgwapi.nextmatchs');
+                       $this->country          = $this->bo->country;
+               }
+ 
+               function save_sessiondata()
+               {
+                       $data = array
+                       (
+                               'country'       => $this->country
+                       );
+                       $this->bo->save_sessiondata($data);
                }
  
***************
*** 55,58 ****
--- 66,70 ----
                        $this->t->set_var('lang_edit',lang('Edit'));
                        $this->t->set_var('lang_add',lang('Add'));
+                       $this->t->set_var('lang_country',lang('Country'));
                        $this->t->set_var('lang_add_stock',lang('Add new 
stock'));
                        $this->t->set_var('lang_delete',lang('Delete'));
***************
*** 60,63 ****
--- 72,77 ----
                        $this->t->set_var('lang_stocks',lang('Stock Quotes'));
                        $this->t->set_var('lang_done',lang('Done'));
+                       $this->t->set_var('lang_submit',lang('Submit'));
+                       $this->t->set_var('lang_select_country',lang('Select 
country'));
                }
  
***************
*** 125,134 ****
--- 139,168 ----
                }
  
+               function selected_country()
+               {
+                       switch($this->country)
+                       {
+                               case 'US': $country_sel[0]=' selected'; break;
+                               case 'DE': $country_sel[1]=' selected'; break;
+                       }
+ 
+                       $country_list = '<option value="US"' . $country_sel[0] 
. '>' . lang('united states') . '</option>' . "\n"
+                               . '<option value="DE"' . $country_sel[1] . '>' 
. lang('germany') . '</option>' . "\n"
+                               . '<option value="">' . lang('Select country') 
. '</option>' . "\n";
+ 
+                       return $country_list;
+               }
+ 
                function index()
                {
+                       $country        = $GLOBALS['HTTP_GET_VARS']['country'];
+ 
                        $this->display_app_header();
                        $this->t->set_file(array('quotes_list' => 'main.tpl'));
+                       
$this->t->set_var('country_list',$this->selected_country($this->country));
+                       
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php','menuaction=stocks.ui.index&country='
 . $this->country));
                        $this->t->set_var('quotes',$this->return_quotes());
                        $this->t->pfp('out','quotes_list');
+                       $this->save_sessiondata();
                }
  
***************
*** 140,144 ****
                        $link_data = array
                        (
!                               'menuaction'    => 'stocks.ui.list_stocks'
                        );
  
--- 174,179 ----
                        $link_data = array
                        (
!                               'menuaction'    => 'stocks.ui.list_stocks',
!                               'country'               => $this->country
                        );
  
***************
*** 158,162 ****
                        $this->t->set_var('h_lang_edit',lang('Edit'));
                        $this->t->set_var('h_lang_delete',lang('Delete'));
!                       
$this->t->set_var('doneurl',$GLOBALS['phpgw']->link('/index.php','menuaction=stocks.ui.index'));
  
                        $stocks = $this->bo->read_stocks();
--- 193,204 ----
                        $this->t->set_var('h_lang_edit',lang('Edit'));
                        $this->t->set_var('h_lang_delete',lang('Delete'));
!                       
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
! 
!                       if (!$country)
!                       {
!                               $country = '';
!                       }
! 
!                       
$this->t->set_var('country_list',$this->selected_country($this->country));
  
                        $stocks = $this->bo->read_stocks();
***************
*** 170,175 ****
                                        $this->t->set_var(array
                                        (
!                                               'dsymbol' => 
rawurldecode($stock['symbol']),
!                                               'dname' => 
rawurldecode($stock['name'])
                                        ));
  
--- 212,218 ----
                                        $this->t->set_var(array
                                        (
!                                               'ssymbol' => 
$GLOBALS['phpgw']->strip_html($stock['symbol']),
!                                               'sname' => 
$GLOBALS['phpgw']->strip_html($stock['name']),
!                                               'scountry' => 
$this->sbox->get_full_name($stock['country'])
                                        ));
  
***************
*** 185,188 ****
--- 228,233 ----
                        $link_data['menuaction'] = 'stocks.ui.add_stock';
                        
$this->t->set_var('addurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
+                       
$this->t->set_var('doneurl',$GLOBALS['phpgw']->link('/index.php','menuaction=stocks.ui.index'));
+                       $this->save_sessiondata();
                        $this->t->pfp('out','stock_list_t',True);
                }
***************
*** 191,194 ****
--- 236,240 ----
                {
                        $mainscreen = $GLOBALS['HTTP_GET_VARS']['mainscreen'];
+                       $prefs          = $GLOBALS['HTTP_GET_VARS']['prefs'];
  
                        $link_data = array
***************
*** 197,213 ****
                        );
  
!                       if ($mainscreen)
                        {
                                
$GLOBALS['phpgw']->preferences->read_repository();
!                               if ($mainscreen == 'enable')
                                {
                                        
$GLOBALS['phpgw']->preferences->change('stocks','mainscreen','enabled');
                                }
! 
!                               if ($mainscreen == 'disable')
                                {
!                                       
$GLOBALS['phpgw']->preferences->delete('stocks','mainscreen','disabled');
                                }
! 
                                
$GLOBALS['phpgw']->preferences->save_repository(True);
                                Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php',$link_data));
--- 243,258 ----
                        );
  
!                       if ($prefs['submit'])
                        {
                                
$GLOBALS['phpgw']->preferences->read_repository();
!                               if ($prefs['mainscreen'])
                                {
                                        
$GLOBALS['phpgw']->preferences->change('stocks','mainscreen','enabled');
                                }
!                               else
                                {
!                                       
$GLOBALS['phpgw']->preferences->change('stocks','mainscreen','disabled');
                                }
!                               
$GLOBALS['phpgw']->preferences->change('stocks','country',$prefs['country']);
                                
$GLOBALS['phpgw']->preferences->save_repository(True);
                                Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php',$link_data));
***************
*** 226,243 ****
                        
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
                        $this->t->set_var('lang_action',lang('Stock Quote 
preferences'));
  
!                       if ($prefs['mainscreen'] == 'enabled')
!                       {
!                               $this->t->set_var('lang_display',lang('Display 
stocks on main screen is enabled'));
!                               $newstatus = 'disable';
!                       }
!                       else
!                       {
!                               $this->t->set_var('lang_display',lang('Display 
stocks on main screen is disabled'));
!                               $newstatus = 'enable';
!                       }
  
-                       
$this->t->set_var('newstatus',$GLOBALS['phpgw']->link('/index.php','menuaction=stocks.ui.preferences&mainscreen='
 . $newstatus));
-                       $this->t->set_var('lang_newstatus',lang($newstatus));
                        
$this->t->set_var('doneurl',$GLOBALS['phpgw']->link('/preferences/index.php'));
                        $this->t->pfp('out','stock_prefs',True);
--- 271,281 ----
                        
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
                        $this->t->set_var('lang_action',lang('Stock Quote 
preferences'));
+                       $this->t->set_var('lang_def_country',lang('Default 
country'));
+                       $this->t->set_var('lang_display',lang('Display stocks 
on main screen is enabled'));
+                       $this->t->set_var('mainscreen', '<input type="checkbox" 
name="prefs[mainscreen]" value="True"'
+                                                                               
. ($prefs['mainscreen'] == 'enabled'?' checked':'') . '>');
  
!                       
$this->t->set_var('country_list',$this->selected_country($prefs['country']));
  
                        
$this->t->set_var('doneurl',$GLOBALS['phpgw']->link('/preferences/index.php'));
                        $this->t->pfp('out','stock_prefs',True);
***************
*** 251,257 ****
                        if ($submit)
                        {
!                               $values['symbol']       = 
urlencode(strtoupper($values['symbol']));
!                               $values['name']         = 
urlencode($values['name']);
!                               $this->bo->save_stock(array('access' => 
'public','name' => $values['name'],'symbol' => $values['symbol']));
                                Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php','menuaction=stocks.ui.list_stocks'));
                                $GLOBALS['phpgw']->common->phpgw_exit();
--- 289,295 ----
                        if ($submit)
                        {
!                               $values['symbol']       = 
strtoupper($values['symbol']);
!                               $values['access']       = 'public';
!                               $this->bo->save_stock(array($values));
                                Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php','menuaction=stocks.ui.list_stocks'));
                                $GLOBALS['phpgw']->common->phpgw_exit();
***************
*** 262,266 ****
                        
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php','menuaction=stocks.ui.add_stock'));
                        $this->t->set_var('h_lang_edit',lang('Add stock'));
! 
                        $this->t->set_var('symbol',$symbol);
                        $this->t->set_var('name',$name);
--- 300,304 ----
                        
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php','menuaction=stocks.ui.add_stock'));
                        $this->t->set_var('h_lang_edit',lang('Add stock'));
!                       
$this->t->set_var('country_list',$this->selected_country($country));
                        $this->t->set_var('symbol',$symbol);
                        $this->t->set_var('name',$name);
***************
*** 289,294 ****
                        if ($submit)
                        {
!                               $values['symbol']       = 
urlencode(strtoupper($values['symbol']));
!                               $values['name']         = 
urlencode($values['name']);
                                $values['id']           = $stock_id;
  
--- 327,332 ----
                        if ($submit)
                        {
!                               $values['symbol']       = 
strtoupper($values['symbol']);
!                               $values['access']       = 'public';
                                $values['id']           = $stock_id;
  
***************
*** 308,314 ****
  
                        $stock = $this->bo->read_single($stock_id);
! 
!                       
$this->t->set_var('symbol',rawurldecode($stock['symbol']));
!                       $this->t->set_var('name',rawurldecode($stock['name']));
  
                        $this->t->pfp('out','edit');
--- 346,352 ----
  
                        $stock = $this->bo->read_single($stock_id);
!                       
$this->t->set_var('country_list',$this->selected_country($stock['country']));
!                       
$this->t->set_var('symbol',$GLOBALS['phpgw']->strip_html($stock['symbol']));
!                       
$this->t->set_var('name',$GLOBALS['phpgw']->strip_html($stock['name']));
  
                        $this->t->pfp('out','edit');




reply via email to

[Prev in Thread] Current Thread [Next in Thread]