|
From: <gem...@li...> - 2011-11-28 10:49:58
|
Revision: 294
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=294&view=rev
Author: matijsdejong
Date: 2011-11-28 10:49:52 +0000 (Mon, 28 Nov 2011)
Log Message:
-----------
Organizations can now be told they have respondents/
Modified Paths:
--------------
trunk/library/classes/Gems/Default/RespondentAction.php
trunk/library/classes/Gems/User/Organization.php
Modified: trunk/library/classes/Gems/Default/RespondentAction.php
===================================================================
--- trunk/library/classes/Gems/Default/RespondentAction.php 2011-11-28 10:41:05 UTC (rev 293)
+++ trunk/library/classes/Gems/Default/RespondentAction.php 2011-11-28 10:49:52 UTC (rev 294)
@@ -176,6 +176,11 @@
public function afterSave(array $data, $isNew)
{
+ if ($isNew) {
+ // Tell the organization it has at least one user
+ $org = $this->loader->getOrganization($data['gr2o_id_organization']);
+ $org->setHasRespondents($data['grs_id_user']);
+ }
$this->openedRespondent($data['gr2o_patient_nr'], $data['gr2o_id_organization'], $data['grs_id_user']);
return true;
}
Modified: trunk/library/classes/Gems/User/Organization.php
===================================================================
--- trunk/library/classes/Gems/User/Organization.php 2011-11-28 10:41:05 UTC (rev 293)
+++ trunk/library/classes/Gems/User/Organization.php 2011-11-28 10:49:52 UTC (rev 294)
@@ -281,10 +281,42 @@
return $this->_organizationData['gor_welcome'];
}
+ /**
+ * Empty the cache of the organization
+ *
+ * @return Gems_User_Organization (continutation pattern)
+ */
public function invalidateCache() {
if ($this->cache) {
$cacheId = $this->_getCacheId();
$this->cache->remove($cacheId);
}
+ return $this;
}
+
+ /**
+ * Tell the organization there is at least one respondent attached to it.
+ *
+ * Does nothing if this is already known.
+ *
+ * @param int $userId The current user
+ * @return Gems_User_Organization (continutation pattern)
+ */
+ public function setHasRespondents($userId)
+ {
+ if (0 == $this->_organizationData['gor_has_respondents']) {
+ $this->_organizationData['gor_has_respondents'] = 1;
+
+ $values['gor_has_respondents'] = 1;
+ $values['gor_changed'] = new Zend_Db_Expr('CURRENT_TIMESTAMP');
+ $values['gor_changed_by'] = $userId;
+
+ $where = $this->db->quoteInto('gor_id_organization = ?', $this->_organizationId);
+
+ $this->db->update('gems__organizations', $values, $where);
+ $this->invalidateCache();
+ }
+
+ return $this;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|