Ejemplo n.º 1
0
 public function testCleanBool()
 {
     $this->assertEquals(TRUE, Cleaner::Bool($this->fixture['bool1']));
     $this->assertEquals(TRUE, Cleaner::Bool($this->fixture['boolT']));
     $this->assertEquals(TRUE, Cleaner::Bool($this->fixture['boolY']));
     $this->assertEquals(FALSE, Cleaner::Bool($this->fixture['bool0']));
     $this->assertEquals(FALSE, Cleaner::Bool($this->fixture['boolF']));
     $this->assertEquals(FALSE, Cleaner::Bool($this->fixture['boolN']));
     $this->assertEquals(TRUE, Cleaner::Bool('    TRUE    '));
     $this->assertEquals(FALSE, Cleaner::Bool('    no       '));
 }
Ejemplo n.º 2
0
 public function Fire()
 {
     // If an ID was passed, try updating the record.
     if ($this->input->_id) {
         try {
             $this->usergroup = new Usergroup($this->input->_id);
             $this->usergroup->FetchInto();
         } catch (\phalanx\data\ModelException $e) {
             EventPump::Pump()->RaiseEvent(new StandardErrorEvent(l10n::S('ERROR_INVALID_ID')));
             return;
         }
     } else {
         // Otherwise, create a new one.
         $this->usergroup = new Usergroup();
     }
     if ($this->input->_method == 'POST') {
         $title = \phalanx\data\Cleaner::HTML($this->input->title);
         if (empty($title)) {
             EventPump::Pump()->RaiseEvent(new StandardErrorEvent('The title field is required.'));
             return;
         }
         $this->usergroup->title = $title;
         if (!empty($this->input->display_title)) {
             $this->usergroup->display_title = \phalanx\data\Cleaner::HTML($this->input->display_title);
         }
         $mask = 0;
         foreach ($this->input->permissions as $name => $bit) {
             $mask += $bit * Usergroup::$permissions[$name];
         }
         $this->usergroup->mask = $mask;
         // Save the actual record.
         if ($this->input->_id) {
             $this->usergroup->Update();
         } else {
             $this->usergroup->Insert();
         }
     }
 }
Ejemplo n.º 3
0
function EventLink($event, $params = NULL)
{
    // Determine the base URL.
    $url = Bugdar::$settings['webroot'];
    // Use the ViewOutputHandler's closure to convert the class name to viewese.
    // We then reverse new_comment to get comment_new.
    $f = EventPump::Pump()->output_handler()->template_loader();
    $parts = explode('_', $f($event));
    $parts = array_reverse($parts);
    $url .= implode('_', $parts);
    // Append parameters.
    if ($params !== NULL) {
        if (KeyDescender::IsDescendable($params)) {
            foreach ($params as $key => $value) {
                $url .= '/' . Cleaner::HTML($key) . '/' . Cleaner::HTML($value);
            }
        } else {
            // This is a single-value type. HTML encode it and append it as the _id
            // parameter.
            $url .= '/' . Cleaner::HTML($params);
        }
    }
    return $url;
}
Ejemplo n.º 4
0
 public function HTML($string)
 {
     return \phalanx\data\Cleaner::HTML($string);
 }
Ejemplo n.º 5
0
 public function Fire()
 {
     $key = Cleaner::HTML($_POST['phalanx_form_key']);
     if (!$key || !$this->manager->Validate($key)) {
         throw new FormKeyException('Form key "' . $key . '" did not validate.');
     }
 }