+ if (is_null($value) || !is_array($value)) {
+ $value = array();
+ $res = XDB::iterator("SELECT eduid, degreeid, fieldid, grad_year, program
+ FROM profile_education
+ WHERE uid = {?} AND !FIND_IN_SET('primary', flags)
+ ORDER BY id",
+ S::v('uid'));
+ while($edu = $res->next()) {
+ $value[] = $edu;
+ }
+ } else {
+ $i = 0;
+ foreach ($value as $key=>&$edu) {
+ if (($edu['grad_year'] < 1921) || ($edu['grad_year'] > (date('Y') + 4))) {
+ Platal::page()->trigError('L\'année d\'obtention du diplôme est mal renseignée, elle doit être du type : 2004.');
+ $edu['error'] = true;
+ $success = false;
+ }
+ if ($key != $i) {
+ $value[$i] = $edu;
+ unset($value[$key]);
+ }
+ $i++;
+ }
+ usort($value, array("ProfileEdu", "sortByGradYear"));
+ }
+ return $value;
+ }
+
+ public function save(ProfilePage &$page, $field, $value)
+ {
+ XDB::execute("DELETE FROM profile_education
+ WHERE uid = {?} AND !FIND_IN_SET('primary', flags)",
+ S::i('uid'));
+ foreach ($value as $eduid=>&$edu) {
+ if ($edu['eduid'] != '') {
+ XDB::execute("INSERT INTO profile_education
+ SET id = {?}, uid = {?}, eduid = {?}, degreeid = {?},
+ fieldid = {?}, grad_year = {?}, program = {?}",
+ $eduid, S::i('uid'), $edu['eduid'], $edu['degreeid'],
+ $edu['fieldid'], $edu['grad_year'], $edu['program']);
+ }
+ }
+ }
+}
+
+class ProfileEmailDirectory implements ProfileSetting
+{
+ public function __construct(){}
+ public function save(ProfilePage &$page, $field, $value){}
+
+ public function value(ProfilePage &$page, $field, $value, &$success)
+ {
+ $p = Platal::page();
+
+ $success = true;
+ if (!is_null($value)) {
+ $email_stripped = strtolower(trim($value));
+ if ((!isvalid_email($email_stripped)) && ($email_stripped) && ($page->values['email_directory'] == "new@example.org")) {
+ $p->assign('email_error', '1');
+ $p->assign('email_directory_error', $email_stripped);
+ $p->trigError('Adresse Email invalide');
+ $success = false;
+ } else {
+ $p->assign('email_error', '0');
+ }
+ }
+ return $value;
+ }
+}
+
+class ProfileNetworking implements ProfileSetting
+{
+ private $email;
+ private $pub;
+ private $web;
+ private $number;
+
+ public function __construct()
+ {
+ $this->email = new ProfileEmail();
+ $this->pub = new ProfilePub();
+ $this->web = new ProfileWeb();
+ $this->number = new ProfileNumber();
+ }
+
+ public function value(ProfilePage &$page, $field, $value, &$success)
+ {