/**
  * Show HTML form to make special query
  *
  * @param array $mailGroup Recipient list DB record
  *
  * @return string HTML form to make a special query
  */
 public function cmd_specialQuery($mailGroup)
 {
     $out = "";
     $this->queryGenerator->init('dmail_queryConfig', $this->MOD_SETTINGS['queryTable']);
     if ($this->MOD_SETTINGS['queryTable'] && $this->MOD_SETTINGS['queryConfig']) {
         $this->queryGenerator->queryConfig = $this->queryGenerator->cleanUpQueryConfig(unserialize($this->MOD_SETTINGS['queryConfig']));
         $this->queryGenerator->extFieldLists['queryFields'] = 'uid';
         $out .= $this->queryGenerator->getSelectQuery();
         $out .= '<div style="padding-top: 20px;"></div>';
     }
     $this->queryGenerator->setFormName($this->formname);
     $this->queryGenerator->noWrap = '';
     $this->queryGenerator->allowedTables = $this->allowedTables;
     $tmpCode = $this->queryGenerator->makeSelectorTable($this->MOD_SETTINGS, 'table,query');
     $tmpCode .= '<input type="hidden" name="CMD" value="displayMailGroup" /><input type="hidden" name="group_uid" value="' . $mailGroup['uid'] . '" />';
     $tmpCode .= '<input type="submit" value="' . $this->getLanguageService()->getLL('dmail_updateQuery') . '" />';
     $out .= $this->doc->section($this->getLanguageService()->getLL('dmail_makeQuery'), $tmpCode);
     $theOutput = '<div style="padding-top: 20px;"></div>';
     $theOutput .= $this->doc->section($this->getLanguageService()->getLL('dmail_query'), $out);
     return $theOutput;
 }
 /**
  * Construct the array of uid's from $table selected
  * by special query of mail group of such type
  *
  * @param MailSelect $queryGenerator The query generator object
  * @param string $table The table to select from
  * @param array $group The direct_mail group record
  *
  * @return string The resulting query.
  */
 public static function getSpecialQueryIdList(MailSelect &$queryGenerator, $table, array $group)
 {
     $outArr = array();
     if ($group['query']) {
         $queryGenerator->init('dmail_queryConfig', $table);
         $queryGenerator->queryConfig = $queryGenerator->cleanUpQueryConfig(unserialize($group['query']));
         $whereClause = $queryGenerator->getQuery($queryGenerator->queryConfig) . BackendUtility::deleteClause($table);
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($table . '.uid', $table, $whereClause);
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             $outArr[] = $row['uid'];
         }
         $GLOBALS['TYPO3_DB']->sql_free_result($res);
     }
     return $outArr;
 }