Example #1
0
 /**
  * 创建分区
  */
 public function createAction()
 {
     $post = $this->_request->getPost();
     $boardName = $post['name'];
     $parentId = $post['parentid'];
     $moderators = $post['moderators'];
     $groups = $post['groups'];
     $classes = array();
     if (!$this->_user->getAccess()->isAllowed(Tudu_Access::PERM_CREATE_BOARD)) {
         return $this->json(false, $this->lang['perm_deny_create']);
     }
     if (!$boardName) {
         return $this->json(false, $this->lang['params_invalid_name']);
     }
     if (!$parentId) {
         return $this->json(false, $this->lang['params_invalid_parentid']);
     }
     $daoBoard = $this->getDao('Dao_Td_Board_Board');
     if (!$daoBoard->existsBoard($this->_user->orgId, $parentId)) {
         return $this->json(false, $this->lang['parent_zone_not_exists']);
     }
     $boardId = Dao_Td_Board_Board::getBoardId($this->_user->orgId);
     $condition = array('orgid' => $this->_user->orgId, 'type' => 'board', 'parentid' => $parentId);
     $orderNum = $daoBoard->getBoardMaxOrderNum($condition);
     $params = array('orgid' => $this->_user->orgId, 'boardid' => $boardId, 'type' => 'board', 'boardname' => $boardName, 'parentid' => $parentId, 'ownerid' => $this->_user->userId, 'memo' => $post['memo'], 'ordernum' => $orderNum + 1);
     // 管理人员
     //$daoUser = Oray_Dao::factory('Dao_Md_User_User', $this->multidb->getDb());
     if (!$moderators) {
         $params['moderators'] = $this->_user->userId . ' ' . $this->_user->trueName;
     } else {
         $params['moderators'] = $moderators;
     }
     if (!$groups) {
         $params['groups'] = '^all';
     } else {
         $params['groups'] = $groups;
     }
     if (isset($post['privacy'])) {
         $params['privacy'] = (int) $post['privacy'];
     }
     if (isset($post['protect'])) {
         $params['protect'] = (int) $post['protect'];
     }
     if (isset($post['isclassify'])) {
         $params['isclassify'] = (int) $post['isclassify'];
     }
     if (isset($post['needconfirm'])) {
         $params['needconfirm'] = (int) $post['needconfirm'];
     }
     if (isset($post['flowonly'])) {
         $params['flowonly'] = (int) $post['flowonly'];
     }
     $ret = $daoBoard->createBoard($params);
     if (!$ret) {
         return $this->json(false, $this->lang['board_create_failure']);
     }
     // 主题分类
     if (!empty($post['newclass']) && is_array($post['newclass'])) {
         $daoClass = $this->getDao('Dao_Td_Tudu_Class');
         $orderNum = 1;
         foreach ($post['newclass'] as $class) {
             if (empty($post['classname-' . $class])) {
                 continue;
             }
             $daoClass->createClass(array('orgid' => $this->_user->orgId, 'boardid' => $boardId, 'classid' => Dao_Td_Tudu_Class::getClassId(), 'classname' => $post['classname-' . $class], 'ordernum' => (int) $post['ordernum-' . $class]));
         }
     }
     // 创建模板
     if (!empty($post['templates'])) {
         $daoTemplate = $this->getDao('Dao_Td_Tudu_Template');
         if (!empty($post['template']) && is_array($post['template'])) {
             foreach ($post['template'] as $number) {
                 if (empty($post['tplname-' . $number])) {
                     continue;
                 }
                 $tplParams = array('orgid' => $this->_user->orgId, 'boardid' => $boardId, 'templateid' => Dao_Td_Tudu_Template::getTemplateId(), 'creator' => $this->_user->uniqueId, 'name' => $post['tplname-' . $number], 'content' => $post['tplcontent-' . $number], 'ordernum' => (int) $post['tplordernum-' . $number]);
                 if (!$daoTemplate->createTemplate($tplParams)) {
                     continue;
                 }
             }
         }
     }
     $this->_writeLog(Dao_Td_Log_Log::TYPE_BOARD, $boardId, Dao_Td_Log_Log::ACTION_CREATE, $params);
     $config = $this->bootstrap->getOption('httpsqs');
     $httpsqs = new Oray_Httpsqs($config['host'], $config['port'], $config['chartset'], $config['name']);
     $httpsqs->put(implode(' ', array('board', 'create', '', http_build_query(array()))), 'notify');
     return $this->json(true, $this->lang['board_create_success'], $boardId);
 }
Example #2
0
 /**
  * Construct
  *
  * @param array $record
  */
 public function __construct(array $record)
 {
     $this->orgId = $record['orgid'];
     $this->boardId = $record['boardid'];
     $this->type = $record['type'];
     $this->parentId = $record['parentid'];
     $this->boardName = $record['boardname'];
     $this->ownerId = $record['ownerid'];
     $this->memo = $record['memo'];
     $this->moderators = Dao_Td_Board_Board::formatModerator(trim($record['moderators']), ',');
     $this->groups = Dao_Td_Board_Board::formatGroups($record['groups']);
     $this->status = $this->_toInt($record['status']);
     $this->privacy = $this->_toBoolean($record['privacy']);
     $this->protect = $this->_toBoolean($record['protect']);
     $this->isClassify = $this->_toBoolean($record['isclassify']);
     $this->needConfirm = $this->_toBoolean($record['needconfirm']);
     $this->flowOnly = $this->_toBoolean($record['flowonly']);
     $this->orderNum = $this->_toInt($record['ordernum']);
     $this->isSystem = 'system' == $record['type'];
     $this->weight = isset($record['weight']) ? $this->_toInt($record['weight']) : null;
     $this->isAttention = array_key_exists('uniqueid', $record) ? (bool) $record['uniqueid'] : null;
     parent::__construct();
 }