Skip to content
Snippets Groups Projects
Commit 15c77d2e authored by Tim Steiner's avatar Tim Steiner
Browse files

Made the request submittal process actually place the new request into the...

Made the request submittal process actually place the new request into the default chain for its type.
parent b097f728
No related branches found
No related tags found
No related merge requests found
Showing with 178 additions and 26 deletions
......@@ -76,7 +76,7 @@ class NewRequestController extends Nmc_Controller_Action
$courseLetter = Zend_Filter::getAlpha($in[3]);
$request = Requests::getInstance()->fetchNew();
$request->owner = Nmc_User::getInstance()->getUser()->getId();
$request->owner = Nmc_User::getInstance()->getUser();
$request->type = RequestTypes::getInstance()->stringToType($type);
$course = Nmc_Registry_Session::getInstance()->course;
......
......@@ -2,23 +2,20 @@
class TestController extends Nmc_Controller_Action
{
public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array())
public function init()
{
parent::__construct($request, $response, $invokeArgs);
//$this->_registerPlugin(new Nmc_Controller_Action_Plugin_Authorize());
//$this->_registerPlugin(new Nmc_Controller_Action_Plugin_Test());
}
public function indexAction()
{
return;
$files = Files::getInstance()->fetchAll();
foreach($files as $file) {
$fileHash = hash('whirlpool', $file->data);
$file->hash = $fileHash;
$file->save();
}
$out = $this->getResponse();
$view = new Nmc_View();
$out->setBody($view->render('index.xhtml'));
//$out->renderExceptions(true);
throw new Exception("this is bad!");
}
}
......
......@@ -19,7 +19,7 @@ class UserAdminController extends Nmc_Controller_Action
$in = $this->getRequest();
$userId = Zend_Filter::getInt($in->getParam(0));
if($in['Submit'] == 'Submit') {
if($in->getPost('Submit') == 'Submit') {
return $this->editUserActionPost();
}
......
......@@ -10,10 +10,8 @@ class CourseGeneration extends Asset
{
protected $_homeCrosslisting;
public function __construct($config = array())
public function _init()
{
parent::__construct($config);
$this->_registerRelation(
new Nmc_Db_Table_Relation_HasOne(CourseDetails::getInstance(), $this, 'generation'));
$this->_registerRelation(
......
......@@ -3,11 +3,33 @@
class Request extends Nmc_Db_Table_Row
{
public function __construct($config = array()) {
parent::__construct($config);
$this->_registerRelation(
new Nmc_Db_Table_Relation_HasMany(RequestFiles::getInstance(),
$this, 'request', 'files'));
public function _init() {
$requestRelation = new Nmc_Db_Table_Relation_HasMany(RequestFiles::getInstance(), $this, 'request', 'files');
$this->_registerRelation($requestRelation);
$ownerRelation = new Nmc_Db_Table_Relation_HasOne(Users::getInstance(), $this, 'owner');
$ownerRelation->setForeignKeyInLocalTable(true);
$ownerRelation->setAttributeName('owner');
$ownerRelation->setOverrideLocal(true);
$this->_registerRelation($ownerRelation);
$stackRelation = new Nmc_Db_Table_Relation_HasOne(RequestStacks::getInstance(), $this, 'stack_pointer');
$stackRelation->setForeignKeyInLocalTable(true);
$stackRelation->setAttributeName('stackPointer');
$stackRelation->setOverrideLocal(true);
$this->_registerRelation($stackRelation);
$stateRelation = new Nmc_Db_Table_Relation_HasOne(RequestStates::getInstance(), $this, 'state');
$stateRelation->setForeignKeyInLocalTable(true);
$stateRelation->setAttributeName('state');
$stateRelation->setOverrideLocal(true);
$this->_registerRelation($stateRelation);
$typeRelation = new Nmc_Db_Table_Relation_HasOne(RequestTypes::getInstance(), $this, 'type');
$typeRelation->setForeignKeyInLocalTable(true);
$typeRelation->setAttributeName('type');
$typeRelation->setOverrideLocal(true);
$this->_registerRelation($typeRelation);
}
/**
......@@ -80,6 +102,25 @@ class Request extends Nmc_Db_Table_Row
$newFile->type = $type;
$this->files[$key] = $newFile;
}
protected function _preSave()
{
// should only need to worry about this when dealing with a new request
if($this->getPrimaryKey() != '') {
return parent::_save();
}
// create the stack for this request and start its journy along the approval chain
$approvalBody = ApprovalBodies::getInstance()->fetchRootApprovalBody();
$stack = RequestStacks::getInstance()->fetchNew();
$stack->chain = $this->type->approvalChain;
$stack->body = $approvalBody;
$stack->save();
$this->stackPointer = $stack;
$this->state = null;
}
}
?>
\ No newline at end of file
<?php
class RequestStack extends Nmc_Db_Table_Row
{
public function _init()
{
$bodyRelation = new Nmc_Db_Table_Relation_HasOne(ApprovalBodies::getInstance(), $this, 'body');
$bodyRelation->setForeignKeyInLocalTable(true);
$bodyRelation->setOverrideLocal(true);
$bodyRelation->setAttributeName('body');
$this->_registerRelation($bodyRelation);
$chainRelation = new Nmc_Db_Table_Relation_HasOne(ApprovalChains::getInstance(), $this, 'chain');
$chainRelation->setForeignKeyInLocalTable(true);
$chainRelation->setOverrideLocal(true);
$chainRelation->setAttributeName('chain');
$this->_registerRelation($chainRelation);
}
}
\ No newline at end of file
<?php
class RequestType extends Nmc_Db_Table_Row
{
protected function _init()
{
$chainRelation = new Nmc_Db_Table_Relation_HasOne(ApprovalChains::getInstance(), $this, 'approval_chain', 'approvalChain', true);
$chainRelation->setOverrideLocal(true);
$this->_registerRelation($chainRelation);
}
}
\ No newline at end of file
......@@ -31,6 +31,15 @@ class ApprovalBodies extends Nmc_Db_Table
}
/**
* Returns the root approval body object (ie: superadmin).
*
* @return ApprovalBody
*/
public function fetchRootApprovalBody()
{
return $this->find(1);
}
}
?>
\ No newline at end of file
......@@ -2,9 +2,31 @@
/**
*
* @rowClass RequestStack
* @primary request_stack_id
*
*/
class RequestStacks extends Nmc_Db_Table {}
class RequestStacks extends Nmc_Db_Table
{
/**
* The one true instance
*
* @var RequestStacks
*/
static protected $_instance;
/**
* Return the one true instance
*
* @return RequestStacks
*/
static public function getInstance($config = array())
{
if (!self::$_instance) {
self::$_instance = new RequestStacks($config);
}
return self::$_instance;
}
}
?>
\ No newline at end of file
<?php
/**
* @primary request_state_id
*
*/
class RequestStates extends Nmc_Db_Table
{
/**
* The one true instance
*
* @var RequestStates
*/
static protected $_instance;
/**
* Return the one true instance
*
* @return RequestStates
*/
static public function getInstance($config = array())
{
if (!self::$_instance) {
self::$_instance = new RequestStates($config);
}
return self::$_instance;
}
}
\ No newline at end of file
......@@ -3,6 +3,7 @@
/**
*
* @primary request_type_id
* @rowClass RequestType
*
*/
class RequestTypes extends Nmc_Db_Table
......@@ -15,7 +16,7 @@ class RequestTypes extends Nmc_Db_Table
parent::__construct($config);
$contents = $this->fetchAll();
foreach($contents as $row) {
$this->_map[$row->name] = $row->getPrimaryKey();
$this->_map[$row->name] = $row;
}
}
......@@ -34,9 +35,30 @@ class RequestTypes extends Nmc_Db_Table
return self::$_instance;
}
public function stringToType($string)
/**
* Returns an instance of the request type specified
*
* @param string $type
* @return RequestType
*/
public function stringToType($type)
{
return $this->_map[$string];
return $this->_map[$type];
}
/**
* Returns an object for the supplied request type
*
* @param string|int $type
* @return RequestType
*/
public function fetchRequestType($type)
{
if(!Zend_Filter::isInt($type)) {
$type = $this->stringToType($string);
}
return $this->find($type);
}
}
......
......@@ -45,7 +45,7 @@
. $request->getCourseGeneration()->courseNumber
. $request->getCourseGeneration()->courseLetter; ?></td>
<td>NONC</td>
<td><?php echo $request->type; ?></td>
<td><?php echo $request->type->name; ?></td>
<td><select><option>Submission</option></select></td>
<td>
<a href="/NewRequest/Load/<?php echo $request->getPrimaryKey(); ?>">
......@@ -91,7 +91,7 @@
. $request->getCourseGeneration()->courseNumber
. $request->getCourseGeneration()->courseLetter; ?></td>
<td>NONC</td>
<td><?php echo $request->type; ?></td>
<td><?php echo $request->type->name; ?></td>
<td><select><option>Submission</option></select></td>
<td>
<a href="/NewRequest/Load/<?php echo $request->getPrimaryKey(); ?>">
......
......@@ -29,6 +29,9 @@ $controller = Zend_Controller_Front::getInstance();
$controller->setRouter($router);
$controller->setControllerDirectory(APPLICATION_PATH . '/controllers');
//$controller->registerPlugin(new Nmc_Controller_Plugin_Http());
$controller->throwExceptions(true);
$controller->dispatch();
?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment