projects
/
platal.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix 'job description' criteria for advanced search (Closes #1410)
[platal.git]
/
classes
/
group.php
diff --git
a/classes/group.php
b/classes/group.php
index
ce93e92
..
c79b0d3
100644
(file)
--- a/
classes/group.php
+++ b/
classes/group.php
@@
-1,6
+1,6
@@
<?php
/***************************************************************************
<?php
/***************************************************************************
- * Copyright (C) 2003-201
0
Polytechnique.org *
+ * Copyright (C) 2003-201
1
Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
@@
-21,6
+21,11
@@
class Group
{
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();
public $id;
public $shortname;
private $data = array();
@@
-32,6
+37,9
@@
class Group
}
$this->id = intval($this->data['id']);
$this->shortname = $this->data['diminutif'];
}
$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)
}
public function __get($name)
@@
-54,9
+62,12
@@
class Group
private function getUF($admin = false, $extra_cond = null, $sort = null)
{
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)) {
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);
}
}
return new UserFilter($cond, $sort);
}
@@
-73,13
+84,13
@@
class Group
public function iterMembers($extra_cond = null, $sort = null, $limit = null)
{
public function iterMembers($extra_cond = null, $sort = null, $limit = null)
{
- $uf = getMembersFilter($extra_cond, $sort);
+ $uf =
$this->
getMembersFilter($extra_cond, $sort);
return $uf->iterUsers($limit);
}
public function iterAdmins($extra_cond = null, $sort = null, $limit = null)
{
return $uf->iterUsers($limit);
}
public function iterAdmins($extra_cond = null, $sort = null, $limit = null)
{
- $uf = getAdminsFilter($extra_cond, $sort);
+ $uf =
$this->
getAdminsFilter($extra_cond, $sort);
return $uf->iterUsers($limit);
}
return $uf->iterUsers($limit);
}
@@
-93,26
+104,41
@@
class Group
return null;
}
return null;
}
- static public function get($id)
+ static public function get($id
, $can_be_shortname = true
)
{
if (!$id) {
return null;
}
{
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 {
} 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,
}
$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, ad.text AS address,
+ p.display_tel AS phone, f.display_tel AS fax
FROM groups AS a
LEFT JOIN group_dom AS d ON d.id = a.dom
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)
+ LEFT JOIN profile_phones AS p ON (p.link_type = \'group\' AND p.link_id = a.id AND p.tel_id = 0)
+ LEFT JOIN profile_phones AS f ON (f.link_type = \'group\' AND f.link_id = a.id AND f.tel_id = 1)
+ LEFT JOIN profile_addresses AS ad ON (ad.type = \'group\' AND ad.groupid = a.id)
WHERE ' . $where);
if ($res->numRows() != 1) {
WHERE ' . $where);
if ($res->numRows() != 1) {
+ if ($can_be_shortname && (is_int($id) || ctype_digit($id))) {
+ return Group::get($id, false);
+ }
return null;
}
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)));
}
}
}
}