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();
}
$this->id = intval($this->data['id']);
$this->shortname = $this->data['diminutif'];
+ if (!is_null($this->axDate)) {
+ $this->axDate = format_datetime($this->axDate, '%d/%m/%Y');
+ }
}
public function __get($name)
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);
}
- 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)) {
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,
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());
+ $data = $res->fetchOneAssoc();
+ $positions = XDB::fetchAllAssoc('SELECT position, uid
+ FROM group_members
+ WHERE asso_id = {?} AND position IS NOT NULL
+ ORDER BY position',
+ $data['id']);
+ return new Group(array_merge($data, array('positions' => $positions)));
}
}