Example #1
0
 public function getStatusAction()
 {
     $email = $this->_request->getQuery('email', '');
     // 获取联系人的IM在线信息
     $config = $this->bootstrap->getOption('im');
     $im = new Oray_Im_Client($config['host'], $config['port']);
     $imStatus = $im->getUserStatus(explode(',', $email));
     header('Accept-Ranges: bytes');
     header('Content-Type: text/plain; charset=UTF-8');
     header('Content-Disposition: inline;filename=response.txt');
     echo $im->getResult();
 }
Example #2
0
 /**
  * 聊天记录
  */
 public function logAction()
 {
     $jid = $this->_request->getQuery('jid');
     $email = $this->_request->getQuery('email');
     $clientKey = $this->_request->getQuery('clientkey');
     $page = max((int) $this->_request->getQuery('page'), 1);
     $pageSize = 100;
     $bootstrap = $this->getInvokeArg('bootstrap');
     $multidb = $bootstrap->getResource('multidb');
     $options = $bootstrap->getOptions();
     $config = $options['im'];
     $im = new Oray_Im_Client($config['host'], $config['port']);
     $userInfo = $im->getUserInfo($jid, $clientKey);
     if (!$userInfo) {
         //return $this->_redirect('/');
     }
     /* @var $daoChatLog Dao_Im_Chat_Log */
     $daoChatLog = Oray_Dao::factory('Dao_Im_Chat_Log', $multidb->getDb('im'));
     /* @var $daoUdContact Dao_Im_Contact_Contact */
     $daoUdContact = Oray_Dao::factory('Dao_Im_Contact_Contact', $multidb->getDb('im'));
     $jemail = explode('@', $jid);
     $userId = $jemail[0];
     $condition = array('orgid' => 'tudu', 'userid' => $userId, 'email' => $email);
     $info = $daoUdContact->getContact($condition);
     if (!$info) {
         $info = array('userid' => $userId, 'email' => $email, 'displayname' => $email);
     } else {
         $info = $info->toArray();
     }
     $logs = $daoChatLog->getLogPage(array('ownerid' => $jid, 'otherid' => $email), 'createtime DESC', $page, $pageSize);
     $this->view->pageinfo = array('currpage' => $logs->currentPage(), 'pagecount' => $logs->pageCount(), 'recordcount' => $logs->recordCount());
     $data = array('pageinfo' => array('currpage' => $logs->currentPage(), 'pagecount' => $logs->pageCount(), 'recordcount' => $logs->recordCount()));
     $logs = $logs->toArray();
     $ret = array();
     foreach ($logs as $log) {
         $ret[strtotime(date('Y-m-d', $log['createtime']))][$log['createtime']] = $log;
     }
     foreach ($ret as &$day) {
         ksort($day);
     }
     ksort($ret);
     $data['logs'] = $ret;
     $this->view->email = $email;
     $this->view->jid = $jid;
     $this->view->logs = $ret;
     $this->view->options = $options;
     $this->view->info = $info;
 }
Example #3
0
 /**
  * 发送IM图度消息
  *
  * @param string $action
  * @param string $query
  */
 public function onTudu($action, $query)
 {
     parse_str($query, $query);
     switch ($action) {
         case 'create':
         case 'update':
         case 'reply':
         case 'cancel':
             $from = $this->_options['im']['robot'];
             $content = $query['content'];
             foreach (explode(',', $query['to']) as $to) {
                 if (empty($to)) {
                     continue;
                 }
                 $this->_im->sendMsg($from, $to, $content, true, 'tudu');
             }
             $this->getLogger()->debug("send messge to {$query['to']}");
             break;
         default:
             break;
     }
 }
Example #4
0
 /**
  * 查看图度内容
  */
 public function viewAction()
 {
     $tuduId = $this->_request->getQuery('tid');
     $page = $this->_request->getQuery('page');
     $isForward = (bool) $this->_request->getQuery('forward');
     $isReview = (bool) $this->_request->getQuery('review');
     $isDivide = (bool) $this->_request->getQuery('isdivide', $this->_request->getQuery('divide'));
     $isInvite = (bool) $this->_request->getQuery('invite');
     //邀请
     $isApply = (bool) $this->_request->getQuery('apply');
     $isInvert = (bool) $this->_request->getQuery('invert', isset($this->_user->option['postsort']) && $this->_user->option['postsort'] == 1);
     $newwin = (bool) $this->_request->getQuery('newwin');
     $floor = $this->_request->getQuery('floor');
     $pageSize = !empty($this->_user->option['replysize']) ? $this->_user->option['replysize'] : 20;
     $query = array();
     $votes = null;
     $params = $this->_request->getPost();
     $isSynchro = false;
     //是否逐级执行
     if (!$tuduId) {
         return $this->_redirect($this->_refererUrl);
     }
     /* @var $daoTudu Dao_Td_Tudu_Tudu */
     $daoTudu = $this->getDao('Dao_Td_Tudu_Tudu');
     $tudu = $daoTudu->getTuduById($this->_user->uniqueId, $tuduId, array());
     if (!$tudu) {
         return $this->_redirect($this->_refererUrl);
         //Oray_Function::alert($LANG['tudu_not_exists'], $_SERVER['HTTP_REFERER']);
     }
     if ($newwin) {
         $daoOrg = $this->getMdDao('Dao_Md_Org_Org');
         $org = $daoOrg->getOrg(array('orgid' => $this->_user->orgId));
         $this->view->org = $org->toArray();
     }
     $upload = $this->options['upload'];
     $upload['cgi']['upload'] .= '?' . session_name() . '=' . Zend_Session::getId() . '&email=' . $this->_user->address;
     $this->view->registModifier('tudu_format_content', array($this, 'formatContent'));
     $this->view->registModifier('tudu_get_attachment_url', array($this, 'getAttachmentUrl'));
     //$this->view->registModifier('tudu_format_post_header', array($this, 'formatPostHeader'));
     $this->view->upload = $upload;
     $this->view->sessionid = $this->_sessionId;
     $boards = $this->getBoards(false);
     $board = $boards[$tudu->boardId];
     $isSender = in_array($tudu->sender, array($this->_user->address, $this->_user->userName), true);
     // 当前版块版主
     $isModerators = array_key_exists($this->_user->userId, $board['moderators']);
     // 上级分区负责人
     $isSuperModerator = !empty($board['parentid']) && array_key_exists($this->_user->userId, $boards[$board['parentid']]['moderators']);
     // 草稿,显示编辑界面
     if ($tudu->isDraft || $isForward || $isDivide || $isReview || $isInvite || $isApply) {
         if ($tudu->isDraft && $tudu->appId == 'attend') {
             $this->_redirect('/app/attend/apply/modify?tid=' . $tudu->tuduId);
         }
         // 判断是否有转发图度的权限
         if ($isForward && !$this->_user->getAccess()->isAllowed(Tudu_Access::PERM_FORWARD_TUDU)) {
             Oray_Function::alert($this->lang['perm_deny_forward_tudu'], '/tudu?view=' . $tuduId . '&page=1');
         }
         // 图度组不能参与审批
         if ($isReview && $tudu->isTuduGroup) {
             Oray_Function::alert($this->lang['tudu_group_review'], '/tudu?view=' . $tuduId . '&page=1');
         }
         $access = array('upload' => $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_UPLOAD_ATTACH));
         $attachments = array();
         if ($tudu->attachNum > 0 && !$isForward) {
             /**
              *
              * @var Dao_Td_Attachment_File
              */
             $daoFile = $this->getDao('Dao_Td_Attachment_File');
             $attachments = $daoFile->getFiles(array('tuduid' => $tudu->tuduId, 'postid' => $tudu->postId));
             $attachments = $attachments->toArray();
         }
         if ($tudu->special == Dao_Td_Tudu_Tudu::SPECIAL_VOTE) {
             /**
              * @var Dao_Td_Tudu_Vote
              */
             $daoVote = $this->getDao('Dao_Td_Tudu_Vote');
             $votes = $daoVote->getVotesByTuduId($tudu->tuduId);
             $votes = $votes->toArray();
             $votes = $daoVote->formatVotes($votes);
         }
         if ($tudu->cycleId) {
             $daoCycle = $this->getDao('Dao_Td_Tudu_Cycle');
             $cycle = $daoCycle->getCycle(array('cycleid' => $tudu->cycleId));
             $this->view->cycle = $cycle->toArray();
         }
         if ($tudu->flowId) {
             /* @var $daoFlow Dao_Td_Flow_Flow */
             $daoFlowTpl = $this->getDao('Dao_Td_Flow_Flow');
             $flows = $daoFlowTpl->getFlows(array('orgid' => $this->_user->orgId, 'boardid' => $tudu->boardId), array('isvalid' => 1));
             $this->view->flows = $flows->toArray();
             $flow = $daoFlowTpl->getFlowById($tudu->flowId, array('isvalid' => 1))->toArray();
             $steps = $this->formatStepsToHtml($flow['steps']);
             $this->view->flowhtml = $steps;
         }
         // 会议信息
         if ($tudu->type == 'meeting') {
             $daoMeeting = $this->getDao('Dao_Td_Tudu_Meeting');
             $meeting = $daoMeeting->getMeeting(array('tuduid' => $tudu->tuduId));
             if (null !== $meeting) {
                 $this->view->meeting = $meeting->toArray();
             }
         }
         $type = $tudu->type;
         $tudu = $tudu->toArray();
         $tudu['attachments'] = $attachments;
         if ($isForward) {
             $tudu['to'] = array();
             //$tudu['cc'] = array();
             $this->view->action = 'forward';
         }
         if ($isReview) {
             $tudu['cc'] = array();
             $this->view->action = 'review';
         }
         if (!($this->_user->getAccess()->isAllowed(Tudu_Access::PERM_UPDATE_TUDU) && ($isSender || $isModerators || $isSuperModerator))) {
             $tudu['bcc'] = array();
         }
         $daoClass = $this->getDao('Dao_Td_Tudu_Class');
         $classes = $daoClass->getClassesByBoardId($this->_user->orgId, $tudu['boardid'], array('ordernum' => 'ASC'));
         // 板块输出
         $daoBoard = $this->getDao('Dao_Td_Board_Board');
         $boards = $this->getBoards();
         foreach ($boards as $key => $board) {
             if (!empty($board['children'])) {
                 foreach ($board['children'] as $k => $child) {
                     if ($tudu['boardid'] == $child['boardid']) {
                         $tudu['boardname'] = $child['boardname'];
                         break;
                     }
                 }
             }
         }
         // 图度组草稿、分工
         if ($tudu['isdraft'] && $tudu['istudugroup'] && !$isForward && !$isReview && !$isInvite || $isDivide) {
             /* @var $daoFlow Dao_Td_Tudu_Flow */
             $daoFlow = $this->getDao('Dao_Td_Tudu_Flow');
             $children = $daoTudu->getGroupTudus(array('parentid' => $tudu['tuduid'], 'senderid' => $this->_user->uniqueId, 'uniqueid' => $this->_user->uniqueId), array('isdraft' => null));
             $children = $children->toArray();
             foreach ($children as $key => $child) {
                 $to = array();
                 $toText = array();
                 if (empty($child['flowid']) && $child['stepid']) {
                     $flow = $daoFlow->getFlow(array('tuduid' => $child['tuduid']));
                     $steps = $flow->steps;
                     $isExceed = false;
                     foreach ($steps as $sid => $step) {
                         if (!$isExceed && ($sid == $flow->currentStepId || $flow->currentStepId == '^head')) {
                             $isExceed = true;
                         }
                         if ($isExceed) {
                             foreach ($step['section'] as $sec) {
                                 foreach ($sec as $idx => $u) {
                                     if ($idx > 0) {
                                         $to[] = '+';
                                     }
                                     $to[] = $u['username'] . ' ' . $u['truename'];
                                 }
                                 if (!empty($to)) {
                                     $to[] = '>';
                                 }
                             }
                         }
                     }
                 }
                 if (!empty($to)) {
                     foreach ($to as $item) {
                         if ($item == '+' || $item == '>') {
                             $toText[] = $item;
                             continue;
                         }
                         $info = explode(' ', $item);
                         if (isset($info[1])) {
                             $toText[] = $info[1];
                         }
                     }
                 }
                 $children[$key]['totext'] = $toText;
                 $children[$key]['to'] = $to;
             }
             $this->view->children = $children;
             $this->view->divide = $isDivide;
             $this->view->type = 'group';
         }
         $tudu['users'] = $daoTudu->getUsers($tudu['tuduid']);
         $accepters = array();
         foreach ($tudu['users'] as $user) {
             if ($user['role'] == 'to' && $user['accepterinfo']) {
                 $info = explode(' ', $user['accepterinfo']);
                 if (count($info) >= 2) {
                     $accepters[] = array('email' => str_replace(array('oray.com', 'tudu.com'), array('oray', ''), $info[0]), 'truename' => $info[1], 'percent' => !empty($user['percent']) ? $user['percent'] : 0);
                 }
             }
         }
         // 逐级执行,获取执行人 及 审批人填充
         if ($isApply || $tudu['stepid'] && $tudu['stepid'] != '^trunk' && $tudu['stepid'] != '^end') {
             /* @var $daoFlow Dao_Td_Tudu_Flow */
             $daoFlow = $this->getDao('Dao_Td_Tudu_Flow');
             $flow = $daoFlow->getFlow(array('tuduid' => $tudu['tuduid']));
             $steps = $flow->steps;
             $reviewer = array();
             $to = array();
             $isExceed = false;
             $processindex = null;
             $toIdx = null;
             foreach ($steps as $sid => $step) {
                 if (!$isExceed && ($sid == $flow->currentStepId || $flow->currentStepId == '^head')) {
                     $isExceed = true;
                 }
                 foreach ($step['section'] as $idx => $sec) {
                     if (!empty($to) && ($step['type'] == 0 || $step['type'] == 2)) {
                         $to[]['userinfo'] = '>';
                     }
                     if (!empty($reviewer) && $step['type'] == 1) {
                         $reviewer[]['userinfo'] = '>';
                     }
                     foreach ($sec as $i => $u) {
                         if ($step['type'] == 1 && (!isset($u['status']) || $u['status'] != 2)) {
                             if ($i > 0) {
                                 $reviewer[]['userinfo'] = '+';
                             }
                             $reviewer[] = array('email' => $u['username'], 'truename' => $u['truename'], 'userinfo' => $u['username'] . ' ' . $u['truename']);
                         }
                         if ($isExceed && $step['type'] == 0 && (!isset($u['status']) || $u['status'] != 4)) {
                             if ($i > 0) {
                                 $u[] = '+';
                             }
                             $to[] = array('email' => $u['username'], 'truename' => $u['truename'], 'userinfo' => $u['username'] . ' ' . $u['truename']);
                         }
                     }
                 }
             }
             // 移除第一个系“+”的问题
             if (!empty($reviewer) && count($reviewer) > 1) {
                 $l = count($reviewer) - 1;
                 if ($reviewer[0]['userinfo'] == '+') {
                     unset($reviewer[0]);
                 }
                 //移除最后一个系“+”的问题
                 if ($reviewer[$l]['userinfo'] == '+') {
                     unset($reviewer[$l]);
                 }
             }
             if (!$isReview) {
                 $this->view->reviewer = $reviewer;
             }
             if (!empty($to)) {
                 $tudu['to'] = $to;
             }
         }
         if ($isReview || $isForward || $isApply) {
             if ($this->_request->getPost('content')) {
                 $tudu['content'] = $this->_request->getPost('content');
             } else {
                 $tudu['content'] = '';
             }
         }
         $arrBoard = $this->getBoards(false);
         $board = isset($arrBoard[$tudu['boardid']]) ? $arrBoard[$tudu['boardid']] : null;
         if ($isForward) {
             $tudu['to'] = array();
             $isModerators = $isSuperModerator = false;
             if ($board) {
                 $board = $arrBoard[$tudu['boardid']];
                 // 当前版块版主
                 $isModerators = array_key_exists($this->_user->userId, $board['moderators']);
                 // 上级分区负责人
                 $isSuperModerator = !empty($board['parentid']) && array_key_exists($this->_user->userId, $arrBoard[$board['parentid']]['moderators']);
             }
             $access['modify'] = $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_UPDATE_TUDU) && ($this->_user->userName == $tudu['sender'] || $isModerators || $isSuperModerator);
         }
         $this->view->registModifier('format_board_list', array($this, 'formatBoardList'));
         $this->view->classes = $classes->toArray();
         $this->view->boards = $boards;
         $this->view->board = $board;
         $this->view->tudu = $tudu;
         $this->view->accepters = $accepters;
         $this->view->access = $access;
         $this->view->isforward = $isForward;
         $this->view->isdivide = $isDivide;
         $this->view->isInvite = $isInvite;
         $this->view->isreview = $isReview;
         $this->view->isapply = $isApply;
         $this->view->votes = $votes;
         $this->view->back = $this->_request->getQuery('back');
         $this->view->newwin = $newwin;
         $this->view->issynchro = $isSynchro;
         $this->render('modify_' . $type);
         return;
     }
     if ($tudu->appId == 'attend') {
         $this->_redirect('/app/attend/apply/view?tid=' . $tudu->tuduId);
     }
     /* @var $tudu Dao_Td_Tudu_Record_Tudu */
     // 注:Receiver跟Accepter不同,前者指相关的接收人(参与人员),后者指图度的执行人
     $isReceiver = $this->_user->uniqueId == $tudu->uniqueId && count($tudu->labels);
     $isAccepter = in_array($this->_user->address, $tudu->accepter, true) || in_array($this->_user->userName, $tudu->accepter, true);
     $isSender = in_array($tudu->sender, array($this->_user->address, $this->_user->userName), true);
     //$this->_user->address == $tudu->sender;
     // 是否当前版块参与人,(所属群组中包含参与群组 || 当前用户[email]在参与人列表中)
     $inGroups = in_array($this->_user->userName, $board['groups'], true) || (bool) sizeof(array_uintersect($this->_user->groups, $board['groups'], "strcasecmp"));
     // 上级分区负责人
     $isSuperModerator = !empty($board['parentid']) && array_key_exists($this->_user->userId, $boards[$board['parentid']]['moderators']);
     // 会议执行人有群组
     if ($tudu->type == 'meeting') {
         foreach ($tudu->accepter as $item) {
             if ($isAccepter) {
                 break;
             }
             if (strpos($item, '^') == 0) {
                 $isAccepter = in_array($item, $this->_user->groups, true);
             }
         }
     }
     // 图度的相关权限
     $access = array('view' => $isReceiver || $isModerators || $isSuperModerator || !$tudu->privacy && !$board['privacy'] && $inGroups, 'reply' => $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_CREATE_POST) || $isReceiver, 'modify' => $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_UPDATE_TUDU) && ($isSender || $isModerators || $isSuperModerator), 'delete' => $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_DELETE_TUDU) && ($isSender || $isModerators || $isSuperModerator), 'upload' => $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_UPLOAD_ATTACH), 'merge' => $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_MERGE_TUDU_GROUP) && $tudu->type == 'task' && !$tudu->isDone && !$tudu->isTuduGroup && ($isSender || $isAccepter), 'accept' => $isAccepter && !$tudu->selfAcceptTime && !$tudu->isDone, 'reject' => $isAccepter && (!$isSender || $tudu->flowId) && $tudu->selfTuduStatus != Dao_Td_Tudu_Tudu::STATUS_REJECT, 'cancel' => $isSender && !$tudu->isDone, 'forward' => $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_FORWARD_TUDU) && $isAccepter, 'progress' => $isAccepter && $tudu->selfAcceptTime, 'confirm' => $isSender && !$tudu->isDone, 'undone' => $isSender && $tudu->isDone, 'ignore' => $isReceiver, 'invite' => $isAccepter && $tudu->type == 'meeting' && !$tudu->isDone, 'divide' => $isAccepter && $tudu->selfAcceptTime && !$tudu->cycleId && $tudu->type == 'task', 'accepter' => $isAccepter, 'sender' => $isSender, 'review' => $isAccepter && $tudu->type == 'task' && !$tudu->isDone && !$tudu->isTuduGroup && $tudu->selfAcceptTime, 'agree' => false, 'disagree' => false, 'claim' => $tudu->type == 'task' && $isAccepter && $tudu->acceptMode && !$tudu->acceptTime, 'resetvote' => $tudu->type == 'discuss' && $isSender && !$tudu->isDone);
     // 临时人员
     if (!$this->_user->status == 2 && !$isSender && !$isReceiver && !$isModerators && !$isSuperModerator) {
         $access['view'] = false;
     }
     if ($tudu->isTuduGroup && $isSender) {
         $access['divide'] = false;
     }
     if ($access['merge'] && $tudu->rootId) {
         $access['merge'] = false;
     }
     if (!$access['view'] && $tudu->rootId) {
         //$this->_redirect($_SERVER['HTTP_REFERER']);
         $daoGroup = $this->getDao('Dao_Td_Tudu_Group');
         $groupTudus = $daoGroup->getParentTudus(array('rootid' => $tudu->rootId));
         // 没有权限
         if (true === $this->_checkParentAccess($tuduId, $groupTudus)) {
             $access['view'] = true;
         }
     }
     if (!$access['view']) {
         Oray_Function::alert($this->lang['perm_deny_view_tudu'], $_SERVER['HTTP_REFERER'], '/frame/home');
     }
     //若图度含有私密任务密码则跳转输入密码页面  草稿箱的不执行此操作
     if (!$isSender && empty($this->session->privacy[$tuduId]) && $tudu->password) {
         $this->view->tudu = $tudu->toArray();
         return $this->render('privacy');
     }
     // 读取投票
     if ($tudu->special == Dao_Td_Tudu_Tudu::SPECIAL_VOTE) {
         /* @var $daoVote Dao_Td_Tudu_Vote */
         $daoVote = $this->getDao('Dao_Td_Tudu_Vote');
         $votes = $daoVote->getVotesByTuduId($tudu->tuduId);
         $votes = $votes->toArray();
         $votes = $daoVote->formatVotes($votes);
         foreach ($votes as $voteId => &$vote) {
             // 统计参与人
             $vote['countvoter'] = $daoVote->countVoter($tudu->tuduId, $voteId);
             $isVoted = $daoVote->hasVote($tudu->tuduId, $voteId, $this->_user->uniqueId);
             $expired = !empty($vote['expiretime']) && time() > $vote['expiretime'] + 86400;
             $vote['expired'] = $expired;
             $vote['isvoted'] = $isVoted;
             $vote['enabled'] = !$isVoted && !$expired && ($isReceiver || $isAccepter);
             // 创建人可见投票参与人
             if ($vote['anonymous'] && $isSender) {
                 $vote['privacy'] = true;
             }
         }
     }
     // 读取周期任务信息
     if ($tudu->special == Dao_Td_Tudu_Tudu::SPECIAL_CYCLE && $tudu->cycleId) {
         /* @var $daoCycle Dao_Td_Tudu_Cycle */
         $daoCycle = $this->getDao('Dao_Td_Tudu_Cycle');
         if ($cycle = $daoCycle->getCycle(array('cycleid' => $tudu->cycleId))) {
             $this->view->cycleremind = $this->_formatCycleInfo($cycle->toArray(), $tudu);
             $this->view->cycle = $cycle->toArray();
         }
     }
     // 会议信息
     if ($tudu->type == 'meeting') {
         $daoMeeting = $this->getDao('Dao_Td_Tudu_Meeting');
         $meeting = $daoMeeting->getMeeting(array('tuduid' => $tudu->tuduId));
         if (null !== $meeting) {
             $this->view->meeting = $meeting->toArray();
         }
     }
     // 读取分工图度
     if ($tudu->nodeType == Dao_Td_Tudu_Group::TYPE_NODE || $tudu->nodeType == Dao_Td_Tudu_Group::TYPE_ROOT) {
         $children = $daoTudu->getGroupTudus(array('parentid' => $tudu->tuduId, 'uniqueid' => $this->_user->uniqueId), null, 'lastposttime DESC')->toArray();
     }
     // 任务的相关逻辑处理
     if ($tudu->type == 'task') {
         if ($isAccepter || $isSender) {
             $access['ignore'] = false;
         }
         // 任务类权限的特殊过滤
         // 已确认完成时,禁止操作的权限
         if ($tudu->isDone) {
             $access['reply'] = false;
             $access['modify'] = false;
             $access['forward'] = false;
             $access['divide'] = false;
             $access['accept'] = false;
             $access['reject'] = false;
         }
         // 已完成(完成、取消、拒绝)时,禁止操作的权限
         if ($isAccepter && $tudu->selfTuduStatus >= Dao_Td_Tudu_Tudu::STATUS_DONE) {
             $access['cancel'] = false;
             $access['accept'] = false;
             $access['reject'] = false;
             $access['forward'] = false;
             if (count($tudu->accepter) > 1 && $tudu->selfTuduStatus >= Dao_Td_Tudu_Tudu::STATUS_DONE) {
                 $access['progress'] = false;
             }
             if ($tudu->selfTuduStatus > Dao_Td_Tudu_Tudu::STATUS_DONE || $tudu->isDone) {
                 $access['divide'] = false;
             }
         }
         if ($tudu->status > Dao_Td_Tudu_Tudu::STATUS_DONE) {
             $access['progress'] = false;
             $access['accept'] = false;
             $access['reject'] = false;
             $access['forward'] = false;
             $access['divide'] = false;
         }
         if ($isSender) {
             if ($tudu->status >= Dao_Td_Tudu_Tudu::STATUS_DONE) {
                 $access['accept'] = false;
                 $access['reject'] = false;
                 $access['cancel'] = false;
                 $access['forward'] = false;
                 $access['progress'] = false;
             } else {
                 $access['confirm'] = false;
             }
         }
         if ($isAccepter && $tudu->selfPercent == 100 && $tudu->isDone === false) {
             $access['forward'] = true;
         }
         /*
                     if ($tudu->stepId && strpos($tudu->stepId, '^') !== 0) {
         
                         $daoStep = $this->getDao('Dao_Td_Tudu_Step');
         
                         $step = $daoStep->getCurrentStep($tuduId, $tudu->stepId, $this->_user->uniqueId);
         
                         if (null !== $step && $step['type'] == Dao_Td_Tudu_Step::TYPE_EXAMINE) {
                             $this->view->isreview = true;
                         }
         
                         if (null !== $step && $step['type'] == Dao_Td_Tudu_Step::TYPE_EXAMINE) {
                             if ($step['uniqueid'] == $this->_user->uniqueId
                                 && $step['status'] == 1
                                 && !$tudu->isDone)
                             {
                                 $access['agree']  = true;
                                 $access['disagree']  = true;
                                 $access['ignore'] = false;
                             }
         
                             $access['forward']  = false;
                             $access['divide']  = false;
                             $access['accept']   = false;
                             $access['reject']   = false;
                             $access['progress'] = false;
                             $access['review']  = false;
                         }
                     }*/
         //循环周期任务 已接受的不允许转发
         if ($tudu->special == 1 && null !== $tudu->acceptTime) {
             $access['forward'] = false;
         }
         // 认领进行中
         if ($isAccepter && $tudu->acceptMode && !$tudu->acceptTime) {
             $access['forward'] = false;
             $access['divide'] = false;
             $access['accept'] = false;
             $access['reject'] = false;
             $access['progress'] = false;
             $access['review'] = false;
             $access['agree'] = false;
             $access['disagree'] = false;
         }
         // 已认领
         //if ($isAccepter && $tudu->acceptMode && $tudu->acceptTime) {
         //$access['progress'] = true;
         //}
         // 屏蔽新手任务的的权限
         // 工作流没有分工及转发权限
         if ($tuduId == 'newbie-' . $this->_user->uniqueId) {
             $access['forward'] = false;
             $access['divide'] = false;
         }
         if ($tudu->flowId && 0 !== strpos('^', $tudu->flowId)) {
             $access['divide'] = false;
         }
         $remind = '';
         if ($tudu->flowId) {
             /* @var $daoFlow Dao_Td_Flow_Flow */
             $daoFlow = $this->getDao('Dao_Td_Flow_Flow');
             $flow = $daoFlow->getFlowById($tudu->flowId);
             $remind .= sprintf($this->lang['remind_flow_tips_info'], $flow->subject, $tudu->from[1] == $this->_user->userId ? $this->lang['me'] : $tudu->from[0]);
             $this->view->remind = $remind;
         }
         // 会议
     } elseif ($tudu->type == 'meeting') {
         if ($isAccepter || $isSender) {
             $access['ignore'] = false;
         }
         $access['forward'] = false;
         $access['progress'] = false;
         $access['confirm'] = false;
         if ($tudu->isDone) {
             $access['reply'] = false;
             $access['modify'] = false;
             $access['accept'] = false;
             $access['reject'] = false;
         }
         if ($tudu->selfTuduStatus > Dao_Td_Tudu_Tudu::STATUS_DONE || $tudu->isDone) {
             $access['reject'] = false;
             $access['accept'] = false;
         }
         // 显示发起人提醒信息
         if ($isAccepter && $meeting) {
             $startTime = $meeting->isAllday ? date('Y-m-d', $tudu->startTime) : date('Y-m-d H:i', $tudu->startTime);
             $remind = sprintf($this->lang['remind_meeting_left'], $tudu->from[1] == $this->_user->userId ? $this->lang['me'] : $tudu->from[0], $startTime);
             // 未接受
             if (!$tudu->selfAcceptTime) {
                 $remind .= $this->lang['remind_meeting_accept'];
             }
             $this->view->remind = $remind;
         }
     } else {
         $access['accept'] = false;
         $access['reject'] = false;
         $access['cancel'] = false;
         $access['forward'] = false;
         $access['progress'] = false;
         $access['confirm'] = false;
         $access['undone'] = false;
         $access['review'] = false;
         $access['modify'] &= !$tudu->isDone;
         $access['reply'] &= !$tudu->isDone;
     }
     // 已分工不能更新任务进度
     if ($tudu->isTuduGroup && ($access['progress'] || $access['forward'])) {
         if ($this->getDao('Dao_Td_Tudu_Group')->getChildrenCount($tudu->tuduId, $this->_user->uniqueId) > 0) {
             $access['progress'] = false;
             $access['forward'] = false;
         }
     }
     // 已关联用户,设置已读状态
     if ($tudu->uniqueId == $this->_user->uniqueId) {
         if (!$tudu->isRead) {
             $daoTudu->markRead($tuduId, $this->_user->uniqueId);
         }
         // 增加到关联用户,解决版块中的已读未读状态问题(!!会导致重新发送的不会投递到用户图度箱)
     } else {
         $daoTudu->addUser($tuduId, $this->_user->uniqueId, array('isread' => true));
     }
     // 增加浏览次数
     $daoTudu->hit($tuduId);
     // 公告从图度箱中移除
     if ($tudu->type == 'notice' && in_array('^i', $tudu->labels) && !in_array('^e', $tudu->labels) && $tudu->stepType != 1 && (!$tudu->isTop && !$tudu->endTime || $tudu->endTime < strtotime('today')) && empty($access['agree'])) {
         $daoTudu->deleteLabel($tuduId, $this->_user->uniqueId, '^i');
     }
     $uniqueId = $this->_request->getQuery('unid');
     $back = $this->_request->getQuery('back');
     $recordCount = $tudu->replyNum + 1;
     $labels = $this->getLabels();
     $query = array('tid' => $tudu->tuduId, 'back' => $back, 'invert' => $isInvert ? 1 : 0);
     $condition = array('tuduid' => $tudu->tuduId);
     /* @var $daoPost Dao_Td_Tudu_Post */
     $daoPost = $this->getDao('Dao_Td_Tudu_Post');
     if ($uniqueId) {
         $condition['uniqueid'] = $uniqueId;
         $query['unid'] = $uniqueId;
         $recordCount = $daoPost->getPostCount($tudu->tuduId, $uniqueId);
     }
     $pageCount = $pageSize > 0 ? intval(($recordCount - 1) / $pageSize) + 1 : 1;
     $isLast = false;
     if ($page == 'last') {
         $page = $pageCount;
         $isLast = true;
     } else {
         $page = min($pageCount, max(1, (int) $page));
     }
     if (isset($floor)) {
         if ($floor == 0) {
             $page = 1;
         } else {
             $page = intval($floor / $pageSize) + 1;
         }
         $this->view->floor = $floor;
         $this->view->jumpfloor = true;
     }
     $postSort = $isInvert ? 'createtime DESC' : 'createtime ASC';
     // 获取回复内容
     $posts = $daoPost->getPostPage($condition, $postSort, $page, $pageSize)->toArray();
     // 回复者的在线状态
     $status = array();
     // 回复的相关权限
     $postAccess = array('modify' => !$board['protect'] && $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_UPDATE_POST), 'delete' => !$board['protect'] && $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_DELETE_POST));
     foreach ($posts as $key => $post) {
         // 公告过滤不可见的回复
         if ($tudu->type == 'notice' && !$access['modify'] && !$post['isfirst'] && !in_array('^v', $tudu->labels) && !in_array('^e', $tudu->labels)) {
             unset($posts[$key]);
             continue;
         }
         // 读取回复的附件信息
         if ($post['attachnum'] > 0) {
             $files = $this->getDao('Dao_Td_Attachment_File')->getFiles(array('tuduid' => $tudu->tuduId, 'postid' => $post['postid']));
             $posts[$key]['attachment'] = $files->toArray();
         }
         // 权限
         if (!$post['isfirst'] && !$tudu->isDone) {
             $posts[$key]['access'] = array('modify' => $postAccess['modify'] && ($isModerators || $post['uniqueid'] == $this->_user->uniqueId), 'delete' => $postAccess['delete'] && ($isModerators || $post['uniqueid'] == $this->_user->uniqueId));
         }
         if ($post['header']) {
             $posts[$key]['header'] = $this->formatPostHeader($post['header'], $post['poster']);
         }
         // 不显示自己的在线状态
         //if ($post['email'] == $this->_user->address) {
         //    $post['email'] = null;
         //}
         if ($post['email']) {
             if (!array_key_exists($post['email'], $status)) {
                 $status[$post['email']] = false;
             }
             $posts[$key]['imstatus'] =& $status[$post['email']];
         }
     }
     // 获取联系人的IM在线信息
     $config = $this->bootstrap->getOption('im');
     $im = new Oray_Im_Client($config['host'], $config['port']);
     $imStatus = $im->getUserStatus(array_keys($status));
     foreach ($imStatus as $email => $_status) {
         if (isset($status[$email])) {
             $status[$email] = $_status;
         }
     }
     $unSendPost = $daoPost->getPost(array('tuduid' => $tuduId, 'uniqueid' => $this->_user->uniqueId, 'issend' => 0));
     if ($unSendPost) {
         $unSendPost = $unSendPost->toArray();
         $unSendPost['content'] = $this->formatContent($unSendPost['content']);
         // 读取回复的附件信息
         if ($unSendPost['attachnum'] > 0) {
             $files = $this->getDao('Dao_Td_Attachment_File')->getFiles(array('tuduid' => $tuduId, 'postid' => $unSendPost['postid']));
             $unSendPost['attachments'] = $files->toArray();
         }
     } else {
         $unSendPost = array();
     }
     $unSendPost = array_merge($unSendPost, $params);
     if (isset($params['percent'])) {
         $unSendPost['percent'] = (int) $params['percent'];
     }
     if (isset($params['attach']) && is_array($params['attach'])) {
         $attachments = $daoFile->getFiles(array('fileid' => $params['attach'], 'uniqueid' => $this->_user->uniqueId), array('isattachment' => null));
         $unSendPost['attachments'] = array_unique($attachments->toArray());
         $unSendPost['attachnum'] = count($params['attachments']);
     }
     if (isset($params['savetime'])) {
         $unSendPost['savetime'] = (int) $params['savetime'];
     }
     if (isset($params['elapsedtime'])) {
         $unSendPost['elapsedtime'] = (int) $params['elapsedtime'] * 3600;
     }
     /**
      * 读取父级图度相关内容
      */
     if ($tudu->parentId) {
         $parent = $daoTudu->getTuduById($this->_user->uniqueId, $tudu->parentId);
         if (null !== $parent) {
             $parentBoard = $boards[$parent->boardId];
             $isParentModerators = array_key_exists($this->_user->userId, $parentBoard['moderators']);
             $inParentGroups = (bool) sizeof(array_uintersect($this->_user->groups, $parentBoard['groups'], "strcasecmp")) || in_array($this->_user->userName, $parentBoard['groups'], true);
             $isParentSuperModerator = !empty($parentBoard['parentid']) && array_key_exists($this->_user->userId, $boards[$parentBoard['parentid']]['moderators']);
             $isParentReceiver = $this->_user->uniqueId == $parent->uniqueId && count($parent->labels);
             if ($isParentReceiver || $isParentModerators || $isParentSuperModerator || !$parent->privacy && !$parentBoard['privacy'] && $inParentGroups) {
                 $this->view->parent = array('subject' => $parent->subject);
             }
         }
     }
     if ($tudu->prevTuduId) {
         $prevTudu = $daoTudu->getTuduById($this->_user->uniqueId, $tudu->prevTuduId);
         //$access['accept'] &= $prevTudu->isDone;
         if (null != $prevTudu) {
             $this->view->prevtudu = array('tuduid' => $prevTudu->tuduId, 'subject' => $prevTudu->subject);
         }
     }
     if (!empty($this->session->tuduContact[$tudu->tuduId])) {
         $contactIds = $this->session->tuduContacts[$tudu->tuduId];
         $contacts = $daoTudu->getUsers($tudu->tuduId, array('uniqueid' => $contactIds, 'isforeign' => 1));
         unset($this->session->tuduContact[$tudu->tuduId]);
         $this->view->contacts = $contacts;
     }
     $isDisagreed = false;
     $isViewFlow = $isSender || $access['modify'] ? true : false;
     if (($tudu->type == 'task' || $tudu->type == 'notice') && $tudu->stepNum > 0) {
         $daoFlow = $this->getDao('Dao_Td_Tudu_Flow');
         $flow = $daoFlow->getFlow(array('tuduid' => $tudu->tuduId));
         $steps = $flow->steps;
         if ($tudu->flowId && 0 !== strpos($flow->currentStepId, '^')) {
             $access['confirm'] = false;
         }
         if ($flow->currentStepId == '^break') {
             $access['forward'] = false;
             $access['divide'] = false;
             $access['accept'] = false;
             $access['reject'] = false;
             $access['progress'] = false;
             $access['review'] = false;
             $access['agree'] = false;
             $access['disagree'] = false;
             $access['confirm'] = false;
         }
         $stepView = array();
         foreach ($steps as &$item) {
             // 处理当前步骤
             if ($item['stepid'] == $flow->currentStepId && count($item['section'])) {
                 // 导入数据的容错
                 $currentSection = $item['currentSection'] >= count($item['section']) ? count($item['section']) - 1 : $item['currentSection'];
                 // 审批
                 if ($item['type'] == 1) {
                     $this->view->isreview = true;
                     $this->view->samereview = count($item['section'][$currentSection]) > 1;
                     $access['forward'] = $access['divide'] = $access['accept'] = $access['reject'] = $access['progress'] = false;
                 }
                 //$currentSection = $item['currentSection'];
                 if (!isset($item['section'][$currentSection])) {
                     break;
                 }
                 $section =& $item['section'][$currentSection];
                 $to = array();
                 foreach ($section as &$user) {
                     // 处理执行步骤显示
                     if ($item['type'] == 0) {
                         $accepters = $this->getDao('Dao_Td_Tudu_Tudu')->getAccepters($tuduId);
                         if (!empty($accepters)) {
                             foreach ($accepters as $accepter) {
                                 if ($accepter['uniqueid'] == $user['uniqueid']) {
                                     $user['percent'] = $accepter['percent'];
                                 }
                             }
                         } else {
                             $user['percent'] = $tudu->percent;
                         }
                     }
                     // 审批权限
                     if ($item['type'] == Dao_Td_Tudu_Step::TYPE_EXAMINE && $user['status'] == 1 && $user['uniqueid'] == $this->_user->uniqueId) {
                         $access['agree'] = $access['disagree'] = true;
                     }
                     $to[$user['username']] = array($user['truename'], null, null, $user['username']);
                 }
                 $tudu->to = $to;
                 if ($item['type'] == Dao_Td_Tudu_Step::TYPE_EXAMINE) {
                     $access['accept'] = $access['reject'] = $access['forward'] = $access['divide'] = false;
                     $this->view->isreview = true;
                 }
             }
             // 被中断
             // 即步骤中有审批不同意
             if (!empty($item['isbreak'])) {
                 if ($tudu->flowId) {
                     $access['accept'] = false;
                     if (strpos($tudu->stepId, '^') === 0) {
                         $access['reject'] = false;
                     }
                 } else {
                     $access['progress'] = $access['accept'] = $access['reject'] = false;
                 }
             }
         }
         $this->view->steps = $steps;
         /*$daoStep = $this->getDao('Dao_Td_Tudu_Step');
         
                     $users = $daoStep->getTuduStepUsers($tudu->tuduId);
                     $accepters = $this->getDao('Dao_Td_Tudu_Tudu')->getAccepters($tuduId);
         
                     // 当前是否最后一步骤,且是否执行
                     $isLastExecute = false;
                     if ($tudu->type == 'task') {
                         $tempUsers = $users;
         
                         do {
                             $arr = array_pop($tempUsers);
         
                             if (!$arr) {
                                 break;
                             }
         
                             if ($arr['type'] == Dao_Td_Tudu_Step::TYPE_EXECUTE && $arr['stepid'] != $tudu->stepId) {
                                 if ($tudu->stepId == '^end') {
                                     $isLastExecute = true;
                                 }
                                 break;
                             }
                             if ($arr['type'] == Dao_Td_Tudu_Step::TYPE_EXECUTE && ($arr['stepid'] == $tudu->stepId || $tudu->stepId == '^end')) {
                                 $isLastExecute = true;
                                 break;
                             }
                         } while (true);
                     }
         
                     $steps        = array();
                     $isExceed     = false;
                     $processIndex = null;
                     $sameReview   = false;
                     $currentUser  = array();
                     $currentIndex = null;
                     $tempStepId   = null;
                     $tempType     = null;
                     foreach ($users as &$user) {
                         if ($tudu->type == 'task' && !$isLastExecute && $tempStepId != $user['stepid'] && $tempType == $user['type'] && $user['type'] == Dao_Td_Tudu_Step::TYPE_EXECUTE) {
                             $isSynchro = true;
                         }
                         $tempStepId = $user['stepid'];
                         $tempType   = $user['type'];
         
                         $info = explode(' ', $user['userinfo']);
                         $user['email']    = $info[0];
                         $user['truename'] = $info[1];
         
                         if ($user['type'] == Dao_Td_Tudu_Step::TYPE_EXAMINE && $user['uniqueid'] == $this->_user->uniqueId) {
                             $isViewFlow = true;
                         }
         
                         if ($user['type'] == Dao_Td_Tudu_Step::TYPE_EXECUTE && $user['stepid'] == $tudu->stepId && !empty($accepters)) {
                             foreach ($accepters as $accepter) {
                                 if ($accepter['uniqueid'] == $user['uniqueid']) {
                                     $user['percent'] = $accepter['percent'];
                                 }
                             }
                         }
         
                         $processIndex = $user['processindex'];
         
                         if (!$isExceed && $user['stepid'] == $tudu->stepId) {
                             $isExceed = true;
                         }
         
                         if ($isExceed && ($user['stepid'] != $tudu->stepId || ($user['type'] == 1 && $user['status'] < 1))) {
                             $user['future'] = true;
                         }
         
                         $steps[$user['ordernum']]['users'][]    = $user;
                         $steps[$user['ordernum']]['stepid']     = $user['stepid'];
                         $steps[$user['ordernum']]['type']       = $user['type'];
                         $steps[$user['ordernum']]['stepstatus'] = $user['stepstatus'];
                         $steps[$user['ordernum']]['future']     = !empty($user['future']);
         
                         if ($user['type'] == Dao_Td_Tudu_Step::TYPE_EXAMINE && $user['status'] > 2) {
                             if (!$tudu->flowId) {
                                 $access['progress'] = false;
                             }
                             $access['divide']   = false;
                             $isDisagreed = true;
                         }
         
                         if ($tudu->flowId && $user['stepid'] == $tudu->stepId) {
                             if (null === $currentIndex && $user['status'] < 2) {
                                 $currentIndex = $user['processindex'];
                             }
                             if ($currentIndex == $user['processindex']) {
                                 $currentUser[] = $user['userinfo'];
                             }
         
                             if ($user['type'] == Dao_Td_Tudu_Step::TYPE_EXAMINE) {
                                 $steptype = 1;
                             } else {
                                 $steptype = 0;
                             }
                             $this->view->steptype = $steptype;
                         }
                     }
                     // 判断是否同时审批
                     $index = null;
                     foreach ($users as $item) {
         
                         if ($item['type'] == Dao_Td_Tudu_Step::TYPE_EXAMINE && $item['stepid'] == $tudu->stepId) {
                             if ($index == $item['processindex']) {
                                 $sameReview = true;
                             }
                             $index = $item['processindex'];
                         }
                     }
         
                     if ($sameReview) {
                         foreach ($users as $item) {
                             if ($tudu->flowId && $item['stepid'] == $tudu->stepId) {
                                 $currentUser[] = $item['userinfo'];
                             }
                         }
                     }
         
                     ksort($steps);
         
                     if (!empty($currentUser)) {
                         $tudu->to = Dao_Td_Tudu_Tudu::formatAddress(implode("\n", array_unique($currentUser)));
                     }
         
                     if ($isDisagreed && count($steps)) {
                         if ($tudu->flowId) {
                             $access['accept'] = false;
                             if (strpos($tudu->stepId, '^') === 0) {
                                 $access['reject'] = false;
                             }
                         } else {
                             $lastStep = end($steps);
         
                             if ($lastStep['type'] == 0) {
                                 $arrTo = array();
                                 foreach ($lastStep['users'] as $u) {
                                     $arrTo[$u['email']] = array($u['truename'], null, null, $u['email']);
                                 }
         
                                 $tudu->to = $arrTo;
         
                                 if (!isset($arrTo[$this->_user->userName])) {
                                     $access['accept'] = false;
                                     $access['reject'] = false;
                                 }
                             }
         
                             reset($steps);
                         }
                     }
         
                     if ($sameReview) {
                         $this->view->samereview = $sameReview;
                     }
         
                     if (count($steps) > 1 || $isViewFlow) {
                         $this->view->steps = $steps;
                     }*/
     }
     if ($tudu->type == 'task' && $isSynchro && !$isLastExecute && !$tudu->flowId) {
         $access['forward'] = false;
         $access['divide'] = false;
     }
     $cookies = $this->_request->getCookie();
     $this->view->tudu = $tudu->toArray();
     $this->view->posts = $posts;
     $this->view->pageinfo = array('currpage' => $page, 'pagecount' => $pageCount, 'pagesize' => $pageSize, 'recordcount' => $recordCount, 'query' => $query, 'url' => '/tudu/view');
     $this->view->last = $isLast;
     $this->view->cookies = serialize($cookies);
     $this->view->votes = $votes;
     $this->view->query = $query;
     $this->view->labels = $labels;
     $this->view->board = $board;
     $this->view->boardnav = $this->getBoardNav($tudu->boardId);
     $this->view->access = $access;
     $this->view->imstatus = $imStatus;
     $this->view->isinvert = $isInvert;
     $this->view->unreply = $unSendPost;
     $this->view->moreaccepter = (bool) (count($tudu->accepter) > 1);
     $this->view->newwin = $newwin;
     $this->view->registFunction('format_label', array($this, 'formatLabels'));
     $this->render('view_' . $tudu->type);
 }
Example #5
0
 /**
  * 获取用户im在线状态
  */
 public function imStatusAction()
 {
     $email = $this->_request->getQuery('email');
     $config = $this->bootstrap->getOption('im');
     $im = new Oray_Im_Client($config['host'], $config['port']);
     $imStatus = $im->getUserStatus($email);
     $this->json(true, null, $imStatus[$email]['show'] ? $imStatus[$email]['show'] : null);
 }
Example #6
0
 /**
  * 显示图度内容
  */
 public function viewAction()
 {
     $tuduId = $this->_request->getQuery('tid');
     $newwin = (bool) $this->_request->getQuery('newwin');
     if (null === $tuduId) {
     }
     $daoTudu = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Tudu', Tudu_Dao_Manager::DB_TS);
     $daoApply = Tudu_Dao_Manager::getDao('Dao_App_Attend_Apply', Tudu_Dao_Manager::DB_APP);
     $tudu = $daoTudu->getTuduById($this->_user->uniqueId, $tuduId);
     if (null === $tudu) {
         return Oray_Function('');
     }
     if ($newwin) {
         $daoOrg = Tudu_Dao_Manager::getDao('Dao_Md_Org_Org', Tudu_Dao_Manager::DB_MD);
         $org = $daoOrg->getOrg(array('orgid' => $this->_user->orgId));
         $this->view->org = $org->toArray();
     }
     $apply = $daoApply->getApply(array('tuduid' => $tuduId));
     if (null === $apply) {
         Oray_Function::alert('考勤申请不存在或已被删除');
     }
     $isSender = $this->_user->uniqueId == $apply->senderId;
     $isTarget = $this->_user->uniqueId == $apply->uniqueId;
     $access = array('view' => $tudu->uniqueId == $this->_user->uniqueId && !empty($tudu->labels), 'reply' => $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_CREATE_POST), 'modify' => $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_UPDATE_TUDU) && $isSender, 'delete' => false, 'upload' => $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_UPLOAD_ATTACH), 'cancel' => ($isSender || $isTarget) && !$tudu->isDone, 'confirm' => $isSender && !$tudu->isDone, 'undone' => $isSender && $tudu->isDone, 'ignore' => true, 'target' => $isTarget, 'sender' => $isSender, 'agree' => false, 'disagree' => false);
     if ($tudu->isDone) {
         $access['reply'] = false;
         $access['modify'] = false;
     }
     // 回复内容
     $page = (int) $this->_request->getQuery('page');
     $pageSize = max(20, (int) $this->_user->option['replysize']);
     $uniqueId = $this->_request->getQuery('unid');
     $back = $this->_request->getQuery('back');
     $recordCount = $tudu->replyNum + 1;
     $labels = $this->_this->getLabels();
     $isInvert = (bool) $this->_request->getQuery('invert', isset($this->_user->option['postsort']) && $this->_user->option['postsort'] == 1);
     $query = array('tid' => $tudu->tuduId, 'back' => $back, 'invert' => $isInvert ? 1 : 0);
     $condition = array('tuduid' => $tudu->tuduId);
     // 已关联用户,设置已读状态
     if ($tudu->uniqueId == $this->_user->uniqueId) {
         if (!$tudu->isRead) {
             $daoTudu->markRead($tuduId, $this->_user->uniqueId);
         }
         // 增加到关联用户,解决版块中的已读未读状态问题(!!会导致重新发送的不会投递到用户图度箱)
     } else {
         $daoTudu->addUser($tuduId, $this->_user->uniqueId, array('isread' => true));
     }
     // 增加浏览次数
     $daoTudu->hit($tudu->tuduId);
     /* @var $daoPost Dao_Td_Tudu_Post */
     $daoPost = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Post', Tudu_Dao_Manager::DB_TS);
     if ($uniqueId) {
         $condition['uniqueid'] = $uniqueId;
         $query['unid'] = $uniqueId;
         $recordCount = $daoPost->getPostCount($tudu->tuduId, $uniqueId);
     }
     $pageCount = intval(($recordCount - 1) / $pageSize) + 1;
     $isLast = false;
     if ($page == 'last') {
         $page = $pageCount;
         $isLast = true;
     } else {
         $page = min($pageCount, max(1, (int) $page));
     }
     $postSort = $isInvert ? 'createtime DESC' : 'createtime ASC';
     // 获取回复内容
     $posts = $daoPost->getPostPage($condition, $postSort, $page, $pageSize)->toArray();
     // 回复者的在线状态
     $status = array();
     // 回复的相关权限
     $postAccess = array('modify' => $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_UPDATE_POST), 'delete' => $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_DELETE_POST));
     foreach ($posts as $key => $post) {
         // 读取回复的附件信息
         if ($post['attachnum'] > 0) {
             $files = Tudu_Dao_Manager::getDao('Dao_Td_Attachment_File', Tudu_Dao_Manager::DB_TS)->getFiles(array('tuduid' => $tudu->tuduId, 'postid' => $post['postid']));
             $posts[$key]['attachment'] = $files->toArray();
         }
         // 权限
         if (!$post['isfirst'] && !$tudu->isDone) {
             $posts[$key]['access'] = array('modify' => $postAccess['modify'] && $post['uniqueid'] == $this->_user->uniqueId, 'delete' => $postAccess['delete'] && $post['uniqueid'] == $this->_user->uniqueId);
         }
         if ($post['header']) {
             $posts[$key]['header'] = $this->formatPostHeader($post['header']);
         }
         if ($post['email']) {
             if (!array_key_exists($post['email'], $status)) {
                 $status[$post['email']] = false;
             }
             $posts[$key]['imstatus'] =& $status[$post['email']];
         }
     }
     if ($tudu->stepId && strpos($tudu->stepId, '^') !== 0) {
         /* @var $daoStep Dao_Td_Tudu_Step */
         $daoStep = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Step', Tudu_Dao_Manager::DB_TS);
         $step = $daoStep->getCurrentStep($tuduId, $tudu->stepId, $this->_user->uniqueId);
         if (null !== $step && $step['type'] == Dao_Td_Tudu_Step::TYPE_EXAMINE) {
             $this->view->isreview = true;
         }
         if (null !== $step && $step['type'] == Dao_Td_Tudu_Step::TYPE_EXAMINE) {
             if ($step['uniqueid'] == $this->_user->uniqueId && $step['status'] == 1 && !$tudu->isDone) {
                 $access['agree'] = true;
                 $access['disagree'] = true;
             }
             $access['forward'] = false;
             $access['divide'] = false;
             $access['accept'] = false;
             $access['reject'] = false;
             $access['progress'] = false;
             $access['review'] = false;
         }
     }
     // 获取联系人的IM在线信息
     $config = $this->_this->bootstrap->getOption('im');
     $im = new Oray_Im_Client($config['host'], $config['port']);
     $imStatus = $im->getUserStatus(array_keys($status));
     foreach ($imStatus as $email => $_status) {
         if (isset($status[$email])) {
             $status[$email] = $_status;
         }
     }
     //$daoStep = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Step', Tudu_Dao_Manager::DB_TS);
     $daoFlow = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Flow', Tudu_Dao_Manager::DB_TS);
     $flow = $daoFlow->getFlow(array('tuduid' => $tudu->tuduId));
     if ($flow) {
         $steps = $flow->steps;
         foreach ($steps as $sid => $step) {
             if ($sid == $flow->currentStepId) {
                 $section = $step['section'][$step['currentSection']];
                 if (count($section) > 1) {
                     $this->view->samereview = true;
                 }
                 foreach ($section as $u) {
                     if ($u['uniqueid'] == $this->_user->uniqueId && $u['status'] == 1) {
                         $access['agree'] = $access['disagree'] = true;
                     }
                 }
             }
         }
         $this->view->steps = $steps;
     }
     /*
             $users   = $daoStep->getTuduStepUsers($tudu->tuduId);
             $accepters = $daoTudu->getAccepters($tuduId);
     
             $isDisagreed = false;
             $steps = array();
             $isExceed = false;
             $processIndex = null;
             $sameReview = false;
             $currentUser = array();
             $currentIndex = null;
             foreach ($users as &$user) {
                 $info = explode(' ', $user['userinfo']);
                 $user['email']    = $info[0];
                 $user['truename'] = $info[1];
     
                 if ($user['type'] == Dao_Td_Tudu_Step::TYPE_EXECUTE && $user['stepid'] == $tudu->stepId && !empty($accepters)) {
                     foreach ($accepters as $accepter) {
                         if ($accepter['uniqueid'] == $user['uniqueid']) {
                             $user['percent'] = $accepter['percent'];
                         }
                     }
                 }
     
                 $processIndex = $user['processindex'];
     
                 if (!$isExceed && $user['stepid'] == $tudu->stepId) {
                     $isExceed = true;
                 }
     
                 if ($isExceed && ($user['stepid'] != $tudu->stepId || ($user['type'] == 1 && $user['status'] < 1))) {
                     $user['future'] = true;
                 }
     
                 $steps[$user['ordernum']]['users'][]    = $user;
                 $steps[$user['ordernum']]['stepid']     = $user['stepid'];
                 $steps[$user['ordernum']]['type']       = $user['type'];
                 $steps[$user['ordernum']]['stepstatus'] = $user['stepstatus'];
                 $steps[$user['ordernum']]['future']     = !empty($user['future']);
     
                 if ($user['type'] == Dao_Td_Tudu_Step::TYPE_EXAMINE && $user['status'] > 2) {
                     $isDisagreed = true;
                 }
     
                 if ($tudu->flowId && $user['stepid'] == $tudu->stepId) {
                     if (null === $currentIndex && $user['status'] < 2) {
                         $currentIndex = $user['processindex'];
                     }
                     if ($currentIndex == $user['processindex']) {
                         $currentUser[] = $user['userinfo'];
                     }
     
                     if ($user['type'] == Dao_Td_Tudu_Step::TYPE_EXAMINE) {
                         $steptype = 1;
                     } else {
                         $steptype = 0;
                     }
                     $this->view->steptype = $steptype;
                 }
             }
             // 判断是否同时审批
             $index = null;
             foreach ($users as $item) {
     
                 if ($item['type'] == Dao_Td_Tudu_Step::TYPE_EXAMINE && $item['stepid'] == $tudu->stepId) {
                     if ($index == $item['processindex']) {
                         $sameReview = true;
                     }
                     $index = $item['processindex'];
                 }
             }
     
             if ($sameReview) {
                 foreach ($users as $item) {
                     if ($tudu->flowId && $item['stepid'] == $tudu->stepId) {
                         $currentUser[] = $item['userinfo'];
                     }
                 }
             }
     
             ksort($steps);
     
             if (!empty($currentUser)) {
                 $tudu->to = Dao_Td_Tudu_Tudu::formatAddress(implode("\n", array_unique($currentUser)));
             }
     
             if ($isDisagreed && count($steps)) {
                 if ($tudu->flowId) {
                     $access['accept'] = false;
                     if (strpos($tudu->stepId, '^') === 0) {
                         $access['reject'] = false;
                     }
                 } else {
                     $lastStep = end($steps);
     
                     if ($lastStep['type'] == 0) {
                         $arrTo = array();
                         foreach ($lastStep['users'] as $u) {
                             $arrTo[$u['email']] = array($u['truename'], null, null, $u['email']);
                         }
     
                         $tudu->to = $arrTo;
     
                         if (!isset($arrTo[$this->_user->userName])) {
                             $access['accept'] = false;
                             $access['reject'] = false;
                         }
                     }
     
                     reset($steps);
                 }
             }
     
             if ($sameReview) {
                 $this->view->samereview = $sameReview;
             }
     
             if (count($steps) > 0) {
                 $this->view->steps = $steps;
             }*/
     if ($access['upload']) {
         $upload = $this->_this->options['upload'];
         $upload['cgi']['upload'] .= '?' . session_name() . '=' . Zend_Session::getId() . '&email=' . $this->_user->address;
         $this->view->upload = $upload;
     }
     $this->view->registModifier('tudu_format_content', array($this, 'formatContent'));
     $this->view->registModifier('tudu_get_attachment_url', array($this, 'getAttachmentUrl'));
     $this->view->registFunction('format_label', array($this, 'formatLabels'));
     $this->view->access = $access;
     $this->view->tudu = $tudu->toArray();
     $this->view->apply = $apply->toArray();
     $this->view->posts = $posts;
     $this->view->pageinfo = array('currpage' => $page, 'pagecount' => $pageCount, 'pagesize' => $pageSize, 'recordcount' => $recordCount, 'query' => $query, 'url' => '/tudu/view');
     $this->view->cookies = serialize($this->_request->getCookie());
     $this->view->query = $query;
     $this->view->labels = $labels;
     $this->view->newwin = $newwin;
     $this->view->imstatus = $imStatus;
     $this->view->isinvert = $isInvert;
 }
Example #7
0
 public function getStatusAction()
 {
     //yezi@oray.com|yuyingbin@oray.com|lvrongheng@oray.com|luojiexia@oray.com|zhangcan@oray.com
     $email = $this->_request->getQuery('email', '');
     // 获取联系人的IM在线信息
     $config = $this->bootstrap->getOption('im');
     $im = new Oray_Im_Client($config['host'], $config['port']);
     $imStatus = $im->getUserStatus(explode(',', $email));
     var_dump($imStatus);
     echo "<pre>";
     echo $im->getRequest();
     echo "\n";
     echo htmlspecialchars($im->getResult());
 }