Exemplo n.º 1
0
        }
        echo '<h1>Report user ' . $u->name . '</h1>';
        $form = new XhtmlForm();
        $form->addHidden('id', $u->id);
        //XXX ugly hack
        $form->addTextarea('reason', 'Reason');
        $form->addSubmit('Send');
        $form->setHandler('handleReportUser');
        echo $form->render();
        break;
    case 'photo':
        // child = file id
        function handleReportPhoto($p)
        {
            ModerationObject::add(MODERATE_PHOTO, $p['id'], $p['reason']);
            js_redirect('u/photo/show/' . $p['id']);
        }
        $f = File::get($this->child);
        d($f);
        echo '<h1>Report photo ' . $f->id . '</h1>';
        $form = new XhtmlForm();
        $form->addHidden('id', $f->id);
        //XXX ugly hack
        $form->addTextarea('reason', 'Reason');
        $form->addSubmit('Send');
        $form->setHandler('handleReportPhoto');
        echo $form->render();
        break;
    default:
        echo 'no such view: ' . $this->owner;
}
Exemplo n.º 2
0
     $fb = Feedback::get($this->child);
     if (!$fb) {
         die('Eppp');
     }
     if ($fb->type == USER) {
         $from = User::get($fb->from);
         echo '<h2>User feedback from ' . $fb->name . '</h2>';
     }
     echo 'Subject: ' . $fb->subject . '<br/>';
     if ($fb->body) {
         echo 'Message: ' . nl2br($fb->body);
     }
     echo '<br/>';
     if ($fb->type == USER) {
         $msg = "In response to your feedback:\n\n" . $fb->body;
         $frm = new XhtmlForm();
         $frm->addHidden('owner', $this->child);
         $frm->addHidden('to', $fb->from);
         $frm->addTextarea('msg', 'Reply', $msg);
         $frm->addSubmit('Send');
         $frm->setHandler('fbHandle');
         echo $frm->render();
     }
     echo '<br/>';
     echo ahref('a/feedback/markhandled/' . $this->child, 'Mark as handled');
     break;
 case 'markhandled':
     // child = tblFeedback.id
     Feedback::markHandled($this->child);
     js_redirect('a/feedback/default');
     break;
 function PersonalInfoForm(User $o_person)
 {
     $this->o_person = $o_person;
     parent::XhtmlForm();
 }
Exemplo n.º 4
0
$session->requireSuperAdmin();
switch ($this->owner) {
    case 'overview':
        echo '<h1>Blogs overview</h1>';
        echo '&raquo; ' . ahref('a/blogs/new', 'Write a new blog post');
        break;
    case 'new':
        function createHandler($p)
        {
            $session = SessionHandler::getInstance();
            $o = new BlogEntry();
            $o->owner = $session->id;
            $o->subject = trim($p['subject']);
            $o->body = trim($p['body']);
            $o->time_created = sql_datetime(time());
            $o->time_published = sql_datetime(time());
            $o->id = $o->store();
            js_redirect('a/blogs/overview');
        }
        echo '<h1>Write a new blog</h1>';
        $x = new XhtmlForm();
        $x->addInput('subject', 'Subject');
        $x->addRichedit('body', 'Body');
        $x->addSubmit('Create');
        $x->setHandler('createHandler');
        echo $x->render();
        break;
    default:
        echo 'No handler for view ' . $this->owner;
}
Exemplo n.º 5
0
namespace cd;

$session->requireAdmin();
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>';
Exemplo n.º 6
0
                    break;
                default:
                    throw new \Exception('eh');
            }
            echo '<hr/>';
        }
        break;
    case 'send':
        // child = send to user id
        if (Bookmark::exists(BOOKMARK_USERBLOCK, $session->id, $this->child)) {
            echo 'User has blocked you from access';
            return;
        }
        function msgSubmit($p)
        {
            Message::send($p['to'], $p['msg']);
            js_redirect('u/messages/inbox');
        }
        $user = User::get($this->child);
        echo '<h2>Send a message to ' . $user->name . '</h2>';
        $form = new XhtmlForm();
        $form->addTextarea('msg', 'Msg');
        $form->addHidden('to', $this->child);
        $form->addSubmit('Send');
        $form->setHandler('msgSubmit');
        $form->setFocus('msg');
        echo $form->render();
        break;
    default:
        echo 'No handler for view ' . $this->owner;
}
Exemplo n.º 7
0
        $m->microtime = microtime(true);
        $m->store();
        $page->setMimeType('text/plain');
        echo 'OK';
        break;
    case 'show':
        // child = room id
        $cr = ChatRoom::get($this->child);
        echo '<h2>Chat in ' . $cr->name . '</h2>';
        if ($cr->locked_by) {
            echo 'The chatroom is locked!';
            return;
        }
        $div_name = 'chatroom_txt';
        $form_id = 'chatfrm';
        ChatRoomUpdater::init($this->child, $div_name, $form_id);
        $css = 'width:500px;' . 'height:300px;' . 'background-color:#eee;' . 'overflow:auto;';
        echo '<div id="' . $div_name . '" style="' . $css . '"></div>';
        $form = new XhtmlForm();
        $form->setId($form_id);
        $form->addInput('msg', $session->username . ':', '', 445);
        $form->setFocus('msg');
        $form->disableAutocomplete();
        echo $form->render();
        YuiTooltip::init();
        echo UserLink::render(27, "martin") . ' ';
        echo UserLink::render(32, "kotte");
        break;
    default:
        echo 'No handler for view ' . $this->owner;
}
 function OnPageLoad()
 {
     echo "<h1>Stoolball matches</h1>";
     # Filter controls
     $filter_box = new XhtmlForm();
     $filter_box->SetCssClass('dataFilter');
     $filter_box->AddAttribute('method', 'get');
     $filter_box->AddControl(new XhtmlElement('p', 'Show me: ', "follow-on large"));
     $filter_inner = new XhtmlElement('div');
     $filter_box->AddControl($filter_inner);
     $gender = new XhtmlSelect('player', 'Player type');
     $gender->SetHideLabel(true);
     $gender->AddControl(new XhtmlOption("mixed and ladies", ''));
     $gender->AddControl(new XhtmlOption('mixed', 1));
     $gender->AddControl(new XhtmlOption("ladies", 2));
     if (isset($_GET['player'])) {
         $gender->SelectOption($_GET['player']);
     }
     $filter_inner->AddControl($gender);
     $type = new XhtmlSelect('type', 'Match type');
     $type->SetHideLabel(true);
     $type->AddControl(new XhtmlOption('all matches', ''));
     $type->AddControl(new XhtmlOption('league matches', MatchType::LEAGUE));
     $type->AddControl(new XhtmlOption('cup matches', MatchType::CUP));
     $type->AddControl(new XhtmlOption('friendlies', MatchType::FRIENDLY));
     $type->AddControl(new XhtmlOption('tournaments', MatchType::TOURNAMENT));
     $type->AddControl(new XhtmlOption('practices', MatchType::PRACTICE));
     if (isset($_GET['type'])) {
         $type->SelectOption($_GET['type']);
     }
     $filter_inner->AddControl($type);
     $filter_inner->AddControl(' in ');
     $month = new XhtmlSelect('month', 'Month');
     $month->SetHideLabel(true);
     $month->AddControl(new XhtmlOption('next few matches', ''));
     foreach ($this->a_months as $i_month => $i_matches) {
         $opt = new XhtmlOption(Date::MonthAndYear($i_month), $i_month);
         if (isset($_GET['month']) and $_GET['month'] == $i_month) {
             $opt->AddAttribute('selected', 'selected');
         }
         $month->AddControl($opt);
         unset($opt);
     }
     $filter_inner->AddControl($month);
     $update = new XhtmlElement('input');
     $update->AddAttribute('type', 'submit');
     $update->AddAttribute('value', 'Update');
     $filter_inner->AddControl($update);
     # Content container
     $container = new XhtmlElement('div', $filter_box, "box");
     $content = new XhtmlElement("div", null, "box-content");
     $container->AddControl($content);
     # Display the matches
     if (count($this->a_matches)) {
         $list = new MatchListControl($this->a_matches);
         $content->AddControl($list);
     } else {
         $content->AddControl(new XhtmlElement('p', 'Sorry, there are no matches to show you.'));
         $content->AddControl(new XhtmlElement('p', 'If you know of a match which should be listed, please <a href="/play/manage/website/">add the match to the website</a>.'));
     }
     echo $container;
 }
 public function __construct(SiteSettings $settings, AuthenticationManager $authentication_manager)
 {
     $this->settings = $settings;
     $this->authentication_manager = $authentication_manager;
     parent::XhtmlForm();
 }
Exemplo n.º 10
0
    echo '<a href="' . $session->fb_handle->getLoginUrl() . '">Login with Facebook</a>';
}
$header->registerJsFunction('function check_login(frm)' . '{' . 'if (!frm.login_usr.value||!frm.login_pwd.value)' . 'return false;' . 'return true;' . '}');
function loginHandler($p)
{
    $session = SessionHandler::getInstance();
    if ($session->id) {
        dp('HACK user ' . $session->name . ' (' . $session->id . ') tried to login user ' . $p['usr']);
        return false;
    }
    if ($session->login($p['usr'], $p['pwd'])) {
        $session->showStartPage();
    }
    return true;
}
$form = new XhtmlForm('login');
$form->cssTable('');
$u_img = new XhtmlComponentImage();
$u_img->src = $page->getRelativeCoreDevUrl() . 'gfx/icon_user.png';
$i = new XhtmlComponentInput();
$i->name = 'usr';
$form->add($i, t('Username'), $u_img);
$p_img = new XhtmlComponentImage();
$p_img->src = $page->getRelativeCoreDevUrl() . 'gfx/icon_keys.png';
$i = new XhtmlComponentPassword();
$i->name = 'pwd';
$form->add($i, t('Password'), $p_img);
$form->addSubmit('Log in', 'font-weight:bold');
$form->setFocus('usr');
$form->onSubmit('return check_login(this);');
$form->setHandler(__NAMESPACE__ . '\\loginHandler');
Exemplo n.º 11
0
 $wiki = Wiki::getByName($this->child);
 echo '<h2>Edit wiki ' . $this->child . '</h2>';
 $menu = new XhtmlMenu();
 $menu->setCss('wiki_menu');
 $menu->add(t('Article'), 'u/wiki/show/' . $this->child);
 $menu->add(t('Edit'), 'u/wiki/edit/' . $this->child);
 $menu->add(t('History'), 'u/wiki/history/' . $this->child);
 echo '<div class="wiki">';
 echo $menu->render();
 /*
     if (!$session->isAdmin && !$this->lockerId) {
         echo "WIKI LOCKED";
         return;
     }
 */
 $form = new XhtmlForm('wiki_edit');
 $form->addHidden('wiki_name', $this->child);
 ///XXXX ugly hack
 $form->addText('Edit wiki article ' . $this->child);
 /*
     if ($this->lockerId)
         echo '<div class="wiki_locked">This article is currently locked from editing.</div>';
 */
 $rows = 8 + substr_count($wiki->text, "\n");
 if ($rows > 36) {
     $rows = 36;
 }
 $form->addRichedit('text', '', $wiki->text);
 /*
     if ($session->isAdmin) {
         if ($this->lockerId) {
Exemplo n.º 12
0
echo '<h2>Group membership</h2>';
echo 'This user is member of the following groups:<br/>';
foreach (UserGroupHandler::getGroups($user->id) as $g) {
    echo '<a href="' . relurl_add(array('rm_grp' => $g->getId())) . '">' . coreButton('Delete') . '</a> ';
    echo ahref('a/usergroup/' . $g->getId(), $g->getName()) . '<br/>';
}
echo '<br/>';
echo xhtmlForm('grp');
$x = new XhtmlComponentDropdown();
$x->name = 'grp_id';
$x->setOptions(UserGroup::getIndexedList());
echo $x->render() . ' ';
echo xhtmlSubmit('Add');
echo xhtmlFormClose() . '<br/><br/>';
echo '<h2>Password</h2>';
$form = new XhtmlForm('pwd');
$form->disableAutocomplete();
$form->addPassword('change_pwd', 'Change password');
$form->addSubmit('Change');
echo $form->render() . '<br/><br/>';
echo '<h2>User settings</h2>';
$settings = UserSetting::getAll($user->id);
echo xhtmlForm('edit_setting');
echo '<table>';
echo '<tr><th>Name</th><th>Value</th><th>Delete</th></tr>';
//XXX use editable YuiDataTable
foreach ($settings as $set) {
    echo '<tr>';
    echo '<td>' . xhtmlInput('setting_name_' . $set['id'], $set['name']) . '</td>';
    echo '<td>' . xhtmlInput('setting_val_' . $set['id'], $set['value']) . '</td>';
    echo '<td><a href="' . relurl_add(array('remove_setting' => $set['name'])) . '">Remove</a></td>';
Exemplo n.º 13
0
        foreach ($list as $row) {
            echo ahref('queue/status/' . $row['fileId'], 'Details');
            $uploader = new User($row['uploaderId']);
            echo ', mime=' . $row['fileMime'] . ' created ' . $row['timeUploaded'] . ' by ' . $uploader->render() . '<br/>';
        }
        break;
    case 'new':
        function uploadSubmit($p)
        {
            // XhtmlForm:s upload handler har redan processat filen här
            $eventId = TaskQueue::addTask(TASK_UPLOAD, $p['f1']);
            if (!$eventId) {
                echo 'file upload handling failed';
                return false;
            }
            echo '<div class="okay">Your file has been uploaded successfully!</div><br/>';
            echo ahref('queue/show/' . $eventId, 'Click here') . ' to perform further actions on this file.';
            return true;
        }
        echo 'Max allowed upload size is ' . ini_get('upload_max_filesize') . '<br/>';
        echo 'Max allowed POST size is ' . ini_get('post_max_size') . '<br/>';
        echo '<br/>';
        $form = new XhtmlForm('ul_pdf');
        $form->addFile('f1', 'Fil', USER);
        $form->addSubmit('Upload');
        $form->setHandler('uploadSubmit');
        echo $form->render();
        break;
    default:
        echo 'No handler for view ' . $this->view;
}
Exemplo n.º 14
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/>';
}
Exemplo n.º 15
0
 case 'edit':
     // child = tblFAQ.id
     function editHandler($p)
     {
         $session = SessionHandler::getInstance();
         $o = FaqItem::get($p['id']);
         $o->question = $p['q'];
         $o->answer = $p['a'];
         $o->creator = $session->id;
         $o->time_created = sql_datetime(time());
         $o->store();
         js_redirect('a/faq');
     }
     echo '<h2>Edit FAQ</h2>';
     $faq = FaqItem::get($this->child);
     $x = new XhtmlForm();
     $x->addHidden('id', $this->child);
     $x->addInput('q', 'Question', $faq->question);
     $x->addTextarea('a', 'Answer', $faq->answer);
     $x->addSubmit('Save');
     $x->setHandler(__NAMESPACE__ . '\\editHandler');
     echo $x->render();
     echo '<br/>';
     echo '&raquo; ' . ahref('a/faq/delete/' . $this->child, 'Delete FAQ entry');
     break;
 case 'delete':
     // child = tblFAQ.id
     if (confirmed('Are you sure you want to delete this FAQ entry?')) {
         FaqItem::remove($this->child);
         js_redirect('a/faq');
     }
Exemplo n.º 16
0
 case 'add':
     // From here you ask the server to fetch a remote media for later processing
     function uploadSubmit($p)
     {
         if (!is_url($p['url'])) {
             $error = ErrorHandler::getInstance();
             $error->add('Not an url');
             return false;
         }
         $eventId = TaskQueue::addTask(TASK_FETCH, $p['url']);
         echo '<div class="okay">URL to process has been enqueued.</div><br/>';
         echo ahref('queue/show/' . $eventId, 'Click here') . ' to perform further actions on this file.';
     }
     $url = 'http://processtest.x/kaos.mp3';
     echo 'Enter resource URL:<br/>';
     $form = new XhtmlForm('ul_pdf');
     $form->addInput('url', 'URL', $url, 60);
     $form->addSubmit('Add');
     $form->setHandler('uploadSubmit');
     echo $form->render();
     break;
 case 'overview':
     //FIXME show failed & in progress aswell
     $list = TaskQueue::getList(0, isset($_GET['completed']) ? ORDER_COMPLETED : ORDER_NEW);
     //d($list);die;
     if (!empty($list)) {
         foreach ($list as $row) {
             echo '<div class="item">';
             echo '<h2>#' . $row['entryId'] . ': ';
             switch ($row['orderType']) {
                 /*
 protected function OnPreRender()
 {
     require_once 'xhtml/forms/textbox.class.php';
     parent::AddControl('<div>');
     # div inside form required by XHTML
     # persist params as requested
     foreach ($this->a_persisted_params as $s_param) {
         $s_param = trim($s_param);
         $a_fields = $this->IsPostback() ? $_POST : $_GET;
         if (isset($a_fields[$s_param])) {
             $o_param_box = new TextBox($s_param);
             $o_param_box->SetText($a_fields[$s_param]);
             $o_param_box->SetMode(TextBoxMode::Hidden());
             parent::AddControl($o_param_box);
             unset($o_param_box);
         }
     }
     # add default buttons
     if ($this->b_show_buttons_at_top) {
         parent::AddControl($this->CreateDefaultButtons());
     }
     # display validator errors
     if (!$this->IsValid() and $this->GetShowValidationErrors()) {
         require_once 'data/validation/validation-summary.class.php';
         $a_controls = array($this);
         parent::AddControl(new ValidationSummary($a_controls));
     }
     # Adjust headings
     if ($this->b_show_sections) {
         foreach ($this->a_edit_controls as $o_control) {
             $o_control->SetIsInSection(true);
         }
     } else {
         foreach ($this->a_section_headings as $o_heading) {
             $i_key = array_search($o_heading, $this->a_controls_to_render, true);
             if (!($i_key === false)) {
                 if (array_key_exists($i_key, $this->a_controls_to_render)) {
                     unset($this->a_controls_to_render[$i_key]);
                 }
             }
         }
     }
     # Add the edit controls themselves, one at a time so that they're streamed
     foreach ($this->a_controls_to_render as $control) {
         parent::AddControl($control);
     }
     # add ids
     $a_items = $this->GetDataObjects();
     $s_item_ids = '';
     foreach ($a_items as $o_data_object) {
         if (is_object($o_data_object) and method_exists($o_data_object, 'GetId')) {
             if ($s_item_ids) {
                 $s_item_ids .= ';';
             }
             $s_item_ids .= $o_data_object->GetId();
         }
     }
     if ($s_item_ids) {
         $o_id_box = new TextBox('items', $s_item_ids);
         $o_id_box->SetMode(TextBoxMode::Hidden());
         parent::AddControl($o_id_box);
     }
     # add default buttons
     parent::AddControl($this->CreateDefaultButtons());
     parent::AddControl('</div>');
     # div inside form required by XHTML
 }
Exemplo n.º 18
0
/**
 * Utility to decode base64 strings
 */
namespace cd;

$session->requireSuperAdmin();
if (!$this->owner) {
    $this->owner = 'default';
}
switch ($this->owner) {
    case 'default':
        function onSubmit($p)
        {
            $error = ErrorHandler::getInstance();
            $res = base64_decode($p['data'], true);
            if ($res === false) {
                $error->add('Input is not base64 encoded');
                return false;
            }
            echo dh($res);
        }
        $form = new XhtmlForm();
        $form->addTextarea('data');
        $form->setFocus('data');
        $form->addSubmit('Analyze');
        $form->setHandler('onSubmit');
        echo $form->render();
        break;
    default:
        throw new \Exception('no such view: ' . $this->owner);
}
Exemplo n.º 19
0
     } else {
         $pollId = PollItem::add(SITE, 0, $p['poll_q'], $p['poll_dur'], $p['poll_start']);
     }
     for ($i = 1; $i <= 8; $i++) {
         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++) {
 /**
  * Gets the XHTML representation of the element's closing tag
  *
  * @return string
  */
 protected function GetCloseTagXhtml()
 {
     # add internal buttons at the last possible stage before closing the form,
     # to ensure that all child controls have a chance to register their internal buttons
     $s_xhtml = $this->b_render_base_element ? parent::GetCloseTagXhtml() : '';
     if (count($this->a_internal_buttons)) {
         $this->a_internal_buttons = array_unique($this->a_internal_buttons);
         $o_internal = new TextBox($this->GetNamingPrefix() . 'InternalButtons', implode('; ', $this->a_internal_buttons));
         $o_internal->SetMode(TextBoxMode::Hidden());
         $s_xhtml = '<div>' . $o_internal->__toString() . '</div>' . $s_xhtml;
     }
     return $s_xhtml;
 }
Exemplo n.º 21
0
        $form->addSubmit('Save');
        $form->setHandler('handleEditPassword');
        echo $form->render();
        break;
    case 'status':
        function handleEditStatus($p)
        {
            $session = SessionHandler::getInstance();
            if (!$session->id) {
                return;
            }
            PersonalStatus::setStatus($session->id, $p['status']);
            js_redirect('u/profile');
        }
        echo '<h1>Change status</h1>';
        $form = new XhtmlForm();
        $form->addInput('status', '');
        $form->addSubmit('Save');
        $form->setHandler('handleEditStatus');
        $form->setFocus('status');
        echo $form->render();
        break;
        break;
    default:
        echo 'no such view: ' . $view;
}
?>



<?php 
 /**
  * Creates a new StatisticsFilterControl
  */
 public function __construct()
 {
     parent::XhtmlForm();
     $this->AddAttribute("method", "get");
 }
Exemplo n.º 23
0
        break;
    case 'remove':
        if (confirmed('Are you sure you want to remove this chatroom?')) {
            ChatRoom::remove($this->child);
            js_redirect('a/chatroom/list');
        }
        break;
    case 'empty':
        if (confirmed('Are you sure you want to remove all messages from this chatroom?')) {
            ChatMessage::deleteByRoom($this->child);
            js_redirect('a/chatroom/list');
        }
        break;
    case 'new':
        function createHandler($p)
        {
            $o = new ChatRoom();
            $o->name = trim($p['name']);
            $o->id = $o->store();
            js_redirect('a/chatroom/list');
        }
        echo '<h2>Create new chatroom</h2>';
        $x = new XhtmlForm();
        $x->addInput('name', 'Name');
        $x->addSubmit('Create');
        $x->setHandler('createHandler');
        echo $x->render();
        break;
    default:
        echo 'No handler for view ' . $this->owner;
}
Exemplo n.º 24
0
    die('XXX gb only for logged in users');
}
$user_id = $this->owner;
if (!$this->owner) {
    $user_id = $session->id;
}
$user = User::get($user_id);
if (!$user) {
    die('ECK');
}
if (Bookmark::exists(BOOKMARK_USERBLOCK, $session->id, $user_id)) {
    echo 'User has blocked you from access';
    return;
}
echo '<h1>Guestbook for ' . $user->name . '</h1>';
$form = new XhtmlForm('msg');
$form->addHidden('to', $this->owner);
$form->addTextarea('body', 'Body');
$form->addSubmit('Send');
$form->setFocus('body');
$form->onSubmit('return check_gb(this);');
$form->setHandler('gbHandler');
$form->handle();
// to get latest added entry in the following query
$list = Guestbook::getEntries($user_id);
$dt = new YuiDatatable();
$dt->addColumn('creator', 'Written by');
/// XXXX show username, show link to user page
$dt->addColumn('time_created', 'When');
$dt->addColumn('body', 'Msg');
$dt->setSortOrder('time_created', 'desc');
Exemplo n.º 25
0
<?php

namespace cd;

switch ($this->owner) {
    case 'user':
        function handleSearch($p)
        {
            $list = UserList::getUsers($p['q']);
            echo '<h2>Showing users matching <u>' . $p['q'] . '</u>';
            echo ' (' . count($list) . ' hits)</h2>';
            $dt = new YuiDatatable();
            $dt->addColumn('id', 'Username', 'link', 'u/profile/', 'name');
            $dt->addColumn('time_last_active', 'Last active');
            $dt->setDataSource($list);
            echo $dt->render();
        }
        $form = new XhtmlForm();
        $form->addInput('q', 'Username search');
        $form->setFocus('q');
        $form->addSubmit('Search');
        $form->setHandler('handleSearch');
        echo $form->render();
        echo '<br/>';
        echo '&raquo; ' . ahref('u/users/online', 'Show users online') . '<br/>';
        echo '&raquo; ' . ahref('u/users/newest', 'Show new members') . '<br/>';
        break;
    default:
        throw new \Exception('no such view: ' . $this->owner);
}
Exemplo n.º 26
0
<?php

namespace cd;

function fbHandler($p)
{
    $session = SessionHandler::getInstance();
    $o = new Feedback();
    $o->type = USER;
    $o->subject = $p['subj'];
    $o->body = $p['body'];
    $o->from = $session->id;
    $o->time_created = sql_datetime(time());
    $o->store();
    js_redirect('');
    // jump to start page
}
echo '<h2>Send us feedback</h2>';
$x = new XhtmlForm();
$x->addInput('subj', 'Subject');
$x->addTextarea('body', 'Body');
$x->addSubmit('Send');
$x->setHandler('fbHandler');
echo $x->render();
Exemplo n.º 27
0
             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');
 }
 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++) {
Exemplo n.º 28
0
    $c->private = 0;
    $c->time_created = sql_datetime(time());
    $c->owner = $p['owner'];
    $c->creator = $session->id;
    $c->creator_ip = client_ip();
    $c->store();
    redir($_SERVER['REQUEST_URI']);
}
$list = Comment::getByTypeAndOwner($this->type, $this->owner);
foreach ($list as $c) {
    $user = User::get($c->creator);
    if ($user) {
        echo $user->name . ' wrote: ';
    } else {
        echo 'user id ' . $c->creator . ' wrote: ';
    }
    echo nl2br($c->msg) . '<br/>';
    echo '<span title="' . ago($c->time_created) . '">';
    echo sql_datetime($c->time_created);
    echo '</span>';
    echo '<hr/>';
}
if ($session->id) {
    $form = new XhtmlForm('addcomment');
    $form->addHidden('type', $this->type);
    $form->addHidden('owner', $this->owner);
    $form->addRichedit('comment', t('Write a comment'), '', 300, 80);
    $form->addSubmit('Save');
    $form->setHandler('handleSubmit');
    echo $form->render();
}
Exemplo n.º 29
0
    case 'new':
        $session->requireLoggedIn();
        // create new photo album
        echo '<h1>Create a new photo album</h1>';
        function handleNew($p)
        {
            $session = SessionHandler::getInstance();
            $o = new PhotoAlbum();
            $o->owner = $session->id;
            $o->name = $p['name'];
            $o->time_created = sql_datetime(time());
            if ($session->isSuperAdmin && $p['system']) {
                $o->owner = 0;
            }
            // create a system wide album
            $o->id = $o->store();
            js_redirect('u/album/show/' . $session->id . '/' . $o->id);
        }
        $form = new XhtmlForm();
        $form->addInput('name', 'Name');
        $form->setFocus('name');
        if ($session->isSuperAdmin) {
            $form->addCheckbox('system', 'System wide album? (SUPERADMIN)');
        }
        $form->addSubmit('Save');
        $form->setHandler('handleNew');
        echo $form->render();
        break;
    default:
        throw new \Exception('no such view: ' . $this->owner);
}
Exemplo n.º 30
0
namespace cd;

$session->requireSuperAdmin();
switch ($this->owner) {
    case 'version':
        echo "<h1>GeoIP database versions</h1>";
        foreach (GeoIp::getDatabaseVersions() as $d) {
            echo '<h2>' . $d['name'] . ' ' . $d['version'] . '</h2>';
            echo 'Date: ' . $d['date'] . ' (' . ago($d['date']) . ')<br/>';
            echo $d['file'] . '<br/>';
            echo '<br/>';
        }
        echo '&raquo; ' . ahref('a/geoip/query', 'Query GeoIP database');
        break;
    case 'query':
        function queryHandler($p)
        {
            echo '<h2>Result for ' . $p['ip'] . '</h2>';
            d(GeoIP::getRecord($p['ip']));
            echo 'Time zone: ' . GeoIP::getTimezone($p['ip']) . '<br/>';
        }
        echo '<h1>Query GeoIP database</h1>';
        $x = new XhtmlForm();
        $x->addInput('ip', 'IP');
        $x->addSubmit('Lookup');
        $x->setHandler('queryHandler');
        echo $x->render();
        break;
    default:
        echo 'No handler for view ' . $this->owner;
}