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

Allow for "pre-votes" in Queue ApprovalAction.

Groundwork for a possible "Submitter Approval" Approval Action
parent e084598f
No related branches found
No related tags found
No related merge requests found
......@@ -108,12 +108,26 @@ class ApprovalActionQueue extends ApprovalAction
*/
public function userMadeDecision(Request $request, User $user, $decision)
{
//
$vote = ApproverVotes::getInstance()->fetchByRequestUserAndAction($request, $user, $this);
if ($vote) {
$vote->vote = $decision;
} else {
$vote = ApproverVotes::getInstance()->fetchNew();
$vote->vote = $decision;
$vote->request = $request;
$vote->user = $user;
$vote->approvalAction = $this;
}
$vote->save();
}
public function getUserDecision(Request $request, User $user)
{
//
$vote = ApproverVotes::getInstance()->fetchByRequestUserAndAction($request, $user, $this);
if ($vote) {
return $vote->vote;
}
return null;
}
// Flushes current and loads pending requests.
......
<?php
class ApprovalActionsVoteVote extends Nmc_Db_Table_Row
class ApproverVote extends Nmc_Db_Table_Row
{
public function _init()
......
......@@ -122,6 +122,24 @@ class Request extends Nmc_Db_Table_Row
$stack->action = null;
$stack->save();
/* Code to automatically create a Submitter Role for the submitter upon submission
* Did I say submit enough? SUBMIT!
* This may be useful in the future, but kinda out of scope right now
$submittersBody = ApprovalBodies::getInstance()->fetchByName('Submitters');
if ($submittersBody) {
$submitterRoles = ApprovalBodyRoles::getInstance()->fetchRolesForUserInBody($this->owner, $submittersBody);
if (count($submitterRoles) > 0) {
$submitterRole = $submitterRoles[0];
} else {
$submitterRole = ApprovalBodyRoles::getInstance()->fetchNew();
$submitterRole->group = $owner->primaryGroup;
$submitterRole->name = $owner->name . "'s Submissions";
$submitterRole->save();
}
}
*/
$this->stackPointer = $stack;
$this->state = null;
}
......
......@@ -47,6 +47,24 @@ class ApprovalBodies extends Nmc_Db_Table
$where = $this->_db->quoteInto('adminGroup IN (?)', $groupIds);
return $this->fetchAll($where);
}
/**
* Returns the approval body with the given name, or NULL if none found
*
* @param string $name
* @return ApprovalBody
*/
public function fetchByName($name)
{
$db = $this->getAdapter();
$where = array();
$where[] = $db->quoteInto('name = ?', $name);
$where = implode(' AND ', $where);
$row = $this->fetchRow($where);
return $row;
}
}
?>
\ No newline at end of file
......@@ -76,6 +76,7 @@ class ApprovalBodyRoleQueues extends Nmc_Db_Table
$this->getTableName() . '.request = ' . $requestTableName . '.' . $requestTablePrimary,
$requestTablePrimary);
$select->where($db->quoteInto('approvalBodyRole = ?', $role->getPrimaryKey()));
$select->where($db->quoteInto('visible = ?', 'yes'));
$rows = $db->fetchCol($select);
$rows[] = -1;
......
......@@ -42,6 +42,19 @@ class ApprovalBodyRoles extends Nmc_Db_Table
}
return $this->fetchAll($where);
}
public function fetchRolesForUserInBody(User $user, ApprovalBody $body)
{
$db = $this->getAdapter();
$where = array();
$where[] = $db->quoteInto('user = ?', $user->getPrimaryKey());
$where[] = $db->quoteInto('approvalBody = ?', $body->getPrimaryKey());
$where = implode(' AND ', $where);
$rowset = $this->fetchAll($where);
return $rowset;
}
}
?>
<?php
class ApprovalActionsVoteVotes extends Nmc_Db_Table
class ApproverVotes extends Nmc_Db_Table
{
protected $_primary = 'approvalActionsVoteVoteId';
protected $_rowClass = 'ApprovalActionsVoteVote';
protected $_primary = 'approverVoteId';
protected $_rowClass = 'ApproverVote';
/**
* The one true instance
*
* @var ApprovalActionsVoteVotes
* @var ApproverVotes
*/
static protected $_instance;
/**
* Return the one true instance
*
* @return ApprovalActionsVoteVotes
* @return ApproverVotes
*/
static public function getInstance($config = array())
{
if (!self::$_instance) {
self::$_instance = new ApprovalActionsVoteVotes($config);
self::$_instance = new ApproverVotes($config);
}
return self::$_instance;
}
......
......@@ -84,7 +84,7 @@ class People extends Nmc_Db_Table
self::$_ldap->bind('uid=fpatrack,ou=service,dc=unl,dc=edu', 'eziehuoz');
}
$person = parent::fetchNew();
$person = $this->fetchNew();
$filter = 'uid='
. strtr($userName,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment