Example #1
0
 /**
  *
  * @param Model_Tudu_Tudu $tudu
  * @param Model_Tudu_Extension_Flow $flow
  */
 public function appendTuduFlow(Model_Tudu_Tudu &$tudu, Model_Tudu_Extension_Flow &$flow)
 {
     // 手动工作流,可修改当前步骤或不同意的后续步骤
     $isExceed = false;
     $prev = $flow->currentStepId ? $flow->currentStepId : '^head';
     $flowTo = null;
     if ($tudu->reviewer) {
         $reviewer = $tudu->reviewer;
         $stepId = $flow->addStep(array('type' => Dao_Td_Tudu_Step::TYPE_EXAMINE, 'prev' => $prev));
         $flowTo = $prev = $stepId;
         foreach ($reviewer as $item) {
             $flow->addStepSection($stepId, $item);
         }
         $tudu->reviewer = $flow->getStepSection($stepId, 0);
     }
     if ($tudu->to) {
         $to = $tudu->to;
         $stepId = $flow->addStep(array('type' => $tudu->acceptMode ? Dao_Td_Tudu_Step::TYPE_CLAIM : Dao_Td_Tudu_Step::TYPE_EXECUTE, 'prev' => $prev));
         foreach ($to as $item) {
             $flow->addStepSection($stepId, $item);
         }
         $tudu->to = $flow->getStepSection($stepId, 0);
         if (0 !== strpos($prev, '^')) {
             $flow->updateStep($prev, array('next' => $stepId));
         }
         if (null === $flowTo) {
             $flowTo = $stepId;
         }
     }
     $flow->flowTo($flowTo);
     // 到头了
     if (0 == strpos($flow->currentStepId, '^')) {
         return;
     }
     $step = $flow->getStep($flow->currentStepId);
     $su = $flow->getStepSection($flow->currentStepId);
     $users = array();
     foreach ($su as $k => $u) {
         $users[$u['username']] = array('uniqueid' => $u['uniqueid'], 'username' => $u['username'], 'truename' => $u['truename'], 'email' => $u['username']);
     }
     if ($step['type'] == 1) {
         if (!$tudu->reviewer) {
             $tudu->reviewer = $users;
         }
     } else {
         if ($step['type'] == 2) {
             $tudu->acceptMode = 1;
         }
         if (!$tudu->to) {
             $tudu->to = $users;
         }
     }
 }
Example #2
0
 /**
  *
  * @param Model_Tudu_Tudu $tudu
  * @param Model_Tudu_Extension_Flow $flow
  */
 public function renewTuduFlow(Model_Tudu_Tudu &$tudu, Model_Tudu_Extension_Flow &$flow)
 {
     // 手动工作流,可修改当前步骤或不同意的后续步骤
     $isExceed = false;
     $prev = '^head';
     if ($tudu->reviewer || $tudu->to) {
         foreach ($flow->steps as $key => $item) {
             $stepId = $item['stepid'];
             foreach ($item['section'] as $idx => $section) {
                 if ($isExceed) {
                     $flow->deleteStep($stepId);
                     continue;
                 }
                 foreach ($section as $k => $u) {
                     if (isset($u['status']) && $u['status'] >= 2) {
                         $isExceed = true;
                         $prev = $stepId;
                     }
                     if ($isExceed && $u['status'] < 2) {
                         $flow->removeStepSection($key, $idx);
                     }
                 }
                 if ($isExceed && empty($item['section'])) {
                     $prev = $item['prev'];
                     $flow->deleteStep($stepId);
                 }
             }
         }
     }
     $flowTo = null;
     if ($tudu->reviewer) {
         $reviewer = $tudu->reviewer;
         $stepId = $flow->addStep(array('type' => Dao_Td_Tudu_Step::TYPE_EXAMINE, 'prev' => $prev));
         $flowTo = $prev = $stepId;
         foreach ($reviewer as $item) {
             $flow->addStepSection($stepId, $item);
         }
         $tudu->reviewer = $flow->getStepSection($stepId, 0);
     }
     if ($tudu->to) {
         $to = $tudu->to;
         $stepId = $flow->addStep(array('type' => $tudu->acceptMode ? Dao_Td_Tudu_Step::TYPE_CLAIM : Dao_Td_Tudu_Step::TYPE_EXECUTE, 'prev' => $prev));
         foreach ($to as $item) {
             $flow->addStepSection($stepId, $item);
         }
         $tudu->to = $flow->getStepSection($stepId, 0);
         if (0 !== strpos($prev, '^')) {
             $flow->updateStep($prev, array('next' => $stepId));
         }
         if (null === $flowTo) {
             $flowTo = $stepId;
         }
     }
     $flow->flowTo($flowTo);
     $step = $flow->getStep($flow->currentStepId);
     if ($step['type'] == 1) {
         if (!$tudu->reviewer) {
             $tudu->reviewer = $flow->getStepSection($flow->currentStepId);
         }
     } else {
         if (!$tudu->to) {
             $tudu->to = $flow->getStepSection($flow->currentStepId);
         }
     }
 }