From c57a1fe07e52034730e77739a8bd8268ad5e6543 Mon Sep 17 00:00:00 2001 From: Tim Steiner <tsteiner2@unl.edu> Date: Tue, 11 Sep 2007 16:31:59 +0000 Subject: [PATCH] Add College/Department/Subject router actions --- .../rows/ApprovalActionCollegeRouter.php | 46 ++++++++++++++ .../rows/ApprovalActionDepartmentRouter.php | 46 ++++++++++++++ .../rows/ApprovalActionSubjectRouter.php | 46 ++++++++++++++ application/models/rows/ApprovalChain.php | 6 +- application/models/rows/CourseGeneration.php | 11 +++- .../tables/ApprovalActionsCollegeRouter.php | 63 +++++++++++++++++++ .../ApprovalActionsDepartmentRouter.php | 63 +++++++++++++++++++ .../tables/ApprovalActionsSubjectRouter.php | 63 +++++++++++++++++++ .../ApprovalActionCollegeRouter.xhtml | 1 + .../ApprovalActionDepartmentRouter.xhtml | 1 + .../ApprovalActionSubjectRouter.xhtml | 1 + 11 files changed, 344 insertions(+), 3 deletions(-) create mode 100644 application/models/rows/ApprovalActionCollegeRouter.php create mode 100644 application/models/rows/ApprovalActionDepartmentRouter.php create mode 100644 application/models/rows/ApprovalActionSubjectRouter.php create mode 100644 application/models/tables/ApprovalActionsCollegeRouter.php create mode 100644 application/models/tables/ApprovalActionsDepartmentRouter.php create mode 100644 application/models/tables/ApprovalActionsSubjectRouter.php create mode 100644 application/views/approval_actions/ApprovalActionCollegeRouter.xhtml create mode 100644 application/views/approval_actions/ApprovalActionDepartmentRouter.xhtml create mode 100644 application/views/approval_actions/ApprovalActionSubjectRouter.xhtml diff --git a/application/models/rows/ApprovalActionCollegeRouter.php b/application/models/rows/ApprovalActionCollegeRouter.php new file mode 100644 index 00000000..8f721493 --- /dev/null +++ b/application/models/rows/ApprovalActionCollegeRouter.php @@ -0,0 +1,46 @@ +<?php + +require_once 'ApprovalActionRow/Interface.php'; + +/** + * @foreignKey approvalActionId + * @tableClass ApprovalActionsCollegeRouter + * + */ +class ApprovalActionCollegeRouter extends ApprovalAction + implements Application_ApprovalActionRow_Interface +{ + + public function getResultStatusStrings() + { + return $this->getTable()->getResultStatusStrings(); + } + + public function consider(Request $request, ApprovalChain $parentChain) + { + $parentChain->advance($request, $request->getCourseGeneration()->getHomeCollege()->name); + } + + public function updateFromForm($formData) + { + // no special data is used. + } + + /** + * Let the action know that a user has made a decsion so that the approval + * process may continue. + * + * @param Request $request + * @param User $user + * @param string $decision + */ + public function userMadeDecision(Request $request, User $user, $decision) + { + // since this is an automatic action, nothing needs to happen here. + } + + public function getUserDecision(Request $request, User $user) + { + return null; + } +} \ No newline at end of file diff --git a/application/models/rows/ApprovalActionDepartmentRouter.php b/application/models/rows/ApprovalActionDepartmentRouter.php new file mode 100644 index 00000000..73dc59ff --- /dev/null +++ b/application/models/rows/ApprovalActionDepartmentRouter.php @@ -0,0 +1,46 @@ +<?php + +require_once 'ApprovalActionRow/Interface.php'; + +/** + * @foreignKey approvalActionId + * @tableClass ApprovalActionsDepartmentRouter + * + */ +class ApprovalActionDepartmentRouter extends ApprovalAction + implements Application_ApprovalActionRow_Interface +{ + + public function getResultStatusStrings() + { + return $this->getTable()->getResultStatusStrings(); + } + + public function consider(Request $request, ApprovalChain $parentChain) + { + $parentChain->advance($request, $request->getCourseGeneration()->getHomeDepartment()->name); + } + + public function updateFromForm($formData) + { + // no special data is used. + } + + /** + * Let the action know that a user has made a decsion so that the approval + * process may continue. + * + * @param Request $request + * @param User $user + * @param string $decision + */ + public function userMadeDecision(Request $request, User $user, $decision) + { + // since this is an automatic action, nothing needs to happen here. + } + + public function getUserDecision(Request $request, User $user) + { + return null; + } +} \ No newline at end of file diff --git a/application/models/rows/ApprovalActionSubjectRouter.php b/application/models/rows/ApprovalActionSubjectRouter.php new file mode 100644 index 00000000..c4fe47d6 --- /dev/null +++ b/application/models/rows/ApprovalActionSubjectRouter.php @@ -0,0 +1,46 @@ +<?php + +require_once 'ApprovalActionRow/Interface.php'; + +/** + * @foreignKey approvalActionId + * @tableClass ApprovalActionsSubjectRouter + * + */ +class ApprovalActionSubjectRouter extends ApprovalAction + implements Application_ApprovalActionRow_Interface +{ + + public function getResultStatusStrings() + { + return $this->getTable()->getResultStatusStrings(); + } + + public function consider(Request $request, ApprovalChain $parentChain) + { + $parentChain->advance($request, $request->getCourseGeneration()->subject); + } + + public function updateFromForm($formData) + { + // no special data is used. + } + + /** + * Let the action know that a user has made a decsion so that the approval + * process may continue. + * + * @param Request $request + * @param User $user + * @param string $decision + */ + public function userMadeDecision(Request $request, User $user, $decision) + { + // since this is an automatic action, nothing needs to happen here. + } + + public function getUserDecision(Request $request, User $user) + { + return null; + } +} \ No newline at end of file diff --git a/application/models/rows/ApprovalChain.php b/application/models/rows/ApprovalChain.php index 40e1e8a8..17927d04 100644 --- a/application/models/rows/ApprovalChain.php +++ b/application/models/rows/ApprovalChain.php @@ -107,7 +107,11 @@ class ApprovalChain extends Nmc_Db_Table_Row $where = array(); $where[] = $db->quoteInto('chain=?', $this->getPrimaryKey()); $where[] = $db->quoteInto('currentAction=?', $request->stackPointer->action->getPrimaryKey()); - $where[] = $db->quoteInto('currentState=?', $request->state); + if ($request->state != '') { + $where[] = $db->quoteInto('currentState=?', $request->state); + } else { + $where[] = 'currentState IS NULL'; + } $where = implode(' AND ', $where); $nextLink = ApprovalLinks::getInstance()->fetchRow($where); diff --git a/application/models/rows/CourseGeneration.php b/application/models/rows/CourseGeneration.php index c4c36704..3ccaa996 100644 --- a/application/models/rows/CourseGeneration.php +++ b/application/models/rows/CourseGeneration.php @@ -176,13 +176,20 @@ class CourseGeneration extends Asset public function getHomeCollege() { - $subject = Subjects::getInstance()->fetchSubject($this->subject); - $department = $subject->department; + $department = $this->getHomeDepartment(); $college = $department->college; return $college; } + public function getHomeDepartment() + { + $subject = Subjects::getInstance()->fetchSubject($this->subject); + $department = $subject->department; + + return $department; + } + /** * Returns a reference to the home crosslist * diff --git a/application/models/tables/ApprovalActionsCollegeRouter.php b/application/models/tables/ApprovalActionsCollegeRouter.php new file mode 100644 index 00000000..c48bd64b --- /dev/null +++ b/application/models/tables/ApprovalActionsCollegeRouter.php @@ -0,0 +1,63 @@ +<?php + +require_once 'ApprovalActionTable/Interface.php'; + +class ApprovalActionsCollegeRouter extends Nmc_Db_Table + implements Application_ApprovalActionTable_Interface +{ + protected $_primary = 'approvalActionId'; + protected $_rowClass = 'ApprovalActionCollegeRouter'; + + /** + * The one true instance + * + * @var ApprovalActionsCollegeRouter + */ + static protected $_instance; + + /** + * Return the one true instance + * + * @return ApprovalActionsCollegeRouter + */ + static public function getInstance($config = array()) + { + if (!self::$_instance) { + self::$_instance = new ApprovalActionsCollegeRouter($config); + } + return self::$_instance; + } + + public function getActionName() + { + return 'College Router'; + } + + public function getResultStatusStrings() + { + $colleges = Colleges::getInstance()->fetchAll(); + $collegesArray = array(); + foreach ($colleges as $college) { + $collegesArray[$college->name] = $college->name; + } + return $collegesArray; + } + + public function getEditTemplate() + { + return 'approval_actions/ApprovalActionCollegeRouter.xhtml'; + } + + public function fetchNew($formData = null) + { + if (!$formData) { + return parent::fetchNew(); + } + + $new = parent::fetchNew(); + $new->className = 'ApprovalActionCollegeRouter'; + + return $new; + } + +} diff --git a/application/models/tables/ApprovalActionsDepartmentRouter.php b/application/models/tables/ApprovalActionsDepartmentRouter.php new file mode 100644 index 00000000..af729022 --- /dev/null +++ b/application/models/tables/ApprovalActionsDepartmentRouter.php @@ -0,0 +1,63 @@ +<?php + +require_once 'ApprovalActionTable/Interface.php'; + +class ApprovalActionsDepartmentRouter extends Nmc_Db_Table + implements Application_ApprovalActionTable_Interface +{ + protected $_primary = 'approvalActionId'; + protected $_rowClass = 'ApprovalActionDepartmentRouter'; + + /** + * The one true instance + * + * @var ApprovalActionsDepartmentRouter + */ + static protected $_instance; + + /** + * Return the one true instance + * + * @return ApprovalActionsDepartmentRouter + */ + static public function getInstance($config = array()) + { + if (!self::$_instance) { + self::$_instance = new ApprovalActionsDepartmentRouter($config); + } + return self::$_instance; + } + + public function getActionName() + { + return 'Department Router'; + } + + public function getResultStatusStrings() + { + $departments = Departments::getInstance()->fetchAll(); + $departmentsArray = array(); + foreach ($departments as $department) { + $departmentsArray[$department->name] = $department->name; + } + return $departmentsArray; + } + + public function getEditTemplate() + { + return 'approval_actions/ApprovalActionDepartmentRouter.xhtml'; + } + + public function fetchNew($formData = null) + { + if (!$formData) { + return parent::fetchNew(); + } + + $new = parent::fetchNew(); + $new->className = 'ApprovalActionDepartmentRouter'; + + return $new; + } + +} diff --git a/application/models/tables/ApprovalActionsSubjectRouter.php b/application/models/tables/ApprovalActionsSubjectRouter.php new file mode 100644 index 00000000..277fcd47 --- /dev/null +++ b/application/models/tables/ApprovalActionsSubjectRouter.php @@ -0,0 +1,63 @@ +<?php + +require_once 'ApprovalActionTable/Interface.php'; + +class ApprovalActionsSubjectRouter extends Nmc_Db_Table + implements Application_ApprovalActionTable_Interface +{ + protected $_primary = 'approvalActionId'; + protected $_rowClass = 'ApprovalActionSubjectRouter'; + + /** + * The one true instance + * + * @var ApprovalActionsSubjectRouter + */ + static protected $_instance; + + /** + * Return the one true instance + * + * @return ApprovalActionsSubjectRouter + */ + static public function getInstance($config = array()) + { + if (!self::$_instance) { + self::$_instance = new ApprovalActionsSubjectRouter($config); + } + return self::$_instance; + } + + public function getActionName() + { + return 'Subject Router'; + } + + public function getResultStatusStrings() + { + $subjects = Subjects::getInstance()->fetchAll(); + $subjectsArray = array(); + foreach ($subjects as $subject) { + $subjectsArray[$subject->name] = $subject->name; + } + return $subjectsArray; + } + + public function getEditTemplate() + { + return 'approval_actions/ApprovalActionSubjectRouter.xhtml'; + } + + public function fetchNew($formData = null) + { + if (!$formData) { + return parent::fetchNew(); + } + + $new = parent::fetchNew(); + $new->className = 'ApprovalActionSubjectRouter'; + + return $new; + } + +} diff --git a/application/views/approval_actions/ApprovalActionCollegeRouter.xhtml b/application/views/approval_actions/ApprovalActionCollegeRouter.xhtml new file mode 100644 index 00000000..1276d21e --- /dev/null +++ b/application/views/approval_actions/ApprovalActionCollegeRouter.xhtml @@ -0,0 +1 @@ +<em>This space intentionally left blank</em> \ No newline at end of file diff --git a/application/views/approval_actions/ApprovalActionDepartmentRouter.xhtml b/application/views/approval_actions/ApprovalActionDepartmentRouter.xhtml new file mode 100644 index 00000000..1276d21e --- /dev/null +++ b/application/views/approval_actions/ApprovalActionDepartmentRouter.xhtml @@ -0,0 +1 @@ +<em>This space intentionally left blank</em> \ No newline at end of file diff --git a/application/views/approval_actions/ApprovalActionSubjectRouter.xhtml b/application/views/approval_actions/ApprovalActionSubjectRouter.xhtml new file mode 100644 index 00000000..1276d21e --- /dev/null +++ b/application/views/approval_actions/ApprovalActionSubjectRouter.xhtml @@ -0,0 +1 @@ +<em>This space intentionally left blank</em> \ No newline at end of file -- GitLab