UserLogic.php 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146
  1. <?php
  2. /**
  3. * 用户操作逻辑
  4. * @author cp
  5. */
  6. class UserLogic extends BaseLogic {
  7. private $categorydao;
  8. private $userdao;
  9. private $questiondao;
  10. private $answerdao;
  11. private $messagedao;
  12. private $group;
  13. private $creditdao;
  14. private $sessiondao;
  15. private $userlogdao;
  16. private $crontadstatusdao;
  17. private $credit3logdao;
  18. private $authissuedao;
  19. private $vipquestiondao;
  20. private $vipanswerdao;
  21. private $examinedao;
  22. function __construct() {
  23. Doo::loadModel ( 'CategoryDao' );
  24. Doo::loadModel ( 'UserDao' );
  25. Doo::loadModel ( 'QuestionDao' );
  26. Doo::loadModel ( 'CreditDao' );
  27. Doo::loadModel ( 'AnswerDao' );
  28. Doo::loadModel ( 'MessageDao' );
  29. Doo::loadModel ( 'GroupDao' );
  30. Doo::loadModel ( 'SessionDao' );
  31. Doo::loadModel ( 'UserlogDao' );
  32. Doo::loadModel ( 'CrontadstatusDao' );
  33. Doo::loadModel ( 'Credit3logDao' );
  34. Doo::loadModel ( 'AuthissueDao' );
  35. Doo::loadModel ( 'VipquestionDao' );
  36. Doo::loadModel ( 'VipanswerDao' );
  37. $this->categorydao = new CategoryDao ();
  38. $this->userdao = new UserDao ();
  39. $this->questiondao = new QuestionDao ();
  40. $this->creditdao = new CreditDao ();
  41. $this->answerdao = new AnswerDao ();
  42. $this->messagedao = new MessageDao ();
  43. $this->groupdao = new GroupDao ();
  44. $this->sessiondao = new SessionDao ();
  45. $this->userlogdao = new UserlogDao ();
  46. $this->crontadstatusdao = new CrontadstatusDao ();
  47. $this->credit3logdao = new Credit3logDao ();
  48. $this->authissuedao = new AuthissueDao ();
  49. $this->vipquestiondao = new VipquestionDao ();
  50. $this->vipanswerdao = new VipanswerDao ();
  51. Doo::loadModel ( 'ExamineDao' );
  52. $this->examinedao = new ExamineDao ();
  53. }
  54. /**
  55. * 完善名师问题
  56. * @param unknown_type $id
  57. * @param unknown_type $title
  58. * @param unknown_type $description
  59. */
  60. function update_vip_question($id = 0, $title = "", $description = "", $uid = 0, $phone = "", $qq = "") {
  61. $this->vipquestiondao->id = $id;
  62. $this->vipquestiondao->title = $title;
  63. $this->vipquestiondao->description = $description;
  64. $this->vipquestiondao->time = get_date ();
  65. $this->vipquestiondao->status = PAID_FILL_IN;
  66. $result = $this->db ()->update ( $this->vipquestiondao );
  67. //更新今天发布数--需要修改每时间段的更新次数-setp2
  68. $this->authissuedao->set_authissue_totals ( $uid );
  69. //添加积分值-setp2
  70. $this->set_credit1 ( 'add', $uid, CREDIT_POINT_ADD, CREDIT_ACTION_ADD );
  71. $que_rs = $this->vipquestiondao->get_vip_question_by_id ( $id );
  72. //加入检索索引-分词还未加入-数据配置--等待搜索页面
  73. //$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' => '' );
  74. //$this->add_search_index ( $pams, SEARCH_WD_DB, SEARCH_VIP_INI );
  75. $this->userdao->uid = $uid;
  76. if (! empty ( $phone ))
  77. $this->userdao->phone = $phone;
  78. if (! empty ( $qq ))
  79. $this->userdao->qq = $qq;
  80. $result = $this->db ()->update ( $this->userdao );
  81. if($result){
  82. include SITE_PATH . '/protected/config/set_email_to_admin.conf.php';
  83. $list=explode("-", $sys ['set_email']);
  84. foreach ($list as $value){
  85. if(filter_var($value, FILTER_VALIDATE_EMAIL))
  86. $this->_mail("有用户发布了名师答疑,赶紧去后台查看:<a href='http://zhzdwd.com/'>问答后台</a>","有新的名师答疑提问",$value);
  87. }
  88. }
  89. }
  90. /**
  91. * 添加名师问题
  92. * @param unknown_type $data
  93. */
  94. function add_vip_question($data = array()) {
  95. $this->vipquestiondao->status = PAID_NO_FILL_IN;
  96. $price = abs ( $data ['price'] );
  97. $this->vipquestiondao->price = $price;
  98. $this->credit3logdao->amount = $price;
  99. $this->vipquestiondao->author = $data ['author'];
  100. $this->credit3logdao->username = $data ['author'];
  101. $this->vipquestiondao->authorid = $data ['authorid'];
  102. $time = get_date ();
  103. $this->vipquestiondao->time = $time;
  104. $this->credit3logdao->time = $time;
  105. $ip = client_ip ();
  106. $this->vipquestiondao->ip = $ip;
  107. $this->credit3logdao->ip = $ip;
  108. $this->vipquestiondao->refunds = 1;
  109. //扣除通行证金额
  110. if ($data ['price'] > 0) {
  111. //扣除通行证的钱 //用户表和记录表
  112. $is = $this->set_credit3 ( - $data ['price'], $data ['authorid'], RICH_ACTION_OFFER, SSO_UID );
  113. if (!$is)
  114. return 0;
  115. }
  116. $result = $this->db ()->insert ( $this->vipquestiondao );
  117. //发邮件
  118. $this->send_email ( $data ['authorid'], "VIP_PAY_FORMONEY", $result, 0 );
  119. if ($result) {
  120. //扣除财富值--财富值记录
  121. if ($data ['price'] > 0) {
  122. $this->credit3logdao->qid = $result;
  123. $action = $this->credit3logdao->set_ACTION_ADD_VIP_QUESTION ();
  124. $this->credit3logdao->add_credit3_log ( $data ['authorid'], $data ['author'], $result, $action, - $price, $ip, 1 );
  125. }
  126. //发布系统信息
  127. $subject = "您的新问题(" . $result ['title'] . ")";
  128. $content = $this->messagedao->set_MESSAGE_ADD_VIP_PAID ();
  129. $this->messagedao->send_message ( ADMIN_NAME, 0, $data ['authorid'], $subject, $content );
  130. }
  131. return $result;
  132. }
  133. /**
  134. * 会话推出
  135. * @param unknown_type $sid
  136. */
  137. function delete_session($sid = "") {
  138. $rs = $this->sessiondao->get_seesion ( $sid );
  139. $this->userlogdao->uid = $rs ['uid'];
  140. $this->userlogdao->username = $rs ['username'];
  141. $this->userlogdao->ip = client_ip ();
  142. $this->userlogdao->time = get_date ();
  143. $action = $this->userlogdao->set_USER_EXIT ();
  144. $this->userlogdao->set_userlog ( $rs ['uid'], $rs ['username'], $action, client_ip () );
  145. $this->sessiondao->sid = $sid;
  146. $this->db ()->delete ( $this->sessiondao );
  147. }
  148. /**
  149. * 完成任务
  150. * @param unknown_type $uid
  151. * @param unknown_type $mission_type
  152. */
  153. function complete_daily_crontab($uid = 0, $mission_type = 0) {
  154. $this->crontadstatusdao->complete_crontab ( $uid, $mission_type );
  155. }
  156. /**
  157. * 获取任务进行状态
  158. * @param unknown_type $uid
  159. * @param unknown_type $mission_type
  160. */
  161. function get_crontab_status($uid = 0, $mission_type = 0) {
  162. $time = get_date ();
  163. //$this->crontadstatusdao->delete_crontab();
  164. //每日登录任务
  165. if ($mission_type == SYSTEM_DAILY_LOGIN) {
  166. $rs = $this->crontadstatusdao->get_crontab_status ( $uid, $mission_type );
  167. $day = get_today ();
  168. if (empty ( $rs )) {
  169. $this->crontadstatusdao->uid = $uid;
  170. $this->crontadstatusdao->cid = $mission_type;
  171. $this->crontadstatusdao->status = NOT_COMPLETED;
  172. $this->crontadstatusdao->time = $time;
  173. $this->db ()->insert ( $this->crontadstatusdao );
  174. return NOT_COMPLETED;
  175. } elseif ($rs ['time'] < $day ['start'])
  176. return DOING;
  177. elseif ($rs ['status'] != 2 && $rs ['time'] > $day ['start']) {
  178. return DOING;
  179. } else
  180. return COMPLETE;
  181. }
  182. }
  183. /**
  184. * 记录用户日志
  185. * @param unknown_type $uid
  186. * @param unknown_type $username
  187. */
  188. function set_userlog($uid = 0, $username = "") {
  189. $this->userlogdao->uid = $uid;
  190. $this->userlogdao->username = $username;
  191. $this->userlogdao->ip = client_ip ();
  192. $this->userlogdao->time = get_date ();
  193. $this->userlogdao->action = $this->userlogdao->set_USER_LOGIN_LOG ();
  194. //设置用户日志
  195. $result = $this->db ()->insert ( $this->userlogdao );
  196. }
  197. /**
  198. * 设置会话
  199. * @param unknown_type $sessionID
  200. * @param unknown_type $uid
  201. * @param unknown_type $username
  202. * @param unknown_type $lifetime
  203. */
  204. function set_session($sessionID = "", $uid = 0, $username = "", $lifetime = 0) {
  205. $this->sessiondao->sid = $sessionID;
  206. $this->sessiondao->uid = $uid;
  207. $this->sessiondao->username = $username;
  208. $this->sessiondao->islogin = 1;
  209. $this->sessiondao->ip = client_ip ();
  210. $this->sessiondao->time = get_date ();
  211. $this->sessiondao->lifetime = $lifetime;
  212. //设置会话
  213. $result = $this->db ()->insert ( $this->sessiondao );
  214. }
  215. /**
  216. * 添加用户--是否要发系统信息
  217. */
  218. function add_user($username = "", $password = "") {
  219. $this->userdao->username = $username;
  220. $this->userdao->password = $password;
  221. $this->userdao->groupid = USER_LV1;
  222. $this->userdao->credits = POINT_REGISTER;
  223. $this->userdao->credit1 = POINT_REGISTER;
  224. $this->userdao->regip = client_ip ();
  225. $this->userdao->regtime = get_date ();
  226. //添加用户
  227. $result = $this->db ()->insert ( $this->userdao );
  228. //注册加20分
  229. $this->creditdao->set_credit_log ( $result, ACTION_REGISTER, POINT_REGISTER, 0, 0 );
  230. return $result;
  231. }
  232. /**
  233. * 添加用户--是否要发系统信息
  234. */
  235. function add_user2($param) {
  236. $this->userdao->username = $param['username'];
  237. $this->userdao->password = $param['password'];
  238. $this->userdao->email = $param['email'];
  239. $this->userdao->phone = $param['mobile'];
  240. $this->userdao->groupid = USER_LV1;
  241. $this->userdao->credits = POINT_REGISTER;
  242. $this->userdao->credit1 = POINT_REGISTER;
  243. $this->userdao->regip = client_ip ();
  244. $this->userdao->regtime = get_date ();
  245. //添加用户
  246. $result = $this->db ()->insert ( $this->userdao );
  247. //注册加20分
  248. $this->creditdao->set_credit_log ( $result, ACTION_REGISTER, POINT_REGISTER, 0, 0 );
  249. return $result;
  250. }
  251. /**
  252. * 更新用户信息
  253. * @param unknown_type $params
  254. */
  255. function update_user2($id,$params) {
  256. $this->userdao->uid = $id;
  257. $this->userdao->phone = $params ['phone'];
  258. $this->userdao->password = md5 ( $params ['password'] );
  259. $this->userdao->email = $params ['email'];
  260. $this->userdao->groupid = $params ['groupid'];
  261. $this->userdao->credits = $params ['credits'];
  262. $this->userdao->credit1 = $params ['credit1'];
  263. $this->userdao->gender = $params ['gender'];
  264. $this->userdao->bday = $params ['bday'];
  265. $this->userdao->qq = $params ['qq'];
  266. $this->userdao->msn = $params ['msn'];
  267. $this->userdao->signature = $params ['signature'];
  268. $this->userdao->expert = $params ['expert'];
  269. $this->userdao->cids=$params['cids'];
  270. $result = $this->db ()->update ( $this->userdao );
  271. }
  272. /**
  273. * 根据用户ID删除,和删除相关信息
  274. */
  275. function delete_user_tem($uid = 0) {
  276. //删除问题
  277. $this->questiondao->delete_question_by_authorid ( $uid );
  278. //删除回答
  279. $this->answerdao->delete_answer_by_authorid ( $uid );
  280. //删除用户积分记录--之后还有财富记录
  281. $this->creditdao->delete_credit_by_uid ( $uid );
  282. $this->userdao->uid = $uid;
  283. $this->db ()->delete ( $this->userdao );
  284. }
  285. /**
  286. * 将问题设置为未解决-值针对已关闭
  287. * @param unknown_type $id
  288. */
  289. function update_question_list($id = array()) {
  290. $id=implode(",", $id);
  291. $queList=array();
  292. if(!empty($id))
  293. $queList=$this->questiondao->get_questions_By_Idlist($id);
  294. foreach ($queList as $key=>$value){
  295. $question = new QuestionDao ();
  296. $question->id=$value['id'];
  297. $question->status=QUESTOIN_STATUS_UNRESOLVED;
  298. $question->time=time();
  299. $question->update();
  300. }
  301. }
  302. /**
  303. * 删除选中问题
  304. * @param unknown_type $id
  305. */
  306. function delete_question_list($id = array()) {
  307. $this->questiondao->delete_question_list ( $id );
  308. //删除索引
  309. $this->delete_search_index ( $id, SEARCH_WD_DB, SEARCH_INI );
  310. }
  311. /**
  312. * 删除选中问题
  313. * @param unknown_type $id
  314. */
  315. function delete_answer_list($id = array()) {
  316. $this->answerdao->delete_answer_list ( $id );
  317. }
  318. /**
  319. * 删除一个用户组
  320. * @param unknown_type $groupid
  321. */
  322. function delete_group($groupid = 0) {
  323. if ($groupid <= GROUPIDLIMIT)
  324. return false;
  325. $this->groupdao->groupid = $groupid;
  326. $this->db ()->delete ( $this->groupdao );
  327. }
  328. /**
  329. * 添加一条用户组
  330. * @param unknown_type $params
  331. */
  332. function add_group($params = array()) {
  333. if (empty ( $params ))
  334. return false;
  335. $this->groupdao->grouptitle = $params ['grouptitle'];
  336. $this->groupdao->grouptype = 2;
  337. $result = $this->db ()->insert ( $this->groupdao );
  338. }
  339. /**
  340. * 批量更新用户组
  341. * @param unknown_type $params
  342. */
  343. function update_group_list($params) {
  344. $pa = array ();
  345. $co = array ();
  346. $wh = array ();
  347. $count = count ( $params ['groupid'] );
  348. foreach ( $params as $key => $value ) {
  349. array_push ( $pa, $key );
  350. if ($key != "groupid") {
  351. array_push ( $wh, $key . "=VALUES(" . $key . ")" );
  352. }
  353. }
  354. //获取更新内容
  355. for($i = 0; $i < $count; $i ++) {
  356. $tm = array ();
  357. foreach ( $pa as $k ) {
  358. array_push ( $tm, "'" . $params [$k] [$i] . "'" );
  359. }
  360. $tm = implode ( ",", $tm );
  361. array_push ( $co, "(" . $tm . ")" );
  362. }
  363. $pa = implode ( ",", $pa );
  364. $wh = implode ( ",", $wh );
  365. $co = implode ( ",", $co );
  366. $this->groupdao->update_group_list ( $pa, $co, $wh );
  367. }
  368. /**
  369. * 删除用户和问答
  370. * @param unknown_type $uid
  371. */
  372. function delete_user_and_QA($uid = array()) {
  373. $this->userdao->delete_user_and_QA ( $uid );
  374. }
  375. /**
  376. * 删除用户
  377. * @param unknown_type $uid
  378. */
  379. function delete_user($uid = array()) {
  380. $this->userdao->delete_user ( $uid );
  381. }
  382. function update_user_avatar_by_id($uid, $avatar) {
  383. Doo::loadModel ( 'UserDao' );
  384. $userdao = new UserDao ();
  385. $userdao->uid = $uid;
  386. $userdao->avatar = $avatar;
  387. $userdao->lastlogin = time ();
  388. $result = $this->db ()->update ( $userdao );
  389. }
  390. /**
  391. * 更新用户信息
  392. * @param unknown_type $params
  393. */
  394. function update_user($params) {
  395. $this->userdao->uid = $params ['uid'];
  396. $this->userdao->phone = $params ['phone'];
  397. $this->userdao->password = md5 ( $params ['password'] );
  398. $this->userdao->email = $params ['email'];
  399. $this->userdao->groupid = $params ['groupid'];
  400. $this->userdao->credits = $params ['credits'];
  401. $this->userdao->credit1 = $params ['credit1'];
  402. $this->userdao->gender = $params ['gender'];
  403. $this->userdao->bday = $params ['bday'];
  404. $this->userdao->qq = $params ['qq'];
  405. $this->userdao->msn = $params ['msn'];
  406. $this->userdao->signature = $params ['signature'];
  407. $this->userdao->expert = $params ['expert'];
  408. $this->userdao->cids=$params['cids'];
  409. $result = $this->db ()->update ( $this->userdao );
  410. }
  411. /**
  412. * 更新退款机会
  413. * @param unknown_type $refunds
  414. */
  415. function update_user_refunds($refunds = array()) {
  416. $this->userdao->uid = $refunds ['uid'];
  417. $this->userdao->refunds = $refunds ['refunds'];
  418. $result = $this->db ()->update ( $this->userdao );
  419. }
  420. /**
  421. * 获取用户组
  422. */
  423. function get_group() {
  424. $result = $this->groupdao->get_group ();
  425. $re = array ('sys' => array (), 'user' => array (), 'vip_user' => array () );
  426. foreach ( $result as $value ) {
  427. if ($value ['grouptype'] == 1)
  428. array_push ( $re ['sys'], $value );
  429. elseif ($value ['grouptype'] == 2)
  430. array_push ( $re ['user'], $value );
  431. elseif ($value ['grouptype'] == 3)
  432. array_push ( $re ['vip_user'], $value );
  433. }
  434. return $re;
  435. }
  436. /**
  437. * 设置赞同数
  438. * @param unknown_type $aid
  439. * @param unknown_type $uid 登录者UID
  440. */
  441. function update_support_answer($aid = 0, $uid = 0) {
  442. $user = $this->userdao->get_userinfo_by_uid ( $uid );
  443. $aids_ar = explode ( ",", $user ['aids'] );
  444. if (in_array ( $aid, $aids_ar ))
  445. return false;
  446. //记录谁赞同
  447. $data ['aids'] = $user ['aids'] . "," . $aid;
  448. if (empty ( $user ['aids'] ))
  449. $data ['aids'] = $aid;
  450. $condition = " ,elect=elect+1 where uid = " . $uid;
  451. $this->userdao->update_user ( $data, $condition );
  452. //更新赞同数
  453. $this->answerdao->update_support_answer ( $aid );
  454. //更新赞同操作
  455. $rs = $this->answerdao->get_answer_by_id ( $aid );
  456. $this->questiondao->set_question_goods ( $rs ['qid'] );
  457. //加积分
  458. $this->set_credit1 ( 'add', $user ['uid'], POINT_SUPPORT, ACTION_SUPPORT );
  459. return true;
  460. }
  461. /**
  462. * 设置最佳答案--整理
  463. * @param unknown_type $qid
  464. */
  465. function set_best_answer($data = array()) {
  466. $type = "ADOPT_ANSWER";
  467. if ($data ['price'] > 0) {
  468. //获取回答用户的通行证ID
  469. $sso_info = $this->get_sso_user_info_by_name ( $data ['username'] );
  470. $is = $this->set_credit3 ( + $data ['price'], $data ['auid'], RICH_ACTION_ADOPT, $sso_info [0] ['id'] );
  471. $type = "PAY_ADOPT_ANSWER";
  472. if ($is == 0)
  473. return $is;
  474. }
  475. //更新问题
  476. $data_question ['endtime'] = get_date ();
  477. $data_question ['status'] = ADOPT;
  478. $condition = " where id = " . $data ['qid'];
  479. $this->questiondao->update_question ( $data_question, $condition );
  480. //更新答案
  481. $data_answer ['adopttime'] = $data_question ['endtime'];
  482. $data_answer ['comment'] = $data ['comment'];
  483. $data_answer ['status'] = ADOPT;
  484. $condition = " where id = " . $data ['aid'];
  485. $this->answerdao->update_answer ( $data_answer, $condition );
  486. //发送邮件
  487. $this->send_email ( $data ['auid'], $type, $data ['qid'], $data ['aid'] );
  488. //更新回答用户信息积分信息
  489. $this->userdao->add_credit1 ( POINT_ADOPT, $data ['auid'], ACTION_ADOPT );
  490. if ($data ['price'] > 0) {
  491. //财富操作记录, 将用户财富划到回答方
  492. //$this->userdao->add_credit3 ( + $data ['price'], $data ['auid'], RICH_ACTION_ADOPT );
  493. //财富流向表
  494. $this->credit3logdao->qid = $data ['qid'];
  495. $this->credit3logdao->ip = client_ip ();
  496. $this->credit3logdao->amount = $data ['price'];
  497. $this->credit3logdao->username = $data ['username'];
  498. $this->credit3logdao->time = get_date ();
  499. $action = $this->credit3logdao->set_ACTION_ADOPT_QUESTION ();
  500. $this->credit3logdao->add_credit3_log ( $data ['auid'], $data ['username'], $data ['qid'], $action, $data ['price'], $this->credit3logdao->ip );
  501. }
  502. //更新该用户的采纳数
  503. $this->userdao->add_adopts ( $data ['auid'], 1 );
  504. $p = "";
  505. if ($data ['price'] > 0)
  506. $p = "<span class=colOrange >获得¥" . $data ['price'] . "元</span>";
  507. //发送系统信息-发送给发回答用户
  508. $subject = "回答&nbsp;<a href=/askpage/" . $data ['qid'] . " >" . $data ['title'] . "</a>&nbsp;被采纳为最佳答案&nbsp;" . $p;
  509. $content = "回答&nbsp;<a href=/askpage/" . $data ['qid'] . " >" . $data ['title'] . "</a>&nbsp;被采纳为最佳答案&nbsp;" . $p;
  510. $this->messagedao->send_message ( ADMIN_NAME, 0, $data ['auid'], $subject, $content );
  511. }
  512. /**
  513. * 获取通行证用户头像--
  514. * @param unknown_type $username
  515. */
  516. function get_user_avatar_by_username($username = "", $client = "") {
  517. if (empty ( $client )) {
  518. require_once (SITE_PATH . '/protected/plugin/client.php');
  519. $client = new client ( ZHSSO );
  520. }
  521. $avatar = array ('180' => DEF_AVATAR, '30' => DEF_AVATAR, '90' => DEF_AVATAR, '45' => DEF_AVATAR );
  522. $userinfo = $client->zhsso_getUserbyName ( $username );
  523. $userinfo = explode ( "\r", $userinfo );
  524. $ts = json_decode ( $userinfo ['1'], true );
  525. //$avatar = $client->url_exists($client->ps_getavatar($ts[0]['id'])) ? $client->ps_getavatar($ts[0]['id']) : DEF_AVATAR;
  526. if (isset ( $ts ) && ! empty ( $ts )) {
  527. $avatar = $client->ps_getavatar ( $ts [0] ['id'] );
  528. }
  529. return $avatar;
  530. }
  531. /**
  532. * 获取用户相关信息
  533. * @param unknown_type $data
  534. * @param unknown_type $condition
  535. * @param unknown_type $limit
  536. */
  537. function get_users_list($data = array(), $condition = "", $limit = "") {
  538. $result = $this->userdao->get_users_list ( $data, $condition, $limit );
  539. $src = "";
  540. $now = 1;
  541. foreach ( $result as $key => $value ) {
  542. $lv = get_lv ( $value ['credit1'] );
  543. $result [$key] ['lv'] = $lv [0];
  544. $result [$key] ['lv_max'] = $lv [1];
  545. $result [$key] ['lv_need'] = $lv [1] - $value ['credit1'];
  546. $result [$key] ['lv_percent'] = $value ['credit1'] / $lv [1] * 100;
  547. $result [$key] ['category'] = "";
  548. $result [$key] ['question'] = "";
  549. $result [$key] ['lastlogin'] = my_date_format2 ( $value ['lastlogin'], "Y-m-d H:i:s" );
  550. //$avatar = $this->get_user_avatar_by_username ( $value ['username'] );
  551. $avatar = json_decode ( $value ['avatar'], true );
  552. if (empty ( $avatar ))
  553. $avatar = array ('180' => DEF_AVATAR, '30' => DEF_AVATAR, '90' => DEF_AVATAR, '45' => DEF_AVATAR );
  554. $result [$key] ['avatar'] = $avatar;
  555. $cidsList = json_decode ( $value ['cids'] );
  556. if(!empty($cidsList)){
  557. foreach ( $cidsList as $c_key => $values ) {
  558. $list = explode ( ":", $values );
  559. $src .= "<a href='/index_c/" . $list[0] . "'>" .$list[1] . "</a>&nbsp;";
  560. }
  561. $result [$key] ['category'] = $src;
  562. }
  563. //读取专家分类
  564. // if (! empty ( $value ['cids'] )) {
  565. // $condition = " and id in (" . $value ['cids'] . ") ";
  566. //
  567. // $c_result = $this->categorydao->get_category_list ( array (), $condition, "" );
  568. //
  569. // $src = "";
  570. //
  571. // foreach ( $c_result as $c_key => $c_value ) {
  572. //
  573. // $src .= "<a href='/index_c/" . $c_value ['id'] . "'>" . $c_value ['name'] . "</a>&nbsp;";
  574. // }
  575. // $result [$key] ['category'] = $src;
  576. // }
  577. $result [$key] ['now'] = $now;
  578. //获取相关问题
  579. $param ['authorid'] = $value ['uid'];
  580. $limit = " order by time desc limit 0 , 3 ";
  581. $q_result = $this->get_list ( $param, "", $limit, t_answer );
  582. $src = "";
  583. if (! empty ( $q_result )) {
  584. foreach ( $q_result as $q_key => $q_value ) {
  585. $src .= "<a href='/askpage/" . $q_value ['qid'] . "'>" . $q_value ['title'] . "</a>";
  586. }
  587. $result [$key] ['question'] = $src;
  588. }
  589. $now ++;
  590. }
  591. return $result;
  592. }
  593. /**
  594. * 根据用户名获取信息
  595. */
  596. function get_users_by_name($username = "") {
  597. $result = $this->userdao->get_users_by_name ( $username );
  598. return $result;
  599. }
  600. function get_group_by_id($id = 0) {
  601. $rs = $this->groupdao->get_group_by_id ( $id );
  602. return $rs;
  603. }
  604. /**
  605. * 获取用户基本信息
  606. * @param unknown_type $uid
  607. * @return $result array;
  608. */
  609. function get_users_information($uid = 0) {
  610. if ($uid == 0 || (! is_numeric ( $uid )))
  611. return array ();
  612. $result = $this->userdao->get_userinfo_by_uid ( $uid );
  613. if (empty ( $result ))
  614. return array ();
  615. $lv = get_lv ( $result ['credit1'] );
  616. $result ['lv'] = $lv [0];
  617. $result ['lv_max'] = $lv [1];
  618. $result ['lv_need'] = $lv [1] - $result ['credit1'];
  619. $result ['lv_percent'] = $result ['credit1'] / $lv [1] * 100;
  620. $result ['credit3'] = 0;
  621. if (defined ( 'CREDIT3' ))
  622. $result ['credit3'] = CREDIT3;
  623. $result ['email'] = "";
  624. if (defined ( 'EMAIL' ))
  625. $result ['email'] = EMAIL;
  626. $cidsList = json_decode ( $result ['cids'] );
  627. $cids=array();
  628. $cids_key = array ();
  629. $cids_name = array ();
  630. if(!empty($cidsList)){
  631. foreach ( $cidsList as $key => $value ) {
  632. $list = explode ( ":", $value );
  633. array_push ( $cids_key, $list [0] );
  634. array_push ( $cids_name, $list [1] );
  635. }
  636. $result ['cids'] = implode(",", $cids_key);
  637. $cids = array_combine($cids_key, $cids_name);
  638. $result ['cids_json'] = $cids;
  639. }
  640. return $result;
  641. }
  642. /**
  643. * 添加一个问题
  644. * @param unknown_type $data
  645. * @return $result 问题ID;
  646. */
  647. function add_examine_question($data = array()) {
  648. $this->examinedao->title = $data ['title'];
  649. $this->examinedao->cid = $data ['category_id'];
  650. $this->examinedao->description = $data ['description'];
  651. //取绝对值
  652. $price = abs ( $data ['price'] );
  653. $this->examinedao->price = $price;
  654. $this->examinedao->author = $data ['author'];
  655. $this->examinedao->authorid = $data ['authorid'];
  656. $this->examinedao->time = get_date ();
  657. $this->examinedao->endtime = get_date ( 15 );
  658. $this->examinedao->ip = client_ip ();
  659. $result = $this->db ()->insert ( $this->examinedao );
  660. //添加提问数
  661. //$this->set_questions ( 'add', $data ['authorid'], $data ['category_id'] );
  662. return $result;
  663. }
  664. /**
  665. * 添加一个问题
  666. * @param unknown_type $data
  667. * @return $result 问题ID;
  668. */
  669. function add_question($data = array()) {
  670. $this->questiondao->title = $data ['title'];
  671. $this->questiondao->cid = $data ['category_id'];
  672. $this->questiondao->description = $data ['description'];
  673. //取绝对值
  674. $price = abs ( $data ['price'] );
  675. $this->questiondao->price = $price;
  676. $this->credit3logdao->amount = $price;
  677. $this->questiondao->author = $data ['author'];
  678. $this->credit3logdao->username = $data ['author'];
  679. $this->questiondao->authorid = $data ['authorid'];
  680. $this->credit3logdao->uid = $data ['authorid'];
  681. $this->questiondao->time = get_date ();
  682. $this->credit3logdao->time = $this->questiondao->time;
  683. $this->questiondao->endtime = get_date ( 15 );
  684. $this->questiondao->ip = client_ip ();
  685. $this->credit3logdao->ip = $this->questiondao->ip;
  686. //扣除金额后才可以添加问题
  687. if ($data ['price'] > 0) {
  688. $is = $this->set_credit3 ( - $data ['price'], $data ['authorid'], RICH_ACTION_OFFER, SSO_UID );
  689. if ($is == 0)
  690. return 0;
  691. }
  692. //推广手段
  693. if($data['price']==0){
  694. $fundstr=file_get_contents(SITE_PATH . '/protected/config/fund.conf.php') ;
  695. if($fundstr){
  696. //获取基金
  697. Doo::loadModel ( 'FundDao' );
  698. $funddao = new FundDao ();
  699. $fund=$funddao->get_fund_by_amount();
  700. if(!empty($fund)){
  701. $funddao->set_fund_amount_spread("-1",$fund['id']);
  702. $this->questiondao->price=1;
  703. }
  704. }
  705. }
  706. $result = $this->db ()->insert ( $this->questiondao );
  707. //发送邮件
  708. if ($data ['price'] > 0) {
  709. $this->send_email ( $data ['authorid'], "PAY_FORMONEY", $result, 0 );
  710. }
  711. //是否需要优化
  712. if ($result) {
  713. //加入检索索引-分词还未加入-数据配置
  714. //$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 );
  715. //$this->add_search_index ( $pams );
  716. //扣除财富值--财富值记录
  717. if ($data ['price'] > 0) {
  718. $this->credit3logdao->qid = $result;
  719. $action = $this->credit3logdao->set_ACTION_OFFER_QUESTION ();
  720. $this->credit3logdao->add_credit3_log ( $data ['authorid'], $data ['author'], $result, $action, - $price, $this->questiondao->ip );
  721. }
  722. //更新今天发布数--需要修改每时间段的更新次数
  723. $this->authissuedao->set_authissue_totals ( $data ['authorid'] );
  724. //发布系统信息
  725. //$subject = "问题 &nbsp;" . $result ['title'] . "&nbsp;新的问题";
  726. //
  727. //$content = $this->messagedao->set_MESSAGE_ADD_QUESTION ( $data ['title'], $result );
  728. //
  729. //$this->messagedao->send_message ( ADMIN_NAME, 0, $data ['authorid'], $subject, $content );
  730. //
  731. //添加提问数
  732. $this->set_questions ( 'add', $data ['authorid'], $data ['category_id'] );
  733. //添加积分值
  734. $this->set_credit1 ( 'add', $data ['authorid'], CREDIT_POINT_ADD, CREDIT_ACTION_ADD );
  735. }
  736. return $result;
  737. }
  738. /**
  739. * 更新检索库
  740. * @param unknown_type $params
  741. */
  742. function update_vip_question_search($params) {
  743. //$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'] );
  744. //$this->update_search_index ( $pams, SEARCH_VWD_DB, SEARCH_VIP_INI );
  745. }
  746. /**
  747. * 设置积分值
  748. * @param unknown_type $type add or take_out
  749. * @param unknown_type $uid
  750. * @param unknown_type $point
  751. * @param unknown_type $action_type
  752. */
  753. function set_credit1($type = 'add', $uid = 0, $point = 0, $action_type = "") {
  754. if ("add" == $type)
  755. return $this->userdao->add_credit1 ( $point, $uid, $action_type );
  756. else if ("take_out" == $type)
  757. return $this->userdao->take_out_credit1 ( $point, $uid, $action_type );
  758. else
  759. return false;
  760. }
  761. /**
  762. * 设置财富值
  763. * @param unknown_type $type add or take_out
  764. * @param unknown_type $price
  765. * @return error_message
  766. */
  767. function set_credit3($price = 0, $uid = 0, $action_type = "", $sso_uid = 0) {
  768. if ($sso_uid == 0)
  769. return 0;
  770. $sso_price = abs ( $price );
  771. //扣除或者增加通行证金额
  772. if ($price < 0)
  773. $is = $this->offer_price_by_sso ( $sso_price, $sso_uid );
  774. else
  775. $is = $this->add_price_by_sso ( $sso_price, $sso_uid );
  776. if ($is <= 0)
  777. return 0;
  778. $this->userdao->add_credit3 ( $price, $uid, $action_type );
  779. return $is;
  780. }
  781. /**
  782. * 设置提问数
  783. * @param unknown_type $type
  784. * @param unknown_type $uid
  785. */
  786. function set_questions($type = 'add', $uid = 0, $category_id = 0) {
  787. if ("add" == $type)
  788. return $this->userdao->add_questions ( $uid, $category_id );
  789. else if ("take_out" == $type)
  790. return $this->userdao->take_out_questions ( $uid, $category_id );
  791. else
  792. return false;
  793. }
  794. /**
  795. * 设置回答数
  796. * @param unknown_type $type
  797. * @param unknown_type $uid 回答问题人UID
  798. * @param unknown_type $qid 回答问题ID
  799. */
  800. function set_answers($type = 'add', $uid = 0, $qid = 0) {
  801. if ("add" == $type)
  802. return $this->userdao->add_answers ( $uid, $qid );
  803. else if ("take_out" == $type)
  804. return $this->userdao->take_out_answers ( $uid, $qid );
  805. else
  806. return false;
  807. }
  808. /**
  809. * 添加一个回答
  810. * @param unknown_type $data
  811. */
  812. function add_answer($data = array()) {
  813. $this->answerdao->qid = $data ['qid'];
  814. $this->answerdao->title = $data ['title'];
  815. $this->answerdao->author = $data ['author'];
  816. $this->answerdao->authorid = $data ['authorid'];
  817. $this->answerdao->content = $data ['content'];
  818. $this->answerdao->time = get_date ();
  819. $this->answerdao->status = 1;
  820. $this->answerdao->ip = client_ip ();
  821. $result = $this->db ()->insert ( $this->answerdao );
  822. if ($result > 0) {
  823. $question = $this->questiondao->get_question_by_id ( $data ['qid'] );
  824. //添加回答数
  825. $this->set_answers ( 'add', $data ['authorid'], $data ['qid'] );
  826. //添加积分值
  827. $this->set_credit1 ( 'add', $data ['authorid'], CREDIT_POINT_ANSWER, CREDIT_ACTION_ANSWER );
  828. $subject = "问题&nbsp;<a href=/askpage/" . $data ['qid'] . " >" . $data ['title'] . "</a>&nbsp;有新的回答";
  829. $content = "问题&nbsp;<a href=/askpage/" . $data ['qid'] . " >" . $data ['title'] . "</a>&nbsp;有新的回答";
  830. $this->messagedao->send_message ( ADMIN_NAME, 0, $question ['authorid'], $subject, $content );
  831. $answer_list = $this->answerdao->get_answer_user_info_by_id ( $data ['qid'] );
  832. $answer = array ();
  833. foreach ( $answer_list as $key => $value ) {
  834. $ans = array ();
  835. $ans ['id'] = $value ['id'];
  836. $ans ['qid'] = $value ['qid'];
  837. $ans ['title'] = $value ['title'];
  838. $ans ['authorid'] = $value ['authorid'];
  839. $ans ['author'] = $value ['author'];
  840. $ans ['time'] = get_date ();
  841. $ans ['adopttime'] = $value ['adopttime'];
  842. $ans ['content'] = $value ['content'];
  843. $ans ['comment'] = $value ['comment'];
  844. array_push ( $answer, $ans );
  845. }
  846. $ans = array ();
  847. $ans ['id'] = $result;
  848. $ans ['qid'] = $data ['qid'];
  849. $ans ['title'] = $data ['title'];
  850. $ans ['authorid'] = $data ['authorid'];
  851. $ans ['author'] = $data ['author'];
  852. $ans ['time'] = $this->answerdao->time;
  853. $ans ['content'] = $data ['content'];
  854. array_push ( $answer, $ans );
  855. $answer = serialize ( $answer );
  856. //更新检索库
  857. //$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 );
  858. //$this->update_search_index ( $pams );
  859. }
  860. return $result;
  861. }
  862. /**
  863. * 删除一个回答
  864. * @param unknown_type $aid
  865. */
  866. function delete_answer($aid = 0, $qid = 0) {
  867. $this->answerdao->id = $aid;
  868. $rs = $this->answerdao->get_answer_by_id ( $aid );
  869. $subject = "回答&nbsp;" . $rs ['title'] . "&nbsp;违规被删除";
  870. $content = "回答&nbsp;" . $rs ['title'] . "&nbsp;<span class=colRed >违规被删除</span>";
  871. $this->messagedao->send_message ( ADMIN_NAME, 0, $rs ['authorid'], $subject, $content );
  872. $this->db ()->delete ( $this->answerdao );
  873. $question = $this->questiondao->get_question_by_id ( $qid );
  874. //回答数更新
  875. $this->set_answers ( 'take_out', $question ['authorid'], $qid );
  876. //扣除积分
  877. $this->set_credit1 ( 'take_out', $rs ['authorid'], POINT_DELETE_ANSWER, ACTION_DELETE_ANSWER );
  878. }
  879. /**
  880. * 删除一个问题
  881. * @param unknown_type $qid
  882. */
  883. function delete_question($qid) {
  884. $condition = " where id = " . $qid;
  885. $data ['hidden'] = 1;
  886. $this->questiondao->update_question ( $data, $condition );
  887. $rs = $this->questiondao->get_question_by_id ( $qid );
  888. //扣除积分
  889. $this->set_credit1 ( 'take_out', $rs ['authorid'], POINT_DELETE_QUESTION, ACTION_DELETE_QUESTION );
  890. $question = $this->questiondao->get_question_by_id ( $qid );
  891. $subject = "问题&nbsp;<a href=/askpage/" . $question ['id'] . ">" . $question ['title'] . "</a>&nbsp;<span class=colRed>违规被删除</span>";
  892. $content = "问题&nbsp;<a href=/askpage/" . $question ['id'] . ">" . $question ['title'] . "</a>&nbsp;<span class=colRed>违规被删除</span>";
  893. $this->send_sys_message ( $subject, $content, $question ['authorid'] );
  894. }
  895. /**
  896. * 修改回答内容
  897. * @param unknown_type $aid
  898. * @param unknown_type $data
  899. */
  900. function update_answer_content($aid = 0, $data) {
  901. $condition = " where id = " . $aid;
  902. $this->answerdao->update_answer ( $data, $condition );
  903. }
  904. /**
  905. * 修改问题内容
  906. * @param unknown_type $qid
  907. * @param unknown_type $data
  908. */
  909. function update_queston_description($qid, $data) {
  910. $condition = " where id = " . $qid;
  911. $this->questiondao->update_question ( $data, $condition );
  912. }
  913. /**
  914. * 添加一个追问
  915. * @param unknown_type $data
  916. */
  917. function to_ask_question($data = array()) {
  918. $data ['tag'] = serialize ( array (0 => $data ['tag'] ) );
  919. $data ['tagtime'] = get_date ();
  920. $this->answerdao->update_taginfo_by_id ( $data );
  921. $rs = $this->answerdao->get_answer_by_id ( $data ['id'] );
  922. $question = $this->questiondao->get_question_by_id ( $rs ['qid'] );
  923. $type = "FOLLOW_QUESTION";
  924. if ($question ['price'] > 0)
  925. $type = "PAY_FOLLOW_QUESTION";
  926. $this->send_email ( $rs ['authorid'], $type, $rs ['qid'], $rs ['id'] );
  927. //发送系统信息-发送给发回答用户
  928. $subject = "回答&nbsp;<a href=/askpage/" . $rs ['qid'] . " >" . $rs ['title'] . "</a>&nbsp;提问者向您追问";
  929. $content = "回答&nbsp;<a href=/askpage/" . $rs ['qid'] . " >" . $rs ['title'] . "</a>&nbsp;提问者向您追问";
  930. $this->messagedao->send_message ( ADMIN_NAME, 0, $rs ['authorid'], $subject, $content );
  931. }
  932. /**
  933. * 添加一个在回答
  934. * @param unknown_type $data
  935. */
  936. function answer_again($data = array()) {
  937. $rs = $this->answerdao->get_answer_by_id ( $data ['id'] );
  938. //追问和回答
  939. $tag_array = unserialize ( $rs ['tag'] );
  940. array_push ( $tag_array, $data ['tag'] );
  941. array_push ( $tag_array, get_date () );
  942. $tag = serialize ( $tag_array );
  943. $data ['tag'] = $tag;
  944. $data ['tagtime'] = $rs ['tagtime'];
  945. $this->answerdao->update_taginfo_by_id ( $data );
  946. $rs = $this->answerdao->get_answer_by_id ( $data ['id'] );
  947. $question = $this->questiondao->get_question_by_id ( $rs ['qid'] );
  948. $type = "FOLLOW_ANSWER";
  949. if ($question ['price'] > 0)
  950. $type = "PAY_FOLLOW_ANSWER";
  951. $this->send_email ( $question ['authorid'], $type, $rs ['qid'], $data ['id'] );
  952. //发送系统信息-发送给发回答用户
  953. $subject = "回答&nbsp;<a href=/askpage/" . $rs ['qid'] . " >" . $rs ['title'] . "</a>&nbsp;追问后有新的回答";
  954. $content = "回答&nbsp;<a href=/askpage/" . $rs ['qid'] . " >" . $rs ['title'] . "</a>&nbsp;追问后有新的回答";
  955. $this->messagedao->send_message ( ADMIN_NAME, 0, $question ['authorid'], $subject, $content );
  956. }
  957. /**
  958. * 更新用户头像
  959. * @param unknown_type $data
  960. */
  961. function update_avatar($data = array()) {
  962. $this->userdao->update_avatar ( $data );
  963. }
  964. /**
  965. * 关闭问题
  966. * @param unknown_type $qid
  967. */
  968. function close_question($qid = 0) {
  969. $this->questiondao->close_question ( $qid );
  970. $result = $this->questiondao->get_question_user_info_by_id ( $qid );
  971. $subject = "问题&nbsp;<a href=/askpage/" . $result ['id'] . " >" . $result ['title'] . "</a>&nbsp;已经关闭";
  972. $content = "问题&nbsp;<a href=/askpage/" . $result ['id'] . " >" . $result ['title'] . "</a>&nbsp;已经关闭";
  973. $this->messagedao->send_message ( ADMIN_NAME, 0, $result ['authorid'], $subject, $content );
  974. //扣除RMB到基金中
  975. if ($result ['price'] > 0)
  976. $this->_set_fund ( $result ['authorid'], $result ['id'], $result ['price'] );
  977. }
  978. /**
  979. * 添加悬赏值
  980. * @param unknown_type $qid
  981. * @param unknown_type $add_price
  982. */
  983. function do_up_price($qid = 0, $add_price = 0) {
  984. $this->questiondao->do_up_price ( $qid, $add_price );
  985. }
  986. /**
  987. * 更新问题补充信息
  988. */
  989. function update_queston_supply($data = array(), $qid = 0) {
  990. $question = $this->questiondao->get_question_by_id ( $qid );
  991. if (! empty ( $question ['supply'] ))
  992. return false;
  993. $condition = " where id = " . $qid;
  994. $supply [0] ['content'] = $data ['supply'];
  995. $supply [0] ['time'] = get_date ();
  996. $data ['supply'] = serialize ( $supply );
  997. $this->questiondao->update_question ( $data, $condition );
  998. $type = "REPLENISH_QUESTION";
  999. if ($question ['price'] > 0)
  1000. $type = "PAY_REPLENISH_QUESTION";
  1001. $this->send_email ( $question ['authorid'], $type, $qid, 0 );
  1002. }
  1003. /**
  1004. * 更新用户信息-仅电话和昵称
  1005. * @param unknown_type $data
  1006. */
  1007. function update_user_info($data = array()) {
  1008. Doo::loadModel ( 'UserDao' );
  1009. $userdao = new UserDao ();
  1010. $userdao->uid = $data ['uid'];
  1011. if (isset ( $data ['phone'] ))
  1012. $userdao->phone = $data ['phone'];
  1013. if (isset ( $data ['nickname'] ))
  1014. $userdao->nickname = $data ['nickname'];
  1015. if (isset ( $data ['cids'] ))
  1016. $userdao->cids = $data ['cids'];
  1017. if (isset ( $data ['is_email'] ))
  1018. $userdao->is_email = $data ['is_email'];
  1019. $result = $this->db ()->update ( $userdao );
  1020. }
  1021. /**
  1022. * 记录财富流向
  1023. * @param unknown_type $data
  1024. */
  1025. function set_credit3_log($data = array(), $price = 0) {
  1026. $this->credit3logdao->qid = $data ['id'];
  1027. $this->credit3logdao->username = $data ['username'];
  1028. $this->credit3logdao->time = get_date ();
  1029. $this->credit3logdao->ip = client_ip ();
  1030. $this->credit3logdao->amount = $price;
  1031. $action = $this->credit3logdao->set_ACTION_OFFER_QUESTION ();
  1032. $this->credit3logdao->add_credit3_log ( $data ['uid'], $data ['username'], $data ['id'], $action, - $price, $this->credit3logdao->ip );
  1033. }
  1034. /**
  1035. * 记录退款
  1036. */
  1037. function set_credit3_refunds_log($data = array()) {
  1038. $this->credit3logdao->qid = $data ['id'];
  1039. $this->credit3logdao->username = $data ['author'];
  1040. $this->credit3logdao->time = get_date ();
  1041. $this->credit3logdao->ip = client_ip ();
  1042. $this->credit3logdao->amount = $data ['price'];
  1043. $action = $this->credit3logdao->set_ACTION_REFUNDS_QUESTION ();
  1044. $this->credit3logdao->add_credit3_log ( $data ['authorid'], $data ['author'], $data ['id'], $action, + $data ['price'], $this->credit3logdao->ip, 1 );
  1045. }
  1046. /**
  1047. * 将名师答疑的问题设置成满意
  1048. * @param unknown_type $id
  1049. */
  1050. function set_vip_question_status($id = 0, $status = 0, $refunds_description = "") {
  1051. if ($status == 0)
  1052. return false;
  1053. $this->vipquestiondao->set_vip_question_status ( $id, $status, $refunds_description );
  1054. }
  1055. /**
  1056. * 发送系统信息
  1057. * @param unknown_type $subject
  1058. * @param unknown_type $content
  1059. * @param unknown_type $uid
  1060. */
  1061. function send_sys_message($subject, $content, $uid) {
  1062. $this->messagedao->send_message ( ADMIN_NAME, 0, $uid, $subject, $content );
  1063. }
  1064. /**
  1065. * 追加一个名师答疑的追问
  1066. * @param unknown_type $id
  1067. * @param unknown_type $tag
  1068. */
  1069. function do_add_vip_tag($id = 0, $tag = "") {
  1070. $tag = serialize ( array (0 => $tag, 1 => get_date () ) );
  1071. $this->vipanswerdao->do_add_vip_tag ( $id, $tag );
  1072. }
  1073. /**
  1074. * 更新名师答疑回答数
  1075. * @param unknown_type $id
  1076. */
  1077. function update_vip_question_by_answers($id) {
  1078. $this->vipquestiondao->update_vip_question_by_answers ( $id );
  1079. }
  1080. /**
  1081. * 添加追问答案
  1082. * @param unknown_type $id
  1083. * @param unknown_type $content
  1084. */
  1085. function update_vip_answer($content = "", $aid = 0, $tag = "") {
  1086. $this->vipanswerdao->id = $aid;
  1087. //追问和回答
  1088. $tag_array = unserialize ( $tag );
  1089. $tag_array ['2'] = $content;
  1090. $tag = serialize ( $tag_array );
  1091. $this->vipanswerdao->tag = $tag;
  1092. $result = $this->db ()->update ( $this->vipanswerdao );
  1093. }
  1094. /**
  1095. * 添加一个公告
  1096. * @param unknown_type $params
  1097. */
  1098. function add_article($params = array()) {
  1099. Doo::loadModel ( 'ArticleDao' );
  1100. $articledao = new ArticleDao ();
  1101. $articledao->title = $params ['title'];
  1102. $articledao->content = $params ['content'];
  1103. $articledao->time = time ();
  1104. $result = $this->db ()->insert ( $articledao );
  1105. }
  1106. /**
  1107. * 获取一个文章
  1108. * @param unknown_type $id
  1109. */
  1110. function get_article_by_id($id = 0) {
  1111. Doo::loadModel ( 'ArticleDao' );
  1112. $articledao = new ArticleDao ();
  1113. $articledao->aid = $id;
  1114. $rs = $this->db ()->find ( $articledao, array ('limit' => 1 ) );
  1115. $rs->time = format_date ( $rs->time );
  1116. return $rs;
  1117. }
  1118. /**
  1119. * 更新一篇文章
  1120. * @param unknown_type $params
  1121. */
  1122. function update_article($params) {
  1123. Doo::loadModel ( 'ArticleDao' );
  1124. $articledao = new ArticleDao ();
  1125. $articledao->aid = $params ['id'];
  1126. $articledao->title = $params ['title'];
  1127. $articledao->content = $params ['content'];
  1128. $this->db ()->update ( $articledao );
  1129. }
  1130. /**
  1131. * 删除文档
  1132. * @param unknown_type $uid
  1133. */
  1134. function delete_article($id = array()) {
  1135. Doo::loadModel ( 'ArticleDao' );
  1136. $articledao = new ArticleDao ();
  1137. $articledao->delete_article ( $id );
  1138. }
  1139. /**
  1140. * 添加名师答疑评价
  1141. * @param unknown_type $qid
  1142. * @param unknown_type $comment
  1143. */
  1144. function update_vip_answer_comment($qid = 0, $comment = "") {
  1145. $this->vipanswerdao->update_vip_answer_comment ( $qid, $comment );
  1146. }
  1147. /**
  1148. * 添加讨论
  1149. * @param unknown_type $qid
  1150. * @param unknown_type $uid
  1151. * @param unknown_type $content
  1152. * @param unknown_type $cid
  1153. */
  1154. function add_discuss($qid = 0, $uid = 0, $content = "", $cid = 0) {
  1155. Doo::loadModel ( 'DiscussDao' );
  1156. $discussdao = new DiscussDao ();
  1157. $discussdao->uid = $uid;
  1158. $discussdao->qid = $qid;
  1159. $discussdao->cid = $cid;
  1160. $discussdao->content = $content;
  1161. $discussdao->time = get_date ();
  1162. $discussdao->discuss = 0;
  1163. $result = $this->db ()->insert ( $discussdao );
  1164. return $result;
  1165. }
  1166. /**
  1167. * 更新讨论数
  1168. * @param unknown_type $cid
  1169. */
  1170. function update_discuss($cid = 0) {
  1171. Doo::loadModel ( 'DiscussDao' );
  1172. $discussdao = new DiscussDao ();
  1173. $discussdao->update_discuss ( $cid );
  1174. }
  1175. /**
  1176. * 添加一个公告
  1177. * @param unknown_type $params
  1178. */
  1179. function add_category($params = array()) {
  1180. Doo::loadModel ( 'CategoryDao' );
  1181. $categorydao = new CategoryDao ();
  1182. $categorydao->name = $params ['name'];
  1183. $categorydao->pid = $params ['pid'];
  1184. $categorydao->grade = 1;
  1185. $result = $this->db ()->insert ( $categorydao );
  1186. }
  1187. /**
  1188. * 删除选中问题
  1189. * @param unknown_type $id
  1190. */
  1191. function delete_category_list($id = array()) {
  1192. $this->categorydao->delete_category_list ( $id );
  1193. }
  1194. /**
  1195. * 更新分类信息
  1196. * @param unknown_type $id
  1197. * @param unknown_type $name
  1198. * @param unknown_type $pid
  1199. */
  1200. function update_category($id = 0, $name = "", $pid = 0) {
  1201. $this->categorydao->id = $id;
  1202. $this->categorydao->name = $name;
  1203. $this->categorydao->pid = $pid;
  1204. $result = $this->db ()->update ( $this->categorydao );
  1205. }
  1206. /**
  1207. * 设置为默认发送邮件
  1208. * @param unknown_type $uid
  1209. */
  1210. function set_email_config($uid = 0) {
  1211. if ($uid == 0)
  1212. return false;
  1213. $data ['normal_question_mail'] = array ("0" => "NEW_ANSWER", "1" => "CLOSE_QUESTION", "2" => "FOLLOW_ANSWER", "3" => "FOLLOW_QUESTION", "4" => "REPLENISH_QUESTION", "5" => "ADOPT_ANSWER" );
  1214. $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" );
  1215. $data ['vip_question_mail'] = array ("1" => "VIP_PAY_FORMONEY", "2" => "VIP_MONEY_BACK", "3" => "VIP_NEW_ANSWER", "4" => "VIP_FOLLOW_ANSWER" );
  1216. $this->add_email_config ( $data, $uid );
  1217. $data ['uid'] = $uid;
  1218. $data ['is_email'] = 1;
  1219. $this->update_user_info ( $data );
  1220. }
  1221. /**
  1222. * 获取个人email配置
  1223. * @param unknown_type $uid
  1224. */
  1225. function get_email_config($uid = 0) {
  1226. Doo::loadModel ( 'EmailconfigDao' );
  1227. $emailconfigdao = new EmailconfigDao ();
  1228. $result = $emailconfigdao->get_emailconfig_by_uid ( $uid );
  1229. $is_email = array ();
  1230. foreach ( $result as $key => $value ) {
  1231. array_push ( $is_email, $value ['action_id'] );
  1232. }
  1233. return $is_email;
  1234. }
  1235. /**
  1236. * 添加email配置
  1237. * @param unknown_type $data
  1238. * @param unknown_type $uid
  1239. */
  1240. function add_email_config($data = array(), $uid = 0) {
  1241. Doo::loadModel ( 'EmailconfigDao' );
  1242. $emailconfigdao = new EmailconfigDao ();
  1243. $emailconfigdao->delete_emailconfig_by_uid ( $uid );
  1244. $normal = $pay = $vip = array ();
  1245. //添加普通问答配置
  1246. foreach ( $data ['normal_question_mail'] as $key => $value ) {
  1247. array_push ( $normal, "(" . $uid . ",'" . $value . "')" );
  1248. }
  1249. if (! empty ( $normal )) {
  1250. $normal = implode ( ",", $normal );
  1251. $emailconfigdao->add_emailconfig ( $normal );
  1252. }
  1253. //悬赏问答
  1254. foreach ( $data ['pay_question_mail'] as $key => $value ) {
  1255. array_push ( $pay, "(" . $uid . ",'" . $value . "')" );
  1256. }
  1257. if (! empty ( $pay )) {
  1258. $pay = implode ( ",", $pay );
  1259. $emailconfigdao->add_emailconfig ( $pay );
  1260. }
  1261. //名师答疑
  1262. foreach ( $data ['vip_question_mail'] as $key => $value ) {
  1263. array_push ( $vip, "(" . $uid . ",'" . $value . "')" );
  1264. }
  1265. if (! empty ( $vip )) {
  1266. $vip = implode ( ",", $vip );
  1267. $emailconfigdao->add_emailconfig ( $vip );
  1268. }
  1269. }
  1270. /**
  1271. * 实现接口
  1272. * (non-PHPdoc)
  1273. * @see BaseLogic::format_email_content()
  1274. */
  1275. protected function format_email_content($html_templete, $templete_name, $qid = 0, $aid = 0) {
  1276. if ($templete_name == "VIP_PAY_FORMONEY" || $templete_name == "VIP_MONEY_BACK" || $templete_name == "VIP_NEW_ANSWER" || $templete_name == "VIP_FOLLOW_ANSWER") {
  1277. $question = $this->vipquestiondao->get_vip_question_by_id ( $qid );
  1278. $answer = $this->vipanswerdao->get_vip_answer_by_qid ( $qid );
  1279. } else {
  1280. $question = $this->questiondao->get_question_by_id ( $qid );
  1281. $answer = $this->answerdao->get_answer_by_id ( $aid );
  1282. }
  1283. $userinfo = $this->get_sso_user_info_by_name ( $question ['author'] );
  1284. $result = array ();
  1285. if ($templete_name == "NEW_ANSWER" || $templete_name == "PAY_NEW_ANSWER") { //提问有新的回答
  1286. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1287. $str = str_replace ( "%uid%", $answer ['authorid'], $str );
  1288. $str = str_replace ( "%answer_username%", $answer ['author'], $str );
  1289. $str = str_replace ( "%answer_time%", format_date ( $answer ['time'], "Y年m月d日" ), $str );
  1290. $str = str_replace ( "%qid%", $question ['id'], $str );
  1291. $str = str_replace ( "%question_title%", $question ['title'], $str );
  1292. $str = str_replace ( "%answer_content%", $answer ['content'], $str );
  1293. $result ['templete'] = $str;
  1294. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:你的提问有新的回答' ) . "?=";
  1295. //$result ['subject'] = "";
  1296. $result ['toemail'] = $userinfo [0] ['useremail'];
  1297. //$result ['toemail'] = "cpthought@vip.qq.com";
  1298. return $result;
  1299. } elseif ($templete_name == "CLOSE_QUESTION" || $templete_name == "PAY_CLOSE_QUESTION") { //问题被关闭
  1300. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1301. $str = str_replace ( "%qid%", $question ['id'], $str );
  1302. $str = str_replace ( "%question_title%", $question ['title'], $str );
  1303. $str = str_replace ( "%question_time%", format_date ( time (), "Y年m月d日" ), $str );
  1304. $result ['templete'] = $str;
  1305. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:你的问题被关闭' ) . "?=";
  1306. $result ['toemail'] = $userinfo [0] ['useremail'];
  1307. return $result;
  1308. } elseif ($templete_name == "FOLLOW_ANSWER" || $templete_name == "PAY_FOLLOW_ANSWER") { //追问有新的回答
  1309. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1310. $str = str_replace ( "%qid%", $question ['id'], $str );
  1311. $str = str_replace ( "%answer_username%", $answer ['author'], $str );
  1312. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1313. $str = str_replace ( "%question_title%", $question ['title'], $str );
  1314. $tag_array = unserialize ( $answer ['tag'] );
  1315. $str = str_replace ( "%ask2%", $tag_array [0], $str );
  1316. $str = str_replace ( "%answer2%", $tag_array [1], $str );
  1317. $result ['templete'] = $str;
  1318. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:你的追问有新的回答' ) . "?=";
  1319. $result ['toemail'] = $userinfo [0] ['useremail'];
  1320. return $result;
  1321. } elseif ($templete_name == "FOLLOW_QUESTION" || $templete_name == "PAY_FOLLOW_QUESTION") { //提问者向您追问
  1322. $str = str_replace ( "%answer_username%", $answer ['author'], $html_templete );
  1323. $str = str_replace ( "%qid%", $question ['id'], $str );
  1324. $str = str_replace ( "%username%", $question ['author'], $str );
  1325. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1326. $str = str_replace ( "%question_title%", $question ['title'], $str );
  1327. $str = str_replace ( "%answer_content%", $answer ['content'], $str );
  1328. $tag_array = unserialize ( $answer ['tag'] );
  1329. $str = str_replace ( "%ask2%", $tag_array [0], $str );
  1330. $result ['templete'] = $str;
  1331. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:提问者向您追问' ) . "?=";
  1332. $result ['toemail'] = $userinfo [0] ['useremail'];
  1333. return $result;
  1334. } elseif ($templete_name == "REPLENISH_QUESTION" || $templete_name == "PAY_REPLENISH_QUESTION") { //提问这对问题进行了补充
  1335. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1336. $str = str_replace ( "%qid%", $question ['id'], $str );
  1337. $str = str_replace ( "%question_title%", $question ['title'], $str );
  1338. $tag_array = unserialize ( $question ['supply'] );
  1339. $str = str_replace ( "%supply%", $tag_array [0] ['content'], $str );
  1340. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1341. $result ['templete'] = $str;
  1342. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:提问者对问题进行了补充' ) . "?=";
  1343. $result ['toemail'] = $userinfo [0] ['useremail'];
  1344. return $result;
  1345. } elseif ($templete_name == "ADOPT_ANSWER" || $templete_name == "PAY_ADOPT_ANSWER") { //回答被采纳了
  1346. $str = str_replace ( "%answer_username%", $answer ['author'], $html_templete );
  1347. $str = str_replace ( "%qid%", $answer ['qid'], $str );
  1348. $str = str_replace ( "%username%", $question ['author'], $str );
  1349. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1350. $str = str_replace ( "%question_title%", $question ['title'], $str );
  1351. $str = str_replace ( "%answer_content%", $answer ['content'], $str );
  1352. $result ['templete'] = $str;
  1353. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:您的回答被采纳了!' ) . "?=";
  1354. $userinfo = $this->get_sso_user_info_by_name ( $answer ['author'] );
  1355. $result ['toemail'] = $userinfo [0] ['useremail'];
  1356. return $result;
  1357. } elseif ($templete_name == "PAY_FORMONEY") {
  1358. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1359. $str = str_replace ( "%price%", $question ['price'], $str );
  1360. $str = str_replace ( "%qid%", $question ['id'], $str );
  1361. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1362. $result ['templete'] = $str;
  1363. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:您进行了一项付费操作' ) . "?=";
  1364. $result ['toemail'] = $userinfo [0] ['useremail'];
  1365. return $result;
  1366. } elseif ($templete_name == "VIP_PAY_FORMONEY") { //名师答疑付费提醒
  1367. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1368. $str = str_replace ( "%price%", $question ['price'], $str );
  1369. $str = str_replace ( "%uid%", $question ['authorid'], $str );
  1370. $result ['templete'] = $str;
  1371. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:您进行了一项付费操作' ) . "?=";
  1372. $result ['toemail'] = $userinfo [0] ['useremail'];
  1373. return $result;
  1374. } elseif ($templete_name == "VIP_NEW_ANSWER") { //名师答疑有回答提醒
  1375. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1376. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1377. $str = str_replace ( "%vqid%", $question ['id'], $str );
  1378. $str = str_replace ( "%vipquestion_title%", $question ['title'], $str );
  1379. $str = str_replace ( "%vanswer_content%", $answer ['content'], $str );
  1380. $result ['templete'] = $str;
  1381. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:你的名师答疑有新的回答' ) . "?=";
  1382. $result ['toemail'] = $userinfo [0] ['useremail'];
  1383. return $result;
  1384. } elseif ($templete_name == "VIP_MONEY_BACK") { //名师答疑退费提醒
  1385. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1386. $str = str_replace ( "%price%", $question ['price'], $str );
  1387. $str = str_replace ( "%uid%", $question ['authorid'], $str );
  1388. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1389. $result ['templete'] = $str;
  1390. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:向您退费成功' ) . "?=";
  1391. $result ['toemail'] = $userinfo [0] ['useremail'];
  1392. return $result;
  1393. } elseif ($templete_name == "VIP_FOLLOW_ANSWER") { //名师答疑追问有了新的回答
  1394. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1395. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1396. $str = str_replace ( "%vipquestion_title%", $question ['title'], $str );
  1397. $str = str_replace ( "%vanswer_content%", $answer ['content'], $str );
  1398. $str = str_replace ( "%vqid%", $question ['id'], $str );
  1399. $result ['templete'] = $str;
  1400. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:你在名师答疑中追问有新的回答' ) . "?=";
  1401. $result ['toemail'] = $userinfo [0] ['useremail'];
  1402. //$result ['toemail'] = "cpthought@vip.qq.com";
  1403. return $result;
  1404. }
  1405. }
  1406. }
  1407. ?>