X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fgroup.php;h=e3ed9b61cef1e9c56a739c3924cc10708d978a37;hb=7ea0c31bce93dddcd4999c1171071cdd9469c022;hp=a13b0779b10b924ccd60eba12ad45712c7a8c28c;hpb=684195f33b11e3067200dd3a9e14304bd7d04463;p=platal.git diff --git a/classes/group.php b/classes/group.php index a13b077..e3ed9b6 100644 --- a/classes/group.php +++ b/classes/group.php @@ -1,6 +1,6 @@ id, $admin); + $cond = new PFC_And(new UFC_Group($this->id, $admin), new PFC_Not(new UFC_Dead())); if (!is_null($extra_cond)) { - $cond = new UFC_And($cond, $extra_cond); + $cond->addChild($extra_cond); + } + if ($this->cat == self::CAT_PROMOTIONS) { + $cond->addChild(new UFC_Registered()); } return new UserFilter($cond, $sort); } - public function getMembers($extra_cond = null, $sort = null) + public function getMembersFilter($extra_cond = null, $sort = null) { return $this->getUF(false, $extra_cond, $sort); } - public function getAdmins($extra_cond = null, $sort = null) + public function getAdminsFilter($extra_cond = null, $sort = null) { return $this->getUF(true, $extra_cond, $sort); } + public function iterMembers($extra_cond = null, $sort = null, $limit = null) + { + $uf = $this->getMembersFilter($extra_cond, $sort); + return $uf->iterUsers($limit); + } + + public function iterAdmins($extra_cond = null, $sort = null, $limit = null) + { + $uf = $this->getAdminsFilter($extra_cond, $sort); + return $uf->iterUsers($limit); + } + public function getLogo($fallback = true) { if (!empty($this->logo)) { @@ -81,23 +101,28 @@ class Group return null; } - static public function get($id) + static public function get($id, $can_be_shortname = true) { if (!$id) { return null; } - if (ctype_digit($id)) { - $where = XDB::format('id = {?}', $id); + if (!$can_be_shortname) { + $where = XDB::format('a.id = {?}', $id); } else { - $where = XDB::format('diminutif = {?}', $id); + $where = XDB::format('a.diminutif = {?}', $id); } $res = XDB::query('SELECT a.*, d.nom AS domnom, FIND_IN_SET(\'wiki_desc\', a.flags) AS wiki_desc, - FIND_IN_SET(\'notif_unsub\', a.flags) AS notif_unsub + FIND_IN_SET(\'notif_unsub\', a.flags) AS notif_unsub, + (nls.id IS NOT NULL) AS has_nl FROM groups AS a LEFT JOIN group_dom AS d ON d.id = a.dom + LEFT JOIN newsletters AS nls ON (nls.group_id = a.id) WHERE ' . $where); if ($res->numRows() != 1) { + if ($can_be_shortname && (is_int($id) || ctype_digit($id))) { + return Group::get($id, false); + } return null; } return new Group($res->fetchOneAssoc());