<?php
/***************************************************************************
- * Copyright (C) 2003-2009 Polytechnique.org *
+ * Copyright (C) 2003-2010 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
public $shortname;
private $data = array();
- private $members = null;
- private $admins = null;
-
private function __construct(array $data)
{
foreach ($data as $key=>$value) {
return property_exists($this, $name) || isset($this->data[$name]);
}
- public function getMemberUIDs()
+ private function getUF($admin = false, $extra_cond = null, $sort = null)
{
- if (is_null($this->members)) {
- $this->members = XDB::fetchColumn('SELECT uid
- FROM groupex.membres
- WHERE asso_id = {?}', $this->id);
+ $cond = new UFC_Group($this->id, $admin);
+ if (!is_null($extra_cond)) {
+ $cond = new PFC_And($cond, $extra_cond);
}
- return $this->members;
+ return new UserFilter($cond, $sort);
}
- public function getMembers($sortby = null, $count = null, $offset = null)
+ public function getMembers($extra_cond = null, $sort = null)
{
- return User::getBuildUsersWithUIDs($this->getMemberUIDs(), $sortby, $count, $offset);
+ return $this->getUF(false, $extra_cond, $sort);
}
- public function getMemberCount()
+ public function getAdmins($extra_cond = null, $sort = null)
{
- return count($this->getMemberUIDs());
+ return $this->getUF(true, $extra_cond, $sort);
}
- public function getAdminUIDs()
+ public function getLogo($fallback = true)
{
- if (is_null($this->admins)) {
- $this->admins = XDB::fetchColumn('SELECT uid
- FROM groupex.membres
- WHERE asso_id = {?} AND perms = \'admin\'', $this->id);
+ if (!empty($this->logo)) {
+ return PlImage::fromData($this->logo, $this->logo_mime);
+ } else if ($fallback) {
+ return PlImage::fromFile(dirname(__FILE__).'/../htdocs/images/dflt_carre.jpg', 'image/jpeg');
}
- return $this->admins;
- }
-
- public function getAdmins($sortby = null, $count = null, $offset = null)
- {
- return User::getBuildUsersWithUIDs($this->getAdminUIDs(), $sortby, $count, $offset);
- }
-
- public function getAdminCount()
- {
- return count($this->getAdminUIDs());
+ return null;
}
static public function get($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
- FROM groupex.asso AS a
- LEFT JOIN groupex.dom AS d ON d.id = a.dom
+ FROM groups AS a
+ LEFT JOIN group_dom AS d ON d.id = a.dom
WHERE ' . $where);
if ($res->numRows() != 1) {
return null;