// Groupes X
private $groups = null;
- public function groups()
+ public function groups($institutions = false, $onlyPublic = false)
{
if (is_null($this->groups)) {
- $this->groups = XDB::fetchAllAssoc('asso_id', 'SELECT asso_id, perms, comm
- FROM group_members
+ $this->groups = XDB::fetchAllAssoc('asso_id', 'SELECT gm.asso_id, gm.perms, gm.comm,
+ g.diminutif, g.nom, g.site, g.cat,
+ g.pub
+ FROM group_members AS gm
+ INNER JOIN groups AS g ON (g.id = gm.asso_id)
WHERE uid = {?}',
$this->id());
}
- return $this->groups;
- }
-
- public function groupNames($institutions = false)
- {
- if ($institutions) {
- $where = ' AND (g.cat = \'GroupesX\' OR g.cat = \'Institutions\')';
+ if (!$institutions && !$onlyPublic) {
+ return $this->groups;
} else {
- $where = '';
+ $result = array();
+ foreach ($this->groups as $id=>$data) {
+ if ($institutions) {
+ if ($data['cat'] != 'GroupesX' && $data['cat'] != 'Institutions') {
+ continue;
+ }
+ }
+ if ($onlyPublic) {
+ if ($data['pub'] != 'public') {
+ continue;
+ }
+ }
+ $result[$id] = $data;
+ }
+ return $result;
}
- return XDB::fetchAllAssoc('SELECT g.diminutif, g.nom, g.site
- FROM group_members AS gm
- LEFT JOIN groups AS g ON (g.id = gm.asso_id)
- WHERE gm.uid = {?}' . $where,
- $this->id());
}
/**
{assign var=photo value=$profile->getPhoto(false)}
{if $photo}<img alt="Photo de {$profile->fullName()}" src="photo/{$profile->hrid()}{if $with_pending_pic}/req{/if}" width="{$photo->width()}"/>{/if}
- {if $logged && $view eq 'private' && ( $profile->section|smarty:nodefaults || $profile->getBinets()|smarty:nodefaults || ($owner && $owner->groups()|smarty:nodefaults))}
+ {if $logged && $view eq 'private' && ( $profile->section|smarty:nodefaults || $profile->getBinets()|smarty:nodefaults || ($owner && $owner->groups(true,true)|smarty:nodefaults))}
<h2>À l'X…</h2>
{if $profile->section}<div><em class="intitule">Section : </em><span>{$profile->section}</span></div>{/if}
<span>{', '|implode:$profile->getBinetsNames()}</span></div>{/if}
{if $owner && $view eq 'private'}
- {assign var=groups value=$owner->groupNames(true)}
+ {assign var=groups value=$owner->groups(true,true)}
{if $groups|@count}<div><em class="intitule">Groupe{if count($groups) > 1}s{/if} et institution{if count($groups) > 1}s{/if} X : </em>
<span><br/>
- {foreach from=$groups item=group key=gk}{if $gk != 0}, {/if}<span title="{$group.nom}"><a href="{$group.site}">{$group.nom}</a></span>{/foreach}
+ {foreach from=$groups item=group name=groups}{if !$smarty.foreach.groups.first}, {/if}<span title="{$group.nom}"><a href="{$group.site}">{$group.nom}</a></span>{/foreach}
</span></div>{/if}
{/if}