public function edit($postArr) { if (!$postArr) { return array('status' => 0, 'msg' => '请填定完成的资料'); } if (!$postArr['Id']) { return array('status' => 0, 'msg' => '您需要编辑的公告不存在'); } if (!$postArr['title']) { return array('status' => 0, 'msg' => '请填定完成的资料'); } if (!$postArr['content']) { return array('status' => 0, 'msg' => '请填定完成的资料'); } if ($postArr['kind'] == '') { return array('status' => 0, 'msg' => '请选择分类'); } if (!count($postArr['users'])) { return array('status' => 0, 'msg' => '请选择用户'); } $users = serialize($postArr['users']); $this->_utilRbac = $this->_getGlobalData('Util_Rbac', 'object'); $userClass = $this->_utilRbac->getUserClass(); $updateArr = array(); $updateArr['user_id'] = $userClass['_id']; $updateArr['title'] = $postArr['title']; $updateArr['content'] = $postArr['content']; $updateArr['create_time'] = CURRENT_TIME; $updateArr['kind'] = $postArr['kind']; $updateArr['not_read'] = $users; if (parent::add($updateArr)) { $id = $this->returnLastInsertId(); #------向用户发送消息------# $sendMsg = array(); $sendMsg['type'] = $updateArr['kind'] ? '2' : '1'; $sendMsg['title'] = $postArr['title']; $sendMsg['href'] = Tools::url('ServiceTools', 'NoticeShow', array('Id' => $id, 'doaction' => 'show')); $this->_utilUserMailManage = $this->_getGlobalData('Util_UserMailManage', 'object'); $this->_utilUserMailManage->addUser($postArr['users']); $this->_utilUserMailManage->addMail($sendMsg); $this->_utilUserMailManage->send(); $error = $this->_utilUserMailManage->getFailureUser(); #------向用户发送消息------# $this->delById($postArr['Id']); $this->_modelBulletinDate = $this->_getGlobalData('Model_BulletinDate', 'object'); $this->_modelBulletinDate->addBulletin($id); return array('status' => 1, 'msg' => $error); } else { return array('status' => 0, 'msg' => '添加失败'); } }
/** * 公告 */ 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(); }