/** * 获取编辑页面数据 * * @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); }
/** * 预览 */ 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(); }
/** * 预览审批流程 */ 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; }
/** * 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(); }