|
From: <gem...@li...> - 2012-06-29 12:52:12
|
Revision: 802
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=802&view=rev
Author: mennodekker
Date: 2012-06-29 12:52:01 +0000 (Fri, 29 Jun 2012)
Log Message:
-----------
Update to data export: source needs to be active, gems survey status and source survey status are interpreted by a helper method to allow other sources to have their own logic.
Fixed a notice in survey when adding a new survey and tracker::verbose
Modified Paths:
--------------
trunk/library/classes/Gems/Default/ExportAction.php
trunk/library/classes/Gems/Tracker/Survey.php
trunk/library/classes/Gems/Util/DbLookup.php
Modified: trunk/library/classes/Gems/Default/ExportAction.php
===================================================================
--- trunk/library/classes/Gems/Default/ExportAction.php 2012-06-29 10:14:01 UTC (rev 801)
+++ trunk/library/classes/Gems/Default/ExportAction.php 2012-06-29 12:52:01 UTC (rev 802)
@@ -140,8 +140,7 @@
*/
public function getForm(&$data)
{
- //Read some data from tables, initialize defaults...
- $surveys = $this->db->fetchPairs('SELECT gsu_id_survey, gsu_survey_name FROM gems__surveys WHERE gsu_active = 1 ORDER BY gsu_survey_name');
+ $surveys = $this->loader->getUtil()->getDbLookup()->getSurveysForExport();
$organizations = $this->loader->getCurrentUser()->getAllowedOrganizations();
$types = $this->export->getExportClasses();
@@ -151,7 +150,7 @@
//Start adding elements
$element = new Zend_Form_Element_Select('sid');
$element->setLabel($this->_('Survey'))
- ->setMultiOptions($surveys);
+ ->setMultiOptions($surveys);
$elements[] = $element;
//Add a field to the form showing the record count. If this is too slow for large recordsets
Modified: trunk/library/classes/Gems/Tracker/Survey.php
===================================================================
--- trunk/library/classes/Gems/Tracker/Survey.php 2012-06-29 10:14:01 UTC (rev 801)
+++ trunk/library/classes/Gems/Tracker/Survey.php 2012-06-29 12:52:01 UTC (rev 802)
@@ -137,7 +137,8 @@
if (Gems_Tracker::$verbose) {
$echo = '';
foreach ($values as $key => $val) {
- $echo .= $key . ': ' . $this->_gemsSurvey[$key] . ' => ' . $val . "\n";
+ $old = isset($this->_gemsSurvey[$key]) ? $this->_gemsSurvey[$key] : null;
+ $echo .= $key . ': ' . $old . ' => ' . $val . "\n";
}
MUtil_Echo::r($echo, 'Updated values for ' . $this->_surveyId);
}
Modified: trunk/library/classes/Gems/Util/DbLookup.php
===================================================================
--- trunk/library/classes/Gems/Util/DbLookup.php 2012-06-29 10:14:01 UTC (rev 801)
+++ trunk/library/classes/Gems/Util/DbLookup.php 2012-06-29 12:52:01 UTC (rev 802)
@@ -342,6 +342,55 @@
return $groups;
}
+ /**
+ * 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.
+ *
+ * @return array
+ */
+ public function getSurveysForExport()
+ {
+ // Read some data from tables, initialize defaults...
+ $select = $this->db->select();
+
+ // Fetch al surveys
+ $select->from('gems__surveys')
+ ->join('gems__sources', 'gsu_id_source = gso_id_source')
+ ->where('gso_active = 1')
+ ->order(array('gsu_active DESC', 'gsu_survey_name'));
+ $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->translate->_('inactive');
+ $sourceInactive = $this->translate->_('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')) {
+ $surveys[$sourceInactive][$id] = $name;
+ }
+ } elseif ($survey['gsu_active'] == 0) {
+ // Inactive in GemsTracker
+ $surveys[$Inactive][$id] = $name;
+ } else {
+ $surveys[$id] = $name;
+ }
+ }
+ } else {
+ $surveys = array();
+ }
+
+ return $surveys;
+ }
+
public function getUserConsents()
{
static $consents;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|