Changeset 859

Show
Ignore:
Timestamp:
05/12/09 18:02:16 (4 years ago)
Author:
d0nut
Message:

maybe this works better

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • g-map/optionals/de.gmap.wbb/files/lib/acp/action/UpdateMapAction.class.php

    r763 r859  
    1212class UpdateMapAction extends UpdateCounterAction { 
    1313        public $action = 'UpdateMap'; 
    14         public $everything = true; 
    1514         
    1615        /** 
    17          * updates the user positions 
     16         * @see Action::execute() 
    1817         */ 
    19         private function myupdate($limit, $offset, $google, $col) { 
     18        public function execute() { 
     19                parent::execute(); 
     20                 
     21                $google = new MapDiscover(true); 
     22                 
     23                // fetch column names 
     24                $col = $google->getColumns(); 
     25                 
     26                 
    2027                //Setting default Values. (Location to City) 
    2128                $sql = "UPDATE          wcf".WCF_N."_user_option_value  
     
    3037                // if there is no api key specified - abort 
    3138                if (defined('MAP_API') && MAP_API != "Api-Key") { 
    32                         $sql = "SELECT          userID,  
    33                                                 ".$col['street']." AS street, 
    34                                                 ".$col['zip']." AS zip, 
    35                                                 ".$col['city']." AS city, 
    36                                                 ".$col['country']." AS country 
    37                                 FROM            wcf".WCF_N."_user_option_value 
    38                                 WHERE           (".$col['enable']." = 1 AND ".$col['location']." != '')  
    39                                 GROUP BY        CONCAT(".$col['street'].",".$col['zip'].",".$col['city'].",".$col['country'].") 
    40                                 LIMIT           $limit 
    41                                 OFFSET          $offset"; 
    42                         $result = WCF::getDB()->sendQuery($sql); 
    43  
    44                         while ($row = WCF::getDB()->fetchArray($result)) { 
    45                                 $google->update($row['street'], $row['zip'], $row['city'], $row['country']); 
    46                         } 
     39                        $this->calcProgress(); 
     40                        $this->finish(); 
    4741                } 
    48         } 
    49          
    50         /** 
    51          * @see Action::execute() 
    52          */ 
    53         public function execute() { 
    54                 parent::execute(); 
    55                  
    56                 $google = new MapDiscover(true); 
    57                  
    58                 // fetch column names 
    59                 $col = $google->getColumns(); 
    60                  
     42                 
    6143                // count 
    6244                $sql = "SELECT  COUNT(userID) AS c 
     
    7052                $count = $row['c']; 
    7153 
    72                 $this->myupdate($this->limit, ($this->limit * $this->loop), $google, $col); 
     54                 
     55                $sql = "SELECT          userID,  
     56                                        ".$col['street']." AS street, 
     57                                        ".$col['zip']." AS zip, 
     58                                        ".$col['city']." AS city, 
     59                                        ".$col['country']." AS country 
     60                        FROM            wcf".WCF_N."_user_option_value 
     61                        WHERE           (".$col['enable']." = 1 AND ".$col['location']." != '')  
     62                        GROUP BY        CONCAT(".$col['street'].",".$col['zip'].",".$col['city'].",".$col['country'].")"; 
     63                $result = WCF::getDB()->sendQuery($sql, $this->limit, ($this->limit * $this->loop)); 
     64                if (!WCF::getDB()->countRows($result)) { 
     65                        $this->calcProgress(); 
     66                        $this->finish(); 
     67                } 
     68                while ($row = WCF::getDB()->fetchArray($result)) { 
     69                        $google->update($row['street'], $row['zip'], $row['city'], $row['country']); 
     70                } 
     71                 
    7372                $this->executed(); 
    7473 
    75                 if($this->everything) { 
    76                         $this->calcProgress(($this->limit * $this->loop), $count); 
    77                         $this->nextLoop(); 
    78                 } 
     74                $this->calcProgress(($this->limit * $this->loop), $count); 
     75                $this->nextLoop(); 
    7976        } 
    8077}