|
From: <gem...@li...> - 2012-11-16 16:47:12
|
Revision: 1022
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1022&view=rev
Author: matijsdejong
Date: 2012-11-16 16:47:05 +0000 (Fri, 16 Nov 2012)
Log Message:
-----------
Moved AddTrack storage to cache and clear the cache after Track or Survey update
Modified Paths:
--------------
trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php
trunk/library/classes/Gems/Default/TrackMaintenanceAction.php
trunk/library/snippets/AddTracksSnippet.php
Modified: trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php
===================================================================
--- trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php 2012-11-16 11:12:14 UTC (rev 1021)
+++ trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php 2012-11-16 16:47:05 UTC (rev 1022)
@@ -48,6 +48,12 @@
{
public $autoFilter = true;
+ /**
+ *
+ * @var Zend_Cache_Core
+ */
+ public $cache;
+
public $menuEditIncludeLevel = 100;
public $menuShowIncludeLevel = 100;
@@ -232,7 +238,23 @@
}
/**
+ * Hook to perform action after a record (with changes) was saved
*
+ * As the data was already saved, it can NOT be changed anymore
+ *
+ * @param array $data
+ * @param boolean $isNew
+ * @return boolean True when you want to display the default 'saved' messages
+ */
+ public function afterSave(array $data, $isNew)
+ {
+ $this->cache->clean('matchTags', array('surveys', 'tracks'));
+
+ return true;
+ }
+
+ /**
+ *
* @param array $data The data that will be saved.
* @param boolean $isNew
* $param Zend_Form $form
Modified: trunk/library/classes/Gems/Default/TrackMaintenanceAction.php
===================================================================
--- trunk/library/classes/Gems/Default/TrackMaintenanceAction.php 2012-11-16 11:12:14 UTC (rev 1021)
+++ trunk/library/classes/Gems/Default/TrackMaintenanceAction.php 2012-11-16 16:47:05 UTC (rev 1022)
@@ -52,6 +52,12 @@
*/
protected $browseMode;
+ /**
+ *
+ * @var Zend_Cache_Core
+ */
+ public $cache;
+
public $sortKey = array('gtr_track_name' => SORT_ASC);
public $summarizedActions = array('index', 'autofilter', 'check-all');
@@ -145,7 +151,23 @@
}
/**
+ * Hook to perform action after a record (with changes) was saved
*
+ * As the data was already saved, it can NOT be changed anymore
+ *
+ * @param array $data
+ * @param boolean $isNew
+ * @return boolean True when you want to display the default 'saved' messages
+ */
+ public function afterSave(array $data, $isNew)
+ {
+ $this->cache->clean('matchTags', array('surveys', 'tracks'));
+
+ return true;
+ }
+
+ /**
+ *
* @param array $data The data that will be saved.
* @param boolean $isNew
* $param Zend_Form $form
Modified: trunk/library/snippets/AddTracksSnippet.php
===================================================================
--- trunk/library/snippets/AddTracksSnippet.php 2012-11-16 11:12:14 UTC (rev 1021)
+++ trunk/library/snippets/AddTracksSnippet.php 2012-11-16 16:47:05 UTC (rev 1022)
@@ -55,6 +55,12 @@
{
/**
*
+ * @var Zend_Cache_Core
+ */
+ protected $cache;
+
+ /**
+ *
* @var Zend_Db_Adapter_Abstract
*/
public $db;
@@ -85,12 +91,6 @@
protected $request;
/**
- *
- * @var Zend_Session
- */
- public $session;
-
- /**
* Switch to set display of respondent dropdown on or off
*
* @var mixed When string, string is used for display, when false, nothing is displayed
@@ -137,13 +137,11 @@
throw new exception('Invalid track type requested.');
}
- $organization_id = intval($this->request->getParam(MUtil_Model::REQUEST_ID2));
- $trackTypeCache = $trackType . '_' . $organization_id;
- $trackTypeTime = $trackType . '_time';
+ $orgId = intval($this->request->getParam(MUtil_Model::REQUEST_ID2));
+ $cacheId = __CLASS__ . '_' . $trackType . '_' . $orgId;
+ $tracks = $this->cache->load($cacheId);
- if (isset($this->session->$trackTypeCache, $this->session->$trackTypeTime) && (time() < $this->session->$trackTypeTime)) {
- $tracks = $this->session->$trackTypeCache;
- } else {
+ if (! $tracks) {
switch ($trackType) {
case 'T':
$sql = "SELECT gtr_id_track, gtr_track_name
@@ -152,7 +150,7 @@
(gtr_date_until IS NULL OR gtr_date_until > CURRENT_TIMESTAMP) AND
gtr_active = 1 AND
gtr_track_type = 'T' AND
- gtr_organizations LIKE '%|$organization_id|%'
+ gtr_organizations LIKE '%|$orgId|%'
ORDER BY gtr_track_name";
break;
case 'S':
@@ -166,7 +164,7 @@
gtr_active = 1 AND
gtr_track_type = 'S' AND
ggp_respondent_members = 1 AND
- gtr_organizations LIKE '%|$organization_id|%'
+ gtr_organizations LIKE '%|$orgId|%'
ORDER BY gtr_track_name";
break;
case 'M':
@@ -180,7 +178,7 @@
gtr_active = 1 AND
gtr_track_type = 'S' AND
ggp_respondent_members = 0 AND
- gtr_organizations LIKE '%|$organization_id|%'
+ gtr_organizations LIKE '%|$orgId|%'
ORDER BY gtr_track_name";
break;
// default:
@@ -188,8 +186,7 @@
}
$tracks = $this->db->fetchPairs($sql);
- $this->session->$trackTypeCache = $tracks;
- $this->session->$trackTypeTime = time() + 600;
+ $this->cache->save($tracks, $cacheId, array('surveys', 'tracks'));
}
$div = MUtil_Html::create()->div(array('class' => 'toolbox'));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|