Пример #1
0
 private function _list()
 {
     $this->_utilRbac = $this->_getGlobalData('Util_Rbac', 'object');
     $userClass = $this->_utilRbac->getUserClass();
     $this->_modelBulletin = $this->_getGlobalData('Model_Bulletin', 'object');
     $bulletinKind = $this->_modelBulletin->createBulletinKind();
     $this->_loadCore('Help_SqlSearch');
     $helpSqlSearch = new Help_SqlSearch();
     $helpSqlSearch->set_tableName($this->_modelBulletin->tName());
     $_GET['kind'] = trim($_GET['kind']);
     if ($_GET['kind'] !== '') {
         $_GET['kind'] = intval($_GET['kind']);
         $helpSqlSearch->set_conditions("kind={$_GET['kind']}");
         $this->_view->assign('selectedKind', $_GET['kind']);
     }
     $_GET['content'] = trim($_GET['content']);
     if ($_GET['content']) {
         $helpSqlSearch->set_conditions("(title like '%{$_GET['content']}%' or content like '%{$_GET['content']}%' )");
     }
     $this->_view->assign('selectedContent', $_GET['content']);
     $helpSqlSearch->set_orderBy("top desc,Id desc");
     $helpSqlSearch->setPageLimit($_GET['page']);
     $sql = $helpSqlSearch->createSql();
     $this->_loadCore('Help_Page');
     //载入分页工具
     $conditions = $helpSqlSearch->get_conditions();
     $helpPage = new Help_Page(array('total' => $this->_modelBulletin->findCount($conditions), 'perpage' => PAGE_SIZE));
     $this->_view->assign('pageBox', $helpPage->show());
     $dataList = $this->_modelBulletin->select($sql);
     $users = $this->_getGlobalData('user_index_id');
     if ($dataList) {
         foreach ($dataList as &$childList) {
             $childList['URL_top'] = Tools::url(CONTROL, ACTION, array('doaction' => 'top', 'subaction' => 'add', 'id' => $childList['Id']));
             $childList['URL_del_top'] = Tools::url(CONTROL, ACTION, array('doaction' => 'top', 'subaction' => 'del', 'id' => $childList['Id']));
             $childList['word_kind'] = $bulletinKind[$childList['kind']];
             $childList['create_time'] = date('Y-m-d H:i:s', $childList['create_time']);
             $childList['word_user_id'] = $users[$childList['user_id']];
             if (strpos($childList['content'], '\\')) {
                 $childList['content'] = str_replace('\\', '', $childList['content']);
             }
             $childList['not_read'] = unserialize($childList['not_read']);
             $childList['url_edit'] = Tools::url(CONTROL, 'Notice', array('Id' => $childList['Id'], 'doaction' => 'edit'));
             $childList['url_del'] = Tools::url(CONTROL, 'Notice', array('Id' => $childList['Id'], 'doaction' => 'del'));
             if (count($childList['not_read'])) {
                 //如果还有未读用户
                 if (array_search($userClass['_id'], $childList['not_read']) !== false) {
                     //如果当前登录用户没有读取这个邮件的话
                     $childList['user_no_read'] = true;
                     //设为用户未读这个邮件
                 }
                 $childList['word_not_read'] = array();
                 foreach ($childList['not_read'] as $userId) {
                     $childList['word_not_read'][$userId] = $users[$userId];
                 }
                 $childList['word_not_read'] = implode(',', $childList['word_not_read']);
             }
         }
     }
     $bulletinKind[''] = '所有';
     $this->_view->assign('kind', $bulletinKind);
     $this->_view->assign('dataList', $dataList);
     $this->_view->set_tpl(array('body' => 'ServiceTools/NoticeSearch.html'));
     $this->_utilMsg->createNavBar();
     $this->_view->display();
 }