Esempio n. 1
0
 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' => '添加失败');
     }
 }