예제 #1
0
                     $fileId = File::importImage(SITE, $p['avatar_' . $i]);
                     UserDataFieldOption::set($f->id, 'avatar_' . $i, $fileId);
                 }
             }
             break;
     }
     js_redirect('a/userdata/list');
 }
 echo '<h1>Edit userdata field</h1>';
 $field = UserDataField::get($this->child);
 $form = new XhtmlForm();
 $form->addHidden('id', $field->id);
 /// XXX  hack!
 $form->addInput('name', 'Name', $field->name);
 $form->addInput('label', 'Label', $field->label);
 $form->addDropdown('type', 'Type', UserDataField::getTypes(), $field->type);
 switch ($field->type) {
     case UserDataField::RADIO:
         for ($i = 1; $i < 6; $i++) {
             $opt = 'opt_' . $i;
             $val = UserDataFieldOption::get($field->id, $opt);
             $form->addInput($opt, 'Option ' . $i, $val);
         }
         break;
     case UserDataField::AVATAR:
         for ($i = 1; $i < 6; $i++) {
             $opt = 'avatar_' . $i;
             $val = UserDataFieldOption::get($field->id, $opt);
             if ($val) {
                 $img = new XhtmlComponentImage();
                 $img->src = getThumbUrl($val);
예제 #2
0
         if (empty($p['poll_a' . $i])) {
             continue;
         }
         $item = new CategoryItem(POLL);
         $item->owner = $pollId;
         $item->title = $p['poll_a' . $i];
         $item->store();
     }
     js_redirect('a/polls/list');
 }
 echo '<h2>Add new poll</h2>';
 $frm = new XhtmlForm();
 $frm->addInput('poll_q', 'Question');
 //    echo '<div id="poll_period_selector">';
 $dur = array('1d' => '1 day', '1w' => '1 week', '1m' => '1 month');
 $frm->addDropdown('poll_dur', 'Duration', $dur, '1w');
 $start = array('thismonday' => 'monday this week', 'nextmonday' => 'monday next week', 'nextfree' => 'next free time');
 $frm->addDropdown('poll_start', 'Starting', $start, 'nextmonday');
 //    echo '<a href="#" onclick="hide_el(\'poll_period_selector\');show_el(\'poll_period_manual\')">Enter dates manually</a>';
 //    echo '</div>';
 //    echo '<div id="poll_period_manual" style="display: none;">';
 //        echo 'Start time: '.xhtmlInput('poll_start_man').' (format YYYY-MM-DD HH:MM)<br/>';
 //        echo 'End time: '.xhtmlInput('poll_end_man').'<br/>';
 //        echo '<a href="#" onclick="hide_el(\'poll_period_manual\');show_el(\'poll_period_selector\')">Use dropdown menus instead</a>';
 //    echo '</div>';
 echo '<br/><br/>';
 for ($i = 1; $i <= 8; $i++) {
     $frm->addInput('poll_a' . $i, 'Answer ' . $i);
 }
 $frm->addSubmit('Create');
 $frm->setHandler('addPoll');
예제 #3
0
function addUserGroupSubmit($p)
{
    $grp = new UserGroup();
    $grp->setName($p['name']);
    $grp->setInfo($p['info']);
    $grp->setLevel($p['level']);
    $grp->save();
    redir('a/usergroups');
}
$header->setTitle('Admin: Manage user groups');
echo '<h1>Manage user groups</h1>';
echo '<h2>Add new group</h2>';
$form = new XhtmlForm('adm_usergroup');
$form->addInput('name', 'Group name');
$form->addTextarea('info', 'Info');
$form->addDropdown('level', 'Level', getUserLevels());
$form->addSubmit('Add');
$form->setHandler('addUserGroupSubmit');
echo $form->render();
echo '<br/>';
echo '<h2>Existing groups</h2>';
echo '<table>';
echo '<tr><th>Name</th><th>Level</th><th>Info</th><th>Created</th></tr>';
foreach (UserGroup::getAll() as $grp) {
    echo '<tr>';
    echo '<td>' . ahref('a/usergroup/' . $grp->getId(), $grp->getName()) . '</td>';
    echo '<td>' . $grp->getLevelDesc() . '</td>';
    echo '<td>' . $grp->getInfo() . '</td>';
    echo '<td>' . sql_datetime($grp->getTimeCreated()) . '</td>';
    echo '</tr>';
}
예제 #4
0
//TODO: ability to remove a empty usergroup
namespace cd;

$session->requireAdmin();
$grp = new UserGroup($this->owner);
$header->setTitle('Admin: Manage user group: ' . $grp->getName());
echo '<h1>Manage user group: ' . $grp->getName() . '</h1>';
echo 'Created at ' . sql_datetime($grp->getTimeCreated()) . ' by ' . $grp->getCreatorName() . '<br/><br/>';
function saveUserGroupSubmit($p)
{
    $grp = new UserGroup($p['g_id']);
    $grp->setName($p['name']);
    $grp->setInfo($p['info']);
    $grp->setLevel($p['level']);
    $grp->save();
    return true;
}
$form = new XhtmlForm('adm_usergroup');
$form->addHidden('g_id', $grp->getId());
//XXXX hax
$form->addInput('name', 'Group name', $grp->getName());
$form->addTextarea('info', 'Info', $grp->getInfo());
$form->addDropdown('level', 'Level', getUserLevels(), $grp->getLevel());
$form->addSubmit('Save');
$form->setHandler('saveUserGroupSubmit');
echo $form->render();
echo '<br/><br/>';
echo '<h1>Group members</h1>';
foreach ($grp->getMembers() as $user) {
    echo ahref('a/user/' . $user->id, $user->name) . '<br/>';
}