/** * * @param Model_Tudu_Tudu $tudu */ public function saveGroup(Model_Tudu_Tudu &$tudu) { $group = $tudu->getExtension('Model_Tudu_Extension_Group'); if (null == $group) { return; } $children = $group->getChildren(); foreach ($children as $child) { } }
/** * * @param Model_Tudu_Tudu $tudu */ public function saveTuduCycle(Model_Tudu_Tudu &$tudu) { $cycle = $tudu->getExtension('Model_Tudu_Extension_Cycle'); /* @var $daoCycle Dao_Td_Tudu_Cycle */ $daoCycle = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Cycle', Tudu_Dao_Manager::DB_TS); $params = $cycle->getAttributes(); if (null !== $daoCycle->getCycle(array('cycleid' => $cycle->cycleId))) { $daoCycle->updateCycle($cycle->cycleId, $params); } else { $daoCycle->createCycle($params); } }
/** * * @param Model_Tudu_Tudu $tudu */ public function action(Model_Tudu_Tudu &$tudu) { $meeting = $tudu->getExtension('Model_Tudu_Extension_Meeting'); /* @var $daoMeeting Dao_Td_Tudu_Meeting */ $daoMeeting = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Meeting', Tudu_Dao_Manager::DB_TS); $params = $meeting->getAttributes(); if ($params['notifytype']) { $params['notifytime'] = Dao_Td_Tudu_Meeting::calNotifyTime(strtotime($tudu->starttime), $params['notifytype']); } else { $params['notifytime'] = null; } if ($daoMeeting->existsMeeting($tudu->tuduId)) { $daoMeeting->updateMeeting($tudu->tuduId, $params); } else { $params['tuduid'] = $tudu->tuduId; $daoMeeting->createMeeting($params); } }
/** * * @param Model_Tudu_Tudu $tudu */ public function action(Model_Tudu_Tudu &$tudu) { $remind = $tudu->getExtension('Model_Tudu_Extension_Remind'); $params = $remind->getAttributes(); /* @var $daoRemind Dao_Td_Tudu_Remind */ $daoRemind = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Remind', Tudu_Dao_Manager::DB_TS); if ($params['action'] == 'update') { if (empty($params)) { $params['isvalid'] = 0; } $daoRemind->updateRemind($tudu->tuduId, $params); } else { if ($params['isvalid']) { $params['tuduid'] = $tudu->tuduId; $daoRemind->createRemind($params); } } }
/** * * @param Model_Tudu_Tudu $tudu */ public function filter(Model_Tudu_Tudu &$tudu) { $cycle = $tudu->getExtension('Model_Tudu_Extension_Cycle'); if (null !== $cycle) { $tudu->cycleId = $cycle->cycleId; $tudu->special = 1; } /* @var $daoCycle Dao_Td_Tudu_Cycle */ $daoCycle = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Cycle', Tudu_Dao_Manager::DB_TS); $params = $cycle->getAttributes(); if (null !== $daoCycle->getCycle(array('cycleid' => $cycle->cycleId))) { $ret = $daoCycle->updateCycle($cycle->cycleId, $params); } else { $ret = $daoCycle->createCycle($params); } if (!$ret) { $tudu->cycleId = null; $tudu->special = 0; } }
/** * * @param Model_Tudu_Tudu $tudu */ protected function _save(Model_Tudu_Tudu &$tudu) { /* @var $apply Model_App_Attend_Tudu_Apply */ $apply = $tudu->getExtension('Model_App_Attend_Tudu_Apply'); /* @var $daoApply Dao_App_Attend_Apply */ $daoApply = Tudu_Dao_Manager::getDao('Dao_App_Attend_Apply', Tudu_Dao_Manager::DB_APP); $params = $apply->getAttributes(); $params['tuduid'] = $tudu->tuduId; if (null !== $this->_fromApply) { if ($apply->status > 2) { $params['status'] = 1; } $ret = $daoApply->updateApply($apply->applyId, $params); $applyId = $apply->applyId; } else { $applyId = Dao_App_Attend_Apply::getApplyId(); $params['applyid'] = $applyId; $ret = $daoApply->createApply($params); } if (!$ret) { require_once 'Model/App/Attend/Exception.php'; throw new Model_App_Attend_Exception('Save apply failure', Model_App_Attend_Exception::APPLY_SAVE_FAILED); } $tudu->applyId = $applyId; }
/** * * @param Model_Tudu_Tudu $tudu */ public function saveTuduFlow(Model_Tudu_Tudu &$tudu) { $flow = $tudu->getExtension('Model_Tudu_Extension_Flow'); if (null === $flow) { return; } if (!$flow->tuduId) { $flow->tuduId = $tudu->tuduId; } if ($flow->fromFlow) { $this->updateFlow($flow); } else { $this->createFlow($flow); } }
/** * * @param Model_Tudu_Tudu $tudu */ public function action(Model_Tudu_Tudu &$tudu) { $group = $tudu->getExtension('Model_Tudu_Extension_Group'); /* @var $daoGroup Dao_Td_Tudu_Group */ $daoGroup = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Group', Tudu_Dao_Manager::DB_TS); if (null == $group) { return; } if (!$tudu->fromTudu || !$tudu->fromTudu->nodeType) { $daoGroup->createNode(array('tuduid' => $tudu->tuduId, 'type' => $tudu->nodeType, 'uniqueid' => $tudu->uniqueId, 'rootid' => $tudu->rootId)); } elseif ($tudu->fromTudu->nodeType == 'leaf') { $daoGroup->updateNode($tudu->tuduId, array('type' => count($group->getChildren()) > 0 ? 'node' : 'leaf')); } $children = $group->getChildren(); $model = $this->getModel(); foreach ($children as &$child) { if ($tudu->fromTudu && !$tudu->fromTudu->isDraft && !$child->isModified) { continue; } $params = array(&$child); $model->compose($child); if (!$child->fromTudu || !$child->fromTudu->nodeType) { $daoGroup->createNode(array('tuduid' => $child->tuduId, 'type' => $child->nodeType, 'parentid' => $tudu->tuduId, 'rootid' => $tudu->rootId, 'uniqueid' => $tudu->uniqueId)); } $model->applyHooksFunc('compose', 'action', $params); if ($tudu->operation != 'save') { $this->getSendModel()->send($child); } } }
/** * 发送图度操作 * * @param Model_Tudu_Tudu $tudu */ public function send(Model_Tudu_Tudu &$tudu) { $object = array('tuduid' => $tudu->tuduId, 'tsid' => $this->_user->tsId, 'uniqueid' => $this->_user->uniqueId, 'orgid' => $this->_user->orgId, 'from' => $this->_user->userName, 'type' => $tudu->type, 'host' => $_SERVER['HTTP_HOST'], 'action' => $tudu->operation, 'iscreate' => !$tudu->fromTudu || $tudu->fromTudu->isDraft, 'isflow' => !!$tudu->flowId, 'parentid' => $tudu->fromTudu ? $tudu->fromTudu->parentId : $tudu->parentId, 'operator' => array('uniqueid' => $this->_user->uniqueId, 'username' => $this->_user->userName, 'truename' => $this->_user->trueName)); if ($tudu->operation == 'review') { $sqsAction = 'review'; $object['stepid'] = $tudu->fromTudu->stepId; $object['agree'] = $tudu->agree; if ($tudu->flowId) { $flow = $tudu->getExtension('Model_Tudu_Extension_Flow'); if ($flow) { $object['flow']['nstepid'] = $flow->currentStepId; $object['flow']['flowid'] = $tudu->flowId; $object['flow']['stepstatus'] = $flow->currentStepId != $tudu->fromTudu->stepId ? 1 : 0; } } if ($tudu->type == 'notice' && $tudu->stepId == '^end') { $sqsAction = 'create'; } } $receiver = array(); if ($tudu->reviewer) { $reviewers = $tudu->reviewer; foreach ($reviewers as $reviewer) { $item = array('username' => $reviewer['username'], 'truename' => $reviewer['truename']); if (isset($reviewer['unqiueid'])) { $item['uniqueid'] = $reviewer['uniqueid']; } $receiver['reviewer'][] = $item; } } elseif ($tudu->to) { $to = $tudu->to; foreach ($to as $u) { if (!Oray_Function::isEmail($u['username'])) { $item = array('username' => $u['username'], 'truename' => $u['truename'], 'role' => 'to', 'percent' => isset($u['percent']) ? $u['percent'] : 0, 'status' => isset($u['status']) ? $u['status'] : (empty($u['percent']) || $u['percent'] < 0 ? 0 : ($u['percent'] >= 100 ? 2 : 1))); } else { $item = array('email' => $u['username'], 'truename' => $u['truename'], 'role' => 'to', 'percent' => isset($u['percent']) ? $u['percent'] : 0, 'status' => isset($u['status']) ? $u['status'] : (empty($u['percent']) || $u['percent'] < 0 ? 0 : ($u['percent'] >= 100 ? 2 : 1))); } $receiver['to'][] = $item; } } if ($tudu->cc && ($tudu->type != 'notice' || !$tudu->reviewer)) { $cc = $tudu->cc; foreach ($cc as $u) { if (!empty($u['groupid'])) { $receiver['cc'][] = array('groupid' => $u['groupid']); } else { $receiver['cc'][] = array('username' => $u['username'], 'truename' => $u['truename']); } } } if ($tudu->bcc) { $bcc = $tudu->bcc; foreach ($bcc as $u) { if ($u['groupid']) { $receiver['bcc'][] = array('groupid' => $u['groupid']); } else { $receiver['bcc'][] = array('username' => $u['username'], 'truename' => $u['truename']); } } } $object['receiver'] = $receiver; $error = null; do { $connection = $this->_getConnection(); $bytes = @fwrite($connection, json_encode(array('type' => 'queue', 'data' => $object))); if (!$bytes) { $error = 'Data transfer error, posting tudu data to deliver service failed.'; break; } $response = @fgets($connection); if (!$response || !($resposne = @json_decode($response, true))) { $error = 'Invalid response data.'; break; } } while (false); if ($error) { require_once 'Model/Tudu/Exception.php'; throw new Model_Tudu_Exception('连接发送服务器失败,请稍候重试'); } // 标记发送 Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Tudu', Tudu_Dao_Manager::DB_TS)->sendTudu($tudu->tuduId); return $response['code'] == self::CODE_SUCCESS; }