Esempio n. 1
0
 /**
  * 删除接收人
  */
 public function foreignDeleteAction()
 {
     $tuduId = $this->_request->getPost('tid');
     $uniqueId = $this->_request->getPost('uniqueid');
     // 参数:图度ID必须存在
     if (!$tuduId || !$uniqueId) {
         return $this->json(false, $this->lang['invalid_tuduid']);
     }
     $tudu = $this->manager->getTuduById($tuduId, $this->_user->uniqueId);
     // 图度必须存在
     if (null === $tudu) {
         return $this->json(false, $this->lang['tudu_not_exists']);
     }
     // 必须是发起人才具备此操作
     if ($tudu->sender != $this->_user->userName) {
         return $this->json(false, $this->lang['perm_deny_add_foreign']);
     }
     $userInfo = $this->manager->getUser($tuduId, $uniqueId);
     if (null === $userInfo) {
         return $this->json(false, $this->lang['foreign_not_exists']);
     }
     if (!$userInfo['isforeign']) {
         return $this->json(false, $this->lang['deny_remove_user_in_foreign']);
     }
     $role = $userInfo['role'];
     $tuduAddr = array('to' => array(), 'cc' => array());
     foreach ($tudu->to as $k => $item) {
         if ($userInfo['accepterinfo'][3] == $k && !is_int($k) || $userInfo['accepterinfo'][0] == $k && !$k) {
             continue;
         }
         $tuduAddr['to'][] = implode(' ', array(!is_int($k) ? $k : '', $item[0]));
     }
     foreach ($tudu->cc as $k => $item) {
         if ($userInfo['accepterinfo'][3] == $k && !is_int($k) || $userInfo['accepterinfo'][0] == $k && !$k) {
             continue;
         }
         $tuduAddr['cc'][] = implode(' ', array(!is_int($k) ? $k : '', $item[0]));
     }
     // 删除标签
     foreach ($tudu->labels as $labelId) {
         $this->manager->deleteLabel($tuduId, $uniqueId, $labelId);
     }
     // 添加用户
     if (!$this->manager->deleteUser($tuduId, $uniqueId)) {
         return $this->json(false, $this->lang['remove_foreign_failure']);
     }
     // 更新图度用户
     $this->manager->updateTudu($tuduId, array('to' => implode("\n", $tuduAddr['to']), 'cc' => implode("\n", $tuduAddr['cc'])));
     // 是接收人,需要重新统计完成率
     if ($role == Dao_Td_Tudu_Tudu::ROLE_ACCEPTER) {
         // 更新转发编辑后的任务进度
         $this->manager->updateProgress($tuduId, $uniqueId, null);
         if ($tudu->parentId) {
             $this->manager->calParentsProgress($tudu->parentId);
         }
     }
     return $this->json(true, $this->lang['remove_foreign_success']);
 }
Esempio n. 2
0
 /**
  * 初始化
  */
 public function init()
 {
     $this->_bootstrap = $this->getInvokeArg('bootstrap');
     $this->_multidb = $this->_bootstrap->getResource('multidb');
     $this->_options = $this->_bootstrap->getOptions();
     $this->_helper->viewRenderer->view->setBasePath(APPLICATION_PATH . '/modules/foreign/views');
     $this->_helper->viewRenderer->setViewScriptPathSpec(':module#:controller#:action.:suffix');
     $this->_tsId = $this->_request->getParam('ts');
     $tuduId = $this->_request->getParam('tid');
     $unId = $this->_request->getParam('fid');
     if (!$this->_tsId || !$tuduId || !$unId) {
         $this->getResponse()->setHttpResponseCode(404);
         $this->getResponse()->sendResponse();
         return;
     }
     Tudu_Dao_Manager::setDbs(array(Tudu_Dao_Manager::DB_TS => $this->getTsDb($this->_tsId)));
     $this->_manager = Tudu_Tudu_Manager::getInstance();
     $this->_deliver = new Tudu_Deliver($this->getTsDb($this->_tsId));
     $this->_tudu = $this->_manager->getTuduById($tuduId, $unId);
     $this->_user = $this->_manager->getUser($tuduId, $unId);
     if (null !== $this->_user) {
         // 用户请求语言
         $language = $this->_request->getHeader('ACCEPT_LANGUAGE');
         if (strpos($language, 'zh') !== false) {
             if (strpos($language, 'hk') !== false || strpos($language, 'tw') !== false) {
                 $language = 'zh_TW';
             } else {
                 $language = 'zh_CN';
             }
         } else {
             $language = 'en_US';
         }
         $this->_user['option'] = array('language' => $language);
         if (null !== $this->_tudu) {
             $this->_session = new Zend_Session_Namespace(self::SESSION_NAMESPACE, true);
             $this->_sessionId = Zend_Session::getId();
             //
             /*if (isset($this->_session->foreign['uniqueid']) && $this->_session->foreign['uniqueid'] != $this->_user['uniqueid']) {
                   $this->_destroySession();
               }*/
             $this->_session->foreign['uniqueid'] = $this->_user['uniqueid'];
             $this->_session->foreign['address'] = $this->_user['email'] ? $this->_user['email'] : $this->_user['uniqueid'];
             $this->_session->foreign['truename'] = $this->_user['truename'];
             $this->_session->foreign['logintime'] = time();
             $this->_session->foreign['orgid'] = $this->_tudu->orgId;
             $this->_session->foreign['tsid'] = $this->_tsId;
             $this->_session->foreign['lasttime'] = time();
             if (empty($this->_session->auth)) {
                 $this->_session->auth = array('uniqueid' => $this->_user['uniqueid'], 'address' => $this->_session->foreign['address'], 'logintime' => $this->_session->foreign['logintime']);
             }
         }
         $this->_timestamp = time();
         $this->view->options = $this->_options;
         $this->view->tsid = $this->_tsId;
         $this->view->user = $this->_user;
     }
 }