X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fuserset.inc.php;h=23a117ee8c2acc4c2c35d639d4b915f6cfa1c691;hb=b270577e919c58455a3629a4d9d61bd38ea49e11;hp=0aefe1f077fc6a991b054961ab8e5f89654c3749;hpb=3314838ec79d553b1575a2fb48e46d4fad3f8887;p=platal.git diff --git a/include/userset.inc.php b/include/userset.inc.php index 0aefe1f..23a117e 100644 --- a/include/userset.inc.php +++ b/include/userset.inc.php @@ -1,6 +1,6 @@ conds->addChild($ufc); $orders = $ufb->getOrders(); - $orders[] = new UFO_Promo(UserFilter::DISPLAY, true); - $orders[] = new UFO_Promo(UserFilter::DN_SORT); if (S::logged() && Env::has('nonins')) { $this->conds = new PFC_And($this->conds, - new UFC_Not(new UFC_Dead()), - new UFC_Registered() + new PFC_Not(new UFC_Dead()), + new PFC_Not(new UFC_Registered()) ); } @@ -119,21 +115,13 @@ class SearchSet extends ProfileSet $this->conds->addChild($ufb->getUFC()); } - public function &get(PlLimit $limit = null, $orders = array()) + protected function &getFilterResults(PlFilter &$pf, PlLimit $limit) { - $orders = array_merge($orders, $this->orders); - - $uf = $this->buildFilter($this->conds, $orders); - if (is_null($limit)) { - $limit = new PlLimit(20, 0); - } - $it = $uf->getProfiles($limit); - $this->count = $uf->getTotalCount(); - return $it; + return $pf->getProfiles($limit, Profile::FETCH_MINIFICHES); } } -class ArraySet extends UserSet +class ArraySet extends ProfileSet { public function __construct(array $users) { @@ -147,44 +135,15 @@ class ArraySet extends UserSet } } -class MinificheView extends MultipageView +abstract class ProfileView extends MultipageView { - public function __construct(PlSet &$set, $data, array $params) - { - require_once 'education.func.inc.php'; - global $globals; - $this->entriesPerPage = $globals->search->per_page; - if (@$params['with_score']) { - $this->addSort(new PlViewOrder('score', array( - new UFO_Score(true), - new UFO_ProfileUpdate(true), - new UFO_Promo(UserFilter::DISPLAY, true), - new UFO_Name(UserFilter::DN_SORT), - ), 'pertinence')); - } - $this->addSort(new PlViewOrder( - 'name', - array(new UFO_Name(UserFilter::DN_SORT)), - 'nom')); - $this->addSort(new PlViewOrder('promo', array( - new UFO_Promo(UserFilter::DISPLAY, true), - new UFO_Name(UserFilter::DN_SORT), - ), 'promotion')); - $this->addSort(new PlViewOrder('date_mod', array( - new UFO_ProfileUpdate(true), - new UFO_Promo(UserFilter::DISPLAY, true), - new UFO_Name(UserFilter::DN_SORT), - ), 'dernière modification')); - parent::__construct($set, $data, $params); - } - protected function getBoundValue($obj) { if ($obj instanceof Profile) { switch ($this->bound_field) { case 'name': $name = $obj->name('%l'); - return strtoupper($name[0]); + return strtoupper($name); case 'promo': return $obj->promo(); default: @@ -210,6 +169,38 @@ class MinificheView extends MultipageView } return $show_bounds; } +} + +class MinificheView extends ProfileView +{ + public function __construct(PlSet &$set, $data, array $params) + { + require_once 'education.func.inc.php'; + global $globals; + $this->entriesPerPage = $globals->search->per_page; + if (@$params['with_score']) { + $this->addSort(new PlViewOrder('score', array( + new UFO_Score(true), + new UFO_ProfileUpdate(true), + new UFO_Promo(UserFilter::DISPLAY, true), + new UFO_Name(Profile::DN_SORT), + ), 'pertinence')); + } + $this->addSort(new PlViewOrder( + 'name', + array(new UFO_Name(Profile::DN_SORT)), + 'nom')); + $this->addSort(new PlViewOrder('promo', array( + new UFO_Promo(UserFilter::DISPLAY, true), + new UFO_Name(Profile::DN_SORT), + ), 'promotion')); + $this->addSort(new PlViewOrder('date_mod', array( + new UFO_ProfileUpdate(true), + new UFO_Promo(UserFilter::DISPLAY, true), + new UFO_Name(Profile::DN_SORT), + ), 'dernière modification')); + parent::__construct($set, $data, $params); + } public function templateName() { @@ -217,118 +208,54 @@ class MinificheView extends MultipageView } } -class MentorView extends MultipageView +class MentorView extends ProfileView { public function __construct(PlSet &$set, $data, array $params) { $this->entriesPerPage = 10; $this->addSort(new PlViewOrder('rand', array(new PFO_Random(S::i('uid'))), 'aléatoirement')); - $this->addSort(new PlViewOrder('name', array(new UFO_Name(UserFilter::DN_SORT)), 'nom')); + $this->addSort(new PlViewOrder('name', array(new UFO_Name(Profile::DN_SORT)), 'nom')); $this->addSort(new PlViewOrder('promo', array( new UFO_Promo(UserFilter::DISPLAY, true), - new UFO_Name(UserFilter::DN_SORT), + new UFO_Name(Profile::DN_SORT), ), 'promotion')); $this->addSort(new PlViewOrder('date_mod', array( new UFO_ProfileUpdate(true), new UFO_Promo(UserFilter::DISPLAY, true), - new UFO_Name(UserFilter::DN_SORT), + new UFO_Name(Profile::DN_SORT), ), 'dernière modification')); parent::__construct($set, $data, $params); } - protected function getBoundValue($obj) - { - if ($obj instanceof Profile) { - switch ($this->bound_field) { - case 'name': - $name = $obj->name('%l'); - return strtoupper($name[0]); - case 'promo': - return $obj->promo(); - default: - return null; - } - } - return null; - } - - public function bounds() - { - $order = Env::v('order', $this->defaultkey); - $show_bounds = 0; - if (($order == "name") || ($order == "-name")) { - $this->bound_field = "nom"; - $show_bounds = 1; - } elseif (($order == "promo") || ($order == "-promo")) { - $this->bound_field = "promo"; - $show_bounds = -1; - } - if ($order{0} == '-') { - $show_bounds = -$show_bounds; - } - return $show_bounds; - } - public function templateName() { return 'include/plview.referent.tpl'; } } -class TrombiView extends MultipageView +class TrombiView extends ProfileView { public function __construct(PlSet &$set, $data, array $params) { $this->entriesPerPage = 24; + $this->defaultkey = 'name'; if (@$params['with_score']) { $this->addSort(new PlViewOrder('score', array( new UFO_Score(true), new UFO_ProfileUpdate(true), new UFO_Promo(UserFilter::DISPLAY, true), - new UFO_Name(UserFilter::DN_SORT), + new UFO_Name(Profile::DN_SORT), ), 'pertinence')); } - $this->addSort(new PlViewOrder('name', array(new UFO_Name(UserFilter::DN_SORT)), 'nom')); + $set->addCond(new UFC_Photo()); + $this->addSort(new PlViewOrder('name', array(new UFO_Name(Profile::DN_SORT)), 'nom')); $this->addSort(new PlViewOrder('promo', array( new UFO_Promo(UserFilter::DISPLAY, true), - new UFO_Name(UserFilter::DN_SORT), + new UFO_Name(Profile::DN_SORT), ), 'promotion')); parent::__construct($set, $data, $params); } - protected function getBoundValue($obj) - { - if ($obj instanceof Profile) { - switch ($this->bound_field) { - case 'name': - $name = $obj->name('%l'); - return strtoupper($name[0]); - case 'promo': - return $obj->promo(); - default: - return null; - } - } - return null; - } - - public function bounds() - { - $order = Env::v('order', $this->defaultkey); - $show_bounds = 0; - if (($order == "name") || ($order == "-name")) { - $this->bound_field = "nom"; - $show_bounds = 1; - } elseif (($order == "promo") || ($order == "-promo")) { - $this->bound_field = "promo"; - $show_bounds = -1; - } - if ($order{0} == '-') { - $show_bounds = -$show_bounds; - } - return $show_bounds; - } - public function templateName() { return 'include/plview.trombi.tpl';