From: Florent Bruneau Date: Wed, 28 Apr 2010 19:53:37 +0000 (+0200) Subject: Update core and replace constructors of some UFC that can take several X-Git-Tag: xorg/1.0.0~278 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=61d1fd8b2ce54b76b7df7a8fa637ffd4932f2403;p=platal.git Update core and replace constructors of some UFC that can take several different argument at once by pl_flatten(func_get_args()). Signed-off-by: Florent Bruneau --- diff --git a/classes/userfilter.php b/classes/userfilter.php index 551d3ac..e4b0080 100644 --- a/classes/userfilter.php +++ b/classes/userfilter.php @@ -60,12 +60,9 @@ class UFC_Hruid implements UserFilterCondition { private $hruids; - public function __construct($val) + public function __construct() { - if (!is_array($val)) { - $val = array($val); - } - $this->hruids = $val; + $this->hruids = pl_flatten(func_get_args()); } public function buildCondition(PlFilter &$uf) @@ -84,12 +81,9 @@ class UFC_Hrpid implements UserFilterCondition { private $hrpids; - public function __construct($val) + public function __construct() { - if (!is_array($val)) { - $val = array($val); - } - $this->hrpids = $val; + $this->hrpids = pl_flatten(func_get_args()); } public function buildCondition(PlFilter &$uf) @@ -227,12 +221,9 @@ class UFC_EducationSchool implements UserFilterCondition { private $val; - public function __construct($val) + public function __construct() { - if (!is_array($val)) { - $val = array($val); - } - $this->val = $val; + $this->val = pl_flatten(func_get_args()); } public function buildCondition(PlFilter &$uf) @@ -248,12 +239,9 @@ class UFC_EducationDegree implements UserFilterCondition { private $diploma; - public function __construct($diploma) + public function __construct() { - if (! is_array($diploma)) { - $diploma = array($diploma); - } - $this->diploma = $diploma; + $this->diploma = pl_flatten(func_get_args()); } public function buildCondition(PlFilter &$uf) @@ -269,12 +257,9 @@ class UFC_EducationField implements UserFilterCondition { private $val; - public function __construct($val) + public function __construct() { - if (!is_array($val)) { - $val = array($val); - } - $this->val = $val; + $this->val = pl_flatten(func_get_args()); } public function buildCondition(PlFilter &$uf) @@ -394,12 +379,9 @@ class UFC_Nationality implements UserFilterCondition { private $val; - public function __construct($val) + public function __construct() { - if (!is_array($val)) { - $val = array($val); - } - $this->val = $val; + $this->val = pl_flatten(func_get_args()); } public function buildCondition(PlFilter &$uf) @@ -586,12 +568,9 @@ class UFC_Binet implements UserFilterCondition { private $val; - public function __construct($val) + public function __construct() { - if (!is_array($val)) { - $val = array($val); - } - $this->val = $val; + $this->val = pl_flatten(func_get_args()); } public function buildCondition(PlFilter &$uf) @@ -610,15 +589,15 @@ class UFC_Section implements UserFilterCondition { private $section; - public function __construct($section) + public function __construct() { - $this->section = $section; + $this->section = pl_flatten(func_get_args()); } public function buildCondition(PlFilter &$uf) { $uf->requireProfiles(); - return 'p.section = ' . XDB::format('{?}', $this->section); + return XDB::format('p.section IN {?}', $this->section); } } // }}} @@ -632,7 +611,7 @@ class UFC_Email implements UserFilterCondition private $emails; public function __construct() { - $this->emails = func_get_args(); + $this->emails = pl_flatten(func_get_args()); } public function buildCondition(PlFilter &$uf) @@ -1187,15 +1166,15 @@ class UFC_Mentor_Country implements UserFilterCondition { private $country; - public function __construct($country) + public function __construct() { - $this->country = $country; + $this->country = pl_flatten(func_get_args()); } public function buildCondition(PlFilter &$uf) { $sub = $uf->addMentorFilter(UserFilter::MENTOR_COUNTRY); - return $sub . '.country = ' . XDB::format('{?}', $this->country); + return $sub . '.country IN ' . XDB::format('{?}', $this->country); } } // }}} diff --git a/core b/core index ded3ae9..983284b 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit ded3ae94c0786b4cf7e6c9e4e704b0d97a3a5be7 +Subproject commit 983284ba502852d0d50c9073274d6de3001acab6 diff --git a/ut/userfiltertest.php b/ut/userfiltertest.php index 7142fc5..a233c92 100644 --- a/ut/userfiltertest.php +++ b/ut/userfiltertest.php @@ -59,12 +59,12 @@ class UserFilterTest extends PlTestCase FROM accounts WHERE hruid IN {?}', array('florent.bruneau.2003', 'stephane.jacob.2004')), - new UFC_Hruid(array('florent.bruneau.2003', 'stephane.jacob.2004')), 2), + new UFC_Hruid('florent.bruneau.2003', 'stephane.jacob.2004'), 2), array(XDB::format('SELECT DISTINCT uid FROM accounts WHERE hruid IN {?}', array('florent.bruneau.2004', 'stephane.jacob.2004')), - new UFC_Hruid(array('florent.bruneau.2004', 'stephane.jacob.2004')), 1), + new UFC_Hruid('florent.bruneau.2004', 'stephane.jacob.2004'), 1), /* UFC_Hrpid */ @@ -83,13 +83,13 @@ class UserFilterTest extends PlTestCase INNER JOIN profiles AS p ON (ap.pid = p.pid AND FIND_IN_SET(\'owner\', perms)) WHERE hrpid IN {?}', array('florent.bruneau.2003', 'stephane.jacob.2004')), - new UFC_Hrpid(array('florent.bruneau.2003', 'stephane.jacob.2004')), 2), + new UFC_Hrpid('florent.bruneau.2003', 'stephane.jacob.2004'), 2), array(XDB::format('SELECT DISTINCT uid FROM account_profiles AS ap INNER JOIN profiles AS p ON (ap.pid = p.pid AND FIND_IN_SET(\'owner\', perms)) WHERE hrpid IN {?}', array('florent.bruneau.2004', 'stephane.jacob.2004')), - new UFC_Hrpid(array('florent.bruneau.2004', 'stephane.jacob.2004')), 1), + new UFC_Hrpid('florent.bruneau.2004', 'stephane.jacob.2004'), 1), /* UFC_IP */ @@ -251,7 +251,7 @@ class UserFilterTest extends PlTestCase INNER JOIN profile_education AS pe ON (pe.pid = ap.pid AND FIND_IN_SET(\'owner\', ap.perms)) LEFT JOIN profile_education_enum AS pee ON (pe.eduid = pee.id) WHERE pee.abbreviation IN {?}', array('X', 'HEC')), - new UFC_EducationSchool(array($id_X, $id_HEC)), -1), + new UFC_EducationSchool($id_X, $id_HEC), -1), ); /* UFC_EducationDegree @@ -274,7 +274,7 @@ class UserFilterTest extends PlTestCase INNER JOIN profile_education AS pe ON (pe.pid = ap.pid AND FIND_IN_SET(\'owner\', ap.perms)) LEFT JOIN profile_education_degree_enum AS pede ON (pe.degreeid = pede.id) WHERE pede.abbreviation IN {?}', array('Ing.', 'PhD')), - new UFC_EducationDegree(array($id_DegreeIng, $id_DegreePhd)), -1), + new UFC_EducationDegree($id_DegreeIng, $id_DegreePhd), -1), ); /* UFC_EducationField */ @@ -297,7 +297,7 @@ class UserFilterTest extends PlTestCase INNER JOIN profile_education AS pe ON (pe.pid = ap.pid AND FIND_IN_SET(\'owner\', ap.perms)) LEFT JOIN profile_education_field_enum AS pefe ON (pe.fieldid = pefe.id) WHERE pefe.field IN {?}', array('Informatique', 'Droit')), - new UFC_EducationField(array($id_FieldInfo, $id_FieldDroit)), 0), // FIXME: should be -1 + new UFC_EducationField($id_FieldInfo, $id_FieldDroit), 0), // FIXME: should be -1 ); $testcases = array();