8aadbddc7632d1d744fe200a22eb189f67d3c512
2 /***************************************************************************
3 * Copyright (C) 2003-2010 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 class ProfileSettingSection
implements ProfileSetting
24 public function value(ProfilePage
&$page, $field, $value, &$success)
27 if (is_null($value)) {
28 $res = XDB
::query("SELECT section
32 return intval($res->fetchOneCell());
34 return intval($value);
37 public function save(ProfilePage
&$page, $field, $value)
39 XDB
::execute("UPDATE profiles
42 $value, $page->pid());
46 class ProfileSettingBinets
implements ProfileSetting
48 public function __construct()
52 public function value(ProfilePage
&$page, $field, $value, &$success)
54 if (is_null($value)) {
56 $res = XDB
::iterRow("SELECT g.id, g.text
57 FROM profile_binet_enum AS g
58 INNER JOIN profile_binets AS i ON (i.binet_id = g.id)
61 while (list($gid, $text) = $res->next()) {
62 $value[intval($gid)] = $text;
65 if (!is_array($value)) {
73 public function save(ProfilePage
&$page, $field, $value)
75 XDB
::execute("DELETE FROM profile_binets
82 foreach ($value as $id=>$text) {
83 $insert[] = XDB
::format('({?}, {?})', $page->pid(), $id);
85 XDB
::execute("INSERT INTO profile_binets (pid, binet_id)
86 VALUES " . implode(',', $insert));
90 class ProfileSettingGroups
extends ProfilePage
92 protected $pg_template = 'profile/groups.tpl';
94 public function __construct(PlWizard
&$wiz)
96 parent
::__construct($wiz);
97 $this->settings
['section'] = new ProfileSettingSection();
98 $this->settings
['binets'] = new ProfileSettingBinets();
99 $this->watched
['section'] = $this->watched
['binets'] = true
;
102 public function _prepare(PlPage
&$page, $id)
104 $page->assign('mygroups', XDB
::iterator("SELECT a.nom, a.site, a.diminutif, a.unsub_url, a.pub, m.perms
106 INNER JOIN group_members AS m ON (m.asso_id = a.id)
107 WHERE m.uid = {?} AND (a.cat = 'GroupesX' OR a.cat = 'Institutions')",
109 $page->assign('listgroups', XDB
::iterator("SELECT a.nom, a.diminutif, a.sub_url,
110 IF (a.cat = 'Institutions', a.cat, d.nom) AS dom
112 LEFT JOIN group_dom AS d ON (d.id = a.dom)
113 WHERE a.inscriptible != 0
114 AND (a.cat = 'GroupesX' OR a.cat = 'Institutions')
115 ORDER BY a.cat, a.dom, a.nom"));
116 # XXX: FIXME: promo_sortie
117 $page->assign('old', (int)date('Y') >= S
::i('promo_sortie'));
121 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: