categorydao = new CategoryDao ();
$this->userdao = new UserDao ();
$this->questiondao = new QuestionDao ();
$this->creditdao = new CreditDao ();
$this->answerdao = new AnswerDao ();
$this->messagedao = new MessageDao ();
$this->groupdao = new GroupDao ();
$this->sessiondao = new SessionDao ();
$this->userlogdao = new UserlogDao ();
$this->crontadstatusdao = new CrontadstatusDao ();
$this->credit3logdao = new Credit3logDao ();
$this->authissuedao = new AuthissueDao ();
$this->vipquestiondao = new VipquestionDao ();
$this->vipanswerdao = new VipanswerDao ();
Doo::loadModel ( 'ExamineDao' );
$this->examinedao = new ExamineDao ();
}
/**
* 完善名师问题
* @param unknown_type $id
* @param unknown_type $title
* @param unknown_type $description
*/
function update_vip_question($id = 0, $title = "", $description = "", $uid = 0, $phone = "", $qq = "") {
$this->vipquestiondao->id = $id;
$this->vipquestiondao->title = $title;
$this->vipquestiondao->description = $description;
$this->vipquestiondao->time = get_date ();
$this->vipquestiondao->status = PAID_FILL_IN;
$result = $this->db ()->update ( $this->vipquestiondao );
//更新今天发布数--需要修改每时间段的更新次数-setp2
$this->authissuedao->set_authissue_totals ( $uid );
//添加积分值-setp2
$this->set_credit1 ( 'add', $uid, CREDIT_POINT_ADD, CREDIT_ACTION_ADD );
$que_rs = $this->vipquestiondao->get_vip_question_by_id ( $id );
//加入检索索引-分词还未加入-数据配置--等待搜索页面
//$pams = array ('id' => $id, 'price' => $que_rs ['price'], 'author' => $que_rs ['author'], 'authorid' => $uid, 'title' => $title, 'description' => $description, 'supply' => '', 'time' => $this->vipquestiondao->time, 'hot' => 0, 'status' => PAID_FILL_IN, 'answers' => 0, 'answer' => '' );
//$this->add_search_index ( $pams, SEARCH_WD_DB, SEARCH_VIP_INI );
$this->userdao->uid = $uid;
if (! empty ( $phone ))
$this->userdao->phone = $phone;
if (! empty ( $qq ))
$this->userdao->qq = $qq;
$result = $this->db ()->update ( $this->userdao );
if($result){
include SITE_PATH . '/protected/config/set_email_to_admin.conf.php';
$list=explode("-", $sys ['set_email']);
foreach ($list as $value){
if(filter_var($value, FILTER_VALIDATE_EMAIL))
$this->_mail("有用户发布了名师答疑,赶紧去后台查看:问答后台","有新的名师答疑提问",$value);
}
}
}
/**
* 添加名师问题
* @param unknown_type $data
*/
function add_vip_question($data = array()) {
$this->vipquestiondao->status = PAID_NO_FILL_IN;
$price = abs ( $data ['price'] );
$this->vipquestiondao->price = $price;
$this->credit3logdao->amount = $price;
$this->vipquestiondao->author = $data ['author'];
$this->credit3logdao->username = $data ['author'];
$this->vipquestiondao->authorid = $data ['authorid'];
$time = get_date ();
$this->vipquestiondao->time = $time;
$this->credit3logdao->time = $time;
$ip = client_ip ();
$this->vipquestiondao->ip = $ip;
$this->credit3logdao->ip = $ip;
$this->vipquestiondao->refunds = 1;
//扣除通行证金额
if ($data ['price'] > 0) {
//扣除通行证的钱 //用户表和记录表
$is = $this->set_credit3 ( - $data ['price'], $data ['authorid'], RICH_ACTION_OFFER, SSO_UID );
if (!$is)
return 0;
}
$result = $this->db ()->insert ( $this->vipquestiondao );
//发邮件
$this->send_email ( $data ['authorid'], "VIP_PAY_FORMONEY", $result, 0 );
if ($result) {
//扣除财富值--财富值记录
if ($data ['price'] > 0) {
$this->credit3logdao->qid = $result;
$action = $this->credit3logdao->set_ACTION_ADD_VIP_QUESTION ();
$this->credit3logdao->add_credit3_log ( $data ['authorid'], $data ['author'], $result, $action, - $price, $ip, 1 );
}
//发布系统信息
$subject = "您的新问题(" . $result ['title'] . ")";
$content = $this->messagedao->set_MESSAGE_ADD_VIP_PAID ();
$this->messagedao->send_message ( ADMIN_NAME, 0, $data ['authorid'], $subject, $content );
}
return $result;
}
/**
* 会话推出
* @param unknown_type $sid
*/
function delete_session($sid = "") {
$rs = $this->sessiondao->get_seesion ( $sid );
$this->userlogdao->uid = $rs ['uid'];
$this->userlogdao->username = $rs ['username'];
$this->userlogdao->ip = client_ip ();
$this->userlogdao->time = get_date ();
$action = $this->userlogdao->set_USER_EXIT ();
$this->userlogdao->set_userlog ( $rs ['uid'], $rs ['username'], $action, client_ip () );
$this->sessiondao->sid = $sid;
$this->db ()->delete ( $this->sessiondao );
}
/**
* 完成任务
* @param unknown_type $uid
* @param unknown_type $mission_type
*/
function complete_daily_crontab($uid = 0, $mission_type = 0) {
$this->crontadstatusdao->complete_crontab ( $uid, $mission_type );
}
/**
* 获取任务进行状态
* @param unknown_type $uid
* @param unknown_type $mission_type
*/
function get_crontab_status($uid = 0, $mission_type = 0) {
$time = get_date ();
//$this->crontadstatusdao->delete_crontab();
//每日登录任务
if ($mission_type == SYSTEM_DAILY_LOGIN) {
$rs = $this->crontadstatusdao->get_crontab_status ( $uid, $mission_type );
$day = get_today ();
if (empty ( $rs )) {
$this->crontadstatusdao->uid = $uid;
$this->crontadstatusdao->cid = $mission_type;
$this->crontadstatusdao->status = NOT_COMPLETED;
$this->crontadstatusdao->time = $time;
$this->db ()->insert ( $this->crontadstatusdao );
return NOT_COMPLETED;
} elseif ($rs ['time'] < $day ['start'])
return DOING;
elseif ($rs ['status'] != 2 && $rs ['time'] > $day ['start']) {
return DOING;
} else
return COMPLETE;
}
}
/**
* 记录用户日志
* @param unknown_type $uid
* @param unknown_type $username
*/
function set_userlog($uid = 0, $username = "") {
$this->userlogdao->uid = $uid;
$this->userlogdao->username = $username;
$this->userlogdao->ip = client_ip ();
$this->userlogdao->time = get_date ();
$this->userlogdao->action = $this->userlogdao->set_USER_LOGIN_LOG ();
//设置用户日志
$result = $this->db ()->insert ( $this->userlogdao );
}
/**
* 设置会话
* @param unknown_type $sessionID
* @param unknown_type $uid
* @param unknown_type $username
* @param unknown_type $lifetime
*/
function set_session($sessionID = "", $uid = 0, $username = "", $lifetime = 0) {
$this->sessiondao->sid = $sessionID;
$this->sessiondao->uid = $uid;
$this->sessiondao->username = $username;
$this->sessiondao->islogin = 1;
$this->sessiondao->ip = client_ip ();
$this->sessiondao->time = get_date ();
$this->sessiondao->lifetime = $lifetime;
//设置会话
$result = $this->db ()->insert ( $this->sessiondao );
}
/**
* 添加用户--是否要发系统信息
*/
function add_user($username = "", $password = "") {
$this->userdao->username = $username;
$this->userdao->password = $password;
$this->userdao->groupid = USER_LV1;
$this->userdao->credits = POINT_REGISTER;
$this->userdao->credit1 = POINT_REGISTER;
$this->userdao->regip = client_ip ();
$this->userdao->regtime = get_date ();
//添加用户
$result = $this->db ()->insert ( $this->userdao );
//注册加20分
$this->creditdao->set_credit_log ( $result, ACTION_REGISTER, POINT_REGISTER, 0, 0 );
return $result;
}
/**
* 添加用户--是否要发系统信息
*/
function add_user2($param) {
$this->userdao->username = $param['username'];
$this->userdao->password = $param['password'];
$this->userdao->email = $param['email'];
$this->userdao->phone = $param['mobile'];
$this->userdao->groupid = USER_LV1;
$this->userdao->credits = POINT_REGISTER;
$this->userdao->credit1 = POINT_REGISTER;
$this->userdao->regip = client_ip ();
$this->userdao->regtime = get_date ();
//添加用户
$result = $this->db ()->insert ( $this->userdao );
//注册加20分
$this->creditdao->set_credit_log ( $result, ACTION_REGISTER, POINT_REGISTER, 0, 0 );
return $result;
}
/**
* 更新用户信息
* @param unknown_type $params
*/
function update_user2($id,$params) {
$this->userdao->uid = $id;
$this->userdao->phone = $params ['phone'];
$this->userdao->password = md5 ( $params ['password'] );
$this->userdao->email = $params ['email'];
$this->userdao->groupid = $params ['groupid'];
$this->userdao->credits = $params ['credits'];
$this->userdao->credit1 = $params ['credit1'];
$this->userdao->gender = $params ['gender'];
$this->userdao->bday = $params ['bday'];
$this->userdao->qq = $params ['qq'];
$this->userdao->msn = $params ['msn'];
$this->userdao->signature = $params ['signature'];
$this->userdao->expert = $params ['expert'];
$this->userdao->cids=$params['cids'];
$result = $this->db ()->update ( $this->userdao );
}
/**
* 根据用户ID删除,和删除相关信息
*/
function delete_user_tem($uid = 0) {
//删除问题
$this->questiondao->delete_question_by_authorid ( $uid );
//删除回答
$this->answerdao->delete_answer_by_authorid ( $uid );
//删除用户积分记录--之后还有财富记录
$this->creditdao->delete_credit_by_uid ( $uid );
$this->userdao->uid = $uid;
$this->db ()->delete ( $this->userdao );
}
/**
* 将问题设置为未解决-值针对已关闭
* @param unknown_type $id
*/
function update_question_list($id = array()) {
$id=implode(",", $id);
$queList=array();
if(!empty($id))
$queList=$this->questiondao->get_questions_By_Idlist($id);
foreach ($queList as $key=>$value){
$question = new QuestionDao ();
$question->id=$value['id'];
$question->status=QUESTOIN_STATUS_UNRESOLVED;
$question->time=time();
$question->update();
}
}
/**
* 删除选中问题
* @param unknown_type $id
*/
function delete_question_list($id = array()) {
$this->questiondao->delete_question_list ( $id );
//删除索引
$this->delete_search_index ( $id, SEARCH_WD_DB, SEARCH_INI );
}
/**
* 删除选中问题
* @param unknown_type $id
*/
function delete_answer_list($id = array()) {
$this->answerdao->delete_answer_list ( $id );
}
/**
* 删除一个用户组
* @param unknown_type $groupid
*/
function delete_group($groupid = 0) {
if ($groupid <= GROUPIDLIMIT)
return false;
$this->groupdao->groupid = $groupid;
$this->db ()->delete ( $this->groupdao );
}
/**
* 添加一条用户组
* @param unknown_type $params
*/
function add_group($params = array()) {
if (empty ( $params ))
return false;
$this->groupdao->grouptitle = $params ['grouptitle'];
$this->groupdao->grouptype = 2;
$result = $this->db ()->insert ( $this->groupdao );
}
/**
* 批量更新用户组
* @param unknown_type $params
*/
function update_group_list($params) {
$pa = array ();
$co = array ();
$wh = array ();
$count = count ( $params ['groupid'] );
foreach ( $params as $key => $value ) {
array_push ( $pa, $key );
if ($key != "groupid") {
array_push ( $wh, $key . "=VALUES(" . $key . ")" );
}
}
//获取更新内容
for($i = 0; $i < $count; $i ++) {
$tm = array ();
foreach ( $pa as $k ) {
array_push ( $tm, "'" . $params [$k] [$i] . "'" );
}
$tm = implode ( ",", $tm );
array_push ( $co, "(" . $tm . ")" );
}
$pa = implode ( ",", $pa );
$wh = implode ( ",", $wh );
$co = implode ( ",", $co );
$this->groupdao->update_group_list ( $pa, $co, $wh );
}
/**
* 删除用户和问答
* @param unknown_type $uid
*/
function delete_user_and_QA($uid = array()) {
$this->userdao->delete_user_and_QA ( $uid );
}
/**
* 删除用户
* @param unknown_type $uid
*/
function delete_user($uid = array()) {
$this->userdao->delete_user ( $uid );
}
function update_user_avatar_by_id($uid, $avatar) {
Doo::loadModel ( 'UserDao' );
$userdao = new UserDao ();
$userdao->uid = $uid;
$userdao->avatar = $avatar;
$userdao->lastlogin = time ();
$result = $this->db ()->update ( $userdao );
}
/**
* 更新用户信息
* @param unknown_type $params
*/
function update_user($params) {
$this->userdao->uid = $params ['uid'];
$this->userdao->phone = $params ['phone'];
$this->userdao->password = md5 ( $params ['password'] );
$this->userdao->email = $params ['email'];
$this->userdao->groupid = $params ['groupid'];
$this->userdao->credits = $params ['credits'];
$this->userdao->credit1 = $params ['credit1'];
$this->userdao->gender = $params ['gender'];
$this->userdao->bday = $params ['bday'];
$this->userdao->qq = $params ['qq'];
$this->userdao->msn = $params ['msn'];
$this->userdao->signature = $params ['signature'];
$this->userdao->expert = $params ['expert'];
$this->userdao->cids=$params['cids'];
$result = $this->db ()->update ( $this->userdao );
}
/**
* 更新退款机会
* @param unknown_type $refunds
*/
function update_user_refunds($refunds = array()) {
$this->userdao->uid = $refunds ['uid'];
$this->userdao->refunds = $refunds ['refunds'];
$result = $this->db ()->update ( $this->userdao );
}
/**
* 获取用户组
*/
function get_group() {
$result = $this->groupdao->get_group ();
$re = array ('sys' => array (), 'user' => array (), 'vip_user' => array () );
foreach ( $result as $value ) {
if ($value ['grouptype'] == 1)
array_push ( $re ['sys'], $value );
elseif ($value ['grouptype'] == 2)
array_push ( $re ['user'], $value );
elseif ($value ['grouptype'] == 3)
array_push ( $re ['vip_user'], $value );
}
return $re;
}
/**
* 设置赞同数
* @param unknown_type $aid
* @param unknown_type $uid 登录者UID
*/
function update_support_answer($aid = 0, $uid = 0) {
$user = $this->userdao->get_userinfo_by_uid ( $uid );
$aids_ar = explode ( ",", $user ['aids'] );
if (in_array ( $aid, $aids_ar ))
return false;
//记录谁赞同
$data ['aids'] = $user ['aids'] . "," . $aid;
if (empty ( $user ['aids'] ))
$data ['aids'] = $aid;
$condition = " ,elect=elect+1 where uid = " . $uid;
$this->userdao->update_user ( $data, $condition );
//更新赞同数
$this->answerdao->update_support_answer ( $aid );
//更新赞同操作
$rs = $this->answerdao->get_answer_by_id ( $aid );
$this->questiondao->set_question_goods ( $rs ['qid'] );
//加积分
$this->set_credit1 ( 'add', $user ['uid'], POINT_SUPPORT, ACTION_SUPPORT );
return true;
}
/**
* 设置最佳答案--整理
* @param unknown_type $qid
*/
function set_best_answer($data = array()) {
$type = "ADOPT_ANSWER";
if ($data ['price'] > 0) {
//获取回答用户的通行证ID
$sso_info = $this->get_sso_user_info_by_name ( $data ['username'] );
$is = $this->set_credit3 ( + $data ['price'], $data ['auid'], RICH_ACTION_ADOPT, $sso_info [0] ['id'] );
$type = "PAY_ADOPT_ANSWER";
if ($is == 0)
return $is;
}
//更新问题
$data_question ['endtime'] = get_date ();
$data_question ['status'] = ADOPT;
$condition = " where id = " . $data ['qid'];
$this->questiondao->update_question ( $data_question, $condition );
//更新答案
$data_answer ['adopttime'] = $data_question ['endtime'];
$data_answer ['comment'] = $data ['comment'];
$data_answer ['status'] = ADOPT;
$condition = " where id = " . $data ['aid'];
$this->answerdao->update_answer ( $data_answer, $condition );
//发送邮件
$this->send_email ( $data ['auid'], $type, $data ['qid'], $data ['aid'] );
//更新回答用户信息积分信息
$this->userdao->add_credit1 ( POINT_ADOPT, $data ['auid'], ACTION_ADOPT );
if ($data ['price'] > 0) {
//财富操作记录, 将用户财富划到回答方
//$this->userdao->add_credit3 ( + $data ['price'], $data ['auid'], RICH_ACTION_ADOPT );
//财富流向表
$this->credit3logdao->qid = $data ['qid'];
$this->credit3logdao->ip = client_ip ();
$this->credit3logdao->amount = $data ['price'];
$this->credit3logdao->username = $data ['username'];
$this->credit3logdao->time = get_date ();
$action = $this->credit3logdao->set_ACTION_ADOPT_QUESTION ();
$this->credit3logdao->add_credit3_log ( $data ['auid'], $data ['username'], $data ['qid'], $action, $data ['price'], $this->credit3logdao->ip );
}
//更新该用户的采纳数
$this->userdao->add_adopts ( $data ['auid'], 1 );
$p = "";
if ($data ['price'] > 0)
$p = "获得¥" . $data ['price'] . "元";
//发送系统信息-发送给发回答用户
$subject = "回答 " . $data ['title'] . " 被采纳为最佳答案 " . $p;
$content = "回答 " . $data ['title'] . " 被采纳为最佳答案 " . $p;
$this->messagedao->send_message ( ADMIN_NAME, 0, $data ['auid'], $subject, $content );
}
/**
* 获取通行证用户头像--
* @param unknown_type $username
*/
function get_user_avatar_by_username($username = "", $client = "") {
if (empty ( $client )) {
require_once (SITE_PATH . '/protected/plugin/client.php');
$client = new client ( ZHSSO );
}
$avatar = array ('180' => DEF_AVATAR, '30' => DEF_AVATAR, '90' => DEF_AVATAR, '45' => DEF_AVATAR );
$userinfo = $client->zhsso_getUserbyName ( $username );
$userinfo = explode ( "\r", $userinfo );
$ts = json_decode ( $userinfo ['1'], true );
//$avatar = $client->url_exists($client->ps_getavatar($ts[0]['id'])) ? $client->ps_getavatar($ts[0]['id']) : DEF_AVATAR;
if (isset ( $ts ) && ! empty ( $ts )) {
$avatar = $client->ps_getavatar ( $ts [0] ['id'] );
}
return $avatar;
}
/**
* 获取用户相关信息
* @param unknown_type $data
* @param unknown_type $condition
* @param unknown_type $limit
*/
function get_users_list($data = array(), $condition = "", $limit = "") {
$result = $this->userdao->get_users_list ( $data, $condition, $limit );
$src = "";
$now = 1;
foreach ( $result as $key => $value ) {
$lv = get_lv ( $value ['credit1'] );
$result [$key] ['lv'] = $lv [0];
$result [$key] ['lv_max'] = $lv [1];
$result [$key] ['lv_need'] = $lv [1] - $value ['credit1'];
$result [$key] ['lv_percent'] = $value ['credit1'] / $lv [1] * 100;
$result [$key] ['category'] = "";
$result [$key] ['question'] = "";
$result [$key] ['lastlogin'] = my_date_format2 ( $value ['lastlogin'], "Y-m-d H:i:s" );
//$avatar = $this->get_user_avatar_by_username ( $value ['username'] );
$avatar = json_decode ( $value ['avatar'], true );
if (empty ( $avatar ))
$avatar = array ('180' => DEF_AVATAR, '30' => DEF_AVATAR, '90' => DEF_AVATAR, '45' => DEF_AVATAR );
$result [$key] ['avatar'] = $avatar;
$cidsList = json_decode ( $value ['cids'] );
if(!empty($cidsList)){
foreach ( $cidsList as $c_key => $values ) {
$list = explode ( ":", $values );
$src .= "" .$list[1] . " ";
}
$result [$key] ['category'] = $src;
}
//读取专家分类
// if (! empty ( $value ['cids'] )) {
// $condition = " and id in (" . $value ['cids'] . ") ";
//
// $c_result = $this->categorydao->get_category_list ( array (), $condition, "" );
//
// $src = "";
//
// foreach ( $c_result as $c_key => $c_value ) {
//
// $src .= "" . $c_value ['name'] . " ";
// }
// $result [$key] ['category'] = $src;
// }
$result [$key] ['now'] = $now;
//获取相关问题
$param ['authorid'] = $value ['uid'];
$limit = " order by time desc limit 0 , 3 ";
$q_result = $this->get_list ( $param, "", $limit, t_answer );
$src = "";
if (! empty ( $q_result )) {
foreach ( $q_result as $q_key => $q_value ) {
$src .= "" . $q_value ['title'] . "";
}
$result [$key] ['question'] = $src;
}
$now ++;
}
return $result;
}
/**
* 根据用户名获取信息
*/
function get_users_by_name($username = "") {
$result = $this->userdao->get_users_by_name ( $username );
return $result;
}
function get_group_by_id($id = 0) {
$rs = $this->groupdao->get_group_by_id ( $id );
return $rs;
}
/**
* 获取用户基本信息
* @param unknown_type $uid
* @return $result array;
*/
function get_users_information($uid = 0) {
if ($uid == 0 || (! is_numeric ( $uid )))
return array ();
$result = $this->userdao->get_userinfo_by_uid ( $uid );
if (empty ( $result ))
return array ();
$lv = get_lv ( $result ['credit1'] );
$result ['lv'] = $lv [0];
$result ['lv_max'] = $lv [1];
$result ['lv_need'] = $lv [1] - $result ['credit1'];
$result ['lv_percent'] = $result ['credit1'] / $lv [1] * 100;
$result ['credit3'] = 0;
if (defined ( 'CREDIT3' ))
$result ['credit3'] = CREDIT3;
$result ['email'] = "";
if (defined ( 'EMAIL' ))
$result ['email'] = EMAIL;
$cidsList = json_decode ( $result ['cids'] );
$cids=array();
$cids_key = array ();
$cids_name = array ();
if(!empty($cidsList)){
foreach ( $cidsList as $key => $value ) {
$list = explode ( ":", $value );
array_push ( $cids_key, $list [0] );
array_push ( $cids_name, $list [1] );
}
$result ['cids'] = implode(",", $cids_key);
$cids = array_combine($cids_key, $cids_name);
$result ['cids_json'] = $cids;
}
return $result;
}
/**
* 添加一个问题
* @param unknown_type $data
* @return $result 问题ID;
*/
function add_examine_question($data = array()) {
$this->examinedao->title = $data ['title'];
$this->examinedao->cid = $data ['category_id'];
$this->examinedao->description = $data ['description'];
//取绝对值
$price = abs ( $data ['price'] );
$this->examinedao->price = $price;
$this->examinedao->author = $data ['author'];
$this->examinedao->authorid = $data ['authorid'];
$this->examinedao->time = get_date ();
$this->examinedao->endtime = get_date ( 15 );
$this->examinedao->ip = client_ip ();
$result = $this->db ()->insert ( $this->examinedao );
//添加提问数
//$this->set_questions ( 'add', $data ['authorid'], $data ['category_id'] );
return $result;
/**
* --------------------
//审批成功后 才记录一下相关信息
$this->credit3logdao->ip = $this->questiondao->ip;
$this->credit3logdao->amount = $price;
$this->credit3logdao->username = $data ['author'];
$this->credit3logdao->uid = $data ['authorid'];
$this->credit3logdao->time = $this->questiondao->time;
//扣除金额后才可以添加问题
if ($data ['price'] > 0) {
$is = $this->set_credit3 ( - $data ['price'], $data ['authorid'], RICH_ACTION_OFFER, SSO_UID );
if ($is == 0)
return 0;
}
//推广手段
if($data['price']==0){
$fundstr=file_get_contents(SITE_PATH . '/protected/config/fund.conf.php') ;
if($fundstr){
//获取基金
Doo::loadModel ( 'FundDao' );
$funddao = new FundDao ();
$fund=$funddao->get_fund_by_amount();
if(!empty($fund)){
$funddao->set_fund_amount_spread("-1",$fund['id']);
$this->questiondao->price=1;
}
}
}
//发送邮件
if ($data ['price'] > 0) {
$this->send_email ( $data ['authorid'], "PAY_FORMONEY", $result, 0 );
}
//是否需要优化
if ($result) {
//扣除财富值--财富值记录
if ($data ['price'] > 0) {
$this->credit3logdao->qid = $result;
$action = $this->credit3logdao->set_ACTION_OFFER_QUESTION ();
$this->credit3logdao->add_credit3_log ( $data ['authorid'], $data ['author'], $result, $action, - $price, $this->questiondao->ip );
}
//更新今天发布数--需要修改每时间段的更新次数
$this->authissuedao->set_authissue_totals ( $data ['authorid'] );
//添加积分值
$this->set_credit1 ( 'add', $data ['authorid'], CREDIT_POINT_ADD, CREDIT_ACTION_ADD );
}
return $result;
*/
}
/**
* 添加一个问题
* @param unknown_type $data
* @return $result 问题ID;
*/
function add_question($data = array()) {
$this->questiondao->title = $data ['title'];
$this->questiondao->cid = $data ['category_id'];
$this->questiondao->description = $data ['description'];
//取绝对值
$price = abs ( $data ['price'] );
$this->questiondao->price = $price;
$this->credit3logdao->amount = $price;
$this->questiondao->author = $data ['author'];
$this->credit3logdao->username = $data ['author'];
$this->questiondao->authorid = $data ['authorid'];
$this->credit3logdao->uid = $data ['authorid'];
$this->questiondao->time = get_date ();
$this->credit3logdao->time = $this->questiondao->time;
$this->questiondao->endtime = get_date ( 15 );
$this->questiondao->ip = client_ip ();
$this->credit3logdao->ip = $this->questiondao->ip;
//扣除金额后才可以添加问题
if ($data ['price'] > 0) {
$is = $this->set_credit3 ( - $data ['price'], $data ['authorid'], RICH_ACTION_OFFER, SSO_UID );
if ($is == 0)
return 0;
}
//推广手段
if($data['price']==0){
$fundstr=file_get_contents(SITE_PATH . '/protected/config/fund.conf.php') ;
if($fundstr){
//获取基金
Doo::loadModel ( 'FundDao' );
$funddao = new FundDao ();
$fund=$funddao->get_fund_by_amount();
if(!empty($fund)){
$funddao->set_fund_amount_spread("-1",$fund['id']);
$this->questiondao->price=1;
}
}
}
$result = $this->db ()->insert ( $this->questiondao );
//发送邮件
if ($data ['price'] > 0) {
$this->send_email ( $data ['authorid'], "PAY_FORMONEY", $result, 0 );
}
//是否需要优化
if ($result) {
//加入检索索引-分词还未加入-数据配置
//$pams = array ('id' => $result, 'cid' => $data ['category_id'], 'price' => $price, 'authorid' => $data ['authorid'], 'author' => $data ['author'], 'title' => $data ['title'], 'description' => $data ['description'], 'time' => $this->questiondao->time, 'status' => QUESTOIN_STATUS_UNRESOLVED );
//$this->add_search_index ( $pams );
//扣除财富值--财富值记录
if ($data ['price'] > 0) {
$this->credit3logdao->qid = $result;
$action = $this->credit3logdao->set_ACTION_OFFER_QUESTION ();
$this->credit3logdao->add_credit3_log ( $data ['authorid'], $data ['author'], $result, $action, - $price, $this->questiondao->ip );
}
//更新今天发布数--需要修改每时间段的更新次数
$this->authissuedao->set_authissue_totals ( $data ['authorid'] );
//发布系统信息
//$subject = "问题 " . $result ['title'] . " 新的问题";
//
//$content = $this->messagedao->set_MESSAGE_ADD_QUESTION ( $data ['title'], $result );
//
//$this->messagedao->send_message ( ADMIN_NAME, 0, $data ['authorid'], $subject, $content );
//
//添加提问数
$this->set_questions ( 'add', $data ['authorid'], $data ['category_id'] );
//添加积分值
$this->set_credit1 ( 'add', $data ['authorid'], CREDIT_POINT_ADD, CREDIT_ACTION_ADD );
}
return $result;
}
/**
* 更新检索库
* @param unknown_type $params
*/
function update_vip_question_search($params) {
//$pams = array ('id' => $params ['vip_question'] ['id'], 'answers' => 1, 'answer' => $params ['answer'], 'title' => $params ['vip_question'] ['title'], 'price' => $params ['vip_question'] ['price'], 'author' => $params ['vip_question'] ['author'], 'authorid' => $params ['vip_question'] ['authorid'], 'description' => $params ['vip_question'] ['description'], 'supply' => $params ['vip_question'] ['supply'], 'time' => $params ['vip_question'] ['time_stamp'], 'hot' => $params ['vip_question'] ['hot'] );
//$this->update_search_index ( $pams, SEARCH_VWD_DB, SEARCH_VIP_INI );
}
/**
* 设置积分值
* @param unknown_type $type add or take_out
* @param unknown_type $uid
* @param unknown_type $point
* @param unknown_type $action_type
*/
function set_credit1($type = 'add', $uid = 0, $point = 0, $action_type = "") {
if ("add" == $type)
return $this->userdao->add_credit1 ( $point, $uid, $action_type );
else if ("take_out" == $type)
return $this->userdao->take_out_credit1 ( $point, $uid, $action_type );
else
return false;
}
/**
* 设置财富值
* @param unknown_type $type add or take_out
* @param unknown_type $price
* @return error_message
*/
function set_credit3($price = 0, $uid = 0, $action_type = "", $sso_uid = 0) {
if ($sso_uid == 0)
return 0;
$sso_price = abs ( $price );
//扣除或者增加通行证金额
if ($price < 0)
$is = $this->offer_price_by_sso ( $sso_price, $sso_uid );
else
$is = $this->add_price_by_sso ( $sso_price, $sso_uid );
if ($is <= 0)
return 0;
$this->userdao->add_credit3 ( $price, $uid, $action_type );
return $is;
}
/**
* 设置提问数
* @param unknown_type $type
* @param unknown_type $uid
*/
function set_questions($type = 'add', $uid = 0, $category_id = 0) {
if ("add" == $type)
return $this->userdao->add_questions ( $uid, $category_id );
else if ("take_out" == $type)
return $this->userdao->take_out_questions ( $uid, $category_id );
else
return false;
}
/**
* 设置回答数
* @param unknown_type $type
* @param unknown_type $uid 回答问题人UID
* @param unknown_type $qid 回答问题ID
*/
function set_answers($type = 'add', $uid = 0, $qid = 0) {
if ("add" == $type)
return $this->userdao->add_answers ( $uid, $qid );
else if ("take_out" == $type)
return $this->userdao->take_out_answers ( $uid, $qid );
else
return false;
}
/**
* 添加一个回答
* @param unknown_type $data
*/
function add_answer($data = array()) {
$this->answerdao->qid = $data ['qid'];
$this->answerdao->title = $data ['title'];
$this->answerdao->author = $data ['author'];
$this->answerdao->authorid = $data ['authorid'];
$this->answerdao->content = $data ['content'];
$this->answerdao->time = get_date ();
$this->answerdao->status = 1;
$this->answerdao->ip = client_ip ();
$result = $this->db ()->insert ( $this->answerdao );
if ($result > 0) {
$question = $this->questiondao->get_question_by_id ( $data ['qid'] );
//添加回答数
$this->set_answers ( 'add', $data ['authorid'], $data ['qid'] );
//添加积分值
$this->set_credit1 ( 'add', $data ['authorid'], CREDIT_POINT_ANSWER, CREDIT_ACTION_ANSWER );
$subject = "问题 " . $data ['title'] . " 有新的回答";
$content = "问题 " . $data ['title'] . " 有新的回答";
$this->messagedao->send_message ( ADMIN_NAME, 0, $question ['authorid'], $subject, $content );
$answer_list = $this->answerdao->get_answer_user_info_by_id ( $data ['qid'] );
$answer = array ();
foreach ( $answer_list as $key => $value ) {
$ans = array ();
$ans ['id'] = $value ['id'];
$ans ['qid'] = $value ['qid'];
$ans ['title'] = $value ['title'];
$ans ['authorid'] = $value ['authorid'];
$ans ['author'] = $value ['author'];
$ans ['time'] = get_date ();
$ans ['adopttime'] = $value ['adopttime'];
$ans ['content'] = $value ['content'];
$ans ['comment'] = $value ['comment'];
array_push ( $answer, $ans );
}
$ans = array ();
$ans ['id'] = $result;
$ans ['qid'] = $data ['qid'];
$ans ['title'] = $data ['title'];
$ans ['authorid'] = $data ['authorid'];
$ans ['author'] = $data ['author'];
$ans ['time'] = $this->answerdao->time;
$ans ['content'] = $data ['content'];
array_push ( $answer, $ans );
$answer = serialize ( $answer );
//更新检索库
//$pams = array ('id' => $data ['qid'], 'cid' => $question ['cid'], 'cid1' => $question ['cid1'], 'cid2' => $question ['cid2'], 'price' => $question ['price'], 'authoid' => $data ['authorid'], 'author' => $data ['author'], 'title' => $data ['title'], 'description' => $question ['description'], 'supply' => $question ['supply'], 'time' => $question ['time'], 'status' => QUESTOIN_STATUS_UNRESOLVED, 'answers' => $question ['answers'], 'answer' => $answer );
//$this->update_search_index ( $pams );
}
return $result;
}
/**
* 删除一个回答
* @param unknown_type $aid
*/
function delete_answer($aid = 0, $qid = 0) {
$this->answerdao->id = $aid;
$rs = $this->answerdao->get_answer_by_id ( $aid );
$subject = "回答 " . $rs ['title'] . " 违规被删除";
$content = "回答 " . $rs ['title'] . " 违规被删除";
$this->messagedao->send_message ( ADMIN_NAME, 0, $rs ['authorid'], $subject, $content );
$this->db ()->delete ( $this->answerdao );
$question = $this->questiondao->get_question_by_id ( $qid );
//回答数更新
$this->set_answers ( 'take_out', $question ['authorid'], $qid );
//扣除积分
$this->set_credit1 ( 'take_out', $rs ['authorid'], POINT_DELETE_ANSWER, ACTION_DELETE_ANSWER );
}
/**
* 删除一个问题
* @param unknown_type $qid
*/
function delete_question($qid) {
$condition = " where id = " . $qid;
$data ['hidden'] = 1;
$this->questiondao->update_question ( $data, $condition );
$rs = $this->questiondao->get_question_by_id ( $qid );
//扣除积分
$this->set_credit1 ( 'take_out', $rs ['authorid'], POINT_DELETE_QUESTION, ACTION_DELETE_QUESTION );
$question = $this->questiondao->get_question_by_id ( $qid );
$subject = "问题 " . $question ['title'] . " 违规被删除";
$content = "问题 " . $question ['title'] . " 违规被删除";
$this->send_sys_message ( $subject, $content, $question ['authorid'] );
}
/**
* 修改回答内容
* @param unknown_type $aid
* @param unknown_type $data
*/
function update_answer_content($aid = 0, $data) {
$condition = " where id = " . $aid;
$this->answerdao->update_answer ( $data, $condition );
}
/**
* 修改问题内容
* @param unknown_type $qid
* @param unknown_type $data
*/
function update_queston_description($qid, $data) {
$condition = " where id = " . $qid;
$this->questiondao->update_question ( $data, $condition );
}
/**
* 添加一个追问
* @param unknown_type $data
*/
function to_ask_question($data = array()) {
$data ['tag'] = serialize ( array (0 => $data ['tag'] ) );
$data ['tagtime'] = get_date ();
$this->answerdao->update_taginfo_by_id ( $data );
$rs = $this->answerdao->get_answer_by_id ( $data ['id'] );
$question = $this->questiondao->get_question_by_id ( $rs ['qid'] );
$type = "FOLLOW_QUESTION";
if ($question ['price'] > 0)
$type = "PAY_FOLLOW_QUESTION";
$this->send_email ( $rs ['authorid'], $type, $rs ['qid'], $rs ['id'] );
//发送系统信息-发送给发回答用户
$subject = "回答 " . $rs ['title'] . " 提问者向您追问";
$content = "回答 " . $rs ['title'] . " 提问者向您追问";
$this->messagedao->send_message ( ADMIN_NAME, 0, $rs ['authorid'], $subject, $content );
}
/**
* 添加一个在回答
* @param unknown_type $data
*/
function answer_again($data = array()) {
$rs = $this->answerdao->get_answer_by_id ( $data ['id'] );
//追问和回答
$tag_array = unserialize ( $rs ['tag'] );
array_push ( $tag_array, $data ['tag'] );
array_push ( $tag_array, get_date () );
$tag = serialize ( $tag_array );
$data ['tag'] = $tag;
$data ['tagtime'] = $rs ['tagtime'];
$this->answerdao->update_taginfo_by_id ( $data );
$rs = $this->answerdao->get_answer_by_id ( $data ['id'] );
$question = $this->questiondao->get_question_by_id ( $rs ['qid'] );
$type = "FOLLOW_ANSWER";
if ($question ['price'] > 0)
$type = "PAY_FOLLOW_ANSWER";
$this->send_email ( $question ['authorid'], $type, $rs ['qid'], $data ['id'] );
//发送系统信息-发送给发回答用户
$subject = "回答 " . $rs ['title'] . " 追问后有新的回答";
$content = "回答 " . $rs ['title'] . " 追问后有新的回答";
$this->messagedao->send_message ( ADMIN_NAME, 0, $question ['authorid'], $subject, $content );
}
/**
* 更新用户头像
* @param unknown_type $data
*/
function update_avatar($data = array()) {
$this->userdao->update_avatar ( $data );
}
/**
* 关闭问题
* @param unknown_type $qid
*/
function close_question($qid = 0) {
$this->questiondao->close_question ( $qid );
$result = $this->questiondao->get_question_user_info_by_id ( $qid );
$subject = "问题 " . $result ['title'] . " 已经关闭";
$content = "问题 " . $result ['title'] . " 已经关闭";
$this->messagedao->send_message ( ADMIN_NAME, 0, $result ['authorid'], $subject, $content );
//扣除RMB到基金中
if ($result ['price'] > 0)
$this->_set_fund ( $result ['authorid'], $result ['id'], $result ['price'] );
}
/**
* 添加悬赏值
* @param unknown_type $qid
* @param unknown_type $add_price
*/
function do_up_price($qid = 0, $add_price = 0) {
$this->questiondao->do_up_price ( $qid, $add_price );
}
/**
* 更新问题补充信息
*/
function update_queston_supply($data = array(), $qid = 0) {
$question = $this->questiondao->get_question_by_id ( $qid );
if (! empty ( $question ['supply'] ))
return false;
$condition = " where id = " . $qid;
$supply [0] ['content'] = $data ['supply'];
$supply [0] ['time'] = get_date ();
$data ['supply'] = serialize ( $supply );
$this->questiondao->update_question ( $data, $condition );
$type = "REPLENISH_QUESTION";
if ($question ['price'] > 0)
$type = "PAY_REPLENISH_QUESTION";
$this->send_email ( $question ['authorid'], $type, $qid, 0 );
}
/**
* 更新用户信息-仅电话和昵称
* @param unknown_type $data
*/
function update_user_info($data = array()) {
Doo::loadModel ( 'UserDao' );
$userdao = new UserDao ();
$userdao->uid = $data ['uid'];
if (isset ( $data ['phone'] ))
$userdao->phone = $data ['phone'];
if (isset ( $data ['nickname'] ))
$userdao->nickname = $data ['nickname'];
if (isset ( $data ['cids'] ))
$userdao->cids = $data ['cids'];
if (isset ( $data ['is_email'] ))
$userdao->is_email = $data ['is_email'];
$result = $this->db ()->update ( $userdao );
}
/**
* 记录财富流向
* @param unknown_type $data
*/
function set_credit3_log($data = array(), $price = 0) {
$this->credit3logdao->qid = $data ['id'];
$this->credit3logdao->username = $data ['username'];
$this->credit3logdao->time = get_date ();
$this->credit3logdao->ip = client_ip ();
$this->credit3logdao->amount = $price;
$action = $this->credit3logdao->set_ACTION_OFFER_QUESTION ();
$this->credit3logdao->add_credit3_log ( $data ['uid'], $data ['username'], $data ['id'], $action, - $price, $this->credit3logdao->ip );
}
/**
* 记录退款
*/
function set_credit3_refunds_log($data = array()) {
$this->credit3logdao->qid = $data ['id'];
$this->credit3logdao->username = $data ['author'];
$this->credit3logdao->time = get_date ();
$this->credit3logdao->ip = client_ip ();
$this->credit3logdao->amount = $data ['price'];
$action = $this->credit3logdao->set_ACTION_REFUNDS_QUESTION ();
$this->credit3logdao->add_credit3_log ( $data ['authorid'], $data ['author'], $data ['id'], $action, + $data ['price'], $this->credit3logdao->ip, 1 );
}
/**
* 将名师答疑的问题设置成满意
* @param unknown_type $id
*/
function set_vip_question_status($id = 0, $status = 0, $refunds_description = "") {
if ($status == 0)
return false;
$this->vipquestiondao->set_vip_question_status ( $id, $status, $refunds_description );
}
/**
* 发送系统信息
* @param unknown_type $subject
* @param unknown_type $content
* @param unknown_type $uid
*/
function send_sys_message($subject, $content, $uid) {
$this->messagedao->send_message ( ADMIN_NAME, 0, $uid, $subject, $content );
}
/**
* 追加一个名师答疑的追问
* @param unknown_type $id
* @param unknown_type $tag
*/
function do_add_vip_tag($id = 0, $tag = "") {
$tag = serialize ( array (0 => $tag, 1 => get_date () ) );
$this->vipanswerdao->do_add_vip_tag ( $id, $tag );
}
/**
* 更新名师答疑回答数
* @param unknown_type $id
*/
function update_vip_question_by_answers($id) {
$this->vipquestiondao->update_vip_question_by_answers ( $id );
}
/**
* 添加追问答案
* @param unknown_type $id
* @param unknown_type $content
*/
function update_vip_answer($content = "", $aid = 0, $tag = "") {
$this->vipanswerdao->id = $aid;
//追问和回答
$tag_array = unserialize ( $tag );
$tag_array ['2'] = $content;
$tag = serialize ( $tag_array );
$this->vipanswerdao->tag = $tag;
$result = $this->db ()->update ( $this->vipanswerdao );
}
/**
* 添加一个公告
* @param unknown_type $params
*/
function add_article($params = array()) {
Doo::loadModel ( 'ArticleDao' );
$articledao = new ArticleDao ();
$articledao->title = $params ['title'];
$articledao->content = $params ['content'];
$articledao->time = time ();
$result = $this->db ()->insert ( $articledao );
}
/**
* 获取一个文章
* @param unknown_type $id
*/
function get_article_by_id($id = 0) {
Doo::loadModel ( 'ArticleDao' );
$articledao = new ArticleDao ();
$articledao->aid = $id;
$rs = $this->db ()->find ( $articledao, array ('limit' => 1 ) );
$rs->time = format_date ( $rs->time );
return $rs;
}
/**
* 更新一篇文章
* @param unknown_type $params
*/
function update_article($params) {
Doo::loadModel ( 'ArticleDao' );
$articledao = new ArticleDao ();
$articledao->aid = $params ['id'];
$articledao->title = $params ['title'];
$articledao->content = $params ['content'];
$this->db ()->update ( $articledao );
}
/**
* 删除文档
* @param unknown_type $uid
*/
function delete_article($id = array()) {
Doo::loadModel ( 'ArticleDao' );
$articledao = new ArticleDao ();
$articledao->delete_article ( $id );
}
/**
* 添加名师答疑评价
* @param unknown_type $qid
* @param unknown_type $comment
*/
function update_vip_answer_comment($qid = 0, $comment = "") {
$this->vipanswerdao->update_vip_answer_comment ( $qid, $comment );
}
/**
* 添加讨论
* @param unknown_type $qid
* @param unknown_type $uid
* @param unknown_type $content
* @param unknown_type $cid
*/
function add_discuss($qid = 0, $uid = 0, $content = "", $cid = 0) {
Doo::loadModel ( 'DiscussDao' );
$discussdao = new DiscussDao ();
$discussdao->uid = $uid;
$discussdao->qid = $qid;
$discussdao->cid = $cid;
$discussdao->content = $content;
$discussdao->time = get_date ();
$discussdao->discuss = 0;
$result = $this->db ()->insert ( $discussdao );
return $result;
}
/**
* 更新讨论数
* @param unknown_type $cid
*/
function update_discuss($cid = 0) {
Doo::loadModel ( 'DiscussDao' );
$discussdao = new DiscussDao ();
$discussdao->update_discuss ( $cid );
}
/**
* 添加一个公告
* @param unknown_type $params
*/
function add_category($params = array()) {
Doo::loadModel ( 'CategoryDao' );
$categorydao = new CategoryDao ();
$categorydao->name = $params ['name'];
$categorydao->pid = $params ['pid'];
$categorydao->grade = 1;
$result = $this->db ()->insert ( $categorydao );
}
/**
* 删除选中问题
* @param unknown_type $id
*/
function delete_category_list($id = array()) {
$this->categorydao->delete_category_list ( $id );
}
/**
* 更新分类信息
* @param unknown_type $id
* @param unknown_type $name
* @param unknown_type $pid
*/
function update_category($id = 0, $name = "", $pid = 0) {
$this->categorydao->id = $id;
$this->categorydao->name = $name;
$this->categorydao->pid = $pid;
$result = $this->db ()->update ( $this->categorydao );
}
/**
* 设置为默认发送邮件
* @param unknown_type $uid
*/
function set_email_config($uid = 0) {
if ($uid == 0)
return false;
$data ['normal_question_mail'] = array ("0" => "NEW_ANSWER", "1" => "CLOSE_QUESTION", "2" => "FOLLOW_ANSWER", "3" => "FOLLOW_QUESTION", "4" => "REPLENISH_QUESTION", "5" => "ADOPT_ANSWER" );
$data ['pay_question_mail'] = array ("1" => "PAY_NEW_ANSWER", "2" => "PAY_CLOSE_QUESTION", "3" => "PAY_FOLLOW_ANSWER", "4" => "PAY_FOLLOW_QUESTION", "5" => "PAY_REPLENISH_QUESTION", "6" => "PAY_ADOPT_ANSWER", "7" => "PAY_FORMONEY" );
$data ['vip_question_mail'] = array ("1" => "VIP_PAY_FORMONEY", "2" => "VIP_MONEY_BACK", "3" => "VIP_NEW_ANSWER", "4" => "VIP_FOLLOW_ANSWER" );
$this->add_email_config ( $data, $uid );
$data ['uid'] = $uid;
$data ['is_email'] = 1;
$this->update_user_info ( $data );
}
/**
* 获取个人email配置
* @param unknown_type $uid
*/
function get_email_config($uid = 0) {
Doo::loadModel ( 'EmailconfigDao' );
$emailconfigdao = new EmailconfigDao ();
$result = $emailconfigdao->get_emailconfig_by_uid ( $uid );
$is_email = array ();
foreach ( $result as $key => $value ) {
array_push ( $is_email, $value ['action_id'] );
}
return $is_email;
}
/**
* 添加email配置
* @param unknown_type $data
* @param unknown_type $uid
*/
function add_email_config($data = array(), $uid = 0) {
Doo::loadModel ( 'EmailconfigDao' );
$emailconfigdao = new EmailconfigDao ();
$emailconfigdao->delete_emailconfig_by_uid ( $uid );
$normal = $pay = $vip = array ();
//添加普通问答配置
foreach ( $data ['normal_question_mail'] as $key => $value ) {
array_push ( $normal, "(" . $uid . ",'" . $value . "')" );
}
if (! empty ( $normal )) {
$normal = implode ( ",", $normal );
$emailconfigdao->add_emailconfig ( $normal );
}
//悬赏问答
foreach ( $data ['pay_question_mail'] as $key => $value ) {
array_push ( $pay, "(" . $uid . ",'" . $value . "')" );
}
if (! empty ( $pay )) {
$pay = implode ( ",", $pay );
$emailconfigdao->add_emailconfig ( $pay );
}
//名师答疑
foreach ( $data ['vip_question_mail'] as $key => $value ) {
array_push ( $vip, "(" . $uid . ",'" . $value . "')" );
}
if (! empty ( $vip )) {
$vip = implode ( ",", $vip );
$emailconfigdao->add_emailconfig ( $vip );
}
}
/**
* 实现接口
* (non-PHPdoc)
* @see BaseLogic::format_email_content()
*/
protected function format_email_content($html_templete, $templete_name, $qid = 0, $aid = 0) {
if ($templete_name == "VIP_PAY_FORMONEY" || $templete_name == "VIP_MONEY_BACK" || $templete_name == "VIP_NEW_ANSWER" || $templete_name == "VIP_FOLLOW_ANSWER") {
$question = $this->vipquestiondao->get_vip_question_by_id ( $qid );
$answer = $this->vipanswerdao->get_vip_answer_by_qid ( $qid );
} else {
$question = $this->questiondao->get_question_by_id ( $qid );
$answer = $this->answerdao->get_answer_by_id ( $aid );
}
$userinfo = $this->get_sso_user_info_by_name ( $question ['author'] );
$result = array ();
if ($templete_name == "NEW_ANSWER" || $templete_name == "PAY_NEW_ANSWER") { //提问有新的回答
$str = str_replace ( "%username%", $question ['author'], $html_templete );
$str = str_replace ( "%uid%", $answer ['authorid'], $str );
$str = str_replace ( "%answer_username%", $answer ['author'], $str );
$str = str_replace ( "%answer_time%", format_date ( $answer ['time'], "Y年m月d日" ), $str );
$str = str_replace ( "%qid%", $question ['id'], $str );
$str = str_replace ( "%question_title%", $question ['title'], $str );
$str = str_replace ( "%answer_content%", $answer ['content'], $str );
$result ['templete'] = $str;
$result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:你的提问有新的回答' ) . "?=";
//$result ['subject'] = "";
$result ['toemail'] = $userinfo [0] ['useremail'];
//$result ['toemail'] = "cpthought@vip.qq.com";
return $result;
} elseif ($templete_name == "CLOSE_QUESTION" || $templete_name == "PAY_CLOSE_QUESTION") { //问题被关闭
$str = str_replace ( "%username%", $question ['author'], $html_templete );
$str = str_replace ( "%qid%", $question ['id'], $str );
$str = str_replace ( "%question_title%", $question ['title'], $str );
$str = str_replace ( "%question_time%", format_date ( time (), "Y年m月d日" ), $str );
$result ['templete'] = $str;
$result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:你的问题被关闭' ) . "?=";
$result ['toemail'] = $userinfo [0] ['useremail'];
return $result;
} elseif ($templete_name == "FOLLOW_ANSWER" || $templete_name == "PAY_FOLLOW_ANSWER") { //追问有新的回答
$str = str_replace ( "%username%", $question ['author'], $html_templete );
$str = str_replace ( "%qid%", $question ['id'], $str );
$str = str_replace ( "%answer_username%", $answer ['author'], $str );
$str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
$str = str_replace ( "%question_title%", $question ['title'], $str );
$tag_array = unserialize ( $answer ['tag'] );
$str = str_replace ( "%ask2%", $tag_array [0], $str );
$str = str_replace ( "%answer2%", $tag_array [1], $str );
$result ['templete'] = $str;
$result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:你的追问有新的回答' ) . "?=";
$result ['toemail'] = $userinfo [0] ['useremail'];
return $result;
} elseif ($templete_name == "FOLLOW_QUESTION" || $templete_name == "PAY_FOLLOW_QUESTION") { //提问者向您追问
$str = str_replace ( "%answer_username%", $answer ['author'], $html_templete );
$str = str_replace ( "%qid%", $question ['id'], $str );
$str = str_replace ( "%username%", $question ['author'], $str );
$str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
$str = str_replace ( "%question_title%", $question ['title'], $str );
$str = str_replace ( "%answer_content%", $answer ['content'], $str );
$tag_array = unserialize ( $answer ['tag'] );
$str = str_replace ( "%ask2%", $tag_array [0], $str );
$result ['templete'] = $str;
$result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:提问者向您追问' ) . "?=";
$result ['toemail'] = $userinfo [0] ['useremail'];
return $result;
} elseif ($templete_name == "REPLENISH_QUESTION" || $templete_name == "PAY_REPLENISH_QUESTION") { //提问这对问题进行了补充
$str = str_replace ( "%username%", $question ['author'], $html_templete );
$str = str_replace ( "%qid%", $question ['id'], $str );
$str = str_replace ( "%question_title%", $question ['title'], $str );
$tag_array = unserialize ( $question ['supply'] );
$str = str_replace ( "%supply%", $tag_array [0] ['content'], $str );
$str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
$result ['templete'] = $str;
$result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:提问者对问题进行了补充' ) . "?=";
$result ['toemail'] = $userinfo [0] ['useremail'];
return $result;
} elseif ($templete_name == "ADOPT_ANSWER" || $templete_name == "PAY_ADOPT_ANSWER") { //回答被采纳了
$str = str_replace ( "%answer_username%", $answer ['author'], $html_templete );
$str = str_replace ( "%qid%", $answer ['qid'], $str );
$str = str_replace ( "%username%", $question ['author'], $str );
$str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
$str = str_replace ( "%question_title%", $question ['title'], $str );
$str = str_replace ( "%answer_content%", $answer ['content'], $str );
$result ['templete'] = $str;
$result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:您的回答被采纳了!' ) . "?=";
$userinfo = $this->get_sso_user_info_by_name ( $answer ['author'] );
$result ['toemail'] = $userinfo [0] ['useremail'];
return $result;
} elseif ($templete_name == "PAY_FORMONEY") {
$str = str_replace ( "%username%", $question ['author'], $html_templete );
$str = str_replace ( "%price%", $question ['price'], $str );
$str = str_replace ( "%qid%", $question ['id'], $str );
$str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
$result ['templete'] = $str;
$result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:您进行了一项付费操作' ) . "?=";
$result ['toemail'] = $userinfo [0] ['useremail'];
return $result;
} elseif ($templete_name == "VIP_PAY_FORMONEY") { //名师答疑付费提醒
$str = str_replace ( "%username%", $question ['author'], $html_templete );
$str = str_replace ( "%price%", $question ['price'], $str );
$str = str_replace ( "%uid%", $question ['authorid'], $str );
$result ['templete'] = $str;
$result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:您进行了一项付费操作' ) . "?=";
$result ['toemail'] = $userinfo [0] ['useremail'];
return $result;
} elseif ($templete_name == "VIP_NEW_ANSWER") { //名师答疑有回答提醒
$str = str_replace ( "%username%", $question ['author'], $html_templete );
$str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
$str = str_replace ( "%vqid%", $question ['id'], $str );
$str = str_replace ( "%vipquestion_title%", $question ['title'], $str );
$str = str_replace ( "%vanswer_content%", $answer ['content'], $str );
$result ['templete'] = $str;
$result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:你的名师答疑有新的回答' ) . "?=";
$result ['toemail'] = $userinfo [0] ['useremail'];
return $result;
} elseif ($templete_name == "VIP_MONEY_BACK") { //名师答疑退费提醒
$str = str_replace ( "%username%", $question ['author'], $html_templete );
$str = str_replace ( "%price%", $question ['price'], $str );
$str = str_replace ( "%uid%", $question ['authorid'], $str );
$str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
$result ['templete'] = $str;
$result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:向您退费成功' ) . "?=";
$result ['toemail'] = $userinfo [0] ['useremail'];
return $result;
} elseif ($templete_name == "VIP_FOLLOW_ANSWER") { //名师答疑追问有了新的回答
$str = str_replace ( "%username%", $question ['author'], $html_templete );
$str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
$str = str_replace ( "%vipquestion_title%", $question ['title'], $str );
$str = str_replace ( "%vanswer_content%", $answer ['content'], $str );
$str = str_replace ( "%vqid%", $question ['id'], $str );
$result ['templete'] = $str;
$result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:你在名师答疑中追问有新的回答' ) . "?=";
$result ['toemail'] = $userinfo [0] ['useremail'];
//$result ['toemail'] = "cpthought@vip.qq.com";
return $result;
}
}
}
?>