コード例 #1
0
ファイル: edit.php プロジェクト: martinlindhe/core_dev
 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');
 }
コード例 #2
0
ファイル: userdata.php プロジェクト: martinlindhe/core_dev
<?php

//TODO: ability to delete userdata field
//TODO: abiltiy to mark a userdata field as required at registration (such as email)
namespace cd;

$session->requireSuperAdmin();
switch ($this->owner) {
    case 'list':
        echo '<h1>Existing userdata fields</h1>';
        $list = UserDataField::getAll();
        $dt = new YuiDatatable();
        $dt->addColumn('id', 'Name', 'link', 'a/userdata/edit/', 'name');
        $dt->addColumn('label', 'Label');
        $dt->addColumn('type', 'Type', 'array', UserDataField::getTypes());
        $dt->setDataSource($list);
        echo $dt->render();
        echo '<br/>';
        echo '&raquo; ' . ahref('a/userdata/new', 'Create new field');
        break;
    case 'new':
        function newSubmit($p)
        {
            $f = new UserDataField();
            $f->name = $p['name'];
            $f->type = $p['type'];
            $f->label = $p['label'];
            $f->id = $f->store();
            if ($f->type == UserDataField::RADIO) {
                js_redirect('a/userdata/edit/' . $f->id);
            } else {