2 /***************************************************************************
3 * Copyright (C) 2003-2011 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 ProfileSettingSearchNames
implements ProfileSetting
24 private $private_name_end;
25 private $search_names;
28 public function __construct() {
29 $this->name_types
= DirEnum
::getOptions(DirEnum
::NAMES
);
32 private function matchWord($old, $new, $newLen)
34 return ($i = strpos($old, $new)) !== false
35 && ($i == 0 ||
$old{$i-1} == ' ')
36 && ($i +
$newLen == strlen($old) ||
$old{$i +
$newLen} == ' ');
39 private function prepareField($value)
41 return name_to_basename($value);
44 private function prepare(ProfilePage
$page, $field, $value, $init, &$success)
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);
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 . ").");
57 return $success ?
$value : $init;
60 /* Removes duplicated entries for the fields that do not allow them. */
61 private function clean($value)
63 $single_types = XDB
::fetchAllAssoc('id',
65 FROM profile_name_enum
66 WHERE NOT FIND_IN_SET(\'allow_duplicates\', flags)');
68 foreach ($value as $key => $item) {
69 if (isset($single_types[$item['typeid']])) {
70 if ($single_types[$item['typeid']] === true
) {
73 $single_types[$item['typeid']] = true
;
81 public function value(ProfilePage
$page, $field, $value, &$success)
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",
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)
106 $sn = $sn_all->next();
107 while ($sn_type = $sn_types->next()) {
108 if ($sn_type['id'] == $sn['typeid']) {
111 $sn = $sn_all->next();
114 $value[] = array('name' => '',
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,
127 } while ($sn = $sn_all->next());
129 $namesRequest = ProfileValidate
::get_typed_requests($page->pid(), 'usage');
130 if (count($namesRequest) > 0) {
131 Platal
::page()->assign('validation', true
);
133 $value = $this->clean($value);
135 require_once 'name.func.inc.php';
137 $value = $this->clean($value);
138 $res = XDB
::query("SELECT s.particle, s.name
139 FROM profile_name AS s
140 INNER JOIN profile_name_enum AS e ON (e.id = s.typeid)
141 WHERE s.pid = {?} AND (e.type = 'lastname' OR e.type = 'firstname')
142 ORDER BY e.type = 'firstname'",
144 $res = $res->fetchAllAssoc();
146 $initial['lastname'] = $res[0]['particle'] . $res[0]['name'];
147 $initial['firstname'] = $res[1]['name'];
148 $sn_types = build_types();
149 $this->search_names
= array();
150 foreach ($value as &$sn) {
151 $sn['name'] = trim($sn['name']);
152 if (S
::user()->isMe($page->owner
) && ($sn['type'] == 'firstname' ||
$sn['type'] == 'lastname')) {
153 $sn['name'] = $this->prepare($page, $sn['type'], $sn['name'],
154 $initial[$sn['type']], $success_tmp);
155 $success = $success && $success_tmp;
158 if (isset($sn['particle']) && ($sn['particle'] != '')) {
159 // particle is before first blank
160 list($particle, $name) = explode(' ', $sn['name'], 2);
161 $particle = trim($particle) . ' ';
163 // particle is before first quote
164 list($particle, $name) = explode('\'', $sn['name'], 2);
165 $particle = trim($particle);
167 // actually there is no particle
177 if ($sn['name'] != '') {
179 $this->search_names
[$sn['typeid']] = array('fullname' => $sn['name'],
181 'particle' => $particle,
182 'pub' => $sn['pub']);
184 if (isset($this->search_names
[$sn['typeid']])) {
185 $this->search_names
[$sn['typeid']][] = $sn['name'];
187 $this->search_names
[$sn['typeid']] = array('fullname' => $sn['name']);
189 $sn['type_name'] = $sn_types[$sn['typeid']];
193 $res = XDB
::query("SELECT public_name, private_name
197 list($public_name, $private_name) = $res->fetchOneRow();
199 $sn_types_private = build_types('private');
200 $this->private_name_end
= build_private_name($this->search_names
, $sn_types_private);
201 $private_name = $public_name . $this->private_name_end
;
203 Platal
::page()->assign('public_name', $public_name);
204 Platal
::page()->assign('private_name', $private_name);
210 public function save(ProfilePage
$page, $field, $value)
212 require_once 'name.func.inc.php';
214 $sn_old = build_sn_pub($page->pid());
215 XDB
::execute("DELETE FROM s
216 USING profile_name AS s
217 INNER JOIN profile_name_enum AS e ON (s.typeid = e.id)
218 WHERE s.pid = {?} AND NOT FIND_IN_SET('not_displayed', e.flags)",
220 $has_new = set_alias_names($this->search_names
, $sn_old, $page->pid(), $page->owner
);
222 // Only requires validation if modification in public names
224 $new_names = new NamesReq(S
::user(), $page->profile
, $this->search_names
, $this->private_name_end
);
225 $new_names->submit();
226 Platal
::page()->trigWarning('La demande de modification de tes noms a bien été prise en compte.' .
227 ' Tu recevras un email dès que ces changements auront été effectués.');
229 $display_names = array();
230 build_display_names($display_names, $this->search_names
,
231 $page->profile
->isFemale(), $this->private_name_end
);
232 set_profile_display($display_names, $page->profile
);
236 public function getText($value) {
238 foreach ($value as $name) {
239 if ($name['name'] != '') {
240 $names[] = mb_strtolower($name['type_name']) . ' : ' . $name['name'];
243 return implode(', ' , $names);
247 class ProfileSettingEdu
implements ProfileSetting
249 public function __construct() {
252 static function sortByGradYear($line1, $line2) {
253 $a = (isset($line1['grad_year'])) ?
(int) $line1['grad_year'] : 0;
254 $b = (isset($line2['grad_year'])) ?
(int) $line2['grad_year'] : 0;
258 return ($a < $b) ?
-1 : 1;
261 public function value(ProfilePage
$page, $field, $value, &$success)
264 if (is_null($value)) {
266 $value = XDB
::fetchAllAssoc("SELECT eduid, degreeid, fieldid, grad_year, program
267 FROM profile_education
268 WHERE pid = {?} AND !FIND_IN_SET('primary', flags)
271 } else if (!is_array($value)) {
275 foreach ($value as $key=>&$edu) {
276 if ($edu['eduid'] < 1 ||
!isset($edu['degreeid']) ||
$edu['degreeid'] < 1) {
277 Platal
::page()->trigError('L\'université ou le diplôme d\'une formation manque.');
280 if (($edu['grad_year'] < 1921) ||
($edu['grad_year'] > (date('Y') +
4))) {
281 Platal
::page()->trigWarning('L\'année d\'obtention du diplôme est mal ou non renseignée, elle doit être du type : 2004.');
282 $edu['grad_year'] = null
;
283 $edu['warning'] = true
;
291 usort($value, array("ProfileSettingEdu", "sortByGradYear"));
296 public function save(ProfilePage
$page, $field, $value)
298 XDB
::execute("DELETE FROM profile_education
299 WHERE pid = {?} AND !FIND_IN_SET('primary', flags)",
301 foreach ($value as $eduid=>&$edu) {
302 if ($edu['eduid'] != '') {
303 $fieldId = ($edu['fieldid'] == 0) ? null
: $edu['fieldid'];
304 XDB
::execute("INSERT INTO profile_education
305 SET id = {?}, pid = {?}, eduid = {?}, degreeid = {?},
306 fieldid = {?}, grad_year = {?}, program = {?}",
307 $eduid, $page->pid(), $edu['eduid'], $edu['degreeid'],
308 $fieldId, $edu['grad_year'], $edu['program']);
313 public function getText($value) {
314 $schoolsList = DirEnum
::getOptions(DirEnum
::EDUSCHOOLS
);
315 $degreesList = DirEnum
::getOptions(DirEnum
::EDUDEGREES
);
316 $fieldsList = DirEnum
::getOptions(DirEnum
::EDUFIELDS
);
317 $educations = array();
318 foreach ($value as $id => $education) {
319 // XXX: the following condition should be removed once there are no more incomplete educations.
320 if (is_null($education['eduid']) ||
is_null($education['degreeid'])) {
321 if (is_null($education['eduid']) && is_null($education['degreeid'])) {
322 $educations[$id] = 'formation manquante';
324 $educations[$id] = (is_null($education['eduid']) ?
'université manquante' : $schoolsList[$education['eduid']]) . ', '
325 . (is_null($education['degreeid']) ?
'diplôme manquant' : $degreesList[$education['degreeid']]);
328 $educations[$id] = $schoolsList[$education['eduid']] . ', ' . $degreesList[$education['degreeid']];
332 if ($education['grad_year']) {
333 $details[] = $education['grad_year'];
335 if ($education['program']) {
336 $details[] = '« ' . $education['program'] . ' »';
338 if ($education['fieldid']) {
339 $details[] = $fieldsList[$education['fieldid']];
341 if (count($details)) {
342 $educations[$id] .= ' (' . implode(', ', $details) . ')';
345 return implode(', ', $educations);
349 class ProfileSettingMainEdu
implements ProfileSetting
353 public function __construct()
355 $eduDegrees = DirEnum
::getOptions(DirEnum
::EDUDEGREES
);
356 $eduDegrees = array_flip($eduDegrees);
357 $this->cycles
= array(
358 $eduDegrees[Profile
::DEGREE_X
] => 'Cycle polytechnicien',
359 $eduDegrees[Profile
::DEGREE_M
] => 'Cycle master',
360 $eduDegrees[Profile
::DEGREE_D
] => 'Cycle doctoral'
364 public function value(ProfilePage
$page, $field, $value, &$success)
367 if (is_null($value)) {
369 $value = XDB
::fetchAllAssoc("SELECT degreeid, fieldid, promo_year, program
370 FROM profile_education
371 WHERE pid = {?} AND FIND_IN_SET('primary', flags)
375 foreach ($value as &$item) {
376 $item['cycle'] = $this->cycles
[$item['degreeid']];
378 } elseif (!is_array($value)) {
381 foreach ($value as $key => $item) {
382 if (!isset($item['degreeid'])) {
391 public function save(ProfilePage
$page, $field, $value)
393 foreach ($value as $item) {
394 $fieldId = ($item['fieldid'] == 0) ? null
: $item['fieldid'];
395 XDB
::execute("UPDATE profile_education
396 SET fieldid = {?}, program = {?}
397 WHERE pid = {?} AND FIND_IN_SET('primary', flags) AND degreeid = {?}",
398 $fieldId, $item['program'], $page->pid(), $item['degreeid']);
402 public function getText($value) {
403 $fieldsList = DirEnum
::getOptions(DirEnum
::EDUFIELDS
);
404 $educations = array();
405 foreach ($value as $item) {
406 $details = array($this->cycles
[$item['degreeid']]);
407 if ($education['program']) {
408 $details[] = '« ' . $education['program'] . ' »';
410 if ($education['fieldid']) {
411 $details[] = $fieldsList[$education['fieldid']];
414 return implode(', ', $educations);
418 class ProfileSettingEmailDirectory
implements ProfileSetting
420 public function __construct(){}
421 public function save(ProfilePage
$page, $field, $value){}
423 public function value(ProfilePage
$page, $field, $value, &$success)
428 if (!is_null($value)) {
429 $email_stripped = strtolower(trim($value));
430 if ((!isvalid_email($email_stripped)) && ($email_stripped) && ($page->values
['email_directory'] == "new@example.org")) {
431 $p->assign('email_error', '1');
432 $p->assign('email_directory_error', $email_stripped);
433 $p->trigError('Adresse Email invalide');
436 $p->assign('email_error', '0');
442 public function getText($value) {
447 class ProfileSettingNetworking
implements ProfileSetting
454 public function __construct()
456 $this->email
= new ProfileSettingEmail();
457 $this->pub
= new ProfileSettingPub();
458 $this->web
= new ProfileSettingWeb();
459 $this->number
= new ProfileSettingNumber();
462 public function value(ProfilePage
$page, $field, $value, &$success)
464 if (is_null($value)) {
465 $value = XDB
::fetchAllAssoc("SELECT n.address, n.pub, n.nwid AS type
466 FROM profile_networking AS n
470 if (!is_array($value)) {
473 $filters = XDB
::fetchAllAssoc('type', 'SELECT filter, nwid AS type, name
474 FROM profile_networking_enum;');
476 foreach($value as $i=>&$network) {
477 if (!trim($network['address'])) {
480 if (!isset($network['pub'])) {
481 $network['pub'] = 'private';
483 $network['error'] = false
;
484 $network['pub'] = $this->pub
->value($page, 'pub', $network['pub'], $s);
486 $network['name'] = $filters[$network['type']]['name'];
487 if ($filters[$network['type']]['filter'] == 'web') {
488 $network['address'] = $this->web
->value($page, 'address', $network['address'], $s);
489 } elseif ($filters[$network['type']]['filter'] == 'email') {
490 $network['address'] = $this->email
->value($page, 'address', $network['address'], $s);
491 } elseif ($filters[$network['type']]['filter'] == 'number') {
492 $network['address'] = $this->number
->value($page, 'address', $network['address'], $s);
496 $network['error'] = true
;
503 public function save(ProfilePage
$page, $field, $value)
505 XDB
::execute("DELETE FROM profile_networking
508 if (!count($value)) {
512 foreach ($value as $id=>$network) {
513 XDB
::execute("INSERT INTO profile_networking (pid, id, nwid, address, pub)
514 VALUES ({?}, {?}, {?}, {?}, {?})",
515 $page->pid(), $id, $network['type'], $network['address'], $network['pub']);
519 public function getText($value) {
520 static $pubs = array('public' => 'publique', 'ax' => 'annuaire AX', 'private' => 'privé');
521 $networkings = array();
522 foreach ($value as $network) {
523 $networkings[] = $network['name'] . ' : ' . $network['address'] . ' (affichage ' . $pubs[$network['pub']] . ')';
525 return implode(', ' , $networkings);
529 class ProfileSettingPromo
implements ProfileSetting
531 public function __construct(){}
533 public function save(ProfilePage
$page, $field, $value)
535 $gradYearNew = $value;
536 if ($page->profile
->mainEducation() == 'X') {
537 $gradYearNew +
= $page->profile
->mainEducationDuration();
539 if (($page->profile
->mainEducation() != 'X'
540 && $value == $page->profile
->entry_year +
$page->profile
->mainEducationDuration())
541 ||
($page->profile
->mainEducation() == 'X' && $value == $page->profile
->entry_year
)) {
542 XDB
::execute('UPDATE profile_display
545 $page->profile
->mainEducation() . strval($value), $page->profile
->id());
546 XDB
::execute('UPDATE profile_education
548 WHERE pid = {?} AND FIND_IN_SET(\'primary\', flags)',
549 $gradYearNew, $page->profile
->id());
550 Platal
::page()->trigSuccess('Ton statut « orange » a été supprimé.');
552 $myorange = new OrangeReq(S
::user(), $page->profile
, $gradYearNew);
554 Platal
::page()->trigSuccess('Tu pourras changer l\'affichage de ta promotion dès que ta nouvelle promotion aura été validée.');
558 public function value(ProfilePage
$page, $field, $value, &$success)
560 $entryYear = $page->profile
->entry_year
;
561 $gradYear = $page->profile
->grad_year
;
562 $yearpromo = $page->profile
->yearpromo();
564 if (is_null($value) ||
$value == $yearpromo) {
565 if ($gradYear != $entryYear +
$page->profile
->mainEducationDuration()) {
566 $promoChoice = array();
567 for ($i = $entryYear; $i <= $gradYear - $page->profile
->mainEducationDuration(); ++
$i) {
568 if ($page->profile
->mainEducation() == 'X') {
569 $promoChoice[] = $page->profile
->mainEducation() . strval($i);
571 $promoChoice[] = $page->profile
->mainEducation() . strval($i +
$page->profile
->mainEducationDuration());
574 Platal
::page()->assign('promo_choice', $promoChoice);
579 // If this profile belongs to an X, $promoNew needs to be changed to
580 // the graduation year.
581 $gradYearNew = $value;
582 if ($page->profile
->mainEducation() == 'X') {
583 $gradYearNew +
= $page->profile
->mainEducationDuration();
586 if ($value < 1000 ||
$value > 9999) {
587 Platal
::page()->trigError('L\'année de sortie doit être un nombre de quatre chiffres.');
589 } elseif ($gradYearNew < $entryYear +
$page->profile
->mainEducationDuration()) {
590 Platal
::page()->trigError('Trop tôt !');
593 return intval($value);
596 public function getText($value) {
602 class ProfilePageGeneral
extends ProfilePage
604 protected $pg_template = 'profile/general.tpl';
606 public function __construct(PlWizard
$wiz)
608 parent
::__construct($wiz);
609 $this->settings
['search_names']
610 = new ProfileSettingSearchNames();
611 $this->settings
['nationality1']
612 = $this->settings
['nationality2']
613 = $this->settings
['nationality3']
614 = $this->settings
['promo_display']
616 $this->settings
['email_directory']
617 = new ProfileSettingEmail();
618 $this->settings
['email_directory_new']
619 = new ProfileSettingEmailDirectory();
620 $this->settings
['networking'] = new ProfileSettingNetworking();
621 $this->settings
['tels'] = new ProfileSettingPhones();
622 $this->settings
['edus'] = new ProfileSettingEdu();
623 $this->settings
['main_edus'] = new ProfileSettingMainEdu();
624 $this->settings
['promo'] = new ProfileSettingPromo();
625 $this->watched
= array('tels' => true
,
626 'networking' => true
, 'edus' => true
,
627 'nationality1' => true
, 'nationality2' => true
,
628 'nationality3' => true
, 'search_names' => true
);
630 /* Some fields editable under condition */
631 if (!S
::user()->isMe($this->owner
)) {
632 $this->settings
['deathdate'] = new ProfileSettingDate(true
);
633 $this->settings
['birthdate'] = new ProfileSettingDate(true
);
635 $this->settings
['yourself'] = null
;
636 $this->settings
['birthdate'] = new ProfileSettingDate();
638 if (S
::user()->checkPerms('directory_private')
639 || S
::user()->isMyProfile($this->owner
)) {
640 $this->settings
['freetext'] = null
;
641 $this->settings
['freetext_pub']
642 = $this->settings
['photo_pub']
643 = new ProfileSettingPub();
644 $this->watched
['freetext'] = true
;
649 protected function _fetchData()
651 // Checkout all data...
652 $res = XDB
::query("SELECT p.nationality1, p.nationality2, p.nationality3, IF(p.birthdate = 0, '', p.birthdate) AS birthdate,
653 p.email_directory as email_directory, pd.promo AS promo_display,
654 p.freetext, p.freetext_pub, p.ax_id AS matricule_ax, pd.yourself,
657 INNER JOIN profile_display AS pd ON (pd.pid = p.pid)
658 WHERE p.pid = {?}", $this->pid());
659 $this->values
= $res->fetchOneAssoc();
661 // Retreive photo informations
662 $res = XDB
::query("SELECT pub
664 WHERE pid = {?}", $this->pid());
665 if ($res->numRows() == 0) {
666 $this->values
['photo_pub'] = 'private';
668 $this->values
['photo_pub'] = $res->fetchOneCell();
672 $res = XDB
::query("SELECT COUNT(*)
674 WHERE type = 'photo' AND pid = {?}",
676 $this->values
['nouvellephoto'] = $res->fetchOneCell();
678 $this->values
['nouvellephoto'] = 0;
682 protected function _saveData()
684 if ($this->changed
['nationality1'] ||
$this->changed
['nationality2'] ||
$this->changed
['nationality3']
685 ||
$this->changed
['birthdate'] ||
$this->changed
['freetext'] ||
$this->changed
['freetext_pub']
686 ||
$this->changed
['email_directory']) {
687 if ($this->values
['nationality3'] == "") {
688 $this->values
['nationality3'] = NULL
;
690 if ($this->values
['nationality2'] == "") {
691 $this->values
['nationality2'] = $this->values
['nationality3'];
692 $this->values
['nationality3'] = NULL
;
694 if ($this->values
['nationality1'] == "") {
695 $this->values
['nationality1'] = $this->values
['nationality2'];
696 $this->values
['nationality2'] = $this->values
['nationality3'];
697 $this->values
['nationality3'] = NULL
;
699 if ($this->values
['nationality1'] == $this->values
['nationality2']
700 && $this->values
['nationality2'] == $this->values
['nationality3']) {
701 $this->values
['nationality2'] = NULL
;
702 $this->values
['nationality3'] = NULL
;
703 } else if ($this->values
['nationality1'] == $this->values
['nationality2']) {
704 $this->values
['nationality2'] = $this->values
['nationality3'];
705 $this->values
['nationality3'] = NULL
;
706 } else if ($this->values
['nationality2'] == $this->values
['nationality3']
707 ||
$this->values
['nationality1'] == $this->values
['nationality3']) {
708 $this->values
['nationality3'] = NULL
;
711 $new_email = ($this->values
['email_directory'] == "new@example.org") ?
712 $this->values
['email_directory_new'] : $this->values
['email_directory'];
713 if ($new_email == "") {
717 XDB
::execute("UPDATE profiles
718 SET nationality1 = {?}, nationality2 = {?}, nationality3 = {?}, birthdate = {?},
719 freetext = {?}, freetext_pub = {?}, email_directory = {?}
721 $this->values
['nationality1'], $this->values
['nationality2'], $this->values
['nationality3'],
722 ProfileSettingDate
::toSQLDate($this->values
['birthdate']),
723 $this->values
['freetext'], $this->values
['freetext_pub'], $new_email, $this->pid());
725 if ($this->changed
['photo_pub']) {
726 XDB
::execute("UPDATE profile_photos
729 $this->values
['photo_pub'], $this->pid());
731 if (S
::user()->isMe($this->owner
) && $this->changed
['yourself']) {
733 XDB
::execute('UPDATE accounts
734 SET display_name = {?}
736 $this->values
['yourself'], $this->owner
->id());
738 XDB
::execute('UPDATE profile_display
740 WHERE pid = {?}', $this->values
['yourself'],
743 if ($this->changed
['promo_display']) {
744 if ($this->values
['promo_display']{0} == $this->profile
->mainEducation()) {
745 $yearpromo = intval(substr($this->values
['promo_display'], 1, 4));
746 if (($this->profile
->mainEducation() == 'X' && $yearpromo >= $this->profile
->entry_year
)
747 ||
($this->profile
->mainEducation() != 'X'
748 && $yearpromo >= $this->profile
->entry_year +
$this->profile
->mainEducationDuration())) {
749 XDB
::execute('UPDATE profile_display
752 $this->values
['promo_display'], $this->pid());
753 XDB
::execute('UPDATE profile_education
755 WHERE pid = {?} AND FIND_IN_SET(\'primary\', flags)',
756 $yearpromo, $this->pid());
760 if (!S
::user()->isMe($this->owner
) && $this->changed
['deathdate']) {
761 XDB
::execute('UPDATE profiles
762 SET deathdate = {?}, deathdate_rec = NOW()
763 WHERE pid = {?} AND deathdate_rec IS NULL',
764 ProfileSettingDate
::toSQLDate($this->values
['deathdate']), $this->pid());
765 if (XDB
::affectedRows() > 0) {
766 $this->profile
->clear();
768 $this->owner
->clear(true
);
771 /* deathdate_rec was not NULL, this is just an update of the death date
773 XDB
::execute('UPDATE profiles
776 ProfileSettingDate
::toSQLDate($this->values
['deathdate']), $this->pid());
781 public function _prepare(PlPage
$page, $id)
783 require_once "education.func.inc.php";
785 $res = XDB
::query("SELECT id, field
786 FROM profile_education_field_enum
788 $page->assign('edu_fields', $res->fetchAllAssoc());
790 require_once "emails.combobox.inc.php";
791 fill_email_combobox($page, array('source', 'redirect', 'job', 'directory'), $this->owner
);
793 $res = XDB
::query("SELECT nw.nwid AS type, nw.name
794 FROM profile_networking_enum AS nw
796 $page->assign('network_list', $res->fetchAllAssoc());
798 $res = XDB
::query("SELECT public_name, private_name
802 $res = $res->fetchOneRow();
803 $page->assign('public_name', $res[0]);
804 $page->assign('private_name', $res[1]);
805 $page->assign('isFemale', $this->profile
->isFemale() ?
1 : 0);
809 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: