/** * @param string $first_name * @param string $last_name * @return ICommunityMember[] */ public function getAllByName($first_name, $last_name) { $query = new QueryObject(new Member()); $query->addAndCondition(QueryCriteria::equal('FirstName', $first_name)); $query->addAndCondition(QueryCriteria::equal('Surname', $last_name)); return $this->getAll($query, 0, 999999); }
/** * @param string $last_name * @param int $offset * @param int $limit * @return array */ function getAllIClaMembersByLastName($last_name, $offset, $limit) { $query = new QueryObject(); $query->addAndCondition(QueryCriteria::equal('CLASigned', true)); $query->addAndCondition(QueryCriteria::like('Surname', $last_name)); return $this->getAll($query, $offset, $limit); }
public function getNominationsByNominee($member_id, $offset = 0, $limit = 10) { $query = new QueryObject(new CandidateNomination()); $query->addAlias(QueryAlias::create('Candidate')); $query->addAndCondition(QueryCriteria::equal('Member.ID', $member_id)); return $this->getAll($query, $offset, $limit); }
/** * @param string $dupe_account_email * @return IDupeMemberActionAccountRequest */ public function findByDupeAccount($dupe_account_email) { $query = new QueryObject(new $this->entity_class()); $query->addAlias(QueryAlias::create('DupeAccount')); $query->addAndCondition(QueryCriteria::equal('Member.Email', $dupe_account_email)); return $this->getBy($query); }
/** * @param int $template_id * @param int $creator_id * @return ISurvey|null */ public function getByTemplateAndCreator($template_id, $creator_id) { $query = new QueryObject(); $query->addAndCondition(QueryCriteria::equal('TemplateID', $template_id)); $query->addAndCondition(QueryCriteria::equal('CreatedByID', $creator_id)); return $this->getBy($query); }
/** * @param int $offset * @param int $limit * @return array */ public function getAllApproved($offset = 0, $limit = 100) { $query = new QueryObject(new MarketPlaceReview()); $query->addAndCondition(QueryCriteria::equal('Approved', 1)); $query->addOrder(QueryOrder::desc('Created')); return $this->getAll($query, $offset, $limit); }
/** * @param string $promo_code_type * @param int $batch_size * @return ISpeakerSummitRegistrationPromoCode */ public function getNextAvailableByType($promo_code_type, $batch_size = 10) { switch ($promo_code_type) { case ISpeakerSummitRegistrationPromoCode::TypeAccepted: if (count($this->promo_code_speaker_session_pool) === 0) { $query = new QueryObject(new SpeakerSummitRegistrationPromoCode()); $query->addAndCondition(QueryCriteria::equal('Type', $promo_code_type)); $query->addAndCondition(QueryCriteria::equal('OwnerID', 0)); $query->addAndCondition(QueryCriteria::equal('SpeakerID', 0)); $query->addAndCondition(QueryCriteria::equal('SummitID', Summit::get_active()->ID)); $query->addOrder(QueryOrder::asc('ID')); list($this->promo_code_speaker_session_pool, $count) = $this->getAll($query, 0, $batch_size); } return array_shift($this->promo_code_speaker_session_pool); break; case ISpeakerSummitRegistrationPromoCode::TypeAlternate: if (count($this->promo_code_alternate_speaker_session_pool) === 0) { $query = new QueryObject(new SpeakerSummitRegistrationPromoCode()); $query->addAndCondition(QueryCriteria::equal('Type', $promo_code_type)); $query->addAndCondition(QueryCriteria::equal('OwnerID', 0)); $query->addAndCondition(QueryCriteria::equal('SpeakerID', 0)); $query->addAndCondition(QueryCriteria::equal('SummitID', Summit::get_active()->ID)); $query->addOrder(QueryOrder::asc('ID')); list($this->promo_code_alternate_speaker_session_pool, $count) = $this->getAll($query, 0, $batch_size); } return array_shift($this->promo_code_alternate_speaker_session_pool); break; } return null; }
/** * @param int $event_id * @param int $page * @param int $page_size * @return IRSVP|null */ public function getByEventPaged($event_id, $page, $page_size) { $query = new QueryObject(); $query->addAndCondition(QueryCriteria::equal('EventID', $event_id)); $offset = ($page - 1) * $page_size; return $this->getAll($query, $offset, $page_size); }
/** * @param int $offset * @param int $limit * @return array */ public function getAllNotPostedAndNotRejected($offset = 0, $limit = 10) { $query = new QueryObject(); $query->addAndCondition(QueryCriteria::equal('isPosted', 0)); $query->addAndCondition(QueryCriteria::equal('isRejected', 0)); return $this->getAll($query, $offset, $limit); }
/** * @param int $batch_size * @param string $email_alert_to * @param string $details_url */ public function makeDigest($batch_size = 15, $email_alert_to, $details_url) { $email_repository = $this->email_repository; $repository = $this->repository; $factory = $this->factory; $this->tx_manager->transaction(function () use($batch_size, $email_alert_to, $details_url, $repository, $email_repository, $factory) { $last_email = $email_repository->getLastOne(); $query = new QueryObject(); $query->addAndCondition(QueryCriteria::equal('isPosted', 0)); $query->addAndCondition(QueryCriteria::equal('isRejected', 0)); if ($last_email) { $query->addAndCondition(QueryCriteria::greater('ID', $last_email->getLastEventRegistrationRequest()->getIdentifier())); } $query->addOrder(QueryOrder::asc('PostDate')); list($list, $size) = $repository->getAll($query, 0, $batch_size); if ($list && count($list) > 0) { $last_one = end($list); reset($list); $email = EmailFactory::getInstance()->buildEmail(EVENT_REGISTRATION_REQUEST_EMAIL_FROM, $email_alert_to, "New Event Registration Requests"); $email->setTemplate('EventAlertEmail'); $email->populateTemplate(array('RegistrationRequests' => new ArrayList($list), 'Details' => $details_url)); $email->send(); $email_repository->add($factory->buildEventAlertEmail($last_one)); } }); }
public function getFeedback($event_id, $member_id) { $query = new QueryObject(new SummitEventFeedback()); $query->addAndCondition(QueryCriteria::equal('OwnerID', $member_id)); $query->addAndCondition(QueryCriteria::equal('EventID', $event_id)); return $this->getBy($query); }
/** * @return bool */ public function isScheduled($event_id) { $query = new QueryObject($this); $query->addAndCondition(QueryCriteria::equal('SummitEvent.ID', $event_id)); $events = AssociationFactory::getInstance()->getMany2ManyAssociation($this, 'Schedule', $query)->toArray(); return count($events) > 0; }
/** * @param string $email * @param ITeam $team * @return ITeamInvitation */ public function findByInviteEmailAndTeam($email, ITeam $team) { $query = new QueryObject(); $query->addAndCondition(QueryCriteria::equal('Email', $email)); $query->addAndCondition(QueryCriteria::equal('TeamID', $team->getIdentifier())); return $this->getBy($query); }
/** * @param string $name * @param int $company_id * @return ITeam */ public function getByNameAndCompany($name, $company_id) { $query = new QueryObject(new Team()); $query->addAndCondition(QueryCriteria::equal('CompanyID', $company_id)); $query->addAndCondition(QueryCriteria::equal('Name', $name)); return $this->getBy($query); }
/** * @return ITraining[] */ public function getTrainings() { $query = new QueryObject(); $query->addAndCondition(QueryCriteria::equal('ClassName', 'TrainingService')); $query->addAndCondition(QueryCriteria::equal('Active', true)); $query = (string) $query; return $this->owner->Services($query); }
/** * @param int $offset * @param int $limit * @return array */ public function getAllPosted($offset = 0, $limit = 10) { $query = new QueryObject(); $query->addAndCondition(QueryCriteria::equal('Active', 1)); $query->addAndCondition(QueryCriteria::greater('ExpirationDate', date('Y-m-d'))); $query->addOrder(QueryOrder::desc('JobPostedDate')); return $this->getAll($query, $offset, $limit); }
public function getLastIdInserted($summit_id) { $query = new QueryObject(new SummitType()); $query->addAndCondition(QueryCriteria::equal('SummitID', $summit_id)); $query->addOrder(QueryOrder::desc('ID')); list($list, $count) = $this->getAll($query, 0, 1); return array_pop($list)->ID; }
/** * @param int $event_id * @param string $seat_type * @return IRSVP[] */ public function getByEventAndType($event_id, $seat_type = null) { $query = new QueryObject(); $query->addAndCondition(QueryCriteria::equal('EventID', $event_id)); if ($seat_type) { $query->addAndCondition(QueryCriteria::equal('SeatType', $seat_type)); } return $this->getAll($query); }
/** * @param string $query * @return GeoCodingQueryResult */ public function getByGeoQuery($query) { $qo = new QueryObject(); $qo->addAndCondition(QueryCriteria::equal('Query', $query)); $res = GeoCodingQuery::get()->where((string) $qo)->first(); if (!$res) { return false; } return new GeoCodingQueryResult((double) $res->Lat, (double) $res->Lng); }
/** * @param int $id * @param array $params * @return void * @throws EntityAlreadyExistsException */ protected function checkDuplicatedEntityCriteria($id, array $params) { if (@$params['name']) { $query = new QueryObject(); $query->addAndCondition(QueryCriteria::equal('Name', $params['name'])); $query->addAndCondition(QueryCriteria::notEqual('ID', $id)); $old_one = $this->repository->get($query); if ($old_one) { throw new EntityAlreadyExistsException($this->entity_class, sprintf('%s %s', 'name', $params['name'])); } } }
/** * @return JoinSpecification[] */ public function build() { $specs = array(); $relation_name = $this->alias->getName(); $class_name = ClassInfo::baseDataClass($this->base_entity); $child_class = $this->relations[$relation_name]; $child_hierarchy = ClassInfo::dataClassesFor($child_class); $base_child_class = array_shift($child_hierarchy); $join_field = $this->base_entity->getRemoteJoinField($relation_name, 'has_many'); $specs[] = new JoinSpecification($base_child_class, $base_child_class . '.' . $join_field . ' = ' . $class_name . '.ID'); $this->base_table = $base_child_class; $this->query->addAndCondition(QueryCriteria::equal("{$base_child_class}.ClassName", $child_class)); return $specs; }
public function processNotifications($batch_size) { $notifications_repository = $this->notifications_repository; return $this->tx_manager->transaction(function () use($batch_size, $notifications_repository) { $qty = 0; $query = new QueryObject(); $query->addAndCondition(QueryCriteria::equal('IsSent', 0)); list($list, $size) = $notifications_repository->getAll($query, 0, $batch_size); // init parse ... ParseClient::initialize(PARSE_APP_ID, PARSE_REST_KEY, PARSE_MASTER_KEY); foreach ($list as $notification) { if (empty($notification->Message)) { continue; } $message = array("data" => array('alert' => $notification->Message)); // Push to speakers try { switch ($notification->Channel) { case 'SPEAKERS': $message['channels'] = ['speakers']; break; case 'ATTENDEES': $message['channels'] = ['attendees']; break; case 'MEMBERS': $recipients = array(); foreach ($notification->Recipients() as $m) { array_push($recipients, 'me_' . $m->ID); } $message['channels'] = $recipients; break; case 'SUMMIT': $message['channels'] = ['su_' . $notification->SummitID]; break; case 'ALL': $message['where'] = ParseInstallation::query(); break; } ParsePush::send($message); $notification->sent(); ++$qty; } catch (Exception $ex) { SS_Log::log($ex->getMessage(), SS_Log::ERR); } } return $qty; }); }
public function getDateSortedJobs($foundation = 0) { $query = new QueryObject(new JobPage()); if ($foundation) { $query->addAndCondition(QueryCriteria::equal('FoundationJob', 1)); } $now = new DateTime(); $six_months_ago = new DateTime(); $query->addAndCondition(QueryCriteria::equal('Active', 1)); $post_date = $six_months_ago->sub(new DateInterval('P6M')); $query->addAndCondition(QueryCriteria::greaterOrEqual('JobPostedDate', $post_date->format('Y-m-d'))); $query->addAndCondition(QueryCriteria::greaterOrEqual('ExpirationDate', $now->format('Y-m-d'))); $query->addOrder(QueryOrder::desc('JobPostedDate')); $query->addOrder(QueryOrder::desc('ID')); list($jobs, $size) = $this->getAll($query, 0, 1000); return new ArrayList($jobs); }
public function DateSortedJobs() { $query = new QueryObject(new JobPage()); $request = Controller::curr()->getRequest(); if ($request->requestVar('foundation')) { $query->addAndCondition(QueryCriteria::equal('FoundationJob', 1)); } $now = new DateTime(); $query->addAndCondition(QueryCriteria::equal('Active', 1)); $post_date = $now->sub(new DateInterval('P6M')); $query->addAndCondition(QueryCriteria::greaterOrEqual('JobPostedDate', $post_date->format('Y-m-d'))); $query->addAndCondition(QueryCriteria::greaterOrEqual('ExpirationDate', $now->format('Y-m-d'))); $query->addOrder(QueryOrder::desc('JobPostedDate')); $query->addOrder(QueryOrder::desc('ID')); list($jobs, $size) = $this->repository->getAll($query, 0, 1000); return new ArrayList($jobs); }
public function getDataCenterLocationsJson() { $locations = array(); $query = new QueryObject(); $query->addAndCondition(QueryCriteria::equal("Active", true)); list($list, $size) = $this->public_cloud_repository->getAll($query, 0, 1000); foreach ($list as $public_cloud) { foreach ($public_cloud->getDataCentersLocations() as $location) { $json_data = array(); $json_data['color'] = $location->getDataCenterRegion()->getColor(); $json_data['country'] = Geoip::countryCode2name($location->getCountry()); $json_data['city'] = $location->getCity(); $json_data['lat'] = $location->getLat(); $json_data['lng'] = $location->getLng(); $json_data['product_name'] = $public_cloud->getName(); $json_data['product_url'] = $this->buildCloudLink($public_cloud->getCompany()->URLSegment . '/' . strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $public_cloud->getName())))); $json_data['owner'] = $public_cloud->getCompany()->getName(); array_push($locations, $json_data); } } return json_encode($locations); }
public function getPackagesPurchaseOrder() { $query = new QueryObject(new SummitPackagePurchaseOrder()); $status = $this->getFilterParamStatus(); switch ($status) { case 'pending': $query->addAndCondition(QueryCriteria::equal('Approved', 0)); $query->addAndCondition(QueryCriteria::equal('Rejected', 0)); break; case 'approved': $query->addAndCondition(QueryCriteria::equal('Approved', 1)); $query->addAndCondition(QueryCriteria::equal('Rejected', 0)); break; case 'rejected': $query->addAndCondition(QueryCriteria::equal('Approved', 0)); $query->addAndCondition(QueryCriteria::equal('Rejected', 1)); break; } $query->addOrder(QueryOrder::asc('Created')); list($list, $count) = $this->packages_repository->getAll($query, 0, 999999); return new ArrayList($list); }
public function getJobsByKeywordTypeAndSortedBy($keywords, $type_id, $sort_by) { $query = new QueryObject(new Job()); $now = new DateTime(); $six_months_ago = new DateTime(); $post_date = $six_months_ago->sub(new DateInterval('P6M')); $query->addAndCondition(QueryCriteria::equal('IsActive', 1)); $query->addAndCondition(QueryCriteria::greaterOrEqual('PostedDate', $post_date->format('Y-m-d H:i:s'))); $query->addAndCondition(QueryCriteria::greaterOrEqual('ExpirationDate', $now->format('Y-m-d H:i:s'))); if (!empty($keywords)) { $query->addAndCondition(QueryCompoundCriteria::compoundOr([QueryCriteria::like('Title', trim($keywords)), QueryCriteria::like('Description', trim($keywords))])); } if (intval($type_id) > 0) { $query->addAndCondition(QueryCriteria::equal('TypeID', $type_id)); } if (!empty($sort_by)) { switch (strtolower($sort_by)) { case 'coa': $query = $query->addOrder(QueryOrder::desc('IsCOANeeded')); break; case 'foundation': $query = $query->addOrder(QueryOrder::desc('IsFoundationJob')); break; case 'company': $query = $query->addOrder(QueryOrder::asc('CompanyName')); break; case 'posted': $query = $query->addOrder(QueryOrder::desc('PostedDate')); $query = $query->addOrder(QueryOrder::desc('ID')); break; case 'location': $query = $query->addOrder(QueryOrder::asc('LocationType')); break; } } list($jobs, $size) = $this->getAll($query, 0, PHP_INT_MAX); return new ArrayList($jobs); }
public function getAlias($join_type = QueryAlias::INNER) { $join = array(); foreach ($this->alias as $alias) { if ($alias->getJoinType() !== $join_type) { continue; } $child = $alias->getName(); $has_many = Config::inst()->get(get_class($this->base_entity), 'has_many'); $class_name = ClassInfo::baseDataClass($this->base_entity); if (!is_null($has_many)) { $has_many_classes = array_flip($has_many); if (array_key_exists($child, $has_many_classes)) { $tableClasses = ClassInfo::dataClassesFor($child); $baseClass = array_shift($tableClasses); $joinField = $this->base_entity->getRemoteJoinField($has_many_classes[$child], 'has_many'); $join[$baseClass] = $baseClass . '.' . $joinField . ' = ' . $class_name . '.ID'; $this->addAndCondition(QueryCriteria::equal("{$baseClass}.ClassName", $child)); } } $has_many_many = Config::inst()->get(get_class($this->base_entity), 'many_many'); if (!is_null($has_many_many)) { $has_many_many_classes = array_flip($has_many_many); if (array_key_exists($child, $has_many_many_classes)) { $base_entity_name = get_class($this->base_entity); $component = $has_many_many_classes[$child]; $joinTable = "{$base_entity_name}_{$component}"; $parentField = $base_entity_name . "ID"; $childField = $child . "ID"; $join[$joinTable] = $joinTable . '.' . $parentField . ' = ' . $class_name . '.ID'; $join[$child] = $child . '.ID = ' . $joinTable . '.' . $childField; } } $has_one = Config::inst()->get(get_class($this->base_entity), 'has_one'); if (!is_null($has_one)) { if (array_key_exists($child, $has_one)) { $table = $has_one[$child]; $join[$table] = $has_one[$child] . '.ID = ' . $class_name . '.' . $child . 'ID'; } else { $has_one_classes = array_flip($has_one); if (array_key_exists($child, $has_one_classes)) { $join[$child] = $child . '.ID = ' . $class_name . '.' . $has_one_classes[$child] . 'ID'; } } } $belongs_many_many = Config::inst()->get(get_class($this->base_entity), 'belongs_many_many'); if (!is_null($belongs_many_many)) { $belongs_many_many_classes = array_flip($belongs_many_many); if (array_key_exists($child, $belongs_many_many_classes)) { $child_many_many = Config::inst()->get($child, 'many_many'); $child_many_many_classes = array_flip($child_many_many); $component_name = $child_many_many_classes[$class_name]; list($parentClass, $componentClass, $child_join_field, $join_field, $join_table) = Singleton($child)->many_many($component_name); $join[$join_table] = $join_table . '`.' . $join_field . ' = `' . $class_name . '`.ID'; $join[$child] = $child . '`.ID = `' . $join_table . '`.' . $child_join_field; } } if ($alias->hasSubAlias()) { $join = array_merge($join, $alias->subAlias($join_type)); } } return $join; }
public function getLanguages() { $term = Convert::raw2sql($this->request->getVar('term')); $query = new QueryObject(); $query->addAndCondition(QueryCriteria::like('Name', $term)); list($list, $size) = $this->languages_repository->getAll($query, 0, 20); $res = array(); foreach ($list as $lang) { array_push($res, array('label' => $lang->getName(), 'value' => $lang->getName())); } return $this->ok($res); }
function renderCloud() { try { $params = $this->request->allParams(); $company_url_segment = Convert::raw2sql($params["Company"]); $slug = Convert::raw2sql($params["Slug"]); $query = new QueryObject(); $query->addAndCondition(QueryCriteria::equal('Slug', $slug)); $this->current_cloud = $this->cloud_repository->getBy($query); if (!$this->current_cloud || !$this->current_cloud->Active) { throw new NotFoundEntityException('', ''); } if ($this->current_cloud->getCompany()->URLSegment != $company_url_segment) { throw new NotFoundEntityException('', ''); } // we need this for reviews. $this->company_service_ID = $this->current_cloud->getIdentifier(); $render = new PublicCloudSapphireRender($this->current_cloud); return $render->draw(); } catch (Exception $ex) { return $this->httpError(404, 'Sorry that Public Cloud could not be found!.'); } }