An education should always contain a university and a degree.
[platal.git] / modules / profile / general.inc.php
1 <?php
2 /***************************************************************************
3 * Copyright (C) 2003-2010 Polytechnique.org *
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
22 class ProfileSettingSearchNames implements ProfileSetting
23 {
24 private $private_name_end;
25 private $search_names;
26 private $name_types;
27
28 public function __construct() {
29 $this->name_types = DirEnum::getOptions(DirEnum::NAMES);
30 }
31
32 private function matchWord($old, $new, $newLen)
33 {
34 return ($i = strpos($old, $new)) !== false
35 && ($i == 0 || $old{$i-1} == ' ')
36 && ($i + $newLen == strlen($old) || $old{$i + $newLen} == ' ');
37 }
38
39 private function prepareField($value)
40 {
41 return name_to_basename($value);
42 }
43
44 private function prepare(ProfilePage &$page, $field, $value, $init, &$success)
45 {
46 $success = true;
47 $ini = $this->prepareField($init);
48 $new = $this->prepareField($value);
49 $newLen = strlen($new);
50 $success = $this->matchWord($ini, $new, $newLen)
51 || ($field == 'lastname' && $new == 'DE ' . $ini);
52 if (!$success) {
53 $field = strtolower($field);
54 Platal::page()->trigError("Le " . $this->name_types[$field] . " que tu as choisi (" . $value .
55 ") est trop loin de ton " . $this->name_types[$field] . " initial (" . $init . ").");
56 }
57 return $success ? $value : $init;
58 }
59
60 /* Removes duplicated entries for the fields that do not allow them. */
61 private function clean($value)
62 {
63 $single_types = XDB::fetchAllAssoc('id',
64 'SELECT id, 0
65 FROM profile_name_enum
66 WHERE NOT FIND_IN_SET(\'allow_duplicates\', flags)');
67
68 foreach ($value as $key => $item) {
69 if (isset($single_types[$item['typeid']])) {
70 if ($single_types[$item['typeid']] === true) {
71 unset($value[$key]);
72 } else {
73 $single_types[$item['typeid']] = true;
74 }
75 }
76 }
77
78 return $value;
79 }
80
81 public function value(ProfilePage &$page, $field, $value, &$success)
82 {
83 $success = true;
84 $success_tmp = true;
85
86 if (is_null($value)) {
87 $sn_all = XDB::iterator("SELECT CONCAT(sn.particle, sn.name) AS name,
88 sn.particle, sn.typeid, e.type, e.name AS type_name,
89 FIND_IN_SET('has_particle', e.flags) AS has_particle,
90 FIND_IN_SET('always_displayed', e.flags) AS always_displayed,
91 FIND_IN_SET('public', e.flags) AS pub
92 FROM profile_name AS sn
93 INNER JOIN profile_name_enum AS e ON (e.id = sn.typeid)
94 WHERE sn.pid = {?} AND NOT FIND_IN_SET('not_displayed', e.flags)
95 ORDER BY NOT FIND_IN_SET('always_displayed', e.flags), e.id, sn.name",
96 $page->pid());
97
98 $sn_types = XDB::iterator("SELECT id, type, name,
99 FIND_IN_SET('has_particle', flags) AS has_particle
100 FROM profile_name_enum
101 WHERE NOT FIND_IN_SET('not_displayed', flags)
102 AND FIND_IN_SET('always_displayed', flags)
103 ORDER BY id");
104
105 $value = array();
106 $sn = $sn_all->next();
107 while ($sn_type = $sn_types->next()) {
108 if ($sn_type['id'] == $sn['typeid']) {
109 $value[] = $sn;
110 if ($sn) {
111 $sn = $sn_all->next();
112 }
113 } else {
114 $value[] = array('name' => '',
115 'particle' => '',
116 'typeid' => $sn_type['id'],
117 'type' => $sn_type['type'],
118 'type_name' => $sn_type['name'],
119 'has_particle' => $sn_type['has_particle'],
120 'always_displayed' => 1,
121 'pub' => 1);
122 }
123 }
124 if ($sn) {
125 do {
126 $value[] = $sn;
127 } while ($sn = $sn_all->next());
128 }
129 $value = $this->clean($value);
130 } else {
131 require_once 'name.func.inc.php';
132
133 $value = $this->clean($value);
134 $res = XDB::query("SELECT s.particle, s.name
135 FROM profile_name AS s
136 INNER JOIN profile_name_enum AS e ON (e.id = s.typeid)
137 WHERE s.pid = {?} AND (e.type = 'lastname' OR e.type = 'firstname')
138 ORDER BY e.type = 'firstname'",
139 $page->pid());
140 $res = $res->fetchAllAssoc();
141 $initial = array();
142 $initial['lastname'] = $res[0]['particle'] . $res[0]['name'];
143 $initial['firstname'] = $res[1]['name'];
144 $sn_types = build_types();
145 $this->search_names = array();
146 foreach ($value as &$sn) {
147 $sn['name'] = trim($sn['name']);
148 if ($sn['type'] == 'firstname' || $sn['type'] == 'lastname') {
149 $sn['name'] = $this->prepare($page, $sn['type'], $sn['name'],
150 $initial[$sn['type']], $success_tmp);
151 $success = $success && $success_tmp;
152 }
153 if ($sn['pub']) {
154 if (isset($sn['particle']) && ($sn['particle'] != '')) {
155 // particle is before first blank
156 list($particle, $name) = explode(' ', $sn['name'], 2);
157 $particle = trim($particle) . ' ';
158 if (!$name) {
159 // particle is before first quote
160 list($particle, $name) = explode('\'', $sn['name'], 2);
161 $particle = trim($particle);
162 if (!$name) {
163 // actually there is no particle
164 $particle = '';
165 $name = $sn['name'];
166 }
167 }
168 } else {
169 $particle = '';
170 $name = $sn['name'];
171 }
172 }
173 if ($sn['name'] != '') {
174 if ($sn['pub']) {
175 $this->search_names[$sn['typeid']] = array('fullname' => $sn['name'],
176 'name' => $name,
177 'particle' => $particle,
178 'pub' => $sn['pub']);
179 } else {
180 if (isset($this->search_names[$sn['typeid']])) {
181 $this->search_names[$sn['typeid']][] = $sn['name'];
182 } else {
183 $this->search_names[$sn['typeid']] = array('fullname' => $sn['name']);
184 }
185 $sn['type_name'] = $sn_types[$sn['typeid']];
186 }
187 }
188 }
189 $res = XDB::query("SELECT public_name, private_name
190 FROM profile_display
191 WHERE pid = {?}",
192 $page->pid());
193 list($public_name, $private_name) = $res->fetchOneRow();
194 if ($success) {
195 $sn_types_private = build_types('private');
196 $this->private_name_end = build_private_name($this->search_names, $sn_types_private);
197 $private_name = $public_name . $this->private_name_end;
198 }
199 Platal::page()->assign('public_name', $public_name);
200 Platal::page()->assign('private_name', $private_name);
201 }
202
203 return $value;
204 }
205
206 public function save(ProfilePage &$page, $field, $value)
207 {
208 require_once 'name.func.inc.php';
209 require_once 'validations.inc.php';
210
211 $sn_old = build_sn_pub($page->pid());
212 XDB::execute("DELETE FROM s
213 USING profile_name AS s
214 INNER JOIN profile_name_enum AS e ON (s.typeid = e.id)
215 WHERE s.pid = {?} AND NOT FIND_IN_SET('not_displayed', e.flags)",
216 $page->pid());
217 $has_new = set_alias_names($this->search_names, $sn_old, $page->pid(), $page->owner->id());
218
219 // Only requires validation if modification in public names
220 if ($has_new) {
221 $new_names = new NamesReq(S::user(), $page->profile, $this->search_names, $this->private_name_end);
222 $new_names->submit();
223 Platal::page()->trigWarning('La demande de modification de tes noms a bien été prise en compte.' .
224 ' Tu recevras un email dès que ces changements auront été effectués.');
225 } else {
226 $display_names = array();
227 build_display_names($display_names, $this->search_names,
228 $page->profile->isFemale(), $this->private_name_end);
229 set_profile_display($display_names, $page->pid());
230 }
231 }
232 }
233
234 class ProfileSettingEdu implements ProfileSetting
235 {
236 public function __construct() {
237 }
238
239 static function sortByGradYear($line1, $line2) {
240 $a = (isset($line1['grad_year'])) ? (int) $line1['grad_year'] : 0;
241 $b = (isset($line2['grad_year'])) ? (int) $line2['grad_year'] : 0;
242 if ($a == $b) {
243 return 0;
244 }
245 return ($a < $b) ? -1 : 1;
246 }
247
248 public function value(ProfilePage &$page, $field, $value, &$success)
249 {
250 $success = true;
251 if (is_null($value)) {
252 $value = array();
253 $value = XDB::fetchAllAssoc("SELECT eduid, degreeid, fieldid, grad_year, program
254 FROM profile_education
255 WHERE pid = {?} AND !FIND_IN_SET('primary', flags)
256 ORDER BY id",
257 $page->pid());
258 } else if (!is_array($value)) {
259 $value = null;
260 } else {
261 $i = 0;
262 foreach ($value as $key=>&$edu) {
263 if ($edu['eduid'] < 1 || !isset($edu['degreeid']) || $edu['degreeid'] < 1) {
264 Platal::page()->trigError('L\'université ou le diplôme d\'une formation manque.');
265 $success = false;
266 }
267 if (($edu['grad_year'] < 1921) || ($edu['grad_year'] > (date('Y') + 4))) {
268 Platal::page()->trigWarning('L\'année d\'obtention du diplôme est mal ou non renseignée, elle doit être du type : 2004.');
269 $edu['grad_year'] = null;
270 $edu['warning'] = true;
271 }
272 if ($key != $i) {
273 $value[$i] = $edu;
274 unset($value[$key]);
275 }
276 $i++;
277 }
278 usort($value, array("ProfileSettingEdu", "sortByGradYear"));
279 }
280 return $value;
281 }
282
283 public function save(ProfilePage &$page, $field, $value)
284 {
285 XDB::execute("DELETE FROM profile_education
286 WHERE pid = {?} AND !FIND_IN_SET('primary', flags)",
287 $page->pid());
288 foreach ($value as $eduid=>&$edu) {
289 if ($edu['eduid'] != '') {
290 XDB::execute("INSERT INTO profile_education
291 SET id = {?}, pid = {?}, eduid = {?}, degreeid = {?},
292 fieldid = {?}, grad_year = {?}, program = {?}",
293 $eduid, $page->pid(), $edu['eduid'], $edu['degreeid'],
294 $edu['fieldid'], $edu['grad_year'], $edu['program']);
295 }
296 }
297 }
298 }
299
300 class ProfileSettingEmailDirectory implements ProfileSetting
301 {
302 public function __construct(){}
303 public function save(ProfilePage &$page, $field, $value){}
304
305 public function value(ProfilePage &$page, $field, $value, &$success)
306 {
307 $p = Platal::page();
308
309 $success = true;
310 if (!is_null($value)) {
311 $email_stripped = strtolower(trim($value));
312 if ((!isvalid_email($email_stripped)) && ($email_stripped) && ($page->values['email_directory'] == "new@example.org")) {
313 $p->assign('email_error', '1');
314 $p->assign('email_directory_error', $email_stripped);
315 $p->trigError('Adresse Email invalide');
316 $success = false;
317 } else {
318 $p->assign('email_error', '0');
319 }
320 }
321 return $value;
322 }
323 }
324
325 class ProfileSettingNetworking implements ProfileSetting
326 {
327 private $email;
328 private $pub;
329 private $web;
330 private $number;
331
332 public function __construct()
333 {
334 $this->email = new ProfileSettingEmail();
335 $this->pub = new ProfileSettingPub();
336 $this->web = new ProfileSettingWeb();
337 $this->number = new ProfileSettingNumber();
338 }
339
340 public function value(ProfilePage &$page, $field, $value, &$success)
341 {
342 if (is_null($value)) {
343 $value = XDB::fetchAllAssoc("SELECT n.address, n.pub, n.nwid AS type
344 FROM profile_networking AS n
345 WHERE n.pid = {?}",
346 $page->pid());
347 }
348 if (!is_array($value)) {
349 $value = array();
350 }
351 $filters = XDB::fetchAllAssoc('type', 'SELECT filter, nwid AS type, name
352 FROM profile_networking_enum;');
353 $success = true;
354 foreach($value as $i=>&$network) {
355 if (!trim($network['address'])) {
356 unset($value[$i]);
357 } else {
358 if (!isset($network['pub'])) {
359 $network['pub'] = 'private';
360 }
361 $network['error'] = false;
362 $network['pub'] = $this->pub->value($page, 'pub', $network['pub'], $s);
363 $s = true;
364 $network['name'] = $filters[$network['type']]['name'];
365 if ($filters[$network['type']]['filter'] == 'web') {
366 $network['address'] = $this->web->value($page, 'address', $network['address'], $s);
367 } elseif ($filters[$network['type']]['filter'] == 'email') {
368 $network['address'] = $this->email->value($page, 'address', $network['address'], $s);
369 } elseif ($filters[$network['type']]['filter'] == 'number') {
370 $network['address'] = $this->number->value($page, 'address', $network['address'], $s);
371 }
372 if (!$s) {
373 $success = false;
374 $network['error'] = true;
375 }
376 }
377 }
378 return $value;
379 }
380
381 public function save(ProfilePage &$page, $field, $value)
382 {
383 XDB::execute("DELETE FROM profile_networking
384 WHERE pid = {?}",
385 $page->pid());
386 if (!count($value)) {
387 return;
388 }
389 $insert = array();
390 foreach ($value as $id=>$network) {
391 XDB::execute("INSERT INTO profile_networking (pid, id, nwid, address, pub)
392 VALUES ({?}, {?}, {?}, {?}, {?})",
393 $page->pid(), $id, $network['type'], $network['address'], $network['pub']);
394 }
395 }
396 }
397
398 class ProfileSettingPromo implements ProfileSetting
399 {
400 public function __construct(){}
401
402 public function save(ProfilePage &$page, $field, $value)
403 {
404 $gradYearNew = $value;
405 if ($page->profile->mainEducation() == 'X') {
406 $gradYearNew += $page->profile->mainEducationDuration();
407 }
408 if (($page->profile->mainEducation() != 'X'
409 && $value == $page->profile->entry_year + $page->profile->mainEducationDuration())
410 || ($page->profile->mainEducation() == 'X' && $value == $page->profile->entry_year)) {
411 XDB::execute('UPDATE profile_display
412 SET promo = {?}
413 WHERE pid = {?}',
414 $page->profile->mainEducation() . strval($value), $page->profile->id());
415 XDB::execute('UPDATE profile_education
416 SET grad_year = {?}
417 WHERE pid = {?} AND FIND_IN_SET(\'primary\', flags)',
418 $gradYearNew, $page->profile->id());
419 Platal::page()->trigSuccess('Ton statut « orange » a été supprimé.');
420 } else {
421 require_once 'validations.inc.php';
422
423 $myorange = new OrangeReq(S::user(), $page->profile, $gradYearNew);
424 $myorange->submit();
425 Platal::page()->trigSuccess('Tu pourras changer l\'affichage de ta promotion dès que ta nouvelle promotion aura été validée.');
426 }
427 }
428
429 public function value(ProfilePage &$page, $field, $value, &$success)
430 {
431 $entryYear = $page->profile->entry_year;
432 $gradYear = $page->profile->grad_year;
433 $yearpromo = $page->profile->grad_year;
434 if ($page->profile->mainEducation() == 'X') {
435 $yearpromo -= $page->profile->mainEducationDuration();
436 }
437 $success = true;
438 if (is_null($value) || $value == $yearpromo) {
439 if ($gradYear != $entryYear + $page->profile->mainEducationDuration()) {
440 $promoChoice = array();
441 for ($i = $entryYear; $i <= $gradYear - $page->profile->mainEducationDuration(); ++$i) {
442 if ($page->profile->mainEducation() == 'X') {
443 $promoChoice[] = $page->profile->mainEducation() . strval($i);
444 } else {
445 $promoChoice[] = $page->profile->mainEducation() . strval($i + $page->profile->mainEducationDuration());
446 }
447 }
448 Platal::page()->assign('promo_choice', $promoChoice);
449 }
450 return $yearpromo;
451 }
452
453 // If this profile belongs to an X, $promoNew needs to be changed to
454 // the graduation year.
455 $gradYearNew = $value;
456 if ($page->profile->mainEducation() == 'X') {
457 $gradYearNew += $page->profile->mainEducationDuration();
458 }
459
460 if ($value < 1000 || $value > 9999) {
461 Platal::page()->trigError('L\'année de sortie doit être un nombre de quatre chiffres.');
462 $success = false;
463 } elseif ($gradYearNew < $entryYear + $page->profile->mainEducationDuration()) {
464 Platal::page()->trigError('Trop tôt&nbsp;!');
465 $success = false;
466 }
467 return intval($value);
468 }
469 }
470
471
472 class ProfileSettingGeneral extends ProfilePage
473 {
474 protected $pg_template = 'profile/general.tpl';
475
476 public function __construct(PlWizard &$wiz)
477 {
478 parent::__construct($wiz);
479 $this->settings['search_names']
480 = new ProfileSettingSearchNames();
481 $this->settings['birthdate'] = new ProfileSettingDate();
482 $this->settings['freetext_pub']
483 = $this->settings['photo_pub']
484 = new ProfileSettingPub();
485 $this->settings['freetext']
486 = $this->settings['nationality1']
487 = $this->settings['nationality2']
488 = $this->settings['nationality3']
489 = $this->settings['yourself']
490 = $this->settings['promo_display']
491 = null;
492 $this->settings['email_directory']
493 = new ProfileSettingEmail();
494 $this->settings['email_directory_new']
495 = new ProfileSettingEmailDirectory();
496 $this->settings['networking'] = new ProfileSettingNetworking();
497 $this->settings['tels'] = new ProfileSettingPhones('user', 0);
498 $this->settings['edus'] = new ProfileSettingEdu();
499 $this->settings['promo'] = new ProfileSettingPromo();
500 $this->watched= array('freetext' => true, 'tels' => true,
501 'networking' => true, 'edus' => true,
502 'nationality1' => true, 'nationality2' => true,
503 'nationality3' => true, 'search_names' => true);
504 }
505
506 protected function _fetchData()
507 {
508 // Checkout all data...
509 $res = XDB::query("SELECT p.nationality1, p.nationality2, p.nationality3, p.birthdate,
510 pp.display_tel as mobile, pp.pub as mobile_pub,
511 p.email_directory as email_directory, pd.promo AS promo_display,
512 p.freetext, p.freetext_pub, p.ax_id AS matricule_ax, pd.yourself
513 FROM profiles AS p
514 INNER JOIN profile_display AS pd ON (pd.pid = p.pid)
515 LEFT JOIN profile_phones AS pp ON (pp.pid = p.pid AND link_type = 'user')
516 WHERE p.pid = {?}", $this->pid());
517 $this->values = $res->fetchOneAssoc();
518 if ($this->owner) {
519 $this->values['yourself'] = $this->owner->displayName();
520 }
521
522 // Retreive photo informations
523 $res = XDB::query("SELECT pub
524 FROM profile_photos
525 WHERE pid = {?}", $this->pid());
526 $this->values['photo_pub'] = $res->fetchOneCell();
527
528 if ($this->owner) {
529 $res = XDB::query("SELECT COUNT(*)
530 FROM requests
531 WHERE type = 'photo' AND pid = {?}",
532 $this->owner->id());
533 $this->values['nouvellephoto'] = $res->fetchOneCell();
534 } else {
535 $this->values['nouvellephoto'] = 0;
536 }
537 }
538
539 protected function _saveData()
540 {
541 if ($this->changed['nationality1'] || $this->changed['nationality2'] || $this->changed['nationality3']
542 || $this->changed['birthdate'] || $this->changed['freetext'] || $this->changed['freetext_pub']
543 || $this->changed['email_directory']) {
544 if ($this->values['nationality3'] == "") {
545 $this->values['nationality3'] = NULL;
546 }
547 if ($this->values['nationality2'] == "") {
548 $this->values['nationality2'] = $this->values['nationality3'];
549 $this->values['nationality3'] = NULL;
550 }
551 if ($this->values['nationality1'] == "") {
552 $this->values['nationality1'] = $this->values['nationality2'];
553 $this->values['nationality2'] = $this->values['nationality3'];
554 $this->values['nationality3'] = NULL;
555 }
556 if ($this->values['nationality1'] == $this->values['nationality2']
557 && $this->values['nationality2'] == $this->values['nationality3']) {
558 $this->values['nationality2'] = NULL;
559 $this->values['nationality3'] = NULL;
560 } else if ($this->values['nationality1'] == $this->values['nationality2']) {
561 $this->values['nationality2'] = $this->values['nationality3'];
562 $this->values['nationality3'] = NULL;
563 } else if ($this->values['nationality2'] == $this->values['nationality3']
564 || $this->values['nationality1'] == $this->values['nationality3']) {
565 $this->values['nationality3'] = NULL;
566 }
567
568 $new_email = ($this->values['email_directory'] == "new@example.org") ?
569 $this->values['email_directory_new'] : $this->values['email_directory'];
570 if ($new_email == "") {
571 $new_email = NULL;
572 }
573
574 XDB::execute("UPDATE profiles
575 SET nationality1 = {?}, nationality2 = {?}, nationality3 = {?}, birthdate = {?},
576 freetext = {?}, freetext_pub = {?}, email_directory = {?}
577 WHERE pid = {?}",
578 $this->values['nationality1'], $this->values['nationality2'], $this->values['nationality3'],
579 preg_replace('@(\d{2})/(\d{2})/(\d{4})@', '\3-\2-\1', $this->values['birthdate']),
580 $this->values['freetext'], $this->values['freetext_pub'], $new_email, $this->pid());
581 }
582 if ($this->changed['photo_pub']) {
583 XDB::execute("UPDATE profile_photos
584 SET pub = {?}
585 WHERE pid = {?}",
586 $this->values['photo_pub'], $this->pid());
587 }
588 if ($this->changed['yourself']) {
589 if ($this->owner) {
590 XDB::execute('UPDATE accounts
591 SET display_name = {?}
592 WHERE uid = {?}',
593 $this->values['yourself'], $this->owner->id());
594 }
595 XDB::execute('UPDATE profile_display
596 SET yourself = {?}
597 WHERE pid = {?}', $this->values['yourself'],
598 $this->pid());
599 }
600 if ($this->changed['promo_display']) {
601 if ($this->values['promo_display']{0} == $this->profile->mainEducation()) {
602 if (($this->profile->mainEducation() == 'X'
603 && intval(substr($this->values['promo_display'], 1, 4)) >= $this->profile->entry_year)
604 || ($this->profile->mainEducation() != 'X'
605 && intval(substr($this->values['promo_display'], 1, 4)) >= $this->profile->entry_year + $this->profile->mainEducationDuration())) {
606 XDB::execute('UPDATE profile_display
607 SET promo = {?}
608 WHERE pid = {?}',
609 $this->values['promo_display'], $this->pid());
610 }
611 }
612 }
613 }
614
615 public function _prepare(PlPage &$page, $id)
616 {
617 require_once "education.func.inc.php";
618
619 $res = XDB::query("SELECT id, field
620 FROM profile_education_field_enum
621 ORDER BY field");
622 $page->assign('edu_fields', $res->fetchAllAssoc());
623
624 require_once "emails.combobox.inc.php";
625 fill_email_combobox($page, $this->owner, $this->profile);
626
627 $res = XDB::query("SELECT nw.nwid AS type, nw.name
628 FROM profile_networking_enum AS nw
629 ORDER BY name");
630 $page->assign('network_list', $res->fetchAllAssoc());
631
632 $res = XDB::query("SELECT public_name, private_name
633 FROM profile_display
634 WHERE pid = {?}",
635 $this->pid());
636 $res = $res->fetchOneRow();
637 $page->assign('public_name', $res[0]);
638 $page->assign('private_name', $res[1]);
639 $page->assign('isFemale', $this->profile->isFemale() ? 1 : 0);
640 }
641 }
642
643 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
644 ?>