Changeset 1306

Show
Ignore:
Timestamp:
02/21/11 20:41:00 (2 years ago)
Author:
Torben Brodt
Message:

working on custom input fields for g-map

Location:
g-map
Files:
14 added
5 modified

Legend:

Unmodified
Added
Removed
  • g-map/files/lib/data/gmap/GmapApi.class.php

    r1301 r1306  
    3838        public function isActive() { 
    3939                return !empty($this->apikey); 
     40        } 
     41         
     42        public function getFields() { 
     43                if(defined('GMAP_CUSTOMINPUT') && !empty(GMAP_CUSTOMINPUT)) { 
     44                        $cols = explode(",", GMAP_CUSTOMINPUT); 
     45                } else { 
     46                        $cols = array('location'); 
     47                } 
     48                return $cols; 
     49        } 
     50         
     51        public function getColumn() { 
     52                $cols = array(); 
     53                foreach($this->getFields() as $field) { 
     54                        $cols[] = User::getUserOptionID($field); 
     55                } 
     56 
     57                $col = array(); 
     58                foreach($cols as $id) { 
     59                        $col[] = 'CONCAT(userOption'.$id.', IF(userOption'.$id.' = '', '', ' '))'; 
     60                } 
     61                $col = 'CONCAT('.implode(',', $col).')'; 
     62                 
     63                return $col; 
    4064        } 
    4165         
  • g-map/files/lib/system/event/listener/GMapUserProfileEditFormListener.class.php

    r1247 r1306  
    2424         
    2525        protected function saved() { 
    26                 if($this->eventObj->activeCategory == 'profile' && isset($this->eventObj->values['location'])) { 
     26                if($this->eventObj->activeCategory == 'profile') { 
     27                        require_once(WCF_DIR.'lib/data/gmap/GmapApi.class.php'); 
     28                        $api = new GmapApi(); 
    2729 
    28                         // update user location                  
    29                         if(!empty($this->eventObj->values['location'])) { 
    30                                 require_once(WCF_DIR.'lib/data/gmap/GmapApi.class.php'); 
    31                                 $api = new GmapApi(); 
    32                                 $point = $api->search($this->eventObj->values['location']); 
    33                  
    34                                 if($point) { 
    35                                         $sql = "REPLACE INTO    wcf".WCF_N."_gmap_user 
    36                                                                 (userID, pt) 
    37                                                 VALUES          (".intval($this->eventObj->user->userID).", 
    38                                                                 PointFromText('POINT(".$point['lon']." ".$point['lat'].")'))"; 
    39                                         WCF::getDB()->sendQuery($sql); 
     30                        // build search query 
     31                        $search = array(); 
     32                        foreach($api->getFields() as $key) { 
     33                                if(isset($this->eventObj->values[$key])) { 
     34                                        $search[] = $this->eventObj->values[$key]; 
    4035                                } 
     36                        } 
     37                         
     38                        // wrong form 
     39                        if(count($search) == 0) { 
     40                                return; 
     41                        } 
     42 
     43                        $point = $api->search(implode(' ', $search)); 
     44         
     45                        if($point) { 
     46                                $sql = "REPLACE INTO    wcf".WCF_N."_gmap_user 
     47                                                        (userID, pt) 
     48                                        VALUES          (".intval($this->eventObj->user->userID).", 
     49                                                        PointFromText('POINT(".$point['lon']." ".$point['lat'].")'))"; 
     50                                WCF::getDB()->sendQuery($sql); 
    4151                        } 
    4252 
  • g-map/optionals/de.gmap.wbb/files/lib/acp/action/UpdateMapAction.class.php

    r1257 r1306  
    1919                parent::execute(); 
    2020 
    21                 $col = User::getUserOptionID('location'); 
    2221                $api = new GmapApi(); 
    23  
    24                 if(empty($col) || !$api->isActive()) { 
     22                if(!$api->isActive()) { 
    2523                        $this->calcProgress(); 
    2624                        $this->finish(); 
    2725                } 
    2826 
    29                 $col = "userOption".$col; 
     27                $col = $api->getColumn(); 
    3028 
    3129                // count board 
  • g-map/optionals/de.gmap.wbb/package.xml

    r1282 r1306  
    1010                <packagedescription language="it"><![CDATA[Questo pacchetto aggiunge alcune ottimizzazioni WBB al G-Map per WCF.]]></packagedescription> 
    1111                <isunique>0</isunique> 
    12                 <version>2.0.1</version> 
     12                <version>2.1.0</version> 
    1313                <date>DATE</date> 
    1414                <plugin>com.woltlab.wbb</plugin> 
     
    3232                <languages languagecode="en">en.xml</languages> 
    3333                <languages languagecode="it">it.xml</languages> 
     34        </instructions> 
     35 
     36        <instructions type="update" fromversion="2.0.1"> 
     37                <files>files.tar</files> 
    3438        </instructions> 
    3539 
  • g-map/package.xml

    r1301 r1306  
    2121         
    2222        <requiredpackages> 
    23                 <requiredpackage minversion="1.1.0 Beta 3">com.woltlab.wcf</requiredpackage> 
     23                <requiredpackage minversion="1.1.0">com.woltlab.wcf</requiredpackage> 
    2424                <requiredpackage minversion="1.0.4">com.woltlab.wcf.page.user.profile</requiredpackage> 
    2525                <requiredpackage minversion="1.0.0" file="requirements/com.woltlab.wcf.data.gmap.tar.gz">com.woltlab.wcf.data.gmap</requiredpackage>