/** * 删除回复 */ public function deleteAction() { $tuduId = $this->_request->getParam('tuduid'); $postId = $this->_request->getParam('postid'); if (!$tuduId) { throw new TuduX_OpenApi_Exception('Missing or invalid value of parameter "tuduid"', TuduX_OpenApi_ResponseCode::MISSING_PARAMETER); } if (!$postId) { throw new TuduX_OpenApi_Exception('Missing or invalid value of parameter "postid"', TuduX_OpenApi_ResponseCode::MISSING_PARAMETER); } /* @var $modelManage Model_Tudu_Manager_Tudu */ $modelManage = Tudu_Model::factory('Model_Tudu_Manager_Tudu'); $params = array('tuduid' => $tuduId, 'postid' => $postId); try { $modelManage->deletePost($params); } catch (Model_Tudu_Exception $e) { switch ($e->getCode()) { case Model_Tudu_Exception::INVALID_USER: $code = TuduX_OpenApi_ResponseCode::MISSING_AUTHORIZE; break; case Model_Tudu_Manager_Tudu::CODE_INVALID_TUDUID: case Model_Tudu_Manager_Tudu::CODE_INVALID_POSTID: $code = TuduX_OpenApi_ResponseCode::MISSING_PARAMETER; break; case Model_Tudu_Manager_Tudu::CODE_POST_NOTEXISTS: $code = TuduX_OpenApi_ResponseCode::RESOURCE_NOT_EXISTS; break; case Model_Tudu_Manager_Tudu::CODE_POST_FIRST: $code = TuduX_OpenApi_ResponseCode::CONTENT_POST_FIRST; break; case Model_Tudu_Manager_Tudu::CODE_DENY_ROLE: $code = TuduX_OpenApi_ResponseCode::ACCESS_DENIED; break; case Model_Tudu_Manager_Tudu::CODE_SAVE_FAILED: default: $code = TuduX_OpenApi_ResponseCode::OPERATE_FAILED; break; } throw new TuduX_OpenApi_Exception($e->getMessage(), $code); } $this->view->code = TuduX_OpenApi_ResponseCode::SUCCESS; }
/** * 向群组添加成员 */ public function addMemberAction() { /* @var @daoGroup Dao_Md_User_Group */ $daoGroup = $this->getDao('Dao_Md_User_Group'); /* @var $daoOrg Dao_Md_Org_Org */ $daoOrg = $this->getDao('Dao_Md_Org_Org'); $groupId = $this->_request->getParam('groupid'); $key = (array) $this->_request->getParam('key'); $message = ''; /* @var $modelGroup Model_User_Group*/ $modelGroup = Tudu_Model::factory('Model_User_Group'); try { $modelGroup->doAddUser(array('orgid' => $this->_orgId, 'groupid' => $groupId, 'userid' => $key)); } catch (Model_User_Exception $e) { switch ($e->getCode()) { case Model_User_Group::CODE_INVALID_ORGID: $message = '缺少参数[orgid]'; break; case Model_User_Group::CODE_INVALID_GROUPID: $message = $this->lang['invalid_params_groupid']; break; case Model_User_Group::CODE_INVALID_UID: $message = '缺少群组成员'; break; case Model_User_Group::CODE_GROUP_NOTEXISTS: $message = '该群组不存在或已被删除'; break; case Model_User_Group::CODE_SAVE_FAILED: $message = $this->lang['group_member_failure']; break; } return $this->json(false, $message); } foreach ($key as $userId) { if (!$userId) { continue; } $this->_clearUserCache($userId . '@' . $this->_orgId); } $this->setUpdateCastTime(); return $this->json(true, $this->lang['operate_success']); }
/** * 更新权限组成员 */ public function updateMemberAction() { /* @var $daoRole Dao_Md_User_Role */ $daoRole = $this->getDao('Dao_Md_User_Role'); /* @var $daoOrg Dao_Md_Org_Org */ $daoOrg = $this->getDao('Dao_Md_Org_Org'); $roleId = $this->_request->getPost('roleid'); $members = (array) $this->_request->getPost('userid'); if (!$roleId) { return $this->json(false, $this->lang['invalid_params_roleid']); } $role = $daoRole->getRole(array('orgid' => $this->_orgId, 'roleid' => $roleId)); if (null === $role) { return $this->json(false, $this->lang['role_not_exists']); } $users = $daoRole->getUserIds($this->_orgId, $roleId); /* @var $modelRole Model_User_Role*/ $modelRole = Tudu_Model::factory('Model_User_Role'); try { $modelRole->doUpdateMember(array('orgid' => $this->_orgId, 'roleid' => $roleId, 'users' => $members, 'isverify' => true)); } catch (Model_User_Exception $e) { switch ($e->getCode()) { case Model_User_Role::CODE_INVALID_ORGID: $message = '缺少参数[orgid]'; break; case Model_User_Role::CODE_INVALID_ROLEID: $message = '缺少参数[roleid]'; break; case Model_User_Role::CODE_ROLE_NOTEXISTS: $message = $this->lang['role_not_exists']; break; case Model_User_Role::CODE_SAVE_FAILED: $message = '更新权限组成员失败'; break; } return $this->json(false, $message); } $userIds = array_unique(array_merge($users, $members)); $this->_clearCache($userIds); //if ($roleId == '^admin') { //$removeAdmin = array_diff($users, $members); /*foreach ($removeAdmin as $userId) { $daoOrg->deleteAdmin($this->_orgId, $userId); }*/ /*foreach ($members as $userId) { $daoOrg->addAdmin($this->_orgId, $userId, 'SA', 3); }*/ //} $this->_createLog('role', 'update', 'member', $roleId, array('rolename' => $role->roleName)); return $this->json(true, '更新权限组成员成功'); }
/** * 标签操作 */ public function labelAction() { $tuduIds = explode(',', $this->_request->getParam('tuduid')); //$fun = $this->_request->getParam('fun'); //$labelId = explode(',', $this->_request->getParam('labelid')); $addLabels = explode(',', $this->_request->getParam('add')); $delLabels = explode(',', $this->_request->getParam('del')); if (empty($tuduIds)) { throw new TuduX_OpenApi_Exception('Missing or invalid value of parameter "tid"', TuduX_OpenApi_ResponseCode::MISSING_PARAMETER); } if (empty($addLabels) || empty($delLabels)) { throw new TuduX_OpenApi_Exception('Missing or invalid value of parameter "lid"', TuduX_OpenApi_ResponseCode::MISSING_PARAMETER); } $labels = array(); if (!empty($addLabels)) { foreach ($addLabels as $item) { $labels[$item] = 'add'; } } if (!empty($delLabels)) { foreach ($delLabels as $item) { $labels[$item] = 'delete'; } } $tuduManager = Tudu_Model::factory('Model_Tudu_Manage'); foreach ($tuduIds as $tuduId) { try { $tuduManager->label($tuduId, $labels); } catch (Model_Tudu_Exception $e) { $exception = $this->getException($e); throw new TuduX_OpenApi_Exception($exception['message'], $exception['code']); } } $this->view->code = TuduX_OpenApi_ResponseCode::SUCCESS; }
/** * 审批 */ public function reviewAction() { $post = $this->_request->getParams(); require_once 'Model/Tudu/Tudu.php'; $tudu = new Model_Tudu_Tudu(); $this->_formatParams($tudu, $post); $tudu->setAttributes(array('orgid' => $this->_user->orgId, 'uniqueid' => $this->_user->uniqueId, 'poster' => $this->_user->trueName, 'isagree' => $this->_request->getParam('agree', true), 'operation' => 'review')); try { /* @var $modelCompose Model_Tudu_Compose_Forward */ $modelCompose = Tudu_Model::factory('Model_Tudu_Compose_Review'); $params = array(&$tudu); $modelCompose->execute('compose', $params); // 考勤流程 if ($tudu->fromTudu->appId == 'attend' && $tudu->stepId == '^end') { $mtudu = new Tudu_Model_Tudu_Entity_Tudu($tudu->getAttributes()); Tudu_Dao_Manager::setDbs(array(Tudu_Dao_Manager::DB_APP => $this->_bootstrap->multidb->getDb('app'))); $daoApply = Tudu_Dao_Manager::getDao('Dao_App_Attend_Apply', Tudu_Dao_Manager::DB_APP); $apply = $daoApply->getApply(array('tuduid' => $tudu->tuduId)); if (null !== $apply) { $mapply = new Tudu_Model_App_Attend_Tudu_Apply($apply->toArray()); $model = new Tudu_Model_App_Attend_Tudu_Extension_Apply(); $model->onReview($mtudu, $mapply); } } $config = $this->_bootstrap->getOption('httpsqs'); $tuduconf = $this->_bootstrap->getOption('tudu'); $sendType = isset($tuduconf['send']) ? ucfirst($tuduconf['send']['class']) : 'Common'; $sendClass = 'Model_Tudu_Send_' . $sendType; $modelSend = new $sendClass(array('httpsqs' => $config)); $modelSend->send(&$tudu); /*$config = $this->_bootstrap->getOption('httpsqs'); $httpsqs = new Oray_Httpsqs($config['host'], $config['port'], $config['chartset'], $config['name']); $action = 'review'; $sqsParam = array( 'tsid' => $this->_user->tsId, 'tuduid' => $tudu->tuduId, 'from' => $this->_user->userName, 'uniqueid' => $this->_user->uniqueId, 'server' => $this->_request->getServer('HTTP_HOST'), 'type' => $tudu->type, 'stepid' => $tudu->fromTudu->stepId, 'stepstatus' => $tudu->stepId && $tudu->fromTudu->stepId != $tudu->stepId && 0 !== strpos($tudu->stepId, '^'), 'nstepid' => $tudu->stepId, 'flowid' => $tudu->flowId, 'agree' => $this->_request->getParam('agree', true), 'ischangedCc' => ($action == 'update' && $tudu->cc) ? (boolean) $tudu->cc : false ); $httpsqs->put(implode(' ', array( 'tudu', $action, '', http_build_query($sqsParam) )), 'tudu');*/ } catch (Model_Tudu_Exception $e) { throw new TuduX_OpenApi_Exception('Tudu review failed', TuduX_OpenApi_ResponseCode::TUDU_SEND_FAILED); } $this->view->tuduid = $tudu->tuduId; $this->view->code = TuduX_OpenApi_ResponseCode::SUCCESS; }
/** * 删除logo */ public function logoDeleteAction() { /* @var $modelOrg Model_Org_Org*/ $modelOrg = Tudu_Model::factory('Model_Org_Org'); try { $modelOrg->execute('updateOrg', array(array('orgid' => $this->_orgId, 'logo' => null))); } catch (Model_Org_Exception $e) { switch ($e->getCode()) { case Model_Org_Org::CODE_INVALID_ORGID: $message = '缺少参数[orgid]'; break; case Model_Org_Org::CODE_ORG_NOTEXISTS: $message = '组织不存在或已被删除'; break; case Model_Org_Org::CODE_SAVE_FAILED: $message = '还原默认Logo失败'; break; } return $this->json(false, $message); } return $this->json(true, $this->lang['logo_revert_success']); }
/** * 排序 */ public function sortAction() { $deptId = str_replace('_', '^', $this->_request->getPost('deptid')); $type = $this->_request->getPost('type'); $clientIp = isset($_SERVER['HTTP_X_REAL_IP']) ? $_SERVER['HTTP_X_REAL_IP'] : $this->_request->getClientIp(); $local = !empty($this->_session->auth['local']) ? $this->_session->auth['local'] : null; /* @var $modelDept Model_Department_Department */ $modelDept = Tudu_Model::factory('Model_Department_Department'); $params = array('orgid' => $this->_orgId, 'deptid' => $deptId, 'operator' => $this->_user->userId, 'clientip' => $clientIp, 'local' => $local); try { $modelDept->addAction('update', array($modelDept, 'sort'), 1, array($this->_orgId, $deptId, $type, $params), false); $modelDept->execute('update', array($params)); } catch (Model_Department_Exception $e) { $message = '排序失败,请刷新页面后重试'; switch ($e->getCode()) { case Model_Department_Department::CODE_INVALID_DEPTID: $message = '缺少参数[deptid]'; break; case Model_Department_Department::CODE_INVALID_ORGID: $message = '缺少参数[orgid]'; break; case Model_Department_Department::CODE_SAVE_FAILED: $message = '排序失败,请刷新页面后重试'; break; } return $this->json(false, $message); } return $this->json(true); }
/** * 创建图度组织 */ public function createOrg() { if (empty($this->_orgParams)) { require_once 'Tudu/Install/Exception.php'; throw new Tudu_Install_Exception('empty org params'); } if (empty($this->_configs['mysql'])) { require_once 'Tudu/Install/Exception.php'; throw new Tudu_Install_Exception('empty configs database'); } $this->_configs['mysql'] = array_merge($this->_configs['mysql'], array('charset' => 'utf8')); require_once 'Zend/Db.php'; require_once 'Zend/Db/Exception.php'; $db = Zend_Db::factory('pdo_mysql', $this->_configs['mysql']); require_once 'Tudu/Dao/Manager.php'; Tudu_Dao_Manager::setDbs(array(Tudu_Dao_Manager::DB_MD => $db, Tudu_Dao_Manager::DB_TS => $db)); if (!empty($this->_dataPath)) { $dataPath = array('data' => array('path' => $this->_dataPath)); require_once 'Tudu/Model.php'; require_once 'Tudu/Model/ResourceManager/Registry.php'; $resourceManager = new Tudu_Model_ResourceManager_Registry(); $resourceManager->setResource('config', $dataPath); Tudu_Model::setResourceManager($resourceManager); } require_once 'Model/Org/Org.php'; require_once 'Model/Org/Exception.php'; /* @var $modelOrg Model_Org_Org */ $modelOrg = Tudu_Model::factory('Model_Org_Org'); try { $modelOrg->addAction('create', array($modelOrg, 'createAdmin'), 10); $modelOrg->addAction('create', array($modelOrg, 'active'), 9); $modelOrg->execute('create', array(array('orgid' => $this->_orgParams['orgid'], 'orgname' => $this->_orgParams['orgname'], 'userid' => $this->_orgParams['userid'], 'password' => $this->_orgParams['password'], 'truename' => $this->_orgParams['userid'], 'domain' => $this->_orgParams['domain']))); } catch (Model_Org_Exception $e) { require_once 'Tudu/Install/Exception.php'; throw new Tudu_Install_Exception($e->getMessage()); } }
/** * 删除用户 */ public function deleteAction() { $userId = $this->_request->getPost('userid'); if (!$userId) { return $this->json(false, $this->lang['invalid_params_userid']); } $userIds = explode(',', $userId); $clientIp = isset($_SERVER['HTTP_X_REAL_IP']) ? $_SERVER['HTTP_X_REAL_IP'] : $this->_request->getClientIp(); $local = !empty($this->_session->auth['local']) ? $this->_session->auth['local'] : null; /* @var $modelUser Model_User_User */ $modelUser = Tudu_Model::factory('Model_User_User'); $params = array('orgid' => $this->_orgId, 'userid' => $userIds, 'operator' => $this->_user->userId, 'clientip' => $clientIp, 'local' => $local); try { $modelUser->doDelete($params); foreach ($userIds as $userId) { // 清除相关缓存 $this->_clearUserCache($userId . '@' . $this->_orgId); } // 清空组织用户列表cache $this->_bootstrap->memcache->delete('TUDU-USER-LIST-' . $this->_orgId); } catch (Model_User_Exception $e) { $message = $this->lang['user_delete_failure']; switch ($e->getCode()) { case Model_User_User::CODE_INVALID_ORGID: $message = '缺少参数[orgid]'; break; case Model_User_User::CODE_MISSING_UID: $message = $this->lang['invalid_params_userid']; break; case Model_User_User::CODE_DELETE_SUPER_ADMIN: $message = '不能删除超级管理员帐号'; break; case Model_User_User::CODE_SAVE_FAILED: $message = $this->lang['user_delete_failure']; break; } return $this->json(false, $message); } $this->json(true, $this->lang['user_delete_success']); }