Example #1
0
 /**
  * 执行
  */
 public function run()
 {
     do {
         $data = $this->_httpsqs->get($this->_options['httpsqs']['names']['send']);
         if (!$data || $data == 'HTTPSQS_GET_END') {
             break;
         }
         list($module, $action, $sub, $query) = explode(' ', $data);
         if ($module != 'send') {
             $this->getLogger()->warn("Invalid param \"module\" values {$module}");
         }
         parse_str($query, $query);
         if (empty($query['tsid'])) {
             $this->getLogger()->warn("Missing param \"tsid\"");
             continue;
         }
         if (!isset($this->_tsDbs['ts' . $query['tsid']])) {
             return;
         }
         $tsId = $query['tsid'];
         Tudu_Dao_Manager::setDb(Tudu_Dao_Manager::DB_TS, $this->_tsDbs['ts' . $tsId]);
         switch ($action) {
             case 'tudu':
                 $this->sendTudu($query);
                 break;
             case 'reply':
                 $this->sendReply($query);
                 break;
             case 'meeting':
                 $this->sendMeeting($query);
                 break;
             case 'email':
                 $this->sendEmail($query);
                 break;
             default:
                 break;
         }
     } while (true);
 }
Example #2
0
 /**
  * 执行
  */
 public function run()
 {
     do {
         $data = $this->_httpsqs->get($this->_options['httpsqs']['names']['admin']);
         if (!$data || $data == 'HTTPSQS_GET_END') {
             break;
         }
         list($module, $action, $sub, $query) = explode(' ', $data);
         if ($module != 'user') {
             $this->getLogger()->warn("Invalid param \"module\" values {$module}");
         }
         switch ($action) {
             case 'create':
                 $this->createUser($query);
                 break;
             case 'delete':
                 $this->deleteUser($query);
                 break;
             default:
                 $this->getLogger()->info("Invalid action values {$action}");
                 break;
         }
     } while (true);
 }
Example #3
0
 /**
  * 用户模块
  *
  * @param string $action
  * @param string $query
  */
 public function onUser($action, $query)
 {
     list($orgId) = explode(':', $query);
     switch ($action) {
         case 'delete':
         case 'update':
         case 'create':
             $this->_refreshCastCache($orgId);
             $this->_im->updateNotify(Oray_Im_Client::NOTIFY_UPDATE_DEPT, $orgId);
             if ($action == 'delete') {
                 $data = implode(' ', array(self::USER_MODULE, $action, null, $query));
                 $this->_httpsqs->put($data, $this->_options['httpsqs']['names']['admin']);
                 $this->_httpsqs->put(implode(' ', array('contact', '', null, http_build_queue(array('orgid' => $orgId)))), $this->_options['httpsqs']['names']['notify']);
             }
             break;
         default:
             break;
     }
 }
Example #4
0
    /**
     * 发送审批回复提醒
     */
    public function sendReviewPostNotify($tudu, $agree, $from, $server, $notifyTo)
    {
        if (!$tudu) {
            return;
        }
        $content = $agree ? '已经同意本次申请。' : '不同意本次申请;<br />请申请者修改后再重新提交审批。';
        $subject = htmlspecialchars(htmlspecialchars($tudu->subject));
        $sendtime = date('Y-m-d H:i:s', $tudu->createTime);
        $tpl = <<<HTML
<strong>您刚收到一个新的回复</strong><br />
<a href="http://{$server}/frame#m=view&tid={$tudu->tuduId}&page=1" target="_blank" _tid="{$tudu->tuduId}">{$subject}</a><br />
发起人:{$tudu->from[0]}<br />
发送日期:{$sendtime}<br />
{$content}
HTML;
        // 发送talk提醒
        $count = @count($notifyTo);
        if ($count >= 20) {
            $to = array();
            $counter = 0;
            do {
                $arr[] = array_shift($notifyTo);
                $counter++;
                if ($counter >= 20 || count($notifyTo) == 0) {
                    $to[] = $arr;
                    $arr = array();
                    $counter = 0;
                }
            } while (count($notifyTo) > 0);
        } else {
            $to = array($notifyTo);
        }
        foreach ($to as $item) {
            // 发送talk提醒
            $data = implode(' ', array('tudu', 'reply', '', http_build_query(array('tuduid' => $tudu->tuduId, 'from' => $from, 'to' => implode(',', $item), 'content' => $tpl))));
            $this->_httpsqs->put($data, $this->_options['httpsqs']['names']['im']);
        }
    }
Example #5
0
 /**
  * 删除板块
  */
 public function deleteAction()
 {
     $boardId = $this->_request->getPost('bid');
     $daoBoard = $this->getDao('Dao_Td_Board_Board');
     /* @var $daoTudu Dao_Td_Tudu_Tudu */
     $daoTudu = $this->getDao('Dao_Td_Tudu_Tudu');
     if (empty($boardId)) {
         return $this->json(false, $this->lang['board_not_exists']);
     }
     $boards = $this->getBoards(false);
     if (!isset($boards[$boardId])) {
         return $this->json(false, $this->lang['board_not_exists']);
     }
     if (strpos($boardId, '^') === 0) {
         return $this->json(false, $this->lang['delete_sys_board']);
     }
     if ($daoTudu->countTudu(array('boardid' => $boardId, 'isdraft' => 0))) {
         return $this->json(false, $this->lang['delete_not_null_board']);
     }
     $board = $boards[$boardId];
     // 继承上级分区权限
     if (!empty($board['parentid']) && array_key_exists($this->_user->userId, $boards[$board['parentid']]['moderators'])) {
         $isSuperModerator = true;
     } else {
         $isSuperModerator = false;
     }
     $isOwner = $this->_user->userId == $board['ownerid'];
     $isModerator = array_key_exists($this->_user->userId, $board['moderators']);
     if (!$this->_user->getAccess()->isAllowed(Tudu_Access::PERM_DELETE_BOARD) || !$isSuperModerator) {
         return $this->json(false, $this->lang['perm_deny_delete']);
     }
     $ret = $daoBoard->deleteBoard($this->_user->orgId, $boardId);
     if (!$ret) {
         return $this->json(false, $this->lang['board_delete_failure']);
     }
     $daoBoard->tidySort($this->_user->orgId, $boards[$boardId]['type'], $boards[$boardId]['parentid']);
     // 插入消息队列
     $options = $this->_bootstrap->getOption('httpsqs');
     $httpsqs = new Oray_Httpsqs($options['host'], $options['port'], $options['charset'], $options['name']);
     $data = implode(' ', array('board', 'delete', null, http_build_query()));
     $httpsqs->put($data, 'notify');
     $this->_writeLog(Dao_Td_Log_Log::TYPE_BOARD, $boardId, Dao_Td_Log_Log::ACTION_DELETE);
     return $this->json(true, $this->lang['board_delete_success']);
 }
Example #6
0
 /**
  * 确认图度
  *
  * 必传参数:
  * tuduid|uniqueid|username|orgid|userinfo|tsid
  * isdone不传值为false
  * score不传值为0
  */
 public function done(array $params)
 {
     if (empty($params['tuduid'])) {
         require_once 'Model/Tudu/Exception.php';
         throw new Model_Tudu_Exception('Missing or invalid value of parameter "tuduid"', self::CODE_INVALID_TUDUID);
     }
     $uniqueId = $this->_user->uniqueId;
     $userName = $this->_user->userName;
     $tuduIds = !is_array($params['tuduid']) ? (array) $params['tuduid'] : $params['tuduid'];
     $isDone = !empty($params['isdone']) ? true : false;
     $score = !empty($params['score']) ? (int) $params['score'] : 0;
     $manager = $this->getManager();
     $success = 0;
     //用于计数操作成功个数
     foreach ($tuduIds as $tuduId) {
         $tudu = $manager->getTuduById($tuduId, $uniqueId);
         // 图度必须存在
         if (null == $tudu) {
             continue;
         }
         // 图度不能是已确定状态
         if ($tudu->isDone && $isDone) {
             continue;
         }
         // 操作人必须为图度发起人
         if ($tudu->sender != $userName) {
             continue;
         }
         // 图度不能是“未开始”,“进行中”等状态
         if (($tudu->type != 'task' || $tudu->status < 2) && $isDone) {
             continue;
         }
         if (!$isDone) {
             $score = 0;
         }
         // 执行确认/取消确认图度操作
         $ret = $manager->doneTudu($tuduId, $isDone, $score, false, $tudu->parentId != null, $tudu->type);
         if ($ret) {
             $success++;
             // 添加操作日志
             $this->_writeLog(Dao_Td_Log_Log::TYPE_TUDU, $tuduId, $isDone ? Dao_Td_Log_Log::ACTION_TUDU_DONE : Dao_Td_Log_Log::ACTION_TUDU_UNDONE, array('orgid' => $this->_user->orgId, 'uniqueid' => $uniqueId, 'userinfo' => $this->_user->userInfo), array('isdone' => $isDone, 'score' => $score));
             // 发送通知,插入消息队列
             if (Tudu_Model::hasResource(Tudu_Model::RESOURCE_CONFIG)) {
                 $config = Tudu_Model::getResource(Tudu_Model::RESOURCE_CONFIG);
                 if ($config['httpsqs']) {
                     $options = $config['httpsqs'];
                     $httpsqs = new Oray_Httpsqs($options['host'], $options['port'], $options['charset'], $options['name']);
                     $data = implode(' ', array('send', 'tudu', '', http_build_query(array('tsid' => $this->_user->tsId, 'tuduid' => $tuduId, 'uniqueid' => $uniqueId, 'to' => '', 'act' => 'confirm'))));
                     $httpsqs->put($data, 'send');
                 }
             }
         }
     }
     if ($success <= 0) {
         require_once 'Model/Tudu/Exception.php';
         throw new Model_Tudu_Exception('Append to inbox failed', self::CODE_SAVE_FAILED);
     }
 }
Example #7
0
 /**
  *
  */
 public function initpwdUpdateAction()
 {
     $this->lang = Tudu_Lang::getInstance()->load(array('common', 'setting'));
     $pwd = $this->_request->getPost('password');
     $repwd = $this->_request->getPost('repassword');
     if ($pwd != $repwd) {
         return $this->json(false, $this->lang['confirm_password_unmatch']);
     }
     // 安全级别匹配
     $regs = array(1 => '/[0-9a-zA-Z]/', 2 => '/[0-9a-zA-Z^a-zA-Z0-9]/');
     $pwdLevel = isset($this->_user->option['passwordlevel']) ? $this->_user->option['passwordlevel'] : 0;
     if ($pwdLevel > 0 && !preg_match($regs[$pwdLevel], $pwd)) {
         return $this->json(false, $this->lang['password_level_not_match_' . $pwdLevel]);
     }
     $daoUser = Oray_Dao::factory('Dao_Md_User_User', $this->multidb->getDb());
     $params = array('password' => $pwd);
     $ret = $daoUser->updateUserInfo($this->_user->orgId, $this->_user->userId, $params);
     $ret = $daoUser->updateUser($this->_user->orgId, $this->_user->userId, array('initpassword' => 0));
     $this->_user->clearCache($this->_user->userName);
     if (!$ret) {
         return $this->json(false, $this->lang['password_update_failure']);
     }
     // 消息队列
     $config = $this->bootstrap->getOption('httpsqs');
     $httpsqs = new Oray_Httpsqs($config['host'], $config['port'], $config['chartset'], $config['name']);
     $httpsqs->put(implode(' ', array('user', 'create', '', implode(':', array($this->_user->orgId, $this->_user->userName, $this->_user->uniqueId, $this->_user->trueName)))), 'admin');
     return $this->json(true, $this->lang['password_update_success']);
 }
Example #8
0
 /**
  * 完成 (确认)图度
  */
 public function doneAction()
 {
     $tuduIds = explode(',', $this->_request->getParam('tid'));
     $isDone = (bool) $this->_request->getParam('isdone');
     $score = (int) $this->_request->getParam('score');
     // 参数:图度ID必须存在
     if (!count($tuduIds)) {
         return $this->json(false, $this->lang['invalid_tuduid']);
     }
     $success = 0;
     //用于计数操作成功个数
     foreach ($tuduIds as $tuduId) {
         // 获得图度数据
         $tudu = $this->manager->getTuduById($tuduId, $this->_user->uniqueId);
         // 图度必须存在
         if (null == $tudu) {
             continue;
         }
         // 图度不能是已确定状态
         if ($tudu->isDone && $isDone) {
             continue;
         }
         // 操作人必须为图度发起人
         if ($tudu->sender != $this->_user->userName) {
             continue;
         }
         // 图度不能是“未开始”,“进行中”等状态
         if (($tudu->type != 'task' || $tudu->status < 2) && $isDone) {
             continue;
         }
         if (!$isDone) {
             $score = 0;
         }
         // 执行确认/取消确认图度操作
         $ret = $this->manager->doneTudu($tuduId, $isDone, $score, false, $tudu->parentId != null, $tudu->type);
         if ($ret) {
             $success++;
             $config = $this->bootstrap->getOption('httpsqs');
             if ($isDone) {
                 // 插入消息队列
                 $httpsqs = new Oray_Httpsqs($config['host'], $config['port'], $config['chartset'], $config['name']);
                 // 发送外部邮件(如果有),处理联系人
                 $data = implode(' ', array('send', 'tudu', '', http_build_query(array('tsid' => $this->_user->tsId, 'tuduid' => $tuduId, 'uniqueid' => $this->_user->uniqueId, 'to' => '', 'act' => 'confirm'))));
                 $httpsqs->put($data, 'send');
             }
             // 添加操作日志
             $this->_writeLog(Dao_Td_Log_Log::TYPE_TUDU, $tuduId, $isDone ? Dao_Td_Log_Log::ACTION_TUDU_DONE : Dao_Td_Log_Log::ACTION_TUDU_UNDONE, array('isdone' => $isDone, 'score' => $score));
         }
     }
     if ($success <= 0) {
         return $this->json(false, $this->lang['state_failure']);
     }
     return $this->json(true, $this->lang['state_success']);
 }
Example #9
0
 /**
  * 创建部门
  */
 public function createDept(array &$params)
 {
     if ($params['deptid'] == '^new') {
         $isImport = !empty($params['import']) ? true : false;
         // 部门名称
         if (!$isImport && empty($params['deptname'])) {
             return $this->json(false, '请输入新部门名称');
         }
         /* @var $daoDepartment Dao_Md_Department_Department */
         $daoDepartment = Tudu_Dao_Manager::getDao('Dao_Md_Department_Department', Tudu_Dao_Manager::DB_MD);
         $departments = $daoDepartment->getDepartments(array('orgid' => $params['orgid']))->toArray('deptid');
         $parentId = '^root';
         $deptPath = array();
         if (!empty($params['deptparentid'])) {
             $parentId = $params['deptparentid'];
             // 父级部门不存在
             if (!isset($departments[$parentId])) {
                 if ($isImport) {
                     $params['exist-parentid'] = true;
                     return;
                 } else {
                     return $this->json(false, '新建部门的父级部门不存在或已被删除');
                 }
             }
             $deptPath = array_merge($departments[$parentId]['path'], array($parentId));
         }
         $deptId = Dao_Md_Department_Department::getDeptId();
         $deptId = $daoDepartment->createDepartment(array('orgid' => $params['orgid'], 'deptname' => $params['deptname'], 'deptid' => $deptId, 'parentid' => $parentId, 'ordernum' => $daoDepartment->getMaxOrderNum($params['orgid'], $parentId) + 1));
         if (!$deptId) {
             if ($isImport) {
                 return;
             } else {
                 return $this->json(false, '所属部门创建失败');
             }
         }
         $this->_createLog(Dao_Md_Log_Oplog::MODULE_DEPT, Dao_Md_Log_Oplog::OPERATION_CREATE, null, implode(':', array($params['orgid'], $deptId)), array('deptname' => $params['deptname']));
         // 插入消息队列
         $options = $this->_bootstrap->getOption('httpsqs');
         $httpsqs = new Oray_Httpsqs($options['host'], $options['port'], $options['charset'], $options['name']);
         $data = implode(' ', array(Dao_Md_Log_Oplog::MODULE_DEPT, Dao_Md_Log_Oplog::OPERATION_CREATE, null, implode(':', array($params['orgid'], $deptId))));
         $httpsqs->put($data);
         $params['deptid'] = $deptId;
         unset($params['deptname']);
         unset($params['deptparentid']);
     }
 }
Example #10
0
 /**
  * 保存联系人
  */
 public function saveAction()
 {
     $post = $this->_request->getPost();
     $groupIds = (array) $this->_request->getParam('group');
     // 当前用户唯一ID
     $uniqueId = $this->_user->uniqueId;
     $daoContact = $this->getDao('Dao_Td_Contact_Contact');
     $daoGroup = $this->getDao('Dao_Td_Contact_Group');
     $contactId = $post['contactid'] ? $post['contactid'] : Dao_Td_Contact_Contact::getContactId();
     $contacts = $daoContact->getContactById($contactId, $uniqueId);
     $trueName = trim($post['truename']);
     if (empty($trueName)) {
         return $this->json(false, $this->lang['missing_name']);
     }
     $email = $this->_request->getPost('email');
     if (!empty($email) && false === strpos($email, '@')) {
         return $this->json(false, $this->lang['email_error']);
     }
     $params = array('contactid' => $contactId, 'uniqueid' => $uniqueId, 'truename' => $trueName, 'pinyin' => Tudu_Pinyin::parse($post['truename'], true), 'email' => $email, 'mobile' => trim($post['mobile']), 'lastupdatetime' => time());
     if (isset($post['corporation'])) {
         $params['properties']['corporation'] = $post['corporation'];
     }
     if (isset($post['position'])) {
         $params['properties']['position'] = $post['position'];
     }
     if (isset($post['tel'])) {
         $params['properties']['tel'] = $post['tel'];
     }
     if (isset($post['fax'])) {
         $params['properties']['fax'] = $post['fax'];
     }
     if (!empty($post['bir-year']) && !empty($post['bir-month']) && !empty($post['bir-day'])) {
         $birthday = $post['bir-year'] . '-' . $post['bir-month'] . '-' . $post['bir-day'];
         $params['properties']['birthday'] = strtotime($birthday);
     }
     if (isset($post['im'])) {
         $params['properties']['im'] = $post['im'];
     }
     if (isset($post['mailbox'])) {
         $params['properties']['mailbox'] = $post['mailbox'];
     }
     if (isset($post['address'])) {
         $params['properties']['address'] = $post['address'];
     }
     if (isset($post['memo'])) {
         $params['memo'] = $post['memo'];
     }
     if (!empty($post['avatars'])) {
         // 头像
         $options = $this->getInvokeArg('bootstrap')->getOption('avatar');
         $fileName = $options['tempdir'] . '/' . $post['avatars'];
         if (file_exists($fileName)) {
             $imginfo = getimagesize($fileName);
             $params['avatarstype'] = $imginfo['mime'];
             $params['avatars'] = base64_encode(file_get_contents($fileName));
         }
         unlink($fileName);
     }
     if (!empty($post['contactid'])) {
         // 修改个人通讯录联系人时,用户判断
         if ($contacts->uniqueId != $uniqueId) {
             return $this->json(false, $this->lang['invalid']);
         }
         if (!$daoContact->updateContact($contactId, $uniqueId, $params)) {
             return $this->json(false, $this->lang['save_fail']);
         }
         $oldGroupIds = $contacts->groups;
         if ($oldGroupIds) {
             $add = array_diff($groupIds, $oldGroupIds);
             // 计算出要插入的联系组
             $remove = array_diff($oldGroupIds, $groupIds);
             // 计算出要删除的联系组
             if ($add) {
                 foreach ($add as $groupId) {
                     $daoGroup->addMember($groupId, $uniqueId, $contactId);
                 }
             }
             if ($remove) {
                 foreach ($remove as $groupId) {
                     $daoGroup->removeMember($groupId, $uniqueId, $contactId);
                 }
             }
         } else {
             foreach ($groupIds as $groupId) {
                 $daoGroup->addMember($groupId, $uniqueId, $contactId);
             }
         }
         $config = $this->bootstrap->getOption('httpsqs');
         $httpsqs = new Oray_Httpsqs($config['host'], $config['port'], $config['chartset'], $config['name']);
         $httpsqs->put(implode(' ', array('contact', '', '', http_build_query(array('username' => $this->_user->userName)))), 'notify');
         return $this->json(true, $this->lang['save_success'], array('contactid' => $contactId));
     }
     if (!$daoContact->createContact($params)) {
         return $this->json(false, $this->lang['save_fail']);
     } else {
         foreach ($groupIds as $groupId) {
             $daoGroup->addMember($groupId, $uniqueId, $contactId);
         }
         //return $this->json(true, $this->lang['save_success'], array('contactid' => $contactId));
     }
     $this->cache->deleteCache(array($daoContact, 'getContactsByUniqueId'), array($this->_user->uniqueId));
     $config = $this->bootstrap->getOption('httpsqs');
     $httpsqs = new Oray_Httpsqs($config['host'], $config['port'], $config['chartset'], $config['name']);
     $httpsqs->put(implode(' ', array('contact', '', '', http_build_query(array('username' => $this->_user->userName)))), 'notify');
     return $this->json(true, $this->lang['save_success']);
 }
Example #11
0
 public function httpsqsAction()
 {
     $config = $this->bootstrap->getOption('httpsqs');
     $httpsqs = new Oray_Httpsqs($config['host'], $config['port'], $config['chartset'], $config['name']);
     do {
         $data = $httpsqs->get();
         echo $data . "\n";
     } while ('HTTPSQS_GET_END' != $data);
     $httpsqs->closeConnection();
     echo "end";
 }
Example #12
0
 /**
  * 删除用户
  */
 public function delete(array $params)
 {
     // 组织ID必须有
     if (empty($params['orgid'])) {
         require_once 'Model/User/Exception.php';
         throw new Model_User_Exception('Missing or invalid value of parameter "orgid"', self::CODE_INVALID_ORGID);
     }
     $orgId = $params['orgid'];
     /* @var $daoUser Dao_Md_User_User */
     $daoUser = Tudu_Dao_Manager::getDao('Dao_Md_User_User', Tudu_Dao_Manager::DB_MD);
     // 用户名
     if (empty($params['userid'])) {
         require_once 'Model/User/Exception.php';
         throw new Model_User_Exception('Missing the value of parameter "userid"', self::CODE_MISSING_UID);
     }
     $userIds = is_array($params['userid']) ? $params['userid'] : (array) $params['userid'];
     $ret = true;
     $uniqueIds = array();
     foreach ($userIds as $userId) {
         $cuser = $daoUser->getUser(array('orgid' => $orgId, 'userid' => $userId));
         $infouser = $daoUser->getUserInfo(array('orgid' => $orgId, 'userid' => $userId));
         // 用户已不存在
         if (null == $cuser) {
             continue;
         }
         // 是否超级管理员
         if ($daoUser->isAdmin($orgId, $userId)) {
             require_once 'Model/User/Exception.php';
             throw new Model_User_Exception('Can not delete super administrator "' . $userId . '@' . $orgId . '"', self::CODE_DELETE_SUPER_ADMIN);
         }
         if (!$daoUser->deleteUser($orgId, $userId)) {
             $ret = false;
             continue;
         }
         $uniqueIds[] = $cuser->uniqueId;
         // 添加操作日志
         if (!empty($params['operator']) && !empty($params['clientip'])) {
             $params['local'] = empty($params['local']) ? null : $params['local'];
             $this->_createLog(Dao_Md_Log_Oplog::MODULE_USER, Dao_Md_Log_Oplog::OPERATION_DELETE, null, array('orgid' => $orgId, 'operator' => $params['operator'], 'clientip' => $params['clientip'], 'local' => $params['local']), implode(':', array($cuser->orgId, $cuser->userName, $cuser->uniqueId)), array('truename' => $infouser->trueName, 'account' => $cuser->userName));
         }
     }
     if (!$ret) {
         require_once 'Model/User/Exception.php';
         throw new Model_User_Exception('Delete user failed', self::CODE_SAVE_FAILED);
     }
     // 发送通知,插入消息队列
     if (Tudu_Model::hasResource(Tudu_Model::RESOURCE_CONFIG)) {
         $config = Tudu_Model::getResource(Tudu_Model::RESOURCE_CONFIG);
         if ($config['httpsqs']) {
             $options = $config['httpsqs'];
             $httpsqs = new Oray_Httpsqs($options['host'], $options['port'], $options['charset'], $options['name']);
             $data = implode(' ', array(Dao_Md_Log_Oplog::MODULE_DEPT, Dao_Md_Log_Oplog::OPERATION_DELETE, null, implode(':', array($orgId, implode(',', $uniqueIds)))));
             $httpsqs->put($data);
         }
     }
 }
Example #13
0
 /**
  * 部门成员
  *
  * @param string $orgId
  * @param string $deptId
  * @param array  $member
  * @param array  $params
  */
 public function updateMember($orgId, $deptId, array $member, array $params)
 {
     /* @var $daoDept Dao_Md_Department_Department */
     $daoDept = Tudu_Dao_Manager::getDao('Dao_Md_Department_Department', Tudu_Dao_Manager::DB_MD);
     if (empty($deptId)) {
         require_once 'Model/Department/Exception.php';
         throw new Model_Department_Exception('Invalid or missing parameter "deptid"', self::CODE_INVALID_DEPTID);
     }
     if (empty($orgId)) {
         require_once 'Model/Department/Exception.php';
         throw new Model_Department_Exception('Invalid or missing params "orgid"', self::CODE_INVALID_ORGID);
     }
     $department = $daoDept->getDepartment(array('orgid' => $orgId, 'deptid' => $deptId));
     if (!$department) {
         require_once 'Model/Department/Exception.php';
         throw new Model_Department_Exception('Parent department not exists', self::CODE_DEPARTMENT_NOTEXISTS);
     }
     $ret = $daoDept->removeUser($orgId, $deptId);
     if (!$ret) {
         require_once 'Model/Department/Exception.php';
         throw new Model_Department_Exception('Update department failed', self::CODE_SAVE_FAILED);
     }
     if (!empty($member)) {
         $ret = $daoDept->addUser($orgId, $deptId, $member);
         if (!$ret) {
             require_once 'Model/Department/Exception.php';
             throw new Model_Department_Exception('Update department failed', self::CODE_SAVE_FAILED);
         }
         /* @var $daoCast Dao_Md_User_Cast */
         $daoCast = Tudu_Dao_Manager::getDao('Dao_Md_User_Cast', Tudu_Dao_Manager::DB_MD);
         foreach ($member as $userId) {
             $daoCast->updateCastDept($orgId, $userId, $deptId);
         }
     }
     // 添加后台操作日志
     if (!empty($params['operator']) && !empty($params['clientip'])) {
         $params['local'] = empty($params['local']) ? null : $params['local'];
         $this->_createLog(Dao_Md_Log_Oplog::MODULE_DEPT, Dao_Md_Log_Oplog::OPERATION_UPDATE, 'user', array('orgid' => $orgId, 'operator' => $params['operator'], 'clientip' => $params['clientip'], 'local' => $params['local']), implode(':', array($orgId, $deptId)), array('deptname' => $department->deptName));
     }
     // 发送通知
     if (Tudu_Model::hasResource(Tudu_Model::RESOURCE_CONFIG)) {
         $config = Tudu_Model::getResource(Tudu_Model::RESOURCE_CONFIG);
         if ($config['httpsqs']) {
             $options = $config['httpsqs'];
             $httpsqs = new Oray_Httpsqs($options['host'], $options['port'], $options['charset'], $options['name']);
             $data = implode(' ', array(Dao_Md_Log_Oplog::MODULE_USER, Dao_Md_Log_Oplog::OPERATION_UPDATE, null, implode(':', array($orgId, $deptId))));
             $ret = $httpsqs->put($data);
         }
     }
 }
Example #14
0
 /**
  * 发送验证邮件
  *
  */
 public function sendAction()
 {
     $authId = $this->_request->getPost('authid');
     if (empty($authId)) {
         return $this->json(false, '验证信息错误,发送验证邮件失败');
     }
     /* @var $daoEmailAuth Dao_Reg_Email */
     $daoEmailAuth = Tudu_Dao_Manager::getDao('Dao_Reg_Email', Tudu_Dao_Manager::DB_SITE);
     $auth = $daoEmailAuth->getEmailAuth(array('emailauthid' => $authId));
     if (null === $auth || $auth->orgId != $this->_user->orgId || $auth->userId !== $this->_user->userId || $auth->status !== 0 || $auth->expireTime < time()) {
         return $this->json(false, '验证信息错误,发送验证邮件失败');
     }
     if ($auth->retryTimes >= self::MAX_RETRY) {
         return $this->json(false, '验证邮件发送请求已超过上限');
     }
     $config = $this->_options['httpsqs'];
     $httpsqs = new Oray_Httpsqs($config['host'], $config['port'], $config['charset'], $config['name']);
     $key = md5($this->_user->userId . '@' . $this->_user->orgId . $authId . self::EMAIL_AUTH_KEY);
     $bind = array('url' => $this->_options['sites']['www'] . "/email/?k={$key}&i={$authId}");
     $httpsqs->put(implode(' ', array('email', $auth->email, serialize($bind), 0)), 'reg');
     $daoEmailAuth->updateEmailAuth($authId, array('retrytimes' => $auth->retryTimes + 1));
     return $this->json(true, '验证邮件已发送', array('authid' => $authId));
 }
Example #15
0
 /**
  * 连接资源监控
  */
 public function checkConfigAction()
 {
     //
     $message = array();
     $ts = time();
     $count = array('warning' => 0, 'error' => 0);
     $queueName = 'check';
     $memcacheKey = 'TUDU-CHECK-MARK';
     if (defined('WWW_ROOT')) {
         $sites = array('www.tudu.com', 'api.tudu.com', 'admin.tudu.com', 'web.tudu.com');
         // 先写入数据,遍历各站点时读取
         // memcache
         $ret = $this->cache->set($memcacheKey, $ts, null);
         if (!$ret) {
             $message[] = "[ERROR] Memcache prepare failure";
             $count['error']++;
         } else {
             $message[] = "[SUCCESS] Memcache prepare success";
         }
         $this->cache->close();
         // httpsqs
         $cfg = $this->options['httpsqs'];
         $httpsqs = new Oray_Httpsqs($cfg['host'], $cfg['port'], $cfg['chartset'], $queueName);
         $ret = $httpsqs->put($ts, $queueName);
         if (!$ret) {
             $count['error']++;
             $message[] = "[ERROR] Httpsqs prepare failure";
         } else {
             $message[] = "[SUCCESS] Httpsqs prepare success";
         }
         $queueStatus = $httpsqs->status($queueName);
         if ($count['error'] <= 0) {
             foreach ($sites as $site) {
                 $configFile = WWW_ROOT . '/htdocs/' . $site . '/application/configs/application.ini';
                 $message[] = '-=' . $site . '=-';
                 try {
                     $config = new Zend_Config_Ini($configFile, 'production');
                 } catch (Zend_Config_Exception $e) {
                     $message[] = '[ERROR] Config read failure';
                     continue;
                 }
                 $config = $config->toArray();
                 if (!empty($config['resources']['multidb'])) {
                     // 遍历数据库配置
                     foreach ($config['resources']['multidb'] as $k => $opt) {
                         $dbParams = array();
                         $adapterName = '';
                         foreach ($opt as $n => $v) {
                             if ($n == 'adapter') {
                                 $adapterName = $v;
                             } else {
                                 $dbParams[$n] = $v;
                             }
                         }
                         try {
                             $db = Zend_Db::factory($adapterName, $dbParams);
                             if (false !== strpos($adapterName, 'oci')) {
                                 $db->query("SELECT 1 FROM TUDU_LOG");
                             } else {
                                 $db->query("SELECT 1");
                             }
                             $message[] = "[SUCCESS] Database \"{$k}\" success";
                         } catch (Zend_Db_Exception $e) {
                             $message[] = "[ERROR] Database \"{$k}\" failure: " . $e->getMessage();
                             $count['error']++;
                         }
                     }
                 }
                 // 匹配memcache,获取指定key,匹配当前检测插入的值
                 if (!empty($config['resources']['memcache'])) {
                     $memcache = new Oray_Memcache($config['resources']['memcache']);
                     $mv = $memcache->get($memcacheKey);
                     if ($mv != $ts) {
                         $message[] = "[WARNING] memcache get failure or value not match:{$mv}";
                         $count['warning']++;
                     } else {
                         $message[] = "[SUCCESS] memcache match success";
                     }
                     $memcache->close();
                 }
                 // 匹配httpsqs
                 if (!empty($config['httpsqs'])) {
                     $cfg = $config['httpsqs'];
                     $charset = isset($cfg['chartset']) ? $cfg['chartset'] : $cfg['charset'];
                     $httpsqs = new Oray_Httpsqs($cfg['host'], $cfg['port'], $charset, $queueName);
                     $status = $httpsqs->status($queueName);
                     if (!$status || $status['put'] != $queueStatus['put'] || $status['get'] != $queueStatus['get'] || $status['unread'] != $queueStatus['unread']) {
                         $message[] = "[WARNING] httpsqs status not match";
                         $count['warning']++;
                     } else {
                         $message[] = "[SUCCESS] httpsqs status match success";
                     }
                 }
             }
             // 检测脚本配置
             $scriptConfig = WWW_ROOT . '/scripts/task/configs/config.ini';
             $message[] = "-=task=-";
             $config = null;
             try {
                 $config = new Zend_Config_Ini($scriptConfig, 'production');
             } catch (Zend_Config_Exception $e) {
                 $message[] = '[ERROR] Config read failure';
             }
             if ($config) {
                 $config = $config->toArray();
                 if (!empty($config['multidb'])) {
                     foreach ($config['multidb'] as $k => $opt) {
                         try {
                             $db = Zend_Db::factory($opt['adapter'], $opt['params']);
                             if (false !== strpos($opt['adapter'], 'oci')) {
                                 $db->query("SELECT 1 FROM TUDU_LOG");
                             } else {
                                 $db->query("SELECT 1");
                             }
                             $message[] = "[SUCCESS] Database \"{$k}\" success";
                         } catch (Zend_Db_Exception $e) {
                             $message[] = "[WARNING] Database \"{$k}\" failure: " . $e->getMessage();
                             $count['warning']++;
                         }
                     }
                 }
                 if (!empty($config['memcache'])) {
                     $cfg = $config['memcache'];
                     $cfg['servers'] = array('host' => $cfg['host'], 'port' => $cfg['port'], 'timeout' => $cfg['timeout']);
                     $memcache = new Oray_Memcache($cfg);
                     $mv = $memcache->get($memcacheKey);
                     if ($mv != $ts) {
                         $message[] = "[WARNING] memcache get failure or value not match: {$mv}";
                         $count['warning']++;
                     } else {
                         $message[] = "[SUCCESS] memcache match success";
                     }
                 }
                 // 匹配httpsqs
                 if (!empty($config['httpsqs'])) {
                     $cfg = $config['httpsqs'];
                     $charset = isset($cfg['chartset']) ? $cfg['chartset'] : $cfg['charset'];
                     $httpsqs = new Oray_Httpsqs($cfg['host'], $cfg['port'], $charset, $queueName);
                     $status = $httpsqs->status($queueName);
                     if (!$status || $status['put'] != $queueStatus['put'] || $status['get'] != $queueStatus['get'] || $status['unread'] != $queueStatus['unread']) {
                         $message[] = "[WARNING] httpsqs status not match";
                         $count['warning']++;
                     } else {
                         $message[] = "[SUCCESS] httpsqs status match success";
                     }
                     $memcache->close();
                 }
             }
         } else {
             $message[] = "[ERROR] Undefined \"WWW_ROOT\"";
             $count['error']++;
         }
     }
     $message[] = '';
     $message[] = "Check complete, {$count['warning']} warnings, {$count['error']} errors";
     $message = implode("\n", $message);
     header('Accept-Ranges: bytes');
     header('Content-Type', 'text/plain; charset=utf-8');
     //header('Content-Length', strlen($message));
     echo $message;
     exit;
 }
Example #16
0
 public function pushDoAction()
 {
     $options = $this->getInvokeArg('bootstrap')->getOptions();
     $post = $this->_request->getPost();
     $deviceToken = str_replace(array('<', '>'), array('', ''), str_replace(' ', '', $post['devicetoken']));
     $playload = array('aps' => array());
     if (!empty($post['badge']) && is_numeric($post['badge'])) {
         $playload['aps']['badge'] = (int) $post['badge'];
     }
     if (!empty($post['body'])) {
         $playload['aps']['alert']['body'] = $post['body'];
     } else {
         if (!empty($post['loc-key'])) {
             $playload['aps']['alert']['loc-key'] = $post['loc-key'];
         }
         if (!empty($post['loc-args'])) {
             $playload['aps']['alert']['loc-args'] = $post['loc-args'];
         }
     }
     if (!empty($post['u'])) {
         $playload['u'] = $post['u'];
     }
     if (!empty($post['ud']) && is_array($post['ud'])) {
         $playload['ud'] = 0;
         foreach ($post['ud'] as $item) {
             $playload['ud'] = $playload['ud'] | (int) $item;
         }
     }
     if (!empty($post['tid'])) {
         $playload['tid'] = $post['tid'];
     }
     if (!empty($post['bid'])) {
         $playload['bid'] = $post['bid'];
     }
     require_once 'Oray/Httpsqs.php';
     $httpsqs = new Oray_Httpsqs($options['httpsqs']['host'], $options['httpsqs']['port'], $options['httpsqs']['chartset'], 'notify');
     $playload = json_encode($playload);
     $httpsqs->put(implode(' ', array('playload', '', '', http_build_query(array('devicetoken' => $deviceToken, 'playload' => $playload)))), 'notify');
     echo 'success';
     exit;
 }
Example #17
0
 /**
  * /compose/reply
  *
  * 回覆
  */
 public function replyAction()
 {
     $tuduId = $this->_request->getPost('tid');
     $action = $this->_request->getPost('action');
     $type = $this->_request->getPost('type');
     $post = $this->_request->getPost();
     $uniqueId = $this->_user->uniqueId;
     $fromPost = null;
     $fromPostId = trim($this->_request->getPost('fpid'));
     $isDoneTudu = false;
     /* @var $manager Tudu_Tudu_Manager */
     $manager = Tudu_Tudu_Manager::getInstance();
     /* @var $storage Tudu_Tudu_Storage */
     $storage = Tudu_Tudu_Storage::getInstance();
     $tudu = $manager->getTuduById($tuduId, $uniqueId);
     if (null === $tudu) {
         return $this->json(false, $this->lang['tudu_not_exists']);
     }
     // 编辑回复的权限判断
     if ($this->_user->orgId != $tudu->orgId) {
         return $this->json(false, $this->lang['tudu_not_exists']);
     }
     // 已确认图度
     if ($tudu->isDone) {
         return $this->json(false, $this->lang['tudu_is_done']);
     }
     if ($fromPostId) {
         $fromPost = $manager->getPostById($tuduId, $fromPostId);
     }
     $isReceiver = $this->_user->uniqueId == $tudu->uniqueId && count($tudu->labels);
     $isAccepter = in_array($this->_user->userName, $tudu->accepter, true);
     $isSender = in_array($tudu->sender, array($this->_user->address, $this->_user->account));
     $sendParam = array();
     if ('modify' == $action) {
         if (null == $fromPost) {
             return $this->json(false, $this->lang['post_not_exists']);
         }
         // 编辑回复的权限判断
         if (!$this->_user->getAccess()->isAllowed(Tudu_Access::PERM_UPDATE_POST) && $fromPost->isSend) {
             return $this->json(false, $this->lang['perm_deny_update_post']);
         }
         // 非回复者时,需要判断版主的权限
         if ($fromPost->uniqueId != $this->_user->uniqueId) {
             $boards = $this->getBoards(false);
             $board = $boards[$tudu->boardId];
             $isModerators = array_key_exists($this->_user->userId, $board['moderators']);
             if (!$isModerators) {
                 return $this->json(false, $this->lang['perm_deny_update_post']);
             }
         }
         if (!$fromPost->isSend) {
             $sendParam['remind'] = true;
         }
     } else {
         // 发表回复的权限判断 - 参与人员或回复权限
         if (!$isReceiver && !$this->_user->getAccess()->isAllowed(Tudu_Access::PERM_CREATE_POST)) {
             return $this->json(false, $this->lang['perm_deny_create_post']);
         }
         // 需要发送提醒
         $sendParam['remind'] = true;
     }
     // 空内容
     if ($type != 'save' && empty($post['content'])) {
         return $this->json(false, $this->lang['missing_content']);
     }
     // 构造参数
     $params = array('orgid' => $tudu->orgId, 'boardid' => $tudu->boardId, 'tuduid' => $tudu->tuduId, 'uniqueid' => $uniqueId, 'email' => $this->_user->userName, 'poster' => $this->_user->trueName, 'posterinfo' => $this->_user->position, 'content' => $post['content'], 'attachment' => !empty($post['attach']) ? array_unique((array) $post['attach']) : array(), 'file' => !empty($post['file']) ? array_unique((array) $post['file']) : array());
     $elapsedtime = round((double) $this->_request->getPost('elapsedtime'), 2) * 3600;
     $percent = min(100, (int) $this->_request->getPost('percent'));
     if ($fromPost && $fromPost->isSend) {
         $isLog = $fromPost->isLog;
         $params['elapsedtime'] = $fromPost->elapsedtime;
         $params['percent'] = $fromPost->percent;
     } else {
         if (isset($post['percent'])) {
             $isLog = $percent != $tudu->selfPercent || $elapsedtime > 0;
         } else {
             $isLog = $elapsedtime > 0;
         }
     }
     $params['islog'] = $isLog;
     if ($isLog && $tudu->selfPercent < 100) {
         $params['elapsedtime'] = $elapsedtime;
         $params['percent'] = $percent;
     }
     // 处理网盘附件
     if (!empty($post['nd-attach'])) {
         $params['attachment'] = array_diff($params['attachment'], $post['nd-attach']);
         $daoNdFile = $this->getDao('Dao_Td_Netdisk_File');
         $daoAttachment = $this->getDao('Dao_Td_Attachment_File');
         foreach ($post['nd-attach'] as $ndfileId) {
             $fileId = $ndfileId;
             $attach = $daoAttachment->getFile(array('fileid' => $fileId));
             if (null !== $attach) {
                 $params['attachment'][] = $fileId;
                 continue;
             }
             $file = $daoNdFile->getFile(array('uniqueid' => $this->_user->uniqueId, 'fileid' => $ndfileId));
             if ($file->fromFileId) {
                 $fileId = $file->fromFileId;
             }
             if ($file->attachFileId) {
                 $fileId = $file->attachFileId;
             }
             $ret = $daoAttachment->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' => time()));
             if ($ret) {
                 $params['attachment'][] = $fileId;
             }
         }
     }
     if (!$fromPost) {
         $postId = $storage->createPost($params);
         if (!$postId) {
             return $this->json(false, $this->lang['post_send_failure']);
         }
         // 添加操作日志
         $this->_writeLog(Dao_Td_Log_Log::TYPE_POST, $postId, Dao_Td_Log_Log::ACTION_CREATE, $params);
     } else {
         $postId = $fromPost->postId;
         // 增加最后编辑信息
         if ($fromPost->isSend) {
             $params['lastmodify'] = implode(chr(9), array($uniqueId, $this->_timestamp, $this->_user->trueName));
         } else {
             $params['createtime'] = time();
         }
         $storage->updatePost($tuduId, $postId, $params);
         // 记录更新内容
         $arrFromPost = $fromPost->toArray();
         $updates = array();
         foreach ($params as $key => $val) {
             if (in_array($key, array('file', 'attachment'))) {
                 continue;
             }
             if ($val != $arrFromPost[$key]) {
                 $updates[$key] = $val;
             }
         }
         // 添加操作日志
         $this->_writeLog(Dao_Td_Log_Log::TYPE_POST, $postId, Dao_Td_Log_Log::ACTION_CREATE, $updates);
     }
     if ($type != 'save') {
         // 未读
         if (!$fromPost || !$fromPost->isSend) {
             $manager->markAllUnread($tudu->tuduId);
         }
         // 标记已经读
         // 加入了批量更新和回复,所以在更新时就需要标示已读
         if ($tudu->isRead) {
             $manager->markRead($tudu->tuduId, $this->_user->uniqueId, true);
         }
         $config = $this->bootstrap->getOption('httpsqs');
         // 插入消息队列
         $httpsqs = new Oray_Httpsqs($config['host'], $config['port'], $config['chartset'], $config['name']);
         $tuduPercent = $tudu->percent;
         $flowPercent = null;
         if ($isLog && $tudu->selfPercent < 100) {
             if ($tudu->flowId) {
                 $tuduPercent = $manager->updateFlowProgress($tudu->tuduId, $tudu->uniqueId, $tudu->stepId, (int) $params['percent'], $flowPercent);
             } else {
                 $tuduPercent = $manager->updateProgress($tudu->tuduId, $tudu->uniqueId, (int) $params['percent']);
             }
             if (!$fromPost || !$fromPost->isSend) {
                 // 添加操作日志
                 $this->_writeLog(Dao_Td_Log_Log::TYPE_TUDU, $tudu->tuduId, Dao_Td_Log_Log::ACTION_TUDU_PROGRESS, array('percent' => $params['percent'], 'elapsedtime' => $tudu->elapsedTime + (int) $post['elapsedtime']));
             }
         }
         // 自动确认
         if ($isLog && $tuduPercent == 100 && null === $flowPercent || $isLog && $flowPercent == 100) {
             if ($isSender && $isAccepter || !$tudu->needConfirm) {
                 $isDoneTudu = true;
                 $doneParams = array('tuduid' => $tudu->tuduId, 'percent' => $params['percent'], 'elapsedtime' => $tudu->elapsedTime + (int) $post['elapsedtime']);
                 // 添加到发起人图度箱 -- 待确认中
             } else {
                 /* @var $addressBook Tudu_AddressBook */
                 $addressBook = Tudu_AddressBook::getInstance();
                 $sender = $addressBook->searchUser($this->_user->orgId, $tudu->sender);
                 $manager->addLabel($tudu->tuduId, $sender['uniqueid'], '^i');
             }
         }
         // 计算父级图度进度  及 图度组达到100%时,确认
         if ($tudu->parentId) {
             $parentPercent = $manager->calParentsProgress($tudu->parentId);
             if ($parentPercent >= 100) {
                 $sendParam['confirm'] = true;
             }
         }
         // 发送回复
         $manager->sendPost($tuduId, $postId);
         // 统计时间
         if ($isLog) {
             $manager->calcElapsedTime($tuduId);
         }
         // 周期任务
         if ($isLog && $tudu->cycleId && $tuduPercent >= 100) {
             $daoCycle = $this->getDao('Dao_Td_Tudu_Cycle');
             $cycle = $daoCycle->getCycle(array('cycleid' => $tudu->cycleId));
             if ($cycle->count == $tudu->cycleNum) {
                 $sendParam['cycle'] = true;
             }
         }
         $sendParam['tuduid'] = $tudu->tuduId;
         $sendParam['from'] = $this->_user->userName;
         $sendParam['sender'] = $this->_user->trueName;
         $sendParam['uniqueid'] = $this->_user->uniqueId;
         $sendParam['postid'] = $postId;
         $sendParam['tsid'] = $this->_user->tsId;
         $sendParam['server'] = $this->_request->getServer('HTTP_HOST');
         // 处理工作流
         // 处理流程发送过程
         if ($tudu->type == 'task' && $percent >= 100) {
             /* @var $daoFlow Dao_Td_Tudu_Flow */
             $daoFlow = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Flow', Tudu_Dao_Manager::DB_TS);
             $flowData = $daoFlow->getFlow(array('tuduid' => $tudu->tuduId));
             if (null !== $flowData) {
                 /* @var $flow Model_Tudu_Extension_Flow */
                 $flow = new Model_Tudu_Extension_Flow($flowData->toArray());
                 $isCurrentUser = $flow->isCurrentUser($this->_user->uniqueId);
                 $isComplete = false;
                 if ($isCurrentUser) {
                     $flow->complete($this->_user->uniqueId);
                     if ($flow->isStepComplete()) {
                         $isComplete = true;
                         $flow->flowTo();
                     }
                 }
                 $modelFlow = $flow->getHandler($flow->getHandlerClass());
                 $modelFlow->updateFlow($flow);
                 if ($flow->currentStepId != '^end') {
                     $isDoneTudu = false;
                 }
                 // 发送下一步
                 if (false === strpos($flow->currentStepId, '^') && $isComplete) {
                     $section = $flow->getStepSection($flow->currentStepId);
                     $tuduParams = array('tuduid' => $tudu->tuduId, 'type' => $tudu->type, 'fromtudu' => $tudu);
                     $users = array();
                     foreach ($section as $sec) {
                         $users[$sec['username']] = array('uniqueid' => $sec['uniqueid'], 'truename' => $sec['truename'], 'username' => $sec['username'], 'email' => $sec['username']);
                     }
                     $step = $flow->getStep($flow->currentStepId);
                     if ($step['type'] == 1) {
                         $tuduParams['reviewer'] = $users;
                     } else {
                         $tuduParams['to'] = $users;
                         if ($step['type'] == 2) {
                             $tuduParams['acceptmode'] = 1;
                         }
                     }
                     $sendTudu = new Model_Tudu_Tudu($tuduParams);
                     $daoTudu = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Tudu', Tudu_Dao_Manager::DB_TS);
                     $params = $sendTudu->getStorageParams();
                     if (!empty($params['to'])) {
                         $accepters = $daoTudu->getAccepters($tudu->tuduId);
                         foreach ($accepters as $item) {
                             $daoTudu->removeAccepter($tudu->tuduId, $item['uniqueid']);
                         }
                     }
                     $daoTudu->updateTudu($tudu->tuduId, $params);
                     $modelTudu = new Model_Tudu_Send_Common();
                     $modelTudu->send($sendTudu);
                     // 更新进度
                     $manager->updateProgress($tudu->tuduId, $this->_user->uniqueId);
                     if ($tudu->parentId) {
                         $manager->calParentsProgress($tudu->parentId);
                     }
                 }
             }
         }
         // 自动确认
         if ($isDoneTudu && isset($doneParams)) {
             $manager->doneTudu($doneParams['tuduid'], true, 0);
             // 添加操作日志
             $this->_writeLog(Dao_Td_Log_Log::TYPE_TUDU, $doneParams['tuduid'], Dao_Td_Log_Log::ACTION_TUDU_DONE, array('percent' => $doneParams['percent'], 'elapsedtime' => $doneParams['elapsedtime']), false, true);
         }
         // 回复消息
         $data = implode(' ', array('tudu', 'reply', '', http_build_query($sendParam)));
         $httpsqs->put($data, 'tudu');
     }
     return $this->json(true, $this->lang['post_send_success'], array('postid' => $postId));
 }
Example #18
0
    /**
     * 认领
     */
    public function claimAction()
    {
        // 获取步骤
        $step = $this->_manager->getStep($this->_tudu->tuduId, $this->_tudu->stepId);
        // 判断当前是否为认领操作
        if ($step->type != Dao_Td_Tudu_Step::TYPE_CLAIM) {
            return $this->json(false, $this->lang['step_not_claim']);
        }
        // 判读图度是否已有user认领
        if ($this->_tudu->acceptTime) {
            return $this->json(false, $this->lang['tudu_has_already_claim']);
        }
        $ret = $this->_manager->claimTudu($this->_tudu->tuduId, $this->_tudu->orgId, $this->_user['uniqueid']);
        if (!$ret) {
            return $this->json(false, $this->lang['tudu_claim_failure']);
        }
        //创建回复
        $content = sprintf($this->lang['claim_accepter_log'], $this->_user['truename']);
        $params = array('orgid' => $this->_tudu->orgId, 'boardid' => $this->_tudu->boardId, 'tuduid' => $this->_tudu->tuduId, 'uniqueid' => $this->_user['uniqueid'], 'poster' => $this->_user['truename'], 'email' => $this->_user['email'], 'postid' => Dao_Td_Tudu_Post::getPostId($this->_tudu->tuduId), 'content' => $content, 'lastmodify' => implode(chr(9), array($this->_user['uniqueid'], time(), $this->_user['truename'])));
        $postId = $this->_manager->createPost($params);
        $this->_manager->sendPost($this->_tudu->tuduId, $postId);
        // 标记为未读
        $this->_manager->markAllUnRead($this->_tudu->tuduId);
        // 添加操作日志
        $this->_writeLog(Dao_Td_Log_Log::TYPE_TUDU, $this->_tudu->tuduId, Dao_Td_Log_Log::ACTION_TUDU_CLAIM, array('claimuser' => $this->_user['truename'], 'claimtime' => time(), 'status' => Dao_Td_Tudu_Tudu::STATUS_DOING));
        $notifyTo = array($this->_tudu->sender);
        $notifyTo = array_merge($notifyTo, array_keys($this->_tudu->to));
        if ($this->_tudu->notifyAll) {
            $notifyTo = array_merge($notifyTo, array_keys($this->_tudu->cc));
        }
        // 消息队列
        $config = $this->_bootstrap->getOption('httpsqs');
        $httpsqs = new Oray_Httpsqs($config['host'], $config['port'], $config['chartset'], $config['name']);
        $tpl = <<<HTML
<strong>您刚收到一个新的回复</strong><br />
<a href="http://{$this->_request->getServer('HTTP_HOST')}/frame#m=view&tid=%s&page=1" target="_blank" _tid="{$this->_tudu->tuduId}">%s</a><br />
发起人:{$this->_user['truename']}<br />
更新日期:%s<br />
{$content}
HTML;
        $data = implode(' ', array('tudu', 'reply', '', http_build_query(array('tuduid' => $this->_tudu->tuduId, 'from' => $this->_user['email'], 'to' => implode(',', $notifyTo), 'content' => sprintf($tpl, $this->_tudu->tuduId, $this->_tudu->subject, date('Y-m-d H:i:s', time()))))));
        $httpsqs->put($data);
        return $this->json(true, $this->lang['tudu_claim_success']);
    }
Example #19
0
 public function sendmailAction()
 {
     $config = $this->_bootstrap->getOption('httpsqs');
     // 插入消息队列
     $httpsqs = new Oray_Httpsqs($config['host'], $config['port'], $config['chartset'], $config['name']);
     // 发送外部邮件(如果有),处理联系人
     $data = implode(' ', array('send', 'tudu', '', http_build_query(array('tsid' => $this->_tsId, 'tuduid' => $this->_tudu->tuduId, 'uniqueid' => $this->_user['uniqueid'], 'to' => ''))));
     $httpsqs->put($data, 'send');
     echo 'x';
     exit;
 }
Example #20
0
 /**
  *
  * 作用与当前存在的图度
  */
 public function affectAction()
 {
     $ruleId = $this->_request->getPost('ruleid');
     $rule = $this->getDao('Dao_Td_Rule_Rule')->getRuleById($ruleId);
     if (null === $rule || $rule->uniqueId != $this->_user->uniqueId || !$rule->isValid) {
         return $this->json(false, null);
     }
     $config = $this->bootstrap->getOption('httpsqs');
     // 插入消息队列
     $httpsqs = new Oray_Httpsqs($config['host'], $config['port'], $config['chartset'], 'tudu');
     $httpsqs->put(implode(' ', array('tudu', 'rule', '', http_build_query(array('tsid' => $this->_user->tsId, 'ruleid' => $ruleId)))));
     return $this->json(true, $this->lang['wait_for_rule_affect']);
 }