コード例 #1
0
 function extractGroup($record_ids)
 {
     // get pages
     if (!empty($record_ids['pages'])) {
         $tables = array('fe_users', 'fe_groups', 'tt_address', 'tt_address_group', 'tx_odsosm_track');
         $pids = implode(',', $record_ids['pages']);
         foreach ($tables as $table) {
             $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', $table, 'pid IN (' . $pids . ')' . $this->cObj->enableFields($table));
             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                 $record_ids[$table][] = $row['uid'];
             }
         }
     }
     // get records
     $records = array();
     foreach ($record_ids as $table => $items) {
         foreach ($items as $item) {
             $item = intval($item);
             switch ($table) {
                 case 'fe_groups':
                     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'fe_groups', 'uid=' . $item . $this->cObj->enableFields('fe_groups'));
                     $group = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
                     if ($group) {
                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'fe_users', 'FIND_IN_SET("' . $item . '",usergroup)' . $this->cObj->enableFields('fe_users'));
                         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                             $records['fe_users'][$row['uid']] = $row;
                             $records['fe_users'][$row['uid']]['group_uid'] = 'fe_groups_' . $group['uid'];
                             $records['fe_users'][$row['uid']]['group_title'] = $group['title'];
                             $records['fe_users'][$row['uid']]['group_description'] = $group['description'];
                             $records['fe_users'][$row['uid']]['tx_odsosm_marker'] = $group['tx_odsosm_marker'];
                         }
                     }
                     break;
                 case 'tt_address_group':
                     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_address_group', 'uid=' . $item . tx_odsosm_div::getWhere('tt_address_group'));
                     $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
                     $group = tx_odsosm_div::getOverlay('tt_address_group', $row);
                     if ($group) {
                         $res = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tt_address.*', 'tt_address', 'tt_address_group_mm', 'tt_address_group', 'AND tt_address_group.uid=' . intval($group['uid']) . $this->cObj->enableFields('tt_address'));
                         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                             $records['tt_address'][$row['uid']] = $row;
                             $records['tt_address'][$row['uid']]['group_uid'] = 'tt_address_group_' . $group['uid'];
                             $records['tt_address'][$row['uid']]['group_title'] = $group['title'];
                             $records['tt_address'][$row['uid']]['group_description'] = $group['description'];
                             $records['tt_address'][$row['uid']]['tx_odsosm_marker'] = $group['tx_odsosm_marker'];
                         }
                     }
                     break;
                 default:
                     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'uid=' . $item . $this->cObj->enableFields($table));
                     $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
                     if ($row) {
                         $records[$table][$item] = $row;
                     }
                     break;
             }
         }
     }
     // Hook to change records
     foreach ($this->hooks as $hook) {
         if (method_exists($hook, 'changeRecords')) {
             $hook->changeRecords($records, $record_ids, $this);
         }
     }
     // get lon&lat
     foreach ($records as $table => $items) {
         foreach ($items as $uid => $row) {
             switch ($table) {
                 case 'fe_users':
                 case 'tt_address':
                     if ($row['tx_odsosm_lon']) {
                         $this->lons[] = floatval($row['tx_odsosm_lon']);
                         $this->lats[] = floatval($row['tx_odsosm_lat']);
                     } else {
                         unset($records[$table][$uid]);
                     }
                     break;
                 case 'tx_odsosm_track':
                 case 'tx_odsosm_vector':
                     if ($row['min_lon']) {
                         $this->lons[] = floatval($row['min_lon']);
                         $this->lats[] = floatval($row['min_lat']);
                         $this->lons[] = floatval($row['max_lon']);
                         $this->lats[] = floatval($row['max_lat']);
                     } else {
                         unset($records[$table][$uid]);
                     }
                     break;
             }
         }
     }
     // No markers
     if (count($this->lons) == 0) {
         if ($this->config['no_marker'] == 1) {
             $this->lons[] = $this->config['lon'];
             $this->lats[] = $this->config['lat'];
         }
     }
     return $records;
 }