public static function sendMsg($phone, $prefix, $content) { $configModel = new Model_Sysconfig(); $configs = $configModel->getConfig(0); $prefix = $configs['cfg_webname']; $msg = new Msg($configs['cfg_sms_username'], $configs['cfg_sms_password']); $status = $msg->sendMsg($phone, $prefix, $content); $status = json_decode($status); return $status; }
/** * 查看站内信 */ public function action_view() { $this->template->msgId = $msgId = (int) $this->getQuery('msg_id'); $select = DB::select('mb.*', 'msgs.title', 'msgs.content', 'msgs.msg_time', 'u2.username', array('u.username', 'send_username'), 'msgs.msg_time', 'msgs.title')->from(array('msg_boxs', 'mb'))->join('msgs')->on('msgs.msg_id', '=', 'mb.msg_id')->join(array('users', 'u'))->on('u.uid', '=', 'mb.uid')->join(array('users', 'u2'))->on('u2.uid', '=', 'msgs.uid')->where('mb.type', '=', 'inbox')->where('mb.is_del', '=', '0')->where('mb.uid', '=', $this->auth['uid'])->where('mb.msg_id', '=', $msgId); $msg = new Msg($this->auth['uid']); $msg->setRead($msgId); $this->template->info = $info = $select->execute()->current(); if ($this->isPost()) { $receiver = trim($this->getPost('receiver')); $title = trim($this->getPost('title')); $content = trim($this->getPost('content')); try { $msg->sendMsg($receiver, $title, $content, 0); $links[] = array('text' => '返回收件箱', 'href' => '/message/list'); $this->show_message('回复邮件成功', 1, array(), true); } catch (Exception $e) { $this->show_message($e->getMessage(), 0, array(), true); } } }
/** * 接收加为好友的请求 * * @param integer $firendUid * @throws EGP_Exception */ public function action_accept() { $accept_uid = (int) $this->getQuery('uid', 17); $user = ORM::factory('user'); $userInfo = $user->where('uid', '=', $accept_uid)->find(); $info = DB::select('friends.*', 'users.username')->from('friends')->join('users')->on('users.uid', '=', 'friends.friend_uid')->where('friends.uid', '=', $accept_uid)->where('friends.friend_uid', '=', $this->auth['uid'])->execute()->current(); if (empty($info)) { $this->show_message('无效的好友请求!'); } if ($info['is_audit'] == 1) { $this->show_message('您已经审核过该请求,请不要重复操作!'); } //更新审核状态 $set = array('is_audit' => 1); DB::update('friends')->set($set)->where('uid', '=', $accept_uid)->where('friend_uid', '=', $this->auth['uid'])->execute(); //添加另一方列表 $data = array('uid', 'friend_uid', 'apply_time', 'is_audit'); DB::insert('friends', $data)->values(array($this->auth['uid'], $accept_uid, time(), 1))->execute(); $content = "<img src='/images/icon/group.gif'> <a href='/user/view?uid={$this->auth['uid']}'>{$this->auth['username']}</a> 已经通过您的好友请求并将您加为好友。"; try { $msg = new Msg($this->auth['uid']); $msg->sendMsg($userInfo->username, '审核好友信息', $content); $this->show_message('成功审核并添加对方为好友!'); } catch (Exception $e) { $this->show_message($e->getMessage()); } }