/** * 合并到图度组 */ public function mergeGroupAction() { $tuduId = $this->_request->getPost('tid'); $targetId = $this->_request->getPost('targetid'); // 目标图度组ID 图度ID if (!$targetId || !$tuduId) { return $this->json(false, $this->lang['invalid_tuduid']); } $targetTudu = $this->manager->getTuduById($targetId, $this->_user->uniqueId); // 目标图度组必须存在 if (null == $targetTudu) { return $this->json(false, $this->lang['target_tudugroup_not_exists']); } $tudu = $this->manager->getTuduById($tuduId, $this->_user->uniqueId); // 图度必须存在 if (null == $tudu) { return $this->json(false, $this->lang['tudu_not_exists']); } // 当前图度发起人是否为目标的图度组的执行人 $isAccepter = in_array($tudu->sender, $targetTudu->accepter, true); /* @var $addressBook Tudu_AddressBook */ $addressBook = Tudu_AddressBook::getInstance(); $user = $addressBook->searchUser($this->_user->orgId, $tudu->sender); if (!$isAccepter) { $ret = $this->manager->addRecipient($targetId, $user['uniqueid'], array('role' => 'to', 'accepterinfo' => $user['email'] . ' ' . $user['truename'], 'tudustatus' => 1)); if (!$ret) { return $this->json(true, $this->lang['append_tudu_group_failed']); } $this->manager->acceptTudu($targetId, $user['uniqueid'], null); $to = array_merge($targetTudu->accepter, (array) $tudu->sender); $this->manager->updateTudu($targetId, array('to' => implode("\n", $to))); $stepUser = array(array('uniqueid' => $user['uniqueid'], 'accepterinfo' => $user['email'] . ' ' . $user['truename'], 'processindex' => 0, 'stepstatus' => 0, 'percent' => 0)); $this->manager->addStepUsers($targetId, $targetTudu->stepId, $stepUser); $this->manager->addLabel($targetId, $user['uniqueid'], '^all'); $this->manager->addLabel($targetId, $user['uniqueid'], '^i'); $this->manager->addLabel($targetId, $user['uniqueid'], '^a'); } /* @var $daoGroup Dao_Td_Tudu_Group */ $daoGroup = $this->getDao('Dao_Td_Tudu_Group'); $ret = $daoGroup->createNode(array('tuduid' => $tuduId, 'parentid' => $targetId, 'uniqueid' => $user['uniqueid'], 'rootid' => !empty($targetTudu->rootId) ? $targetTudu->rootId : null, 'type' => Dao_Td_Tudu_Group::TYPE_LEAF)); if (!$ret) { return $this->json(true, $this->lang['append_tudu_group_failed']); } // 计算图度组进度 $this->manager->calParentsProgress($targetId); // 标记所有为未读 $this->manager->markAllUnRead($targetId); return $this->json(true, $this->lang['append_tudu_group_success']); }