$ap = Authoritative_Plant::createNewAuthoritativePlant($DB);
        } elseif (is_numeric($_REQUEST['authoritative_plant_id'])) {
            $ap = Authoritative_Plant::getOneFromDb(['authoritative_plant_id' => $_REQUEST['authoritative_plant_id']], $DB);
            if (!$ap->matchesDb) {
                util_redirectToAppPage('app_code/authoritative_plant.php?action=list', 'failure', util_lang('no_authoritative_plant_found'));
            }
        } else {
            util_redirectToAppPage('app_code/authoritative_plant.php?action=list', 'failure', util_lang('no_authoritative_plant_found'));
        }
    } else {
        // no authoritative_plant_id in request
        if ($action != 'list') {
            // list actions can have no id - all other actions need an id
            util_redirectToAppPage('app_code/authoritative_plant.php?action=list', 'failure', util_lang('no_authoritative_plant_specified'));
        }
        $ap = Authoritative_Plant::createNewAuthoritativePlant($DB);
    }
}
if ($action == 'create' || $action == 'update') {
    if (!$ap) {
        $action = 'list';
    }
} elseif (!$ap || !$ap->matchesDb) {
    $action = 'list';
}
# 3. confirm that the user is allowed to take that action on that object (if not, redirect them to the home page with an appropriate warning)
if ($action == 'list' && !$USER->canActOnTarget($ACTIONS[$action], $ap)) {
    //        util_prePrintR($USER);
    //        exit;
    util_redirectToAppHome('failure', util_lang('no_permission'));
} elseif ($action != 'list' && !$USER->canActOnTarget($ACTIONS[$action], $ap)) {
 function testCreateNewAuthoritativePlant()
 {
     $n = Authoritative_Plant::createNewAuthoritativePlant($this->DB);
     $this->assertEqual('NEW', $n->authoritative_plant_id);
     $this->assertNotEqual('', $n->created_at);
     $this->assertNotEqual('', $n->updated_at);
     $this->assertEqual('', $n->class);
     $this->assertEqual('', $n->order);
     $this->assertEqual('', $n->family);
     $this->assertEqual('', $n->genus);
     $this->assertEqual('', $n->species);
     $this->assertEqual('', $n->variety);
     $this->assertEqual('', $n->catalog_identifier);
     $this->assertEqual(false, $n->flag_active);
     $this->assertEqual(false, $n->flag_delete);
 }