/** * * @param Model_Tudu_Tudu $tudu */ public function prepareTuduReview(Model_Tudu_Tudu &$tudu) { /* @var $daoFlow Dao_Td_Tudu_Flow */ $daoFlow = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Flow', Tudu_Dao_Manager::DB_TS); $flowData = $daoFlow->getFlow(array('tuduid' => $tudu->tuduId)); if (null === $flowData) { require_once 'Model/Tudu/Exception.php'; throw new Model_Tudu_Exception('Not allow to review tudu', Model_Tudu_Exception::PERMISSION_DENIED); } $flow = new Model_Tudu_Extension_Flow($flowData->toArray()); $flow->fromFlow = true; if (!$flow->isCurrentUser($tudu->uniqueId)) { require_once 'Model/Tudu/Exception.php'; throw new Model_Tudu_Exception('Not allow to review tudu', Model_Tudu_Exception::PERMISSION_DENIED); } // 处理同意流程 $flow->review($tudu->uniqueId, $tudu->agree); if ($tudu->agree) { $this->renewTuduFlow($tudu, $flow); } else { $step = $flow->getStep($flow->currentStepId); $next = $tudu->agree ? null : $step['prev']; if (null !== $next && 0 !== strpos($next, '^')) { $flow->flowTo($next); $nextStep = $flow->getStep($flow->currentStepId); $su = $flow->getStepSection($flow->currentStepId); // XXX :-( $users = array(); foreach ($su as $k => $u) { $users[$u['username']] = array('uniqueid' => $u['uniqueid'], 'email' => $u['username'], 'username' => $u['username'], 'truename' => $u['truename']); } if ($nextStep && $nextStep['type'] == 1) { $tudu->reviewer = $users; } else { if ($nextStep['type'] == 2) { $tudu->acceptMode = 1; } $tudu->to = $users; } } } $tudu->setExtension($flow); }
/** * * @param Model_Tudu_Tudu $tudu */ public function prepareTuduReview(Model_Tudu_Tudu &$tudu) { /* @var $daoFlow Dao_Td_Tudu_Flow */ $daoFlow = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Flow', Tudu_Dao_Manager::DB_TS); $flowData = $daoFlow->getFlow(array('tuduid' => $tudu->tuduId)); if (null === $flowData) { require_once 'Model/Tudu/Exception.php'; throw new Model_Tudu_Exception('Not allow to review tudu', Model_Tudu_Exception::PERMISSION_DENIED); } $flow = new Model_Tudu_Extension_Flow($flowData->toArray()); $flow->fromFlow = true; if (!$flow->isCurrentUser($tudu->uniqueId)) { require_once 'Model/Tudu/Exception.php'; throw new Model_Tudu_Exception('Not allow to review tudu', Model_Tudu_Exception::PERMISSION_DENIED); } // 处理同意流程 $flow->review($tudu->uniqueId, $tudu->agree); if (!$tudu->flowId) { $this->renewTuduFlow($tudu, $flow); } else { $flow->flowTo(); $step = $flow->getSteps(); if ($step['type'] == 1) { $tudu->reviewer = $flow->getStepSection($step['stepid']); } else { $tudu->to = $flow->getStepSection($step['stepid']); } } $tudu->setExtension($flow); }