X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fuserset.inc.php;h=f99faf2ff3a0cd0f679a1ae352c367c56eaab599;hb=a1c554a92888e0b017ba362817a67cc2849a9154;hp=0612d2f6cec03f2eaf6a5d0ee7884a3e20b00fcc;hpb=853ff307303faf861396c4e22dbaa56114366751;p=platal.git diff --git a/include/userset.inc.php b/include/userset.inc.php index 0612d2f..f99faf2 100644 --- a/include/userset.inc.php +++ b/include/userset.inc.php @@ -1,6 +1,6 @@ quick = $quick; - if (is_null($cond)) { $conds = new PFC_And(); } else if ($cond instanceof PFC_And) { @@ -67,26 +62,8 @@ class SearchSet extends ProfileSet $conds = new PFC_And($cond); } - if ($quick) { - $this->getQuick($conds); - } else { - $this->getAdvanced($conds); - } - } - - /** Sets up the conditions for a Quick Search - * @param $conds Additional conds (as a PFC_And) - */ - private function getQuick($conds) - { - if (!S::logged()) { - Env::kill('with_soundex'); - } - - require_once 'ufbuilder.inc.php'; - $ufb = new UFB_QuickSearch(); - if (!$ufb->isValid()) { + $this->valid = false; return; } @@ -95,35 +72,12 @@ class SearchSet extends ProfileSet $orders = $ufb->getOrders(); - if (S::logged() && Env::has('nonins')) { - $conds = new PFC_And($conds, - new PFC_Not(new UFC_Dead()), - new PFC_Not(new UFC_Registered()) - ); - } - parent::__construct($conds, $orders); } - /** Sets up the conditions for an Advanced Search - * @param $conds Additional conds (as a PFC_And) - */ - private function getAdvanced($conds) + public function isValid() { - $this->advanced = true; - require_once 'ufbuilder.inc.php'; - $ufb = new UFB_AdvancedSearch(); - - if (!$ufb->isValid()) { - return; - } - - $ufc = $ufb->getUFC(); - $conds->addChild($ufc); - - $orders = $ufb->getOrders(); - - parent::__construct($conds, $orders); + return $this->valid; } /** Add a "rechercher=Chercher" field to the query to simulate the POST @@ -145,6 +99,30 @@ class SearchSet extends ProfileSet } } +// Specialized SearchSet for quick search. +class QuickSearchSet extends SearchSet +{ + public function __construct(PlFilterCondition $cond = null) + { + if (!S::logged()) { + Env::kill('with_soundex'); + } + + parent::__construct(new UFB_QuickSearch(), $cond); + } +} + +// Specialized SearchSet for advanced search. +class AdvancedSearchSet extends SearchSet +{ + public function __construct($xorg_admin_fields, $ax_admin_fields, + PlFilterCondition $cond = null) + { + parent::__construct(new UFB_AdvancedSearch($xorg_admin_fields, $ax_admin_fields), + $cond); + } +} + /** Simple set based on an array of User objects */ class ArraySet extends ProfileSet @@ -342,5 +320,40 @@ class GadgetView implements PlView } } +class AddressesView implements PlView +{ + private $set; + + public function __construct(PlSet &$set, array $params) + { + $this->set =& $set; + } + + public function apply(PlPage &$page) + { + $pids = $this->set->getIds(new PlLimit()); + $visibility = new ProfileVisibility(ProfileVisibility::VIS_AX); + pl_cached_content_headers('text/x-csv', 1); + + $csv = fopen('php://output', 'w'); + fputcsv($csv, array('adresses'), ';'); + $res = XDB::query('SELECT pd.public_name, pa.postalText + FROM profile_addresses AS pa + INNER JOIN profile_display AS pd ON (pd.pid = pa.pid) + WHERE pa.type = \'home\' AND pa.pub IN (\'public\', \'ax\') AND FIND_IN_SET(\'mail\', pa.flags) AND pa.pid IN {?} + GROUP BY pa.pid', $pids); + foreach ($res->fetchAllAssoc() as $item) { + fputcsv($csv, $item, ';'); + } + fclose($csv); + exit(); + } + + public function args() + { + return $this->set->args(); + } +} + // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>