Esempio n. 1
0
 /**
  * 欢迎公告
  */
 public function welcomeAction()
 {
     $orgId = $this->_request->getQuery('orgid', 'oray');
     $daoOrg = $this->getMdDao('Dao_Md_Org_Org');
     $org = $daoOrg->getOrg(array('orgid' => $orgId));
     if (null === $org) {
         exit('org not exists');
     }
     // 添加组织公告
     $content = file_get_contents($this->options['data']['path'] . '/tudu/template/welcome.tpl');
     if ($content) {
         $deliver = new Tudu_Deliver($this->getTsDb());
         $tudu = array('orgid' => $orgId, 'tuduid' => md5($orgId . '-welcome'), 'boardid' => '^system', 'uniqueid' => '^system', 'type' => 'notice', 'subject' => '欢迎使用图度工作管理系统!!', 'email' => '^system', 'from' => '^system 图度', 'to' => null, 'cc' => null, 'priority' => 0, 'privacy' => 0, 'status' => Dao_Td_Tudu_Tudu::STATUS_UNSTART, 'content' => $content, 'poster' => '图度', 'posterinfo' => '', 'lastposter' => '图度', 'lastposttime' => time(), 'createtime' => time(), 'attachment' => array());
         $ret = $deliver->createTudu($tudu);
         $deliver->sendTudu($tudu['tuduid'], array());
         exit($ret ? 'success' : 'error');
     }
     exit('tpl not exists or content is null');
 }
Esempio n. 2
0
 /**
  * 创建组织超级管理员
  *
  * @param array $params
  */
 public function createAdmin(array $params)
 {
     //echo 'create admin', "\n";
     /* @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/Org/Exception.php';
         throw new Model_Org_Exception('Missing or invalid value of parameter "uid"', self::CODE_INVALID_UID);
     }
     if (empty($params['orgid'])) {
         require_once 'Model/Org/Exception.php';
         throw new Model_Org_Exception('Missing or invalid value of parameter "orgid"', self::CODE_INVALID_ORGID);
     }
     if (empty($params['password'])) {
         require_once 'Model/Org/Exception.php';
         throw new Model_Org_Exception('Missing or invalid value of parameter "password"', self::CODE_INVALID_PWD);
     }
     $orgId = $params['orgid'];
     $userId = $params['userid'];
     $password = $params['password'];
     $trueName = $params['truename'];
     $uniqueId = Dao_Md_User_User::getUniqueId($orgId, $userId);
     /* @var $daoUser Dao_Md_User_User */
     $daoUser = Tudu_Dao_Manager::getDao('Dao_Md_User_User', Tudu_Dao_Manager::DB_MD);
     /* @var $daoGroup Dao_Md_User_Group */
     $daoGroup = Tudu_Dao_Manager::getDao('Dao_Md_User_Group', Tudu_Dao_Manager::DB_MD);
     /* @var $daoRole Dao_Md_User_Role */
     $daoRole = Tudu_Dao_Manager::getDao('Dao_Md_User_Role', Tudu_Dao_Manager::DB_MD);
     /* @var $daoOrg Dao_Md_Org_Org*/
     $daoOrg = Tudu_Dao_Manager::getDao('Dao_Md_Org_Org', Tudu_Dao_Manager::DB_MD);
     $org = $daoOrg->getOrgById($orgId);
     if (!$org) {
         require_once 'Model/Org/Exception.php';
         throw new Model_Org_Exception('Org id "' . $orgId . '" not exists', self::CODE_ORG_NOTEXISTS);
     }
     // 创建超级管理员用户
     $user = array('orgid' => $orgId, 'userid' => $userId, 'uniqueid' => $uniqueId, 'status' => 1, 'isshow' => 1);
     $userInfo = array('orgid' => $orgId, 'userid' => $userId, 'truename' => $trueName, 'ismd5' => true, 'password' => $password);
     $ret = $daoUser->createUser($user);
     if (!$ret) {
         require_once 'Model/Org/Exception.php';
         throw new Model_Org_Exception('Create user data failed', self::CODE_SAVE_FAILED);
     }
     $ret = $daoUser->createUserInfo($userInfo);
     if (!$ret) {
         require_once 'Model/Org/Exception.php';
         throw new Model_Org_Exception('Create user info failed', self::CODE_SAVE_FAILED);
     }
     // 添加群组 - 全体员工
     $daoGroup->addUser($orgId, '^all', $userId);
     // 添加权限 - 管理员
     $daoRole->addUsers($orgId, '^admin', $userId);
     // 添加管理员
     $daoOrg->addAdmin($orgId, $userId, 'SA', 3);
     if (!empty($params['email'])) {
         // 绑定邮箱
         $daoUser->createEmail(array('orgid' => $orgId, 'userid' => $userId, 'email' => $params['email']));
     }
     /* @var $daoCast Dao_Md_User_Cast */
     $daoCast = Tudu_Dao_Manager::getDao('Dao_Md_User_Cast', Tudu_Dao_Manager::DB_MD);
     // 看到自己
     $daoCast->addUser($orgId, $userId, $userId);
     // 看到根部门
     $daoCast->addDepartment($orgId, $userId, '^root');
     // 创建欢迎公告
     try {
         $config = Tudu_Model::getResource('config');
         if (!empty($config['path']['data']) || !empty($config['data']['path'])) {
             $tplFile = !empty($config['path']['data']) ? $config['path']['data'] : $config['data']['path'];
             $content = @file_get_contents($tplFile . '/templates/tudu/welcome.tpl');
             if (!empty($content)) {
                 require_once 'Tudu/Deliver.php';
                 $deliver = new Tudu_Deliver(Tudu_Dao_Manager::getDb(Tudu_Dao_Manager::DB_TS));
                 $tudu = array('orgid' => $orgId, 'tuduid' => md5($orgId . '-welcome'), 'boardid' => '^system', 'uniqueid' => '^system', 'type' => 'notice', 'subject' => '欢迎使用图度工作管理系统!!', 'email' => '*****@*****.**', 'from' => '^system 图度系统', 'to' => null, 'cc' => null, 'priority' => 0, 'privacy' => 0, 'issend' => 1, 'status' => Dao_Td_Tudu_Tudu::STATUS_UNSTART, 'content' => $content, 'poster' => '图度系统', 'posterinfo' => '', 'lastposter' => '图度系统', 'lastposttime' => time(), 'createtime' => time(), 'attachment' => array());
                 $deliver->createTudu($tudu);
                 $deliver->sendTudu($tudu['tuduid'], array());
                 if (!empty($uniqueId)) {
                     $deliver->addRecipient($tudu['tuduid'], $uniqueId);
                     $deliver->addLabel($tudu['tuduid'], $uniqueId, '^all');
                     $deliver->addLabel($tudu['tuduid'], $uniqueId, '^i');
                     $deliver->addLabel($tudu['tuduid'], $uniqueId, '^n');
                 }
             }
         }
     } catch (Exception $e) {
     }
 }