X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fgroup.php;h=b5f45007b879f5ceff6697d276be76e0eb8a752a;hb=1c4a1d0a32c52851e9ffbbf585bb206c9a472dc9;hp=f58ff6b1a3e96489a2f10b838ae92eb32929a40a;hpb=23ba40c466e05d369cd9e2a96107f38e309b767a;p=platal.git diff --git a/classes/group.php b/classes/group.php index f58ff6b..b5f4500 100644 --- a/classes/group.php +++ b/classes/group.php @@ -21,6 +21,11 @@ class Group { + const CAT_GROUPESX = "GroupesX"; + const CAT_BINETS = "Binets"; + const CAT_PROMOTIONS = "Promotions"; + const CAT_INSTITUTIONS = "Institutions"; + public $id; public $shortname; private $data = array(); @@ -54,9 +59,12 @@ class Group private function getUF($admin = false, $extra_cond = null, $sort = null) { - $cond = new UFC_Group($this->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 PFC_And($cond, $extra_cond); + $cond->addChild($extra_cond); + } + if ($this->cat == self::CAT_PROMOTIONS) { + $cond->addChild(new UFC_Registered()); } return new UserFilter($cond, $sort); } @@ -93,15 +101,15 @@ class Group return null; } - static public function get($id) + static public function get($id, $can_be_shortname = true) { if (!$id) { return null; } - if (is_int($id) || 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, @@ -110,6 +118,9 @@ class Group LEFT JOIN group_dom AS d ON d.id = a.dom 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());