original_string: public function getSurveysForExport($trackId = null, $roundDescription = null, $flat = false)
      {
          // Read some data from tables, initialize defaults...
          $select = $this->db->select();
  
          // Fetch all surveys
          $select->from('gems__surveys')
              ->join('gems__sources', 'gsu_id_source = gso_id_source')
              ->where('gso_active = 1')
              //->where('gsu_surveyor_active = 1')
              // Leave inactive surveys, we toss out the inactive ones for limesurvey
              // as it is no problem for OpenRosa to have them in
              ->order(array('gsu_active DESC', 'gsu_survey_name'));
  
          if ($trackId) {
              if ($roundDescription) {
                  $select->where('gsu_id_survey IN (SELECT gto_id_survey FROM gems__tokens WHERE gto_id_track = ? AND gto_round_description = ' . $this->db->quote($roundDescription) . ')', $trackId);
              } else {
                  $select->where('gsu_id_survey IN (SELECT gto_id_survey FROM gems__tokens WHERE gto_id_track = ?)', $trackId);
              }
          } elseif ($roundDescription) {
              $select->where('gsu_id_survey IN (SELECT gto_id_survey FROM gems__tokens WHERE gto_round_description = ?)', $roundDescription);
          }
  
          $result = $this->db->fetchAll($select);
  
          if ($result) {
              // And transform to have inactive surveys in gems and source in a
              // different group at the bottom
              $surveys = array();
              $inactive = $this->_('inactive');
              $sourceInactive = $this->_('source inactive');
              foreach ($result as $survey) {
                  $id   = $survey['gsu_id_survey'];
                  $name = $survey['gsu_survey_name'];
                  if ($survey['gsu_surveyor_active'] == 0) {
                      // Inactive in the source, for LimeSurvey this is a problem!
                      if (strpos($survey['gso_ls_class'], 'LimeSurvey') === false) {
                          if ($flat) {
                              $surveys[$id] = $name . " ($sourceInactive) ";
                          } else {
                              $surveys[$sourceInactive][$id] = $name;
                          }
                      }
                  } elseif ($survey['gsu_active'] == 0) {
                      if ($flat) {
                          $surveys[$id] = $name . " ($inactive) ";
                      } else {
                          $surveys[$inactive][$id] = $name;
                      }
                  } else {
                      $surveys[$id] = $name;
                  }
              }
          } else {
              $surveys = array();
          }
  
          return $surveys;
      }
code: public function getSurveysForExport($trackId = null, $roundDescription = null, $flat = false)
      {
          // Read some data from tables, initialize defaults...
          $select = $this->db->select();
  
          // Fetch all surveys
          $select->from('gems__surveys')
              ->join('gems__sources', 'gsu_id_source = gso_id_source')
              ->where('gso_active = 1')
              //->where('gsu_surveyor_active = 1')
              // Leave inactive surveys, we toss out the inactive ones for limesurvey
              // as it is no problem for OpenRosa to have them in
              ->order(array('gsu_active DESC', 'gsu_survey_name'));
  
          if ($trackId) {
              if ($roundDescription) {
                  $select->where('gsu_id_survey IN (SELECT gto_id_survey FROM gems__tokens WHERE gto_id_track = ? AND gto_round_description = ' . $this->db->quote($roundDescription) . ')', $trackId);
              } else {
                  $select->where('gsu_id_survey IN (SELECT gto_id_survey FROM gems__tokens WHERE gto_id_track = ?)', $trackId);
              }
          } elseif ($roundDescription) {
              $select->where('gsu_id_survey IN (SELECT gto_id_survey FROM gems__tokens WHERE gto_round_description = ?)', $roundDescription);
          }
  
          $result = $this->db->fetchAll($select);
  
          if ($result) {
              // And transform to have inactive surveys in gems and source in a
              // different group at the bottom
              $surveys = array();
              $inactive = $this->_('inactive');
              $sourceInactive = $this->_('source inactive');
              foreach ($result as $survey) {
                  $id   = $survey['gsu_id_survey'];
                  $name = $survey['gsu_survey_name'];
                  if ($survey['gsu_surveyor_active'] == 0) {
                      // Inactive in the source, for LimeSurvey this is a problem!
                      if (strpos($survey['gso_ls_class'], 'LimeSurvey') === false) {
                          if ($flat) {
                              $surveys[$id] = $name . " ($sourceInactive) ";
                          } else {
                              $surveys[$sourceInactive][$id] = $name;
                          }
                      }
                  } elseif ($survey['gsu_active'] == 0) {
                      if ($flat) {
                          $surveys[$id] = $name . " ($inactive) ";
                      } else {
                          $surveys[$inactive][$id] = $name;
                      }
                  } else {
                      $surveys[$id] = $name;
                  }
              }
          } else {
              $surveys = array();
          }
  
          return $surveys;
      }
code_tokens: public function getSurveysForExport ( $ trackId = null , $ roundDescription = null , $ flat = false ) { // Read some data from tables, initialize defaults... $ select = $ this -> db -> select ( ) ; // Fetch all surveys $ select -> from ( 'gems__surveys' ) -> join ( 'gems__sources' , 'gsu_id_source = gso_id_source' ) -> where ( 'gso_active = 1' ) //->where('gsu_surveyor_active = 1') // Leave inactive surveys, we toss out the inactive ones for limesurvey // as it is no problem for OpenRosa to have them in -> order ( array ( 'gsu_active DESC' , 'gsu_survey_name' ) ) ; if ( $ trackId ) { if ( $ roundDescription ) { $ select -> where ( 'gsu_id_survey IN (SELECT gto_id_survey FROM gems__tokens WHERE gto_id_track = ? AND gto_round_description = ' . $ this -> db -> quote ( $ roundDescription ) . ')' , $ trackId ) ; } else { $ select -> where ( 'gsu_id_survey IN (SELECT gto_id_survey FROM gems__tokens WHERE gto_id_track = ?)' , $ trackId ) ; } } elseif ( $ roundDescription ) { $ select -> where ( 'gsu_id_survey IN (SELECT gto_id_survey FROM gems__tokens WHERE gto_round_description = ?)' , $ roundDescription ) ; } $ result = $ this -> db -> fetchAll ( $ select ) ; if ( $ result ) { // And transform to have inactive surveys in gems and source in a // different group at the bottom $ surveys = array ( ) ; $ inactive = $ this -> _ ( 'inactive' ) ; $ sourceInactive = $ this -> _ ( 'source inactive' ) ; foreach ( $ result as $ survey ) { $ id = $ survey [ 'gsu_id_survey' ] ; $ name = $ survey [ 'gsu_survey_name' ] ; if ( $ survey [ 'gsu_surveyor_active' ] == 0 ) { // Inactive in the source, for LimeSurvey this is a problem! if ( strpos ( $ survey [ 'gso_ls_class' ] , 'LimeSurvey' ) === false ) { if ( $ flat ) { $ surveys [ $ id ] = $ name . " ($sourceInactive) " ; } else { $ surveys [ $ sourceInactive ] [ $ id ] = $ name ; } } } elseif ( $ survey [ 'gsu_active' ] == 0 ) { if ( $ flat ) { $ surveys [ $ id ] = $ name . " ($inactive) " ; } else { $ surveys [ $ inactive ] [ $ id ] = $ name ; } } else { $ surveys [ $ id ] = $ name ; } } } else { $ surveys = array ( ) ; } return $ surveys ; }
docstring: Get all surveys that can be exported
  
  For export not only active surveys should be returned, but all surveys that can be exported.
  As this depends on the kind of source used it is in this method so projects can change to
  adapt to their own sources.
  
  @param int $trackId Optional track id
  @return array
docstring_tokens: Get all surveys that can be exported