/** Compute the conditions to use for the current request. * @return A PlFilterCondition instance (actually a PFC_And) */ protected function getCond() { $cond = new PFC_And(); foreach ($this->criteria as $criterion => $value) { switch ($criterion) { // ENUM fields case WSRequestCriteria::SCHOOL: // Useless criterion: we don't need to check on origin school if (WSRequestCriteria::$choices_enum[$criterion][$value]) { $cond->addChild(new PFC_True()); } else { $cond->addChild(new PFC_False()); } break; case WSRequestCriteria::DIPLOMA: $diploma = WSRequestCriteria::$choices_enum[$criterion][$value]; $id_X = XDB::fetchOneCell('SELECT id FROM profile_education_enum WHERE abbreviation = {?}', 'X'); $cond->addChildren(array(new UFC_EducationSchool($id_X), new UFC_EducationDegree($diploma))); break; // TEXT fields // TEXT fields case WSRequestCriteria::FIRSTNAME: case WSRequestCriteria::LASTNAME: $cond->addChild(new UFC_NameTokens($value, UFC_NameTokens::FLAG_PUBLIC, false, false, $criterion)); break; case WSRequestCriteria::PROMOTION: $cond->addChild(new PFC_Or(new UFC_Promo(UserFilter::OP_EQUALS, UserFilter::GRADE_ING, $value), new UFC_Promo(UserFilter::OP_EQUALS, UserFilter::GRADE_MST, $value), new UFC_Promo(UserFilter::OP_EQUALS, UserFilter::GRADE_PHD, $value))); break; case WSRequestCriteria::ALT_DIPLOMA: $cond->addChild(new UFC_EducationDegree(DirEnum::getIds(DirEnum::EDUDEGREES, $value))); break; case WSRequestCriteria::DIPLOMA_FIELD: $cond->addChild(new UFC_EducationField(DirEnum::getIds(DirEnum::EDUFIELDS, $value))); break; case WSRequestCriteria::CITY: $cond->addChild(new UFC_AddressField($value, UFC_AddressField::FIELD_LOCALITY, UFC_Address::TYPE_HOME, UFC_Address::FLAG_CURRENT)); break; case WSRequestCriteria::COUNTRY: $cond->addChild(new UFC_AddressField($value, UFC_AddressField::FIELD_COUNTRY, UFC_Address::TYPE_HOME, UFC_Address::FLAG_CURRENT)); break; case WSRequestCriteria::ZIPCODE: $cond->addChild(new UFC_AddressField($value, UFC_AddressField::FIELD_ZIPCODE, UFC_Address::TYPE_HOME, UFC_Address::FLAG_CURRENT)); break; case WSRequestCriteria::JOB_ANY_COUNTRY: $cond->addChild(new UFC_AddressField($value, UFC_AddressField::FIELD_COUNTRY, UFC_Address::TYPE_PRO, UFC_Address::FLAG_ANY)); break; case WSRequestCriteria::JOB_CURRENT_CITY: $cond->addChild(new UFC_AddressField($value, UFC_AddressField::FIELD_LOCALITY, UFC_Address::TYPE_PRO, UFC_Address::FLAG_ANY)); break; case WSRequestCriteria::JOB_ANY_COMPANY: case WSRequestCriteria::JOB_CURRENT_COMPANY: $cond->addChild(new UFC_Job_Company(UFC_Job_Company::JOBNAME, $value)); break; case WSRequestCriteria::JOB_ANY_SECTOR: case WSRequestCriteria::JOB_CURRENT_SECTOR: case WSRequestCriteria::JOB_CURRENT_TITLE: $cond->addChild(new UFC_Job_Terms(DirEnum::getIds(DirEnum::JOBTERMS, $value))); break; // LIST fields // LIST fields case WSRequestCriteria::HOBBIES: $subcond = new PFC_Or(); foreach ($value as $val) { $subcond->addChild(new UFC_Comment($value)); } $cond->addChild($subcond); break; case WSRequestCriteria::JOB_COMPETENCIES: case WSRequestCriteria::JOB_RESUME: case WSRequestCriteria::PROFESSIONAL_PROJECT: $subcond = new PFC_Or(); foreach ($value as $val) { $subcond->addChild(new UFC_Job_Description($value, UserFilter::JOB_USERDEFINED)); } $cond->addChild($subcond); break; case WSRequestCriteria::NOT_UID: $cond->addChild(new PFC_Not(new UFC_PartnerSharingID($this->partner->id, $value))); break; default: break; } } return $cond; }
protected function buildUFC(UserFilterBuilder $ufb) { if (count($this->val) == 1) { return new UFC_Group($this->val[0]); } $or = new PFC_Or(); foreach ($this->val as $grp) { $or->addChild(new UFC_Group($grp)); } return $or; }