Commit | Line | Data |
---|---|---|
fd38b30e FB |
1 | <?php |
2 | /*************************************************************************** | |
8d84c630 | 3 | * Copyright (C) 2003-2009 Polytechnique.org * |
fd38b30e FB |
4 | * http://opensource.polytechnique.org/ * |
5 | * * | |
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. * | |
10 | * * | |
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. * | |
15 | * * | |
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 * | |
18 | * Foundation, Inc., * | |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | |
20 | ***************************************************************************/ | |
21 | ||
c4b45374 | 22 | class ProfileSearchNames implements ProfileSetting |
fd38b30e | 23 | { |
dced83b4 SJ |
24 | private $private_name_end; |
25 | private $search_names; | |
c4b45374 | 26 | |
fd38b30e | 27 | private function matchWord($old, $new, $newLen) { |
93553cea | 28 | return ($i = strpos($old, $new)) !== false |
fd38b30e FB |
29 | && ($i == 0 || $old{$i-1} == ' ') |
30 | && ($i + $newLen == strlen($old) || $old{$i + $newLen} == ' '); | |
31 | } | |
32 | ||
33 | private function prepareField($value) | |
34 | { | |
35 | $value = strtoupper(replace_accent($value)); | |
36 | return preg_replace('/[^A-Z]/', ' ', $value); | |
37 | } | |
38 | ||
c4b45374 | 39 | private function prepare(ProfilePage &$page, $field, $value, $init, &$success) |
fd38b30e FB |
40 | { |
41 | $success = true; | |
dced83b4 SJ |
42 | $ini = $this->prepareField($init); |
43 | $new = $this->prepareField($value); | |
c4b45374 SJ |
44 | $newLen = strlen($new); |
45 | $success = $this->matchWord($ini, $new, $newLen) | |
6cb58d39 | 46 | || ($field == 'lastname' && $new == 'DE ' . $ini); |
fd38b30e | 47 | if (!$success) { |
c4b45374 SJ |
48 | $field = strtolower($field); |
49 | Platal::page()->trigError("Le " . $field . " que tu as choisi (" . $value . | |
50 | ") est trop loin de ton " . $field . " initial (" . $init . ")."); | |
fd38b30e | 51 | } |
c4b45374 | 52 | return $success ? $value : $init; |
fd38b30e FB |
53 | } |
54 | ||
c4b45374 | 55 | public function value(ProfilePage &$page, $field, $value, &$success) |
fd38b30e | 56 | { |
dced83b4 | 57 | $success = true; |
c4b45374 SJ |
58 | $success_tmp = true; |
59 | if (is_null($value)) { | |
60 | $sn_all = XDB::iterator("SELECT CONCAT(sn.particle, sn.name) AS name, | |
6cb58d39 | 61 | sn.particle, sn.typeid, e.type, e.name AS type_name, |
c4b45374 SJ |
62 | FIND_IN_SET('has_particle', e.flags) AS has_particle, |
63 | FIND_IN_SET('always_displayed', e.flags) AS always_displayed, | |
64 | FIND_IN_SET('public', e.flags) AS pub | |
97a98687 SJ |
65 | FROM profile_name AS sn |
66 | INNER JOIN profile_name_enum AS e ON (e.id = sn.typeid) | |
c4b45374 SJ |
67 | WHERE sn.pid = {?} AND NOT FIND_IN_SET('not_displayed', e.flags) |
68 | ORDER BY NOT FIND_IN_SET('always_displayed', e.flags), e.id, sn.name", | |
69 | S::v('uid')); | |
70 | ||
6cb58d39 SJ |
71 | $sn_types = XDB::iterator("SELECT id, type, name, |
72 | FIND_IN_SET('has_particle', flags) AS has_particle | |
97a98687 | 73 | FROM profile_name_enum |
c4b45374 SJ |
74 | WHERE NOT FIND_IN_SET('not_displayed', flags) |
75 | AND FIND_IN_SET('always_displayed', flags) | |
76 | ORDER BY id"); | |
77 | ||
78 | $value = array(); | |
79 | $sn = $sn_all->next(); | |
80 | while ($sn_type = $sn_types->next()) { | |
81 | if ($sn_type['id'] == $sn['typeid']) { | |
82 | $value[] = $sn; | |
83 | $sn = $sn_all->next(); | |
84 | } else { | |
6cb58d39 SJ |
85 | $value[] = array('typeid' => $sn_type['id'], |
86 | 'type' => $sn_type['type'], | |
87 | 'type_name' => $sn_type['name'], | |
88 | 'pub' => 1, | |
c4b45374 SJ |
89 | 'has_particle' => $sn_type['has_particle'], |
90 | 'always_displayed' => 1); | |
91 | } | |
92 | } | |
6cb58d39 SJ |
93 | if ($sn) { |
94 | do { | |
95 | $value[] = $sn; | |
96 | } while ($sn = $sn_all->next()); | |
97 | } | |
c4b45374 | 98 | } else { |
6cb58d39 SJ |
99 | require_once 'name.func.inc.php'; |
100 | ||
c4b45374 | 101 | $res = XDB::query("SELECT s.particle, s.name |
97a98687 SJ |
102 | FROM profile_name AS s |
103 | INNER JOIN profile_name_enum AS e ON (e.id = s.typeid) | |
6cb58d39 SJ |
104 | WHERE s.pid = {?} AND e.type LIKE '%ini' |
105 | ORDER BY e.type = 'firstname_ini'", | |
c4b45374 SJ |
106 | S::i('uid')); |
107 | $res = $res->fetchAllAssoc(); | |
108 | $initial = array(); | |
6cb58d39 SJ |
109 | $initial['lastname'] = $res[0]['particle'] . $res[0]['name']; |
110 | $initial['firstname'] = $res[1]['name']; | |
111 | $sn_types = build_types(); | |
dced83b4 SJ |
112 | $this->search_names = array(); |
113 | foreach ($value as &$sn) { | |
c4b45374 | 114 | $sn['name'] = trim($sn['name']); |
6cb58d39 | 115 | if ($sn['type'] == 'firstname' || $sn['type'] == 'lastname') { |
c4b45374 SJ |
116 | $sn['name'] = $this->prepare($page, $sn['type'], $sn['name'], |
117 | $initial[$sn['type']], $success_tmp); | |
118 | $success = $success && $success_tmp; | |
119 | } | |
dced83b4 SJ |
120 | if ($sn['pub']) { |
121 | if (isset($sn['particle']) && ($sn['particle'] != '')) { | |
122 | list($particle, $name) = explode(' ', $sn['name'], 2); | |
123 | $particle = trim($particle) . ' '; | |
124 | if (!$name) { | |
125 | list($particle, $name) = explode('\'', $sn['name'], 2); | |
126 | $particle = trim($particle); | |
127 | } | |
128 | } else { | |
129 | $particle = ''; | |
130 | $name = $sn['name']; | |
131 | } | |
132 | } | |
c4b45374 | 133 | if ($sn['name'] != '') { |
dced83b4 SJ |
134 | if ($sn['pub']) { |
135 | $this->search_names[$sn['typeid']] = array('fullname' => $sn['name'], | |
136 | 'name' => $name, | |
137 | 'particle' => $particle, | |
138 | 'pub' => $sn['pub']); | |
c4b45374 | 139 | } else { |
dced83b4 SJ |
140 | if (isset($this->search_names[$sn['typeid']])) { |
141 | $this->search_names[$sn['typeid']][] = $sn['name']; | |
142 | } else { | |
143 | $this->search_names[$sn['typeid']] = array('fullname' => $sn['name']); | |
144 | } | |
6cb58d39 | 145 | $sn['type_name'] = $sn_types[$sn['typeid']]; |
c4b45374 SJ |
146 | } |
147 | } | |
148 | } | |
dced83b4 SJ |
149 | $res = XDB::query("SELECT public_name, private_name |
150 | FROM profile_display | |
151 | WHERE pid = {?}", | |
152 | S::v('uid')); | |
153 | list($public_name, $private_name) = $res->fetchOneRow(); | |
154 | if ($success) { | |
dced83b4 SJ |
155 | $sn_types_private = build_types('private'); |
156 | $this->private_name_end = build_private_name($this->search_names, $sn_types_private); | |
157 | $private_name = $public_name . $this->private_name_end; | |
158 | } | |
159 | Platal::page()->assign('public_name', $public_name); | |
160 | Platal::page()->assign('private_name', $private_name); | |
c4b45374 SJ |
161 | } |
162 | return $value; | |
163 | } | |
164 | ||
165 | public function save(ProfilePage &$page, $field, $value) | |
166 | { | |
dced83b4 SJ |
167 | require_once 'name.func.inc.php'; |
168 | $sn_old = build_sn_pub(); | |
c4b45374 | 169 | XDB::execute("DELETE FROM s |
97a98687 SJ |
170 | USING profile_name AS s |
171 | INNER JOIN profile_name_enum AS e ON (s.typeid = e.id) | |
c4b45374 SJ |
172 | WHERE s.pid = {?} AND NOT FIND_IN_SET('not_displayed', e.flags)", |
173 | S::i('uid')); | |
dced83b4 SJ |
174 | $has_new = set_alias_names($this->search_names, $sn_old); |
175 | ||
176 | // Only requires validation if modification in public names | |
177 | if ($has_new) { | |
178 | $new_names = new NamesReq(S::user(), $this->search_names, $this->private_name_end); | |
179 | $new_names->submit(); | |
180 | Platal::page()->trigWarning("La demande de modification de tes noms a bien été prises en compte." . | |
181 | " Tu recevras un email dès que ces changements auront été effectués."); | |
182 | } else { | |
183 | $display_names = array(); | |
184 | build_display_names($display_names, $this->search_names, $this->private_name_end); | |
185 | set_profile_display($display_names); | |
c4b45374 | 186 | } |
fd38b30e FB |
187 | } |
188 | } | |
189 | ||
043bbacf | 190 | class ProfileEdu implements ProfileSetting |
576777d7 | 191 | { |
b814a8b8 | 192 | public function __construct(){} |
043bbacf | 193 | |
5ba8842e | 194 | static function sortByGradYear($line1, $line2) { |
22f0a0a8 SJ |
195 | $a = (int) $line1['grad_year']; |
196 | $b = (int) $line2['grad_year']; | |
197 | if ($a == $b) { | |
5ba8842e SJ |
198 | return 0; |
199 | } | |
22f0a0a8 | 200 | return ($a < $b) ? -1 : 1; |
5ba8842e SJ |
201 | } |
202 | ||
576777d7 FB |
203 | public function value(ProfilePage &$page, $field, $value, &$success) |
204 | { | |
205 | $success = true; | |
043bbacf SJ |
206 | if (is_null($value) || !is_array($value)) { |
207 | $value = array(); | |
1504ac45 | 208 | $res = XDB::iterator("SELECT eduid, degreeid, fieldid, grad_year, program |
043bbacf | 209 | FROM profile_education |
fb2c09c9 | 210 | WHERE uid = {?} AND !FIND_IN_SET('primary', flags) |
043bbacf SJ |
211 | ORDER BY id", |
212 | S::v('uid')); | |
213 | while($edu = $res->next()) { | |
214 | $value[] = $edu; | |
215 | } | |
216 | } else { | |
217 | $i = 0; | |
218 | foreach ($value as $key=>&$edu) { | |
219 | if (($edu['grad_year'] < 1921) || ($edu['grad_year'] > (date('Y') + 4))) { | |
220 | Platal::page()->trigError('L\'année d\'obtention du diplôme est mal renseignée, elle doit être du type : 2004.'); | |
221 | $edu['error'] = true; | |
222 | $success = false; | |
223 | } | |
224 | if ($key != $i) { | |
225 | $value[$i] = $edu; | |
226 | unset($value[$key]); | |
227 | } | |
228 | $i++; | |
229 | } | |
5ba8842e | 230 | usort($value, array("ProfileEdu", "sortByGradYear")); |
576777d7 FB |
231 | } |
232 | return $value; | |
233 | } | |
234 | ||
043bbacf | 235 | public function save(ProfilePage &$page, $field, $value) |
576777d7 | 236 | { |
043bbacf | 237 | XDB::execute("DELETE FROM profile_education |
fb2c09c9 | 238 | WHERE uid = {?} AND !FIND_IN_SET('primary', flags)", |
043bbacf SJ |
239 | S::i('uid')); |
240 | foreach ($value as $eduid=>&$edu) { | |
241 | if ($edu['eduid'] != '') { | |
242 | XDB::execute("INSERT INTO profile_education | |
1504ac45 SJ |
243 | SET id = {?}, uid = {?}, eduid = {?}, degreeid = {?}, |
244 | fieldid = {?}, grad_year = {?}, program = {?}", | |
245 | $eduid, S::i('uid'), $edu['eduid'], $edu['degreeid'], | |
246 | $edu['fieldid'], $edu['grad_year'], $edu['program']); | |
043bbacf | 247 | } |
576777d7 FB |
248 | } |
249 | } | |
250 | } | |
251 | ||
b715c1e1 SJ |
252 | class ProfileEmailDirectory implements ProfileSetting |
253 | { | |
b814a8b8 SJ |
254 | public function __construct(){} |
255 | public function save(ProfilePage &$page, $field, $value){} | |
b715c1e1 SJ |
256 | |
257 | public function value(ProfilePage &$page, $field, $value, &$success) | |
258 | { | |
ad3fee9d | 259 | $p = Platal::page(); |
b715c1e1 SJ |
260 | |
261 | $success = true; | |
262 | if (!is_null($value)) { | |
263 | $email_stripped = strtolower(trim($value)); | |
ad3fee9d SJ |
264 | if ((!isvalid_email($email_stripped)) && ($email_stripped) && ($page->values['email_directory'] == "new@example.org")) { |
265 | $p->assign('email_error', '1'); | |
266 | $p->assign('email_directory_error', $email_stripped); | |
267 | $p->trigError('Adresse Email invalide'); | |
b715c1e1 SJ |
268 | $success = false; |
269 | } else { | |
ad3fee9d | 270 | $p->assign('email_error', '0'); |
b715c1e1 SJ |
271 | } |
272 | } | |
273 | return $value; | |
274 | } | |
b715c1e1 SJ |
275 | } |
276 | ||
d1a2252a GB |
277 | class ProfileNetworking implements ProfileSetting |
278 | { | |
279 | private $email; | |
280 | private $pub; | |
281 | private $web; | |
92446a53 | 282 | private $number; |
d1a2252a GB |
283 | |
284 | public function __construct() | |
285 | { | |
286 | $this->email = new ProfileEmail(); | |
287 | $this->pub = new ProfilePub(); | |
288 | $this->web = new ProfileWeb(); | |
92446a53 | 289 | $this->number = new ProfileNumber(); |
d1a2252a GB |
290 | } |
291 | ||
292 | public function value(ProfilePage &$page, $field, $value, &$success) | |
293 | { | |
294 | if (is_null($value)) { | |
295 | $value = array(); | |
296 | $res = XDB::iterator("SELECT n.address, n.network_type AS type, n.pub, m.name | |
297 | FROM profile_networking AS n | |
298 | INNER JOIN profile_networking_enum AS m ON (n.network_type = m.network_type) | |
299 | WHERE n.uid = {?}", | |
300 | S::i('uid')); | |
301 | while($network = $res->next()) { | |
302 | $value[] = $network; | |
303 | } | |
304 | } | |
305 | if (!is_array($value)) { | |
306 | $value = array(); | |
307 | } | |
b715c1e1 SJ |
308 | $res = XDB::iterator("SELECT filter, network_type AS type |
309 | FROM profile_networking_enum;"); | |
d1a2252a GB |
310 | $filters = array(); |
311 | while($filter = $res->next()) { | |
312 | $filters[$filter['type']] = $filter['filter']; | |
313 | } | |
314 | $success = true; | |
315 | foreach($value as $i=>&$network) { | |
92c3f9e5 GB |
316 | if (!trim($network['address'])) { |
317 | unset($value[$i]); | |
318 | } else { | |
319 | if (!isset($network['pub'])) { | |
320 | $network['pub'] = 'private'; | |
321 | } | |
322 | $network['error'] = false; | |
323 | $network['pub'] = $this->pub->value($page, 'pub', $network['pub'], $s); | |
324 | $s = true; | |
325 | if ($filters[$network['type']] == 'web') { | |
326 | $network['address'] = $this->web->value($page, 'address', $network['address'], $s); | |
327 | } elseif ($filters[$network['type']] == 'email') { | |
328 | $network['address'] = $this->email->value($page, 'address', $network['address'], $s); | |
329 | } elseif ($filters[$network['type']] == 'number') { | |
330 | $network['address'] = $this->number->value($page, 'address', $network['address'], $s); | |
331 | } | |
332 | if (!$s) { | |
333 | $success = false; | |
334 | $network['error'] = true; | |
335 | } | |
d1a2252a GB |
336 | } |
337 | } | |
338 | return $value; | |
339 | } | |
340 | ||
341 | public function save(ProfilePage &$page, $field, $value) | |
342 | { | |
343 | XDB::execute("DELETE FROM profile_networking | |
344 | WHERE uid = {?}", | |
345 | S::i('uid')); | |
346 | if (!count($value)) { | |
347 | return; | |
348 | } | |
349 | $insert = array(); | |
350 | foreach ($value as $id=>$network) { | |
351 | XDB::execute("INSERT INTO profile_networking (uid, nwid, network_type, address, pub) | |
352 | VALUES ({?}, {?}, {?}, {?}, {?})", | |
353 | S::i('uid'), $id, $network['type'], $network['address'], $network['pub']); | |
354 | } | |
355 | } | |
356 | } | |
357 | ||
fd38b30e FB |
358 | class ProfileGeneral extends ProfilePage |
359 | { | |
360 | protected $pg_template = 'profile/general.tpl'; | |
361 | ||
362 | public function __construct(PlWizard &$wiz) | |
363 | { | |
364 | parent::__construct($wiz); | |
c4b45374 SJ |
365 | $this->settings['search_names'] |
366 | = new ProfileSearchNames(); | |
62835757 SJ |
367 | $this->settings['naissance'] |
368 | = new ProfileDate(); | |
bde2be3b | 369 | $this->settings['freetext_pub'] |
576777d7 | 370 | = $this->settings['photo_pub'] |
93553cea FB |
371 | = new ProfilePub(); |
372 | $this->settings['freetext'] | |
576777d7 | 373 | = $this->settings['nationalite'] |
8450c2aa SJ |
374 | = $this->settings['nationalite2'] |
375 | = $this->settings['nationalite3'] | |
b04882ff | 376 | = $this->settings['yourself'] |
62835757 | 377 | = $this->settings['promo'] |
93553cea | 378 | = null; |
576777d7 FB |
379 | $this->settings['synchro_ax'] |
380 | = new ProfileBool(); | |
b715c1e1 SJ |
381 | $this->settings['email_directory'] |
382 | = new ProfileEmail(); | |
383 | $this->settings['email_directory_new'] | |
384 | = new ProfileEmailDirectory(); | |
d1a2252a | 385 | $this->settings['networking'] = new ProfileNetworking(); |
043bbacf SJ |
386 | $this->settings['tels'] = new ProfilePhones('user', 0); |
387 | $this->settings['edus'] = new ProfileEdu(); | |
6e32823c | 388 | $this->watched= array('freetext' => true, 'tels' => true, |
043bbacf | 389 | 'networking' => true, 'edus' => true, |
8450c2aa | 390 | 'nationalite' => true, 'nationalite2' => true, |
981d6bb2 | 391 | 'nationalite3' => true, 'search_names' => true); |
93553cea FB |
392 | } |
393 | ||
7c2e0f0d | 394 | protected function _fetchData() |
93553cea | 395 | { |
576777d7 | 396 | // Checkout all data... |
62835757 | 397 | $res = XDB::query("SELECT p.promo, e.entry_year AS entry_year, e.grad_year AS grad_year, |
6e32823c | 398 | u.nationalite, u.nationalite2, u.nationalite3, u.naissance, |
5e4417a9 | 399 | t.display_tel as mobile, t.pub as mobile_pub, |
b715c1e1 | 400 | d.email_directory as email_directory, |
93553cea | 401 | q.profile_freetext as freetext, q.profile_freetext_pub as freetext_pub, |
c4b45374 | 402 | q.profile_from_ax as synchro_ax, u.matricule_ax, p.yourself |
b715c1e1 | 403 | FROM auth_user_md5 AS u |
fb2c09c9 | 404 | INNER JOIN auth_user_quick AS q ON (u.user_id = q.user_id) |
d1319488 | 405 | INNER JOIN profile_display AS p ON (p.pid = u.user_id) |
fb2c09c9 SJ |
406 | INNER JOIN profile_education AS e ON (e.uid = u.user_id AND FIND_IN_SET('primary', e.flags)) |
407 | LEFT JOIN profile_phones AS t ON (u.user_id = t.uid AND link_type = 'user') | |
408 | LEFT JOIN profile_directory AS d ON (d.uid = u.user_id) | |
93553cea FB |
409 | WHERE u.user_id = {?}", S::v('uid', -1)); |
410 | $this->values = $res->fetchOneAssoc(); | |
576777d7 | 411 | |
576777d7 FB |
412 | // Retreive photo informations |
413 | $res = XDB::query("SELECT pub | |
414 | FROM photo | |
415 | WHERE uid = {?}", S::v('uid')); | |
416 | $this->values['photo_pub'] = $res->fetchOneCell(); | |
417 | ||
418 | $res = XDB::query("SELECT COUNT(*) | |
419 | FROM requests | |
420 | WHERE type='photo' AND user_id = {?}", | |
421 | S::v('uid')); | |
422 | $this->values['nouvellephoto'] = $res->fetchOneCell(); | |
b715c1e1 | 423 | |
62835757 | 424 | // Proposes choice for promotion |
fb2c09c9 SJ |
425 | if ($this->values['entry_year'] != $this->values['grad_year'] - 3) { |
426 | for ($i = $this->values['entry_year']; $i < $this->values['grad_year'] - 2; $i++) { | |
427 | $this->values['promo_choice'][] = "X" . $i; | |
428 | } | |
429 | } | |
93553cea FB |
430 | } |
431 | ||
7c2e0f0d | 432 | protected function _saveData() |
93553cea | 433 | { |
8450c2aa | 434 | if ($this->changed['nationalite'] || $this->changed['nationalite2'] || $this->changed['nationalite3'] |
6e32823c | 435 | || $this->changed['naissance']) { |
8450c2aa SJ |
436 | if ($this->values['nationalite3'] == "") { |
437 | $this->values['nationalite3'] = NULL; | |
438 | } | |
439 | if ($this->values['nationalite2'] == "") { | |
440 | $this->values['nationalite2'] = $this->values['nationalite3']; | |
441 | $this->values['nationalite3'] = NULL; | |
442 | } | |
443 | if ($this->values['nationalite'] == "") { | |
444 | $this->values['nationalite'] = $this->values['nationalite2']; | |
445 | $this->values['nationalite2'] = $this->values['nationalite3']; | |
446 | $this->values['nationalite3'] = NULL; | |
447 | } | |
448 | ||
fb2c09c9 | 449 | XDB::execute("UPDATE auth_user_md5 |
6e32823c | 450 | SET nationalite = {?}, nationalite2 = {?}, nationalite3 = {?}, naissance={?} |
fb2c09c9 | 451 | WHERE user_id = {?}", |
6e32823c SJ |
452 | $this->values['nationalite'], $this->values['nationalite2'], $this->values['nationalite3'], |
453 | preg_replace('@(\d{2})/(\d{2})/(\d{4})@', '\3-\2-\1', $this->values['naissance']), | |
454 | S::v('uid')); | |
576777d7 | 455 | } |
6e32823c | 456 | if ($this->changed['freetext'] || $this->changed['freetext_pub'] || $this->changed['synchro_ax']) { |
576777d7 | 457 | XDB::execute("UPDATE auth_user_quick |
6e32823c SJ |
458 | SET profile_freetext={?}, profile_freetext_pub={?}, profile_from_ax = {?} |
459 | WHERE user_id = {?}", | |
576777d7 FB |
460 | $this->values['freetext'], $this->values['freetext_pub'], |
461 | $this->values['synchro_ax'], S::v('uid')); | |
462 | } | |
b715c1e1 | 463 | if ($this->changed['email_directory']) { |
6ea6d9c1 | 464 | $new_email = ($this->values['email_directory'] == "new@example.org") ? |
b715c1e1 | 465 | $this->values['email_directory_new'] : $this->values['email_directory']; |
039ed1a1 SJ |
466 | if ($new_email == "") { |
467 | $new_email = NULL; | |
468 | } | |
b715c1e1 SJ |
469 | XDB::execute("REPLACE INTO profile_directory (uid, email_directory) |
470 | VALUES ({?}, {?})", | |
471 | S::v('uid'), $new_email); | |
472 | } | |
a7c28fff FB |
473 | if ($this->changed['photo_pub']) { |
474 | XDB::execute("UPDATE photo | |
475 | SET pub = {?} | |
476 | WHERE uid = {?}", | |
477 | $this->values['photo_pub'], S::v('uid')); | |
478 | } | |
c4b45374 SJ |
479 | if ($this->changed['yourself']) { |
480 | XDB::execute("UPDATE profile_display | |
481 | SET yourself = {?} | |
482 | WHERE pid = {?}", | |
483 | $this->values['yourself'], S::v('uid')); | |
fb2c09c9 | 484 | } |
62835757 | 485 | if ($this->changed['promo']) { |
fb2c09c9 | 486 | XDB::execute("UPDATE profile_display |
d1319488 FB |
487 | SET promo = {?} |
488 | WHERE pid = {?}", | |
62835757 | 489 | $this->values['promo'], S::v('uid')); |
b04882ff | 490 | } |
fd38b30e FB |
491 | } |
492 | ||
04334c61 | 493 | public function _prepare(PlPage &$page, $id) |
fd38b30e | 494 | { |
f711b03f | 495 | require_once "education.func.inc.php"; |
d1a2252a | 496 | |
043bbacf SJ |
497 | $res = XDB::iterator("SELECT id, field |
498 | FROM profile_education_field_enum | |
499 | ORDER BY field"); | |
500 | $page->assign('edu_fields', $res->fetchAllAssoc()); | |
501 | ||
b715c1e1 SJ |
502 | require_once "emails.combobox.inc.php"; |
503 | fill_email_combobox($page); | |
504 | ||
505 | $res = XDB::iterator("SELECT nw.network_type AS type, nw.name | |
506 | FROM profile_networking_enum AS nw | |
507 | ORDER BY name"); | |
d1a2252a | 508 | $page->assign('network_list', $res->fetchAllAssoc()); |
c4b45374 SJ |
509 | |
510 | $res = XDB::query("SELECT public_name, private_name | |
511 | FROM profile_display | |
512 | WHERE pid = {?}", | |
513 | S::v('uid')); | |
514 | $res = $res->fetchOneRow(); | |
515 | $page->assign('public_name', $res[0]); | |
516 | $page->assign('private_name', $res[1]); | |
fd38b30e FB |
517 | } |
518 | } | |
519 | ||
520 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: | |
521 | ?> |