Beispiel #1
0
 /**
  * @depends test_get_classes
  */
 function test_recent_user()
 {
     // recent with user
     DB::execute('update versions set user = 1');
     $recent = Versions::recent(1);
     $this->assertEquals(count($recent), 2);
 }
Beispiel #2
0
    $p->edited = gmdate('Y-m-d H:i:s');
    $p->editor = User::$user->id;
    $p->votable = isset($_POST['votable']) ? 1 : 0;
    $p->visible = isset($_POST['visible']) ? 1 : 0;
    $p->fallback = isset($_POST['fallback']) ? 1 : 0;
    $p->options = isset($_POST['options']) ? array_filter(explode("\n", str_replace("\r", '', $_POST['options']))) : $p->options;
    $p->allowed = $_POST['allowed'] ? $_POST['allowed'] : 1;
    $p->required = $_POST['required'] ? $_POST['required'] : 1;
    if (!$p->put()) {
        $_POST['options'] = $p->options;
        $this->add_notification('Error: Unable to save poll data.');
        @error_log('Error: ' . $p->error);
        $page->add_script('/apps/polls/js/poll.edit.js', 'head');
        echo View::render('polls/edit', $_POST);
        return;
    }
    if (isset($_POST['fallback'])) {
        $polls = polls\Poll::query()->where('fallback', true)->fetch();
        foreach ($polls as $poll) {
            if ($poll->id != $this->params[0]) {
                $poll->fallback = 0;
                $poll->put();
            }
        }
    }
    if (\Versions::recent($p) != $p) {
        \Versions::add($p);
    }
    $this->add_notification('Success.');
    $this->redirect('/polls/admin');
}