X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fuserfilter.php;h=453d94a21390d9a6110a90afbbbfd7ef3a7ffb4c;hb=49056fe2c32629b7b63b7936e6d9a25562fe5b5a;hp=2e8af866f73c3339b5898ebe9e11baa7869e73c5;hpb=d82359a556779137f8a90d0312b3098a2db6f482;p=platal.git diff --git a/classes/userfilter.php b/classes/userfilter.php index 2e8af86..453d94a 100644 --- a/classes/userfilter.php +++ b/classes/userfilter.php @@ -764,9 +764,9 @@ class UserFilter extends PlFilter /** EDUCATION */ - const GRADE_ING = 'Ing.'; - const GRADE_PHD = 'PhD'; - const GRADE_MST = 'M%'; + const GRADE_ING = Profile::DEGREE_X; + const GRADE_PHD = Profile::DEGREE_D; + const GRADE_MST = Profile::DEGREE_M; static public function isGrade($grade) { return ($grade !== 0) && ($grade == self::GRADE_ING || $grade == self::GRADE_PHD || $grade == self::GRADE_MST); @@ -813,7 +813,7 @@ class UserFilter extends PlFilter foreach ($this->pepe as $grade => $sub) { if ($this->isGrade($grade)) { $joins['pe' . $sub] = PlSqlJoin::left('profile_education', '$ME.eduid = pee.id AND $ME.pid = $PID'); - $joins['pede' . $sub] = PlSqlJoin::inner('profile_education_degree_enum', '$ME.id = pe' . $sub . '.degreeid AND $ME.abbreviation LIKE {?}', $grade); + $joins['pede' . $sub] = PlSqlJoin::inner('profile_education_degree_enum', '$ME.id = pe' . $sub . '.degreeid AND $ME.degree LIKE {?}', $grade); } else { $joins['pe' . $sub] = PlSqlJoin::left('profile_education', '$ME.pid = $PID'); $joins['pee' . $sub] = PlSqlJoin::inner('profile_education_enum', '$ME.id = pe' . $sub . '.eduid'); @@ -846,6 +846,15 @@ class UserFilter extends PlFilter return $sub; } + private $gpfm = array(); + public function addGroupFormerMemberFilter() + { + $this->requireAccounts(); + $sub = '_' . $this->option++; + $this->gpfm[] = $sub; + return $sub; + } + protected function groupJoins() { $joins = array(); @@ -860,6 +869,9 @@ class UserFilter extends PlFilter $joins['gpm' . $sub] = PlSqlJoin::left('group_members', '$ME.uid = $UID AND $ME.asso_id = gpa' . $sub . '.id'); } } + foreach ($this->gpfm as $sub) { + $joins['gpfm' . $sub] = PlSqlJoin::left('group_former_members', '$ME.uid = $UID'); + } return $joins; } @@ -937,12 +949,22 @@ class UserFilter extends PlFilter * that email as a source email. * @return Suffix to use to access the adequate table. */ - public function addAliasFilter($email = null) + public function addAliasFilter($email = null) { $this->requireAccounts(); return $this->register_optional($this->sa, $email); } + private $with_rf = false; + /** Allows filtering by active redirection. + * @return Suffix to use to access the adequate table. + */ + public function addActiveEmailRedirectFilter($email = null) + { + $this->requireAccounts(); + $this->with_rf = true; + } + protected function emailJoins() { global $globals; @@ -954,18 +976,18 @@ class UserFilter extends PlFilter if (!is_array($redirections)) { $key = array($redirections); } - $joins['ra' . $sub] = PlSqlJoin::left('email_redriect_account', '$ME.uid = $UID AND $ME.type != \'imap\' + $joins['ra' . $sub] = PlSqlJoin::left('email_redirect_account', '$ME.uid = $UID AND $ME.type != \'imap\' AND $ME.redirect IN {?}', $redirections); } } foreach ($this->sa as $sub => $emails) { if (is_null($emails)) { $joins['sa' . $sub] = PlSqlJoin::left('email_source_account', '$ME.uid = $UID'); - } else if ($key == self::ALIAS_BEST) { + } else if ($sub == self::ALIAS_BEST) { $joins['sa' . $sub] = PlSqlJoin::left('email_source_account', '$ME.uid = $UID AND FIND_IN_SET(\'bestalias\', $ME.flags)'); - } else if ($key == self::ALIAS_FORLIFE) { + } else if ($sub == self::ALIAS_FORLIFE) { $joins['sa' . $sub] = PlSqlJoin::left('email_source_account', '$ME.uid = $UID AND $ME.type = \'forlife\''); - } else if ($key == self::ALIAS_AUXILiIARY) { + } else if ($sub == self::ALIAS_AUXILIARY) { $joins['sa' . $sub] = PlSqlJoin::left('email_source_account', '$ME.uid = $UID AND $ME.type = \'alias_aux\''); } else { if (!is_array($emails)) { @@ -974,6 +996,9 @@ class UserFilter extends PlFilter $joins['sa' . $sub] = PlSqlJoin::left('email_source_account', '$ME.uid = $UID AND $ME.email IN {?}', $emails); } } + if ($this->with_rf) { + $joins['rf'] = PlSqlJoin::left('email_redirect_account', '$ME.uid = $UID AND $ME.type != \'imap\' AND $ME.flags = \'active\'');; + } return $joins; } @@ -1033,10 +1058,10 @@ class UserFilter extends PlFilter $this->requireProfiles(); $this->pc = true; if ($type == UFC_Corps::CURRENT) { - $pce['pcec'] = 'current_corpsid'; + $this->pce['pcec'] = 'current_corpsid'; return 'pcec'; } else if ($type == UFC_Corps::ORIGIN) { - $pce['pceo'] = 'original_corpsid'; + $this->pce['pceo'] = 'original_corpsid'; return 'pceo'; } } @@ -1188,6 +1213,37 @@ class UserFilter extends PlFilter return $joins; } + /** DELTATEN + */ + private $dts = array(); + const DELTATEN = 1; + const DELTATEN_MESSAGE = 2; + // TODO: terms + + public function addDeltaTenFilter($type) + { + $this->requireProfiles(); + switch ($type) { + case self::DELTATEN: + $this->dts['pdt'] = 'profile_deltaten'; + return 'pdt'; + case self::DELTATEN_MESSAGE: + $this->dts['pdtm'] = 'profile_deltaten'; + return 'pdtm'; + default: + Platal::page()->killError("Undefined DeltaTen filter."); + } + } + + protected function deltatenJoins() + { + $joins = array(); + foreach ($this->dts as $sub => $tab) { + $joins[$sub] = PlSqlJoin::left($tab, '$ME.pid = $PID'); + } + return $joins; + } + /** MENTORING */ @@ -1200,7 +1256,7 @@ class UserFilter extends PlFilter public function addMentorFilter($type) { - $this->requireAccounts(); + $this->requireProfiles(); switch($type) { case self::MENTOR: $this->pms['pm'] = 'profile_mentor';