Beispiel #1
0
 function editSubmit($p)
 {
     $f = UserDataField::get($p['id']);
     $f->name = $p['name'];
     $f->label = $p['label'];
     $f->type = $p['type'];
     $f->id = $f->store();
     switch ($f->type) {
         case UserDataField::RADIO:
             for ($i = 1; $i < 6; $i++) {
                 if (!empty($p['opt_' . $i])) {
                     UserDataFieldOption::set($f->id, 'opt_' . $i, $p['opt_' . $i]);
                 }
             }
             break;
         case UserDataField::AVATAR:
             for ($i = 1; $i < 6; $i++) {
                 if (!empty($p['avatar_' . $i])) {
                     if ($p['avatar_' . $i]['error'] == UPLOAD_ERR_NO_FILE) {
                         continue;
                     }
                     $fileId = File::importImage(SITE, $p['avatar_' . $i]);
                     UserDataFieldOption::set($f->id, 'avatar_' . $i, $fileId);
                 }
             }
             break;
     }
     js_redirect('a/userdata/list');
 }
Beispiel #2
0
 function handleEdit($p)
 {
     $session = SessionHandler::getInstance();
     foreach (UserDataField::getAll() as $f) {
         if (!empty($p['remove_' . $f->id])) {
             UserSetting::set($session->id, $f->name, 0);
             continue;
         }
         switch ($f->type) {
             case UserDataField::IMAGE:
                 if ($p[$f->name]['error'] == UPLOAD_ERR_NO_FILE) {
                     continue;
                 }
                 $album = PhotoAlbum::getProfileAlbumId();
                 $fileId = File::importImage(USER, $p[$f->name], $album);
                 UserSetting::set($session->id, $f->name, $fileId);
                 break;
             default:
                 UserSetting::set($session->id, $f->name, $p[$f->name]);
         }
     }
     js_redirect('u/profile');
 }