/** * 获取编辑页面数据 * * @param boolean $isExternal 是否获取扩展数据(周期任务,投票,图度组子任务等) */ private function _getModifyParams($isExternal = false) { $params = $this->_request->getParams(); $tuduFields = array('type', 'bid', 'subject', 'subject', 'to', 'cc', 'priority', 'privacy', 'status', 'content', 'attach', 'starttime', 'endtime', 'totaltime', 'percent', 'classid', 'notifyall', 'istop', 'classname', 'nd-attach', 'isauth', 'chidx', 'prev'); $tudu = array(); $vote = array(); $cycle = array(); $children = array(); // 获取图度数据 foreach ($tuduFields as $key) { if (array_key_exists($key, $params)) { if (empty($params[$key])) { continue; } switch ($key) { case 'bid': $tudu['boardid'] = $params[$key]; break; case 'ftid': $tudu['tuduid'] = $params[$key]; break; case 'prev': $tudu['prevtuduid'] = $params[$key]; break; case 'to': if ($params['type'] == 'tudu') { $to = explode("\n", $params[$key]); foreach ($to as $item) { $tudu[$key][]['userinfo'] = $item; } } else { $tudu[$key] = Dao_Td_Tudu_Tudu::formatAddress($params[$key]); } break; case 'cc': $tudu[$key] = Dao_Td_Tudu_Tudu::formatAddress($params[$key]); break; case 'percent': if ($params[$key] != 0) { $tudu[$key] = (int) $params[$key]; } break; case 'totaltime': $tudu[$key] = (int) $params[$key] * 3600; break; default: $tudu[$key] = $params[$key]; } } } if (!empty($tudu['to'])) { $tudu['accepter'] = array_keys($tudu['to']); } if (!empty($tudu['attach']) && !empty($tudu['nd-attach'])) { $tudu['attach'] = array_diff($tudu['attach'], array_intersect($tudu['attach'], $tudu['nd-attach'])); $tudu['attachnum'] = !empty($tudu['attach']) ? count($tudu['attach']) : 0; } // 获取附件 if (!empty($tudu['attach'])) { $daoFile = $this->getDao('Dao_Td_Attachment_File'); $tudu['attachments'] = $daoFile->getFiles(array('fileid' => $tudu['attach']), array('isattachment' => null))->toArray(); } if (!empty($tudu['nd-attach'])) { $daoNetdisk = $this->getDao('Dao_Td_Netdisk_File'); $files = $daoNetdisk->getFiles(array('fileid' => $tudu['nd-attach'], 'uniqueid' => $this->_user->uniqueId)); $tudu['attachnum'] += count($files); $tudu['nd-attach'] = $files->toArray(); } // 扩展数据,于预览页面显示内容 if ($isExternal && !empty($tudu['type'])) { switch ($tudu['type']) { // 获取重复周期 或 图度组新建子任务 case 'task': $chIndex = isset($params['chidx']) ? $params['chidx'] : null; $cycle = isset($params['cycle']) && $params['cycle'] ? $params['cycle'] : null; if (null !== $chIndex) { foreach ($chIndex as $idx) { // 获取图度数据 $child = array(); foreach ($tuduFields as $key) { if (!empty($params[$key . '-' . $idx])) { if ($key == 'bid') { $child['boardid'] = $params[$key . '-' . $idx]; } elseif (in_array($key, array('to', 'cc'))) { $child[$key] = Dao_Td_Tudu_Tudu::formatAddress($params[$key . '-' . $idx]); } elseif ($key == 'percent') { $child[$key] = (int) $params[$key . '-' . $idx]; } else { $child[$key] = $params[$key . '-' . $idx]; } } elseif (isset($tudu[$key])) { $child[$key] = $tudu[$key]; } } if (!empty($child['to'])) { $child['accepter'] = array_keys($child['to']); } if (!empty($child['attach'])) { $child['attachnum'] = count($child['attach']); } $children[] = $child; } } elseif (null !== $cycle) { $cycleFields = array('at', 'what', 'day', 'week', 'month', 'weeks'); $cycle = array('endtype' => isset($params['endtype']) ? $params['endtype'] : null, 'enddate' => isset($params['enddate']) ? $params['enddate'] : null, 'endcount' => isset($params['endcount']) ? $params['endcount'] : null, 'cycleid' => isset($params['cycleid']) ? $params['cycleid'] : null, 'mode' => isset($params['mode']) ? $params['mode'] : null); $cycle['type'] = isset($params['type-' . $cycle['mode']]) ? $params['type-' . $cycle['mode']] : null; $prefix = $cycle['mode'] . '-' . $cycle['type'] . '-'; foreach ($cycleFields as $key) { if (isset($params[$prefix . $key])) { $cycle[$key] = $params[$prefix . $key]; } } } break; // 尝试获取投票数据 // 尝试获取投票数据 case 'discuss': if (isset($params['vote']) && $params['vote'] && !empty($params['newoption']) && is_array($params['newoption'])) { $vote['maxchoices'] = isset($params['maxchoices']) ? (int) $params['maxchoices'] : 1; foreach ($params['newoption'] as $item) { if (empty($params['text-' . $item])) { continue; } $vote['options'][] = array('optionid' => $item, 'text' => $params['text-' . $item], 'ordernum' => !empty($params['ordernum-' . $item]) ? $params['ordernum' . $item] : 0); } } break; } } return array('tudu' => $tudu, 'cycle' => $cycle, 'vote' => $vote, 'children' => $children); }
/** * * @param Model_Tudu_Tudu $tudu * @throws Model_Tudu_Exception */ protected function _createTudu(Model_Tudu_Tudu &$tudu) { /* @var $daoTudu Dao_Td_Tudu_Tudu */ $daoTudu = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Tudu', Tudu_Dao_Manager::DB_TS); /* @var $daoPost Dao_Td_Tudu_Post */ $daoPost = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Post', Tudu_Dao_Manager::DB_TS); /* @var $daoAttach Dao_Td_Attachment_File */ $daoAttach = Tudu_Dao_Manager::getDao('Dao_Td_Attachment_File', Tudu_Dao_Manager::DB_TS); /* @var $daoFile Dao_Td_Netdisk_File */ $daoFile = Tudu_Dao_Manager::getDao('Dao_Td_Netdisk_File', Tudu_Dao_Manager::DB_TS); if (!$tudu->tuduId) { $tudu->tuduId = Dao_Td_Tudu_Tudu::getTuduId(); } if (!$tudu->postId) { $tudu->postId = Dao_Td_Tudu_Post::getPostId($tudu->tuduId); } $params = $tudu->getStorageParams(); $attachments = $tudu->getAttachments(); // 处理网盘附件 $attachNum = 0; foreach ($attachments as $k => $attach) { if ($attach['isnetdisk']) { $fileId = $attach['fileid']; if (null !== $daoAttach->getFile(array('fileid' => $fileId))) { $ret['attachment'][] = $fileId; continue; } $file = $daoFile->getFile(array('uniqueid' => $this->_user->uniqueId, 'fileid' => $fileId)); if (null === $file) { continue; } $fileId = $file->fromFileId ? $file->fromFileId : $file->attachFileId; $ret = $daoAttach->createFile(array('uniqueid' => $this->_user->uniqueId, 'fileid' => $fileId, 'orgid' => $this->_user->orgId, 'filename' => $file->fileName, 'path' => $file->path, 'type' => $file->type, 'size' => $file->size, 'createtime' => $this->_time)); if ($ret) { $attachments[$k]['fileid'] = $fileId; } else { unset($attachments[$k]); } } if ($attach['isattach']) { $attachNum++; } } $params['attachnum'] = $attachNum; $params['isfirst'] = 1; $tuduId = $daoTudu->createTudu($params); if (!$tuduId) { require_once 'Model/Tudu/Exception.php'; throw new Model_Tudu_Exception('Tudu save failed', Model_Tudu_Exception::SAVE_FAILED); } $params['issend'] = 1; $postId = $daoPost->createPost($params); if (!$postId) { $daoTudu->deleteTudu($tuduId); require_once 'Model/Tudu/Exception.php'; throw new Model_Tudu_Exception('Tudu content save failed', Model_Tudu_Exception::SAVE_FAILED); } $tudu->postId = $postId; foreach ($attachments as $attach) { $daoAttach->addPost($tuduId, $postId, $attach['fileid'], (bool) $attach['isattach']); } }
/** * 发送图度 * * @param Tudu_Model_Tudu_Entity_Tudu $tudu */ public function send(Tudu_Model_Tudu_Entity_Tudu &$tudu, &$output) { $user = self::getResource(self::RESOURCE_NAME_USER); $error = null; $code = 0; $isSender = true; $isAccepter = false; $fromTudu = null; $logDetail = array(); $logAction = 'create'; /* @var Dao_Td_Tudu_Tudu */ $daoTudu = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Tudu', Tudu_Dao_Manager::DB_TS); if ($tudu->tuduId) { $fromTudu = $daoTudu->getTuduById($user->uniqueId, $tudu->tuduId); $isSender = true; do { if (null === $fromTudu) { $error = 'tudu not exists'; break; } $isSender = $fromTudu->sender == $user->userName; // 草稿,权限上属新建操作 if ($tudu->isDraft) { if (!$tudu->uniqueId || !$user->getAccess()->isAllowed(Tudu_Access::PERM_CREATE_TUDU)) { $error = 'perm deny create tudu'; break; } // 编辑图度权限 // 有权限 && (发起人 || 版主 || 分区负责人) } else { if (!$user->getAccess()->isAllowed(Tudu_Access::PERM_UPDATE_TUDU)) { $error = 'perm deny create tudu'; break; } if (!$isSender) { // 版主权限 $boards = $this->_getBoards($user->orgId); $board = $boards[$fromTudu->boardId]; $isModerator = array_key_exists($user->userName, $board['moderators']); $isSuperModerator = null; // 不是版主,看看是不是分区负责人 if (!$isModerator && isset($boards[$board['parentid']])) { $parentBoard = $boards[$board['parentid']]; $isSuperModerator = array_key_exists($user->userName, $parentBoard['moderators']); } if (!$isModerator && !$isSuperModerator) { $error = 'perm deny create tudu'; break; } } $logAction = 'update'; } } while (false); if (null !== $error) { require_once 'Tudu/Model/Tudu/Exception.php'; throw new Tudu_Model_Tudu_Exception($error); } $params = array('stepid' => $fromTudu->stepId, 'postid' => $fromTudu->postId, 'from' => $fromTudu->sender . ' ' . $fromTudu->from[0], 'email' => $fromTudu->from[0], 'sender' => $fromTudu->sender); if ($tudu->isDraft) { $params['lastmodify'] = implode(chr(9), array($user->uniqueId, time(), $user->trueName)); } else { $params['createtime'] = time(); } $tudu->setAttribute($params); $logDetail = $this->_getLogDetails($params, $fromTudu); } else { // 创建权限 if (!$user->getAccess()->isAllowed(Tudu_Access::PERM_CREATE_TUDU)) { require_once 'Tudu/Model/Tudu/Exception.php'; throw new Tudu_Model_Tudu_Exception('perm deny create tudu'); } $tudu->setAttribute(array('tuduid' => Dao_Td_Tudu_Tudu::getTuduId(), 'isdraft' => true, 'from' => $user->userName . ' ' . $user->trueName, 'email' => $user->userName, 'sender' => $user->trueName, 'createtime' => time())); $logDetail = $this->_getLogDetails($tudu->getAttributes(), null); } // 处理扩展数据内容 $extensions = $tudu->getExtensions(); foreach ($extensions as $item) { if ($item instanceof Tudu_Model_Tudu_Entity_Extension_Flow) { $this->getExtension($item->getHandler())->prevSave($tudu, $item); } } // 保存图度数据 if (null !== $fromTudu) { $tuduId = $this->updateTudu($tudu); } else { $tuduId = $this->createTudu($tudu); } foreach ($extensions as $item) { if ($item instanceof Tudu_Model_Tudu_Entity_Extension_Flow || $item instanceof Tudu_Model_App_Attend_Tudu_Apply) { $this->getExtension($item->getHandler())->onSave($tudu, $item); } } $output['tuduid'] = $tudu->tuduId; // 执行发送操作 $this->sendTudu($tudu); foreach ($extensions as $item) { if ($item instanceof Tudu_Model_App_Attend_Tudu_Apply) { $this->getExtension($item->getHandler())->onSend($tudu, $item); } } $sqsParam = array('tsid' => $user->tsId, 'tuduid' => $tudu->tuduId, 'from' => $user->userName, 'uniqueid' => $user->uniqueId, 'server' => $_SERVER['HTTP_HOST'], 'type' => $tudu->type, 'ischangedCc' => isset($fromTudu) && !$fromTudu->isDraft && $tudu->cc ? true : false); $httpsqs = self::getResource(self::RESOURCE_NAME_HTTPSQS); $httpsqs->put(implode(' ', array('tudu', isset($fromTudu) ? 'update' : 'create', '', http_build_query($sqsParam))), 'tudu'); $this->createLog(Dao_Td_Log_Log::TYPE_TUDU, $tudu->tuduId, $logAction, $logDetail, 0); return $tuduId; }
/** * 预览 */ public function previewAction() { $params = $this->_request->getParams(); /* @var $daoCategory Dao_App_Attend_Category */ $daoCategory = Tudu_Dao_Manager::getDao('Dao_App_Attend_Category', Tudu_Dao_Manager::DB_APP); $apply = array(); if (!empty($params['categoryid'])) { $categoryId = $params['categoryid']; $condition = array('categoryid' => $categoryId, 'orgid' => $this->_user->orgId); $category = $daoCategory->getCategory($condition); if (null !== $category) { $apply['subject'] = $category->categoryName; $apply['categoryname'] = $category->categoryName; } $apply['categoryid'] = $categoryId; } $apply['period'] = $params['period']; $apply['content'] = $params['content']; $apply['starttime'] = !empty($params['starttime']) ? strtotime($params['starttime']) : null; $apply['endtime'] = !empty($params['endtime']) ? strtotime($params['endtime']) : null; $apply['createtime'] = time(); $apply['from'] = array($this->_user->trueName, $this->_user->userName); $to = $this->_user->userName . ' ' . $this->_user->trueName; if (!empty($params['target'])) { $to = $params['target']; } $apply['to'] = Dao_Td_Tudu_Tudu::formatAddress($to); if (!empty($params['cc'])) { $apply['cc'] = Dao_Td_Tudu_Tudu::formatAddress($params['cc']); } if (isset($params['checkintype'])) { $apply['checkintype'] = $params['checkintype']; } if (isset($params['isallday'])) { $apply['isallday'] = $params['isallday']; } $apply['attachnum'] = 0; // 获取附件 if (!empty($params['attach'])) { $daoFile = Tudu_Dao_Manager::getDao('Dao_Td_Attachment_File', Tudu_Dao_Manager::DB_TS); $apply['attachments'] = $daoFile->getFiles(array('fileid' => $params['attach']), array('isattachment' => null))->toArray(); } if (!empty($params['nd-attach'])) { $daoNetdisk = Tudu_Dao_Manager::getDao('Dao_Td_Netdisk_File', Tudu_Dao_Manager::DB_TS); $files = $daoNetdisk->getFiles(array('fileid' => $params['nd-attach'], 'uniqueid' => $this->_user->uniqueId)); $apply['attachnum'] += count($files); $apply['ndattach'] = $files->toArray(); } $this->view->apply = $apply; $this->view->registModifier('tudu_format_content', array($this, 'formatContent')); }
/** * 格式化数组 * * @param array $data * return array */ public static function formatData($data) { $ret = array(); foreach ($data as $key => $value) { $key = $value['tuduid']; $value['from'] = Dao_Td_Tudu_Tudu::formatAddress($value['from'], true); $value['to'] = Dao_Td_Tudu_Tudu::formatAddress($value['to']); $value['cc'] = Dao_Td_Tudu_Tudu::formatAddress($value['cc']); $ret[$key] = $value; } return $ret; }
/** * Construct * * @param array $record */ public function __construct(array $record) { $this->orgId = $record['orgid']; $this->boardId = $record['boardid']; $this->tuduId = $record['tuduid']; $this->classId = $record['classid']; $this->className = $record['classname']; $this->type = $record['type']; $this->subject = $record['subject']; $this->from = Dao_Td_Tudu_Tudu::formatAddress($record['from'], true); $this->to = Dao_Td_Tudu_Tudu::formatAddress($record['to']); $this->cc = Dao_Td_Tudu_Tudu::formatAddress($record['cc']); $this->priority = $this->_toInt($record['priority']); $this->privacy = $this->_toInt($record['privacy']); $this->attachNum = $this->_toInt($record['attachnum']); $this->lastPostTime = $this->_toTimestamp($record['lastposttime']); $this->lastPoster = $record['lastposter']; $this->posterInfo = $record['posterinfo']; $this->viewNum = $record['viewnum']; $this->replyNum = $this->_toInt($record['replynum']); $this->logNum = $this->_toInt($record['lognum']); $this->startTime = $this->_toTimestamp($record['starttime']); $this->endTime = $this->_toTimestamp($record['endtime']); $this->acceptTime = $this->_toTimestamp($record['accepttime']); $this->createTime = $this->_toTimestamp($record['createtime']); $this->percent = $this->_toInt($record['percent']); $this->status = $this->_toInt($record['status']); $this->special = $this->_toInt($record['special']); $this->uniqueId = $record['uniqueid']; $this->isRead = $this->_toBoolean($record['isread']); $this->isForward = $this->_toBoolean($record['isforward']); $this->isDone = $this->_toBoolean($record['isdone']); $this->labels = $this->_toArray($record['labels']); $this->nodeType = isset($record['nodetype']) ? $record['nodetype'] : null; $this->parentId = isset($record['parentid']) ? $record['parentid'] : null; $this->isTuduGroup = in_array($this->nodeType, array(Dao_Td_Tudu_Group::TYPE_NODE, Dao_Td_Tudu_Group::TYPE_ROOT)); $this->selfPercent = isset($record['selfpercent']) ? $this->_toInt($record['selfpercent']) : null; $this->role = !empty($record['role']) ? $record['role'] : null; $this->selfTuduStatus = isset($record['selftudustatus']) ? $this->_toInt($record['selftudustatus']) : null; $this->selfAcceptTime = isset($record['selfaccepttime']) ? $this->_toTimestamp($record['selfaccepttime']) : null; $this->isExpired = $this->endTime && $this->status <= Dao_Td_Tudu_Tudu::STATUS_DOING && Oray_Function::dateDiff('d', $this->endTime, time()) > 0; if (isset($this->from[3])) { $this->sender = $this->from[3]; } $this->accepter = !empty($this->to) ? array_keys($this->to) : array(); if (isset($record['forwardinfo']) || isset($record['lastforward'])) { $forwardInfo = count($this->accepter) > 1 ? $record['forwardinfo'] : $record['lastforward']; $array = explode("\n", $forwardInfo); if (count($array) == 2) { $this->lastForwarder = $array[0]; $this->lastForwardTime = $this->_toInt($array[1]); } } parent::__construct(); }
/** * 获取图度ID * * @return string */ private function _getTuduId() { return $this->_tuduDao->getTuduId(); }
/** * 预览审批流程 */ public function previewAction() { $flowId = str_replace('_', '^', $this->_request->getQuery('flowid')); /* @var $daoFlow Dao_App_Attend_Flow */ $daoFlow = Tudu_Dao_Manager::getDao('Dao_App_Attend_Flow', Tudu_Dao_Manager::DB_APP); $condition = array('flowid' => $flowId, 'orgid' => $this->_user->orgId); $flow = $daoFlow->getFlow($condition); $flow = $flow->toArray(); foreach ($flow['steps'] as &$step) { if (isset($step['branches'])) { foreach ($step['branches'] as &$branch) { if ($branch['type'] == 2) { $branch['users'] = Dao_Td_Tudu_Tudu::formatAddress($branch['users']); } } } else { if ($step['type'] == 2) { $step['users'] = Dao_Td_Tudu_Tudu::formatAddress($step['users']); } } } $this->view->flow = $flow; }
/** * 发送图度 * * @param Model_Tudu_Tudu $tudu * @throws Model_Tudu_Exception */ public function compose(Model_Tudu_Tudu &$tudu) { if (!$tudu->tuduId) { $tudu->setAttribute('tuduid', Dao_Td_Tudu_Tudu::getTuduId()); } // 保存图度 if (null !== $tudu->fromTudu) { if (!$tudu->fromTudu->isDraft) { $user = Tudu_User::getInstance(); $time = time(); $tudu->lastPostTime = $time; $tudu->lastPoster = $user->trueName; $tudu->lastModify = implode(chr(9), array($user->uniqueId, $time, $user->trueName)); } $this->_updateTudu($tudu); } else { $this->_createTudu($tudu); } $logAction = null !== $tudu->fromTudu && !$tudu->fromTudu->isDraft ? 'update' : 'send'; $this->_tuduLog($logAction, $tudu); }
/** * 周期任务/会议 * 图度数据 * * @param $tudu * @param $fromUnId */ public function getCycleTuduParams($tudu, $cycle, $to, $fromUnId, $time) { // 基本参数 return array('orgid' => $tudu->orgId, 'boardid' => $tudu->boardId, 'classid' => $tudu->classId, 'tuduid' => Dao_Td_Tudu_Tudu::getTuduId(), 'special' => Dao_Td_Tudu_Tudu::SPECIAL_CYCLE, 'cycleid' => $cycle->cycleId, 'uniqueid' => $fromUnId, 'email' => $tudu->sender, 'type' => $tudu->type, 'subject' => $tudu->subject, 'from' => $tudu->from[3] . ' ' . $tudu->from[0], 'to' => implode("\n", $to), 'priority' => $tudu->priority, 'privacy' => $tudu->privacy, 'status' => Dao_Td_Tudu_Tudu::STATUS_UNSTART, 'content' => $tudu->content, 'poster' => $tudu->from[0], 'posterinfo' => $tudu->posterInfo, 'lastposter' => $tudu->from[0], 'lastposttime' => time(), 'starttime' => $time[0], 'endtime' => $time[1], 'createtime' => time(), 'password' => $tudu->password, 'isauth' => $tudu->isAuth, 'cyclenum' => $tudu->cycleNum + 1, 'stepid' => Dao_Td_Tudu_Step::getStepId(), 'stepnum' => 1, 'issend' => 1, 'acceptmode' => $tudu->acceptMode, 'needconfirm' => $tudu->needConfirm, 'attachment' => array(), 'file' => array()); }
/** * Construct * * @param array $record */ public function __construct(array $record) { $this->orgId = $record['orgid']; $this->boardId = $record['boardid']; $this->tuduId = $record['tuduid']; $this->postId = $record['postid']; $this->cycleId = $record['cycleid']; $this->stepId = isset($record['stepid']) ? $record['stepid'] : null; $this->appId = isset($record['appid']) ? $record['appid'] : null; $this->flowId = isset($record['flowid']) ? $record['flowid'] : null; $this->classId = $record['classid']; $this->prevTuduId = !empty($record['prevtuduid']) ? $record['prevtuduid'] : null; $this->className = $record['classname']; $this->type = $record['type']; $this->subject = $record['subject']; $this->from = Dao_Td_Tudu_Tudu::formatAddress($record['from'], true); $this->to = Dao_Td_Tudu_Tudu::formatAddress($record['to']); $this->cc = Dao_Td_Tudu_Tudu::formatAddress($record['cc']); $this->bcc = isset($record['bcc']) ? Dao_Td_Tudu_Tudu::formatAddress($record['bcc']) : null; $this->content = $record['content']; $this->priority = $this->_toInt($record['priority']); $this->privacy = $this->_toInt($record['privacy']); $this->needConfirm = isset($record['needconfirm']) ? $this->_toInt($record['needconfirm']) : null; $this->password = $record['password']; $this->isAuth = isset($record['isauth']) ? $this->_toBoolean($record['isauth']) : null; $this->authCode = isset($record['authcode']) ? $record['authcode'] : null; $this->attachNum = $this->_toInt($record['attachnum']); $this->lastPostTime = $this->_toTimestamp($record['lastposttime']); $this->lastPoster = $record['lastposter']; $this->posterInfo = $record['posterinfo']; $this->viewNum = $record['viewnum']; $this->cycleNum = isset($record['cyclenum']) ? $this->_toInt($record['cyclenum']) : null; $this->replyNum = $this->_toInt($record['replynum']); $this->logNum = $this->_toInt($record['lognum']); $this->stepNum = isset($record['stepnum']) ? $this->_toInt($record['stepnum']) : null; $this->startTime = $this->_toTimestamp($record['starttime']); $this->endTime = $this->_toTimestamp($record['endtime']); $this->completeTime = isset($record['completetime']) ? $this->_toTimestamp($record['completetime']) : null; $this->totalTime = $this->_toInt($record['totaltime']); $this->elapsedTime = $this->_toInt($record['elapsedtime']); $this->acceptTime = $this->_toTimestamp($record['accepttime']); $this->createTime = $this->_toTimestamp($record['createtime']); $this->percent = $this->_toInt($record['percent']); $this->score = $this->_toInt($record['score']); $this->status = $this->_toInt($record['status']); $this->special = $this->_toInt($record['special']); $this->uniqueId = $record['uniqueid']; $this->isRead = $this->_toBoolean($record['isread']); $this->isDraft = $this->_toBoolean($record['isdraft']); $this->isForward = $this->_toBoolean($record['isforward']); $this->isTop = $this->_toBoolean($record['istop']); $this->isDone = $this->_toBoolean($record['isdone']); $this->mark = isset($record['mark']) ? $this->_toInt($record['mark']) : null; $this->isSend = isset($record['issend']) ? $this->_toBoolean($record['issend']) : null; $this->notifyAll = isset($record['notifyall']) ? $this->_toBoolean($record['notifyall']) : null; $this->acceptMode = isset($record['accepmode']) ? $this->_toBoolean($record['accepmode']) : null; $this->labels = $this->_toArray($record['labels']); $this->nodeType = isset($record['nodetype']) ? $record['nodetype'] : null; $this->parentId = isset($record['parentid']) ? $record['parentid'] : null; $this->rootId = isset($record['rootid']) ? $record['rootid'] : null; $this->isTuduGroup = in_array($this->nodeType, array(Dao_Td_Tudu_Group::TYPE_NODE, Dao_Td_Tudu_Group::TYPE_ROOT)); $this->selfPercent = isset($record['selfpercent']) ? $this->_toInt($record['selfpercent']) : null; $this->role = !empty($record['role']) ? $record['role'] : null; $this->selfTuduStatus = isset($record['selftudustatus']) ? $this->_toInt($record['selftudustatus']) : null; $this->selfAcceptTime = isset($record['selfaccepttime']) ? $this->_toTimestamp($record['selfaccepttime']) : null; $this->selfStepStatus = isset($record['selfstepstatus']) ? $this->_toInt($record['selfstepstatus']) : null; $this->displayDate = isset($record['displaydate']) ? $this->_toInt($record['displaydate']) : null; $this->stepType = isset($record['steptype']) ? $this->_toInt($record['steptype']) : null; $this->isExpired = $this->endTime && $this->status <= Dao_Td_Tudu_Tudu::STATUS_DOING && Oray_Function::dateDiff('d', $this->endTime, time()) > 0; if (isset($this->from[3])) { $this->sender = $this->from[3]; } $this->accepter = !empty($this->to) ? array_keys($this->to) : array(); if (isset($record['forwardinfo']) || isset($record['lastforward'])) { $forwardInfo = count($this->accepter) > 1 ? $record['forwardinfo'] : $record['lastforward']; $array = explode("\n", $forwardInfo); if (count($array) == 2) { $this->lastForwarder = $array[0]; $this->lastForwardTime = $this->_toInt($array[1]); } } parent::__construct(); }
/** * Construct * * @param array $record */ public function __construct(array $record) { $this->orgId = $record['orgid']; $this->boardId = $record['boardid']; $this->tuduId = $record['tuduid']; $this->from = Dao_Td_Tudu_Tudu::formatAddress($record['from'], true); $this->to = Dao_Td_Tudu_Tudu::formatAddress($record['to'], false); $this->isDraft = $this->_toBoolean($record['isdraft']); $this->subject = $record['subject']; $this->nodeType = $record['nodetype']; $this->parentId = $record['parentid']; $this->isTuduGroup = in_array($this->nodeType, array(Dao_Td_Tudu_Group::TYPE_NODE, Dao_Td_Tudu_Group::TYPE_ROOT)); if (isset($this->from[3])) { $this->sender = $this->from[3]; } parent::__construct(); }
/** * Construct * * @param array $record */ public function __construct(array $record) { $this->orgId = $record['orgid']; $this->boardId = $record['boardid']; $this->tuduId = $record['tuduid']; $this->type = $record['type']; $this->subject = $record['subject']; $this->from = Dao_Td_Tudu_Tudu::formatAddress($record['from'], true); $this->to = Dao_Td_Tudu_Tudu::formatAddress($record['to']); $this->uniqueId = $record['uniqueid']; $this->nodeType = isset($record['nodetype']) ? $record['nodetype'] : null; if (isset($this->from[3])) { $this->sender = $this->from[3]; } $this->accepter = !empty($this->to) ? array_keys($this->to) : array(); parent::__construct(); }
/** * * @param $params * @param $tudu */ public function prepareTudu(array $params, Dao_Td_Tudu_Record_Tudu $tudu = null) { if (null !== $tudu) { $params['isdraft'] = $tudu->isDraft; $params['postid'] = $tudu->postId; $params['tuduid'] = $tudu->tuduId; $params['from'] = $tudu->from[3] . ' ' . $tudu->from[0]; $params['sender'] = $tudu->sender; $params['stepid'] = $tudu->stepId; $params['type'] = $tudu->type; $params['flowid'] = $tudu->flowId; if (!$tudu->isDraft) { $params['boardid'] = $tudu->boardId; } if ($tudu->parentId) { $params['parentid'] = $tudu->parentId; } if ($tudu->rootId) { $params['rootid'] = $tudu->rootId; } //$params['lastpost'] = ; // 继承需要的字段 if (!$tudu->isDraft) { // 抄送人,只添加 if ($tudu->cc) { $cc = !empty($params['cc']) ? $params['cc'] : array(); foreach ($tudu->cc as $key => $item) { if (false !== strpos($key, '@')) { $cc[$key] = array('email' => $key, 'truename' => $item[0]); } else { $cc[$key] = array('groupid' => $key, 'truename' => $item[0]); } } $params['cc'] = $cc; } if ($tudu->bcc) { $bcc = !empty($params['bcc']) ? $params['bcc'] : array(); foreach ($tudu->bcc as $key => $item) { if (false !== strpos($key, '@')) { $bcc[$key] = array('email' => $key, 'truename' => $item[0]); } else { $bcc[$key] = array('groupid' => $key, 'truename' => $item[0]); } } $params['bcc'] = $bcc; } } } else { $params['tuduid'] = Dao_Td_Tudu_Tudu::getTuduId(); } if (isset($params['vote'])) { if (!Tudu_Tudu_Extension::isRegistered('vote')) { Tudu_Tudu_Extension::registerExtension('vote', 'Tudu_Tudu_Extension_Vote'); } } $tudu = new Tudu_Tudu_Storage_Tudu($params, $tudu); if ($tudu->type == 'task' && $tudu->to && is_array($tudu->to)) { $to = array(); foreach ($tudu->to as $item) { foreach ($item as $val) { $to[$val['email']] = array('email' => $val['email'], 'truename' => $val['truename']); if (isset($val['percent'])) { $to[$val['email']]['percent'] = $val['percent']; } } break; } $tudu->setAttributes(array('to' => $to, 'stepto' => $tudu->to)); } $extensions = Tudu_Tudu_Extension::getRegisteredExtensions(); foreach ($extensions as $key) { Tudu_Tudu_Extension::getExtension($key)->onPrepare($tudu, $params); } return $tudu; }