コード例 #1
0
 function testCreateNewSpecimenForAuthoritativePlant()
 {
     global $USER;
     $USER = User::getOneFromDb(['username' => TESTINGUSER], $this->DB);
     $s = Specimen::createNewSpecimenForAuthoritativePlant(5001, $this->DB);
     $this->assertEqual('NEW', $s->specimen_id);
     $this->assertNotEqual('', $s->created_at);
     $this->assertNotEqual('', $s->updated_at);
     $this->assertEqual($USER->user_id, $s->user_id);
     $this->assertEqual('authoritative_plant', $s->link_to_type);
     $this->assertEqual(5001, $s->link_to_id);
     $this->assertEqual(util_lang('new_specimen_name'), $s->name);
     $this->assertEqual(0, $s->gps_longitude);
     $this->assertEqual(0, $s->gps_latitude);
     $this->assertEqual(util_lang('new_specimen_notes'), $s->notes);
     $this->assertEqual(0, $s->ordering);
     $this->assertEqual('', $s->catalog_identifier);
     $this->assertEqual(0, $s->flag_workflow_published);
     $this->assertEqual(0, $s->flag_workflow_validated);
     $this->assertEqual(false, $s->flag_delete);
 }
コード例 #2
0
                        $del_s->doDelete();
                    }
                }
            }
        }
        // altered
        $ap->cacheSpecimens();
        foreach ($ap->specimens as $db_specimen) {
            $db_specimen->setFromArray($_REQUEST);
            $db_specimen->updateDb();
        }
        // created
        $created_specimen_ids = explode(',', $_REQUEST['created_specimen_ids']);
        foreach ($created_specimen_ids as $created_specimen_id) {
            if ($created_specimen_id) {
                $new_s = Specimen::createNewSpecimenForAuthoritativePlant($ap->authoritative_plant_id, $DB);
                $new_s->specimen_id = $created_specimen_id;
                $new_s->setFromArray($_REQUEST);
                if ($new_s->name != util_lang('new_specimen_name')) {
                    $new_s->specimen_id = 'NEW';
                    $new_s->updateDb();
                }
            }
        }
    }
    $action = 'view';
}
if ($action == 'list') {
    echo '<h2>' . ucfirst(util_lang('authoritative_plants')) . '</h2>' . "\n";
    if ($USER->canActOnTarget($ACTIONS['edit'], $ap)) {
        ?>