From 8730264859dd3d4291a1e5333e9e252a3d0623f5 Mon Sep 17 00:00:00 2001 From: Sebastian Marcet Date: Mon, 8 Dec 2014 11:17:59 -0300 Subject: [PATCH] [smarcet] - #7856 * fix on user survey --- .../DeploymentSurveyPage.php | 4 ++-- registration/code/MemberDecorator.php | 24 +++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/openstack/code/deployment-survey/DeploymentSurveyPage.php b/openstack/code/deployment-survey/DeploymentSurveyPage.php index 608d512..9e7c471 100644 --- a/openstack/code/deployment-survey/DeploymentSurveyPage.php +++ b/openstack/code/deployment-survey/DeploymentSurveyPage.php @@ -116,7 +116,7 @@ HTML; class DeploymentSurveyPage_Controller extends Page_Controller { - static $allowed_actions = array( + private static $allowed_actions = array( 'Login', 'OrgInfo', 'AppDevSurvey', @@ -290,7 +290,7 @@ class DeploymentSurveyPage_Controller extends Page_Controller if (isset($data['Organization'])) { $org_data = Convert::raw2sql(trim($data['Organization'])); if (!empty($org_data)) { - $org = DataObject::get_one('Org', " Name = '{$org_data}' "); + $org = Org::get()->filter(array('Name' => $org_data))->first(); if (!$org) { $org = new Org; $org->Name = $org_data; diff --git a/registration/code/MemberDecorator.php b/registration/code/MemberDecorator.php index db641a0..f4d9ca5 100644 --- a/registration/code/MemberDecorator.php +++ b/registration/code/MemberDecorator.php @@ -183,17 +183,27 @@ class MemberDecorator extends DataExtension { public function hasCurrentAffiliation($org){ $org = Convert::raw2sql($org); + $affiliations = $this->owner->Affiliations(); + + $affiliations = $affiliations->filterAny(array( + 'Current' => '1', + 'EndDate' => 'NULL', + )); + if(is_numeric($org)){ - $org = intval($org); - $org_filter = " OrganizationID = {$org}"; + + $affiliations = $affiliations->filter(array( + 'OrganizationID' => intval($org) + )); } else{ - $org_filter = " Org.Name = '{$org}' "; + + $affiliations->innerJoin('Org','Org.ID = Affiliation.OrganizationID','O'); + $affiliations = $affiliations->filter(array( + 'O.Name' => $org + )); } - $res = $this->owner->Affiliations("(Current=1 OR EndDate IS NULL ) AND {$org_filter}"); - if(!is_numeric($org)) - $res->leftJoin('Org','Org.ID = Affiliation.OrganizationID'); - return $res->count() > 0; + return $affiliations->count() > 0; } public function getCurrentOrganization(){