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(); }
/** * @param ISummit $summit * @param array $attendee_data * @return mixed */ public function updateAttendee(ISummit $summit, array $attendee_data) { $attendee_repository = $this->attendee_repository; return $this->tx_service->transaction(function () use($summit, $attendee_data, $attendee_repository) { if (!isset($attendee_data['id'])) { throw new EntityValidationException('missing required param: id'); } $member_id = $attendee_data['member']; $attendee_id = intval($attendee_data['id']); $attendee = $attendee_repository->getByMemberAndSummit($member_id, $summit->getIdentifier()); if ($attendee && $attendee->ID != $attendee_id) { throw new EntityValidationException('This member is already assigned to another tix'); } $attendee = $attendee_repository->getById($attendee_id); if (is_null($attendee)) { throw new NotFoundEntityException('Summit Attendee', sprintf('id %s', $attendee_id)); } if (intval($attendee->SummitID) !== intval($summit->getIdentifier())) { throw new EntityValidationException('attendee doest not belong to summit'); } $attendee->MemberID = $member_id; $attendee->SharedContactInfo = $attendee_data['share_info']; if ($attendee_data['checked_in']) { $attendee->registerSummitHallChecking(); } else { $attendee->SummitHallCheckedIn = $attendee_data['checked_in']; } if ($attendee->Member() && $attendee->Member()->Speaker()->ID) { $attendee->Member()->Speaker()->Title = $attendee_data['title']; $attendee->Member()->Speaker()->FirstName = $attendee_data['first_name']; $attendee->Member()->Speaker()->LastName = $attendee_data['last_name']; $attendee->Member()->Speaker()->Bio = $attendee_data['bio']; $attendee->Member()->Speaker()->write(); } if ($attendee->Member()) { $current_affiliation = $attendee->Member()->getcurrentAffiliation(); if (!$current_affiliation) { $current_affiliation = new Affiliation(); } $current_affiliation->OrganizationID = $attendee_data['aff_company']; $current_affiliation->StartDate = $attendee_data['aff_from']; $current_affiliation->EndDate = $attendee_data['aff_to']; $current_affiliation->Current = $attendee_data['aff_current']; $current_affiliation->write(); $attendee->Member()->Affiliations()->add($current_affiliation); } return $attendee; }); }