Example #1
0
 public function save(ProfilePage $page, $field, $value)
 {
     $original =& $page->orig[$field];
     $i = $j = 0;
     $total_original = count($original);
     $total_value = count($value);
     if ($total_original && !S::user()->isMyProfile($profile) && $page->values['medals_pub'] == 'private' && !S::user()->checkPerms(User::PERM_DIRECTORY_PRIVATE)) {
         return;
     }
     while ($i < $total_original || $j < $total_value) {
         if (isset($value[$j]) && (!isset($original[$i]) || self::compareMedals($original[$i], $value[$j]))) {
             $req = new MedalReq(S::user(), $page->profile, $value[$j]['id'], $value[$j]['grade'], $value[$j]['level'], $value[$j]['has_levels']);
             $req->submit();
             sleep(1);
             ++$j;
         } elseif (isset($original[$i]) && (!isset($value[$j]) || self::compareMedals($value[$j], $original[$i]))) {
             if ($original[$i]['valid']) {
                 XDB::execute('DELETE FROM  profile_medals
                                     WHERE  pid = {?} AND mid = {?} AND gid = {?}', $page->pid(), $original[$i]['id'], $original[$i]['grade']);
             } else {
                 $req = MedalReq::get_request($page->pid(), $original[$i]['id'], $original[$i]['grade'], $value[$j]['level']);
                 if ($req) {
                     $req->clean();
                 }
             }
             ++$i;
         } else {
             ++$i;
             ++$j;
         }
     }
 }
Example #2
0
 public function save(ProfilePage $page, $field, $value)
 {
     $deletePrivate = S::user()->isMe($page->owner) || S::admin();
     Phone::deletePhones($page->pid(), Phone::LINK_ADDRESS, null, $deletePrivate);
     Address::deleteAddresses($page->pid(), Address::LINK_PROFILE, null, null, $deletePrivate);
     AddressReq::purge_requests($page->pid(), 0, 0, Address::LINK_PROFILE);
     Address::saveFromArray($value, $page->pid(), Address::LINK_PROFILE, null, $deletePrivate);
     if (S::user()->isMe($page->owner) && count($value) > 1) {
         Platal::page()->trigWarning('Attention, tu as plusieurs adresses sur ton profil. Pense à supprimer celles qui sont obsolètes.');
     }
 }
Example #3
0
 public function save(ProfilePage $page, $field, $value)
 {
     XDB::execute("DELETE FROM  profile_binets\n                            WHERE  pid = {?}", $page->pid());
     if (!count($value)) {
         return;
     }
     $insert = array();
     foreach ($value as $id => $text) {
         $insert[] = XDB::format('({?}, {?})', $page->pid(), $id);
     }
     XDB::execute("INSERT INTO  profile_binets (pid, binet_id)\n                           VALUES  " . implode(',', $insert));
 }
Example #4
0
 public function save(ProfilePage $page, $field, $value)
 {
     if (!S::user()->isMe($page->owner)) {
         XDB::execute('INSERT INTO  profile_corps (original_corpsid, current_corpsid, rankid, corps_pub, pid)
                            VALUES  ({?}, {?}, {?}, {?}, {?})
           ON DUPLICATE KEY UPDATE  original_corpsid = VALUES(original_corpsid), current_corpsid = VALUES(current_corpsid),
                                    rankid = VALUES(rankid), corps_pub = VALUES(corps_pub)', $value['original'], $value['current'], $value['rank'], $value['pub'], $page->pid());
     } else {
         XDB::execute('INSERT INTO  profile_corps (current_corpsid, rankid, corps_pub, pid)
                            VALUES  ({?}, {?}, {?}, {?})
           ON DUPLICATE KEY UPDATE  current_corpsid = VALUES(current_corpsid),
                                    rankid = VALUES(rankid), corps_pub = VALUES(corps_pub)', $value['current'], $value['rank'], $value['pub'], $page->pid());
     }
 }
Example #5
0
 public function save(ProfilePage $page, $field, $value)
 {
     XDB::execute('DELETE FROM profile_hobby
                         WHERE pid = {?}', $page->pid());
     if (!count($value)) {
         return;
     }
     foreach ($value as $id => $hobby) {
         XDB::execute("INSERT INTO  profile_hobby (pid, id, type, text, pub)\n                               VALUES  ({?}, {?}, {?}, {?}, {?})", $page->pid(), $id, $hobby['type'], $hobby['text'], $hobby['pub']);
     }
 }
Example #6
0
 public function save(ProfilePage $page, $field, $value)
 {
     XDB::execute("DELETE FROM  profile_mentor_country\n                            WHERE  pid = {?}", $page->pid());
     foreach ($value as $id => &$name) {
         XDB::execute("INSERT INTO  profile_mentor_country (pid, country)\n                               VALUES  ({?}, {?})", $page->pid(), $id);
     }
 }
Example #7
0
 public function save(ProfilePage $page, $field, $value)
 {
     Phone::deletePhones($page->pid(), Phone::LINK_PROFILE, null, S::user()->isMe($page->owner) || S::admin());
     Phone::savePhones($value, $page->pid(), Phone::LINK_PROFILE);
 }