public static function Save(Affiliation $dbAffiliation, $newAffiliation, $org_name, Member $CurrentMember) { $org_name = Convert::raw2sql($org_name); // attempt to retrieve Org by the submitted name $org = Org::get()->filter('Name', $org_name)->First(); if (!$org) { // no org matched, create a new org of that name and associate it $org = new Org(); $org->Name = $org_name; $org->write(); } $config = HTMLPurifier_Config::createDefault(); // Remove any CSS or inline styles $config->set('CSS.AllowedProperties', array()); $purifier = new HTMLPurifier($config); $dbAffiliation->OrganizationID = $org->ID; $dbAffiliation->JobTitle = $newAffiliation->JobTitle; $dbAffiliation->MemberID = $CurrentMember->ID; $dbAffiliation->StartDate = $newAffiliation->StartDate; $dbAffiliation->EndDate = !empty($newAffiliation->EndDate) ? $newAffiliation->EndDate : null; $dbAffiliation->Current = $newAffiliation->Current == 1 ? true : false; if (empty($newAffiliation->EndDate)) { $dbAffiliation->Current = true; } $dbAffiliation->write(); }
public static function Save(Affiliation $dbAffiliation, $newAffiliation, $org_name, Member $CurrentMember) { $org_name = Convert::raw2sql($org_name); // attempt to retrieve Org by the submitted name $org = Org::get()->filter('Name', $org_name)->First(); if (!$org) { // no org matched, create a new org of that name and associate it $org = new Org(); $org->Name = $org_name; $org->write(); //register new request $new_request = new OrganizationRegistrationRequest(); $new_request->MemberID = $CurrentMember->ID; $new_request->OrganizationID = $org->ID; $new_request->write(); } $config = HTMLPurifier_Config::createDefault(); // Remove any CSS or inline styles $config->set('CSS.AllowedProperties', array()); $purifier = new HTMLPurifier($config); if (!empty($newAffiliation->EndDate) && $newAffiliation->Current == 1) { $today = new DateTime($newAffiliation->ClientToday); $end_date = new DateTime($newAffiliation->EndDate); if ($end_date < $today) { throw new Exception('Current Affiliation: End Date must me greater than today!.'); } } $dbAffiliation->OrganizationID = $org->ID; $dbAffiliation->MemberID = $CurrentMember->ID; $dbAffiliation->StartDate = $newAffiliation->StartDate; $dbAffiliation->EndDate = !empty($newAffiliation->EndDate) ? $newAffiliation->EndDate : null; $dbAffiliation->Current = $newAffiliation->Current == 1 ? true : false; if (empty($newAffiliation->EndDate)) { $dbAffiliation->Current = true; } //$dbAffiliation->JobTitle = $purifier->purify($newAffiliation->JobTitle); //$dbAffiliation->Role = $purifier->purify($newAffiliation->Role); $dbAffiliation->write(); }
* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. **/ PublisherSubscriberManager::getInstance()->subscribe('survey_organization_selected', function ($member, $organization_name) { //create the affiliation as current $organization_name = Convert::raw2sql(trim($organization_name)); if (!empty($organization_name)) { $org = Org::get()->filter(array('Name' => $organization_name))->first(); if (!$org) { $org = new Org(); $org->Name = $organization_name; $org->IsStandardizedOrg = false; $org->write(); //register new request $new_request = new OrganizationRegistrationRequest(); $new_request->MemberID = $member->getIdentifier(); $new_request->OrganizationID = $org->ID; $new_request->write(); } // If a new org name was provided for the member, find / create the new org and update the member record if (!$member->hasCurrentAffiliation($organization_name)) { $newAffiliation = new StdClass(); $newAffiliation->StartDate = date('Y-m-d'); $newAffiliation->EndDate = null; $newAffiliation->Current = 1; $newAffiliation->JobTitle = ""; $newAffiliation->Role = ""; AffiliationController::Save(new Affiliation(), $newAffiliation, $organization_name, $member);
public function NextStep($data, $form) { // Save our work $survey = $this->GetCurrentSurvey(); $form->saveInto($survey); //Update Member if need be if (isset($data['Organization'])) { $org_data = Convert::raw2sql(trim($data['Organization'])); if (!empty($org_data)) { $org = Org::get()->filter(array('Name' => $org_data))->first(); if (!$org) { $org = new Org(); $org->Name = $org_data; $org->IsStandardizedOrg = false; $org->write(); //register new request $new_request = new OrganizationRegistrationRequest(); $new_request->MemberID = Member::currentUserID(); $new_request->OrganizationID = $org->ID; $new_request->write(); } $this->updateMember($org_data); $survey->OrgID = $org->ID; $survey->UpdateDate = SS_Datetime::now()->Rfc2822(); $survey->write(); } } $newIndex = array_search($this->CurrentStep(), DeploymentSurvey::$steps) + 1; if ($form instanceof DeploymentSurveyAboutYouForm) { //check if user info has changed $current_user = Member::currentUser(); $current_user->FirstName = $data['FirstName']; $current_user->Surname = $data['Surname']; $current_user->write(); } if ($form instanceof DeploymentSurveyYourThoughtsForm) { if (strpos($survey->OpenStackActivity, 'Write applications that run on OpenStack') !== false || strpos($survey->OpenStackActivity, 'Manage people who write applications that run on OpenStack') !== false || strpos($survey->OpenStackInvolvement, 'Cloud Consumer') !== false) { //normal flow - Send them to user-survey/AppDevSurvey as normal $newIndex = array_search('AppDevSurvey', DeploymentSurvey::$steps); } else { // Send them to user-survey/Deployments $newIndex = array_search('Deployments', DeploymentSurvey::$steps); } } if ($newIndex > count(DeploymentSurvey::$steps)) { $newIndex = count(DeploymentSurvey::$steps); } $CurrentStep = DeploymentSurvey::$steps[$newIndex]; Session::set('CurrentStep', $CurrentStep); $survey->CurrentStep = $CurrentStep; $DesiredHighestStepIndex = array_search($survey->CurrentStep, DeploymentSurvey::$steps); // The index of this step in the list $HighestStepAllowedIndex = array_search($survey->HighestStepAllowed, DeploymentSurvey::$steps); // The index of the highest allowed step in the list if ($DesiredHighestStepIndex > $HighestStepAllowedIndex) { $survey->HighestStepAllowed = $CurrentStep; } $survey->UpdateDate = SS_Datetime::now()->Rfc2822(); $survey->write(); $this->redirect($this->Link() . $CurrentStep); }