Select Git revision
RequestController.php
TestformController.php 2.67 KiB
<?php
class TestFormController extends Nmc_Controller_Action
{
public function indexAction()
{
$record = CourseGenerations::fetchBySubjectNumberLetter('CSCE', 155);
$newRecord = clone $record;
$newRecord->title = 'Computer Science I, part 2';
$newRecord->save();
/*
$sem = new Nmc_Semaphore('tnohu');
$sem->lock();
header('Content-type: text');
echo "doing stuff...\n";
sleep(10);
echo "done!\n";
$sem->unlock();
*/
//return $this->viewAction();
}
public function listAction()
{
$table = new TestAddressBook();
$recrods = $table->fetchAll();
$out = new Nmc_View_Unl();
$out->assign('page', 'listAddress');
$out->assign('records', $recrods);
echo $out->render('index.xhtml');
}
public function viewAction()
{
$in = $this->getRequest();
$id = Zend_Filter_Int::filter($in->getParam(0));
$table = new TestAddressBook();
$record = $table->find($id);
$out = new Nmc_View_Unl();
$out->assign('page', 'viewAddress');
$out->assign('record', $record);
echo $out->render('index.xhtml');
}
public function addAction()
{
$out = new Nmc_View_Unl();
$out->page = 'addAddress';
echo $out->render('index.xhtml');
}
public function editAction()
{
$in = $this->getRequest();
$id = Zend_Filter_Int::filter($in->getParam(0));
$table = new TestAddressBook();
$record = $table->find($id);
$out = new Nmc_View_Unl();
$out->assign('page', 'editAddress');
$out->assign('record', $record);
echo $out->render('index.xhtml');
}
public function saveAction()
{
$in = $this->getRequest();
$id = Zend_Filter_Int::filter($in->getPost('id'));
$table = new TestAddressBook();
if($id < 0) {
$record = $table->fetchNew();
} else {
$record = $table->find($id);
}
$record->firstName = Zend_Filter_Alnum::filter($in->getPost('firstName'));
$record->lastName = Zend_Filter_Alnum::filter($in->getPost('lastName'));
$record->phone = Zend_Filter_Alnum::filter($in->getPost('phone'));
$record->address = Zend_Filter_Alnum::filter($in->getPost('address'));
$record->zip = Zend_Filter_Alnum::filter($in->getPost('zip'));
$record->save();
if($id < 0) {
$id = $table->getAdapter()->lastInsertId();
}
$out = new Nmc_View_Unl();
$out->refresh = '/testform/view/' . $id;
echo $out->render('index.xhtml');
}
}
?>