Пример #1
0
 /**
  * 公告
  */
 private function _index()
 {
     $this->_utilRbac = $this->_getGlobalData('Util_Rbac', 'object');
     $userClass = $this->_utilRbac->getUserClass();
     $this->_modelBulletinDate = $this->_getGlobalData('Model_BulletinDate', 'object');
     $this->_loadCore('Help_SqlSearch');
     $this->_loadCore('Help_Page');
     $helpSqlSearch = new Help_SqlSearch();
     $helpSqlSearch->set_tableName($this->_modelBulletinDate->tName());
     $helpSqlSearch->setPageLimit($_GET['page'], 4);
     $helpSqlSearch->set_orderBy('date desc');
     $sql = $helpSqlSearch->createSql();
     $helpPage = new Help_Page(array('total' => $this->_modelBulletinDate->findCount(), 'perpage' => 4));
     $dateList = $this->_modelBulletinDate->select($sql);
     //找到这四天的记录
     if ($dateList) {
         $users = $this->_getGlobalData('user');
         $this->_modelBulletin = $this->_getGlobalData('Model_Bulletin', 'object');
         $bulletinKind = $this->_modelBulletin->createBulletinKind();
         foreach ($dateList as &$date) {
             $date['date'] = strtotime($date['date']);
             $date['date'] = date('Y-m-d', $date['date']);
             $ids = unserialize($date['child_ids']);
             if (count($ids)) {
                 $list = $this->_modelBulletin->findByIds($ids);
                 if (count($list)) {
                     //如果有记录
                     foreach ($list as &$childList) {
                         $childList['word_kind'] = $bulletinKind[$childList['kind']];
                         $childList['create_time'] = date('H:i:s', $childList['create_time']);
                         $childList['word_user_id'] = $users[$childList['user_id']]['nick_name'];
                         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]['nick_name'];
                             }
                             $childList['word_not_read'] = implode(',', $childList['word_not_read']);
                         }
                     }
                     $date['list'] = $list;
                 }
             }
         }
         $this->_view->assign('dataList', $dateList);
     }
     $this->_view->assign('pageBox', $helpPage->show());
     $this->_view->set_tpl(array('body' => 'ServiceTools/Index.html'));
     $this->_utilMsg->createNavBar();
     $this->_view->display();
 }