UserLogic.php 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204
  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. $this->credit3logdao->ip = $this->questiondao->ip;
  667. $this->credit3logdao->amount = $price;
  668. $this->credit3logdao->username = $data ['author'];
  669. $this->credit3logdao->uid = $data ['authorid'];
  670. $this->credit3logdao->time = $this->questiondao->time;
  671. //扣除金额后才可以添加问题
  672. if ($data ['price'] > 0) {
  673. $is = $this->set_credit3 ( - $data ['price'], $data ['authorid'], RICH_ACTION_OFFER, SSO_UID );
  674. if ($is == 0)
  675. return 0;
  676. }
  677. //推广手段
  678. if($data['price']==0){
  679. $fundstr=file_get_contents(SITE_PATH . '/protected/config/fund.conf.php') ;
  680. if($fundstr){
  681. //获取基金
  682. Doo::loadModel ( 'FundDao' );
  683. $funddao = new FundDao ();
  684. $fund=$funddao->get_fund_by_amount();
  685. if(!empty($fund)){
  686. $funddao->set_fund_amount_spread("-1",$fund['id']);
  687. $this->questiondao->price=1;
  688. }
  689. }
  690. }
  691. //发送邮件
  692. if ($data ['price'] > 0) {
  693. $this->send_email ( $data ['authorid'], "PAY_FORMONEY", $result, 0 );
  694. }
  695. //是否需要优化
  696. if ($result) {
  697. //扣除财富值--财富值记录
  698. if ($data ['price'] > 0) {
  699. $this->credit3logdao->qid = $result;
  700. $action = $this->credit3logdao->set_ACTION_OFFER_QUESTION ();
  701. $this->credit3logdao->add_credit3_log ( $data ['authorid'], $data ['author'], $result, $action, - $price, $this->questiondao->ip );
  702. }
  703. //更新今天发布数--需要修改每时间段的更新次数
  704. $this->authissuedao->set_authissue_totals ( $data ['authorid'] );
  705. //添加积分值
  706. $this->set_credit1 ( 'add', $data ['authorid'], CREDIT_POINT_ADD, CREDIT_ACTION_ADD );
  707. }
  708. return $result;
  709. */
  710. }
  711. /**
  712. * 添加一个问题
  713. * @param unknown_type $data
  714. * @return $result 问题ID;
  715. */
  716. function add_question($data = array()) {
  717. $this->questiondao->title = $data ['title'];
  718. $this->questiondao->cid = $data ['category_id'];
  719. $this->questiondao->description = $data ['description'];
  720. //取绝对值
  721. $price = abs ( $data ['price'] );
  722. $this->questiondao->price = $price;
  723. $this->credit3logdao->amount = $price;
  724. $this->questiondao->author = $data ['author'];
  725. $this->credit3logdao->username = $data ['author'];
  726. $this->questiondao->authorid = $data ['authorid'];
  727. $this->credit3logdao->uid = $data ['authorid'];
  728. $this->questiondao->time = get_date ();
  729. $this->credit3logdao->time = $this->questiondao->time;
  730. $this->questiondao->endtime = get_date ( 15 );
  731. $this->questiondao->ip = client_ip ();
  732. $this->credit3logdao->ip = $this->questiondao->ip;
  733. //扣除金额后才可以添加问题
  734. if ($data ['price'] > 0) {
  735. $is = $this->set_credit3 ( - $data ['price'], $data ['authorid'], RICH_ACTION_OFFER, SSO_UID );
  736. if ($is == 0)
  737. return 0;
  738. }
  739. //推广手段
  740. if($data['price']==0){
  741. $fundstr=file_get_contents(SITE_PATH . '/protected/config/fund.conf.php') ;
  742. if($fundstr){
  743. //获取基金
  744. Doo::loadModel ( 'FundDao' );
  745. $funddao = new FundDao ();
  746. $fund=$funddao->get_fund_by_amount();
  747. if(!empty($fund)){
  748. $funddao->set_fund_amount_spread("-1",$fund['id']);
  749. $this->questiondao->price=1;
  750. }
  751. }
  752. }
  753. $result = $this->db ()->insert ( $this->questiondao );
  754. //发送邮件
  755. if ($data ['price'] > 0) {
  756. $this->send_email ( $data ['authorid'], "PAY_FORMONEY", $result, 0 );
  757. }
  758. //是否需要优化
  759. if ($result) {
  760. //加入检索索引-分词还未加入-数据配置
  761. //$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 );
  762. //$this->add_search_index ( $pams );
  763. //扣除财富值--财富值记录
  764. if ($data ['price'] > 0) {
  765. $this->credit3logdao->qid = $result;
  766. $action = $this->credit3logdao->set_ACTION_OFFER_QUESTION ();
  767. $this->credit3logdao->add_credit3_log ( $data ['authorid'], $data ['author'], $result, $action, - $price, $this->questiondao->ip );
  768. }
  769. //更新今天发布数--需要修改每时间段的更新次数
  770. $this->authissuedao->set_authissue_totals ( $data ['authorid'] );
  771. //发布系统信息
  772. //$subject = "问题 &nbsp;" . $result ['title'] . "&nbsp;新的问题";
  773. //
  774. //$content = $this->messagedao->set_MESSAGE_ADD_QUESTION ( $data ['title'], $result );
  775. //
  776. //$this->messagedao->send_message ( ADMIN_NAME, 0, $data ['authorid'], $subject, $content );
  777. //
  778. //添加提问数
  779. $this->set_questions ( 'add', $data ['authorid'], $data ['category_id'] );
  780. //添加积分值
  781. $this->set_credit1 ( 'add', $data ['authorid'], CREDIT_POINT_ADD, CREDIT_ACTION_ADD );
  782. }
  783. return $result;
  784. }
  785. /**
  786. * 更新检索库
  787. * @param unknown_type $params
  788. */
  789. function update_vip_question_search($params) {
  790. //$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'] );
  791. //$this->update_search_index ( $pams, SEARCH_VWD_DB, SEARCH_VIP_INI );
  792. }
  793. /**
  794. * 设置积分值
  795. * @param unknown_type $type add or take_out
  796. * @param unknown_type $uid
  797. * @param unknown_type $point
  798. * @param unknown_type $action_type
  799. */
  800. function set_credit1($type = 'add', $uid = 0, $point = 0, $action_type = "") {
  801. if ("add" == $type)
  802. return $this->userdao->add_credit1 ( $point, $uid, $action_type );
  803. else if ("take_out" == $type)
  804. return $this->userdao->take_out_credit1 ( $point, $uid, $action_type );
  805. else
  806. return false;
  807. }
  808. /**
  809. * 设置财富值
  810. * @param unknown_type $type add or take_out
  811. * @param unknown_type $price
  812. * @return error_message
  813. */
  814. function set_credit3($price = 0, $uid = 0, $action_type = "", $sso_uid = 0) {
  815. if ($sso_uid == 0)
  816. return 0;
  817. $sso_price = abs ( $price );
  818. //扣除或者增加通行证金额
  819. if ($price < 0)
  820. $is = $this->offer_price_by_sso ( $sso_price, $sso_uid );
  821. else
  822. $is = $this->add_price_by_sso ( $sso_price, $sso_uid );
  823. if ($is <= 0)
  824. return 0;
  825. $this->userdao->add_credit3 ( $price, $uid, $action_type );
  826. return $is;
  827. }
  828. /**
  829. * 设置提问数
  830. * @param unknown_type $type
  831. * @param unknown_type $uid
  832. */
  833. function set_questions($type = 'add', $uid = 0, $category_id = 0) {
  834. if ("add" == $type)
  835. return $this->userdao->add_questions ( $uid, $category_id );
  836. else if ("take_out" == $type)
  837. return $this->userdao->take_out_questions ( $uid, $category_id );
  838. else
  839. return false;
  840. }
  841. /**
  842. * 设置回答数
  843. * @param unknown_type $type
  844. * @param unknown_type $uid 回答问题人UID
  845. * @param unknown_type $qid 回答问题ID
  846. */
  847. function set_answers($type = 'add', $uid = 0, $qid = 0) {
  848. if ("add" == $type)
  849. return $this->userdao->add_answers ( $uid, $qid );
  850. else if ("take_out" == $type)
  851. return $this->userdao->take_out_answers ( $uid, $qid );
  852. else
  853. return false;
  854. }
  855. /**
  856. * 添加一个回答
  857. * @param unknown_type $data
  858. */
  859. function add_answer($data = array()) {
  860. $this->answerdao->qid = $data ['qid'];
  861. $this->answerdao->title = $data ['title'];
  862. $this->answerdao->author = $data ['author'];
  863. $this->answerdao->authorid = $data ['authorid'];
  864. $this->answerdao->content = $data ['content'];
  865. $this->answerdao->time = get_date ();
  866. $this->answerdao->status = 1;
  867. $this->answerdao->ip = client_ip ();
  868. $result = $this->db ()->insert ( $this->answerdao );
  869. if ($result > 0) {
  870. $question = $this->questiondao->get_question_by_id ( $data ['qid'] );
  871. //添加回答数
  872. $this->set_answers ( 'add', $data ['authorid'], $data ['qid'] );
  873. //添加积分值
  874. $this->set_credit1 ( 'add', $data ['authorid'], CREDIT_POINT_ANSWER, CREDIT_ACTION_ANSWER );
  875. $subject = "问题&nbsp;<a href=/askpage/" . $data ['qid'] . " >" . $data ['title'] . "</a>&nbsp;有新的回答";
  876. $content = "问题&nbsp;<a href=/askpage/" . $data ['qid'] . " >" . $data ['title'] . "</a>&nbsp;有新的回答";
  877. $this->messagedao->send_message ( ADMIN_NAME, 0, $question ['authorid'], $subject, $content );
  878. $answer_list = $this->answerdao->get_answer_user_info_by_id ( $data ['qid'] );
  879. $answer = array ();
  880. foreach ( $answer_list as $key => $value ) {
  881. $ans = array ();
  882. $ans ['id'] = $value ['id'];
  883. $ans ['qid'] = $value ['qid'];
  884. $ans ['title'] = $value ['title'];
  885. $ans ['authorid'] = $value ['authorid'];
  886. $ans ['author'] = $value ['author'];
  887. $ans ['time'] = get_date ();
  888. $ans ['adopttime'] = $value ['adopttime'];
  889. $ans ['content'] = $value ['content'];
  890. $ans ['comment'] = $value ['comment'];
  891. array_push ( $answer, $ans );
  892. }
  893. $ans = array ();
  894. $ans ['id'] = $result;
  895. $ans ['qid'] = $data ['qid'];
  896. $ans ['title'] = $data ['title'];
  897. $ans ['authorid'] = $data ['authorid'];
  898. $ans ['author'] = $data ['author'];
  899. $ans ['time'] = $this->answerdao->time;
  900. $ans ['content'] = $data ['content'];
  901. array_push ( $answer, $ans );
  902. $answer = serialize ( $answer );
  903. //更新检索库
  904. //$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 );
  905. //$this->update_search_index ( $pams );
  906. }
  907. return $result;
  908. }
  909. /**
  910. * 删除一个回答
  911. * @param unknown_type $aid
  912. */
  913. function delete_answer($aid = 0, $qid = 0) {
  914. $this->answerdao->id = $aid;
  915. $rs = $this->answerdao->get_answer_by_id ( $aid );
  916. $subject = "回答&nbsp;" . $rs ['title'] . "&nbsp;违规被删除";
  917. $content = "回答&nbsp;" . $rs ['title'] . "&nbsp;<span class=colRed >违规被删除</span>";
  918. $this->messagedao->send_message ( ADMIN_NAME, 0, $rs ['authorid'], $subject, $content );
  919. $this->db ()->delete ( $this->answerdao );
  920. $question = $this->questiondao->get_question_by_id ( $qid );
  921. //回答数更新
  922. $this->set_answers ( 'take_out', $question ['authorid'], $qid );
  923. //扣除积分
  924. $this->set_credit1 ( 'take_out', $rs ['authorid'], POINT_DELETE_ANSWER, ACTION_DELETE_ANSWER );
  925. }
  926. /**
  927. * 删除一个问题
  928. * @param unknown_type $qid
  929. */
  930. function delete_question($qid) {
  931. $condition = " where id = " . $qid;
  932. $data ['hidden'] = 1;
  933. $this->questiondao->update_question ( $data, $condition );
  934. $rs = $this->questiondao->get_question_by_id ( $qid );
  935. //扣除积分
  936. $this->set_credit1 ( 'take_out', $rs ['authorid'], POINT_DELETE_QUESTION, ACTION_DELETE_QUESTION );
  937. $question = $this->questiondao->get_question_by_id ( $qid );
  938. $subject = "问题&nbsp;<a href=/askpage/" . $question ['id'] . ">" . $question ['title'] . "</a>&nbsp;<span class=colRed>违规被删除</span>";
  939. $content = "问题&nbsp;<a href=/askpage/" . $question ['id'] . ">" . $question ['title'] . "</a>&nbsp;<span class=colRed>违规被删除</span>";
  940. $this->send_sys_message ( $subject, $content, $question ['authorid'] );
  941. }
  942. /**
  943. * 修改回答内容
  944. * @param unknown_type $aid
  945. * @param unknown_type $data
  946. */
  947. function update_answer_content($aid = 0, $data) {
  948. $condition = " where id = " . $aid;
  949. $this->answerdao->update_answer ( $data, $condition );
  950. }
  951. /**
  952. * 修改问题内容
  953. * @param unknown_type $qid
  954. * @param unknown_type $data
  955. */
  956. function update_queston_description($qid, $data) {
  957. $condition = " where id = " . $qid;
  958. $this->questiondao->update_question ( $data, $condition );
  959. }
  960. /**
  961. * 添加一个追问
  962. * @param unknown_type $data
  963. */
  964. function to_ask_question($data = array()) {
  965. $data ['tag'] = serialize ( array (0 => $data ['tag'] ) );
  966. $data ['tagtime'] = get_date ();
  967. $this->answerdao->update_taginfo_by_id ( $data );
  968. $rs = $this->answerdao->get_answer_by_id ( $data ['id'] );
  969. $question = $this->questiondao->get_question_by_id ( $rs ['qid'] );
  970. $type = "FOLLOW_QUESTION";
  971. if ($question ['price'] > 0)
  972. $type = "PAY_FOLLOW_QUESTION";
  973. $this->send_email ( $rs ['authorid'], $type, $rs ['qid'], $rs ['id'] );
  974. //发送系统信息-发送给发回答用户
  975. $subject = "回答&nbsp;<a href=/askpage/" . $rs ['qid'] . " >" . $rs ['title'] . "</a>&nbsp;提问者向您追问";
  976. $content = "回答&nbsp;<a href=/askpage/" . $rs ['qid'] . " >" . $rs ['title'] . "</a>&nbsp;提问者向您追问";
  977. $this->messagedao->send_message ( ADMIN_NAME, 0, $rs ['authorid'], $subject, $content );
  978. }
  979. /**
  980. * 添加一个在回答
  981. * @param unknown_type $data
  982. */
  983. function answer_again($data = array()) {
  984. $rs = $this->answerdao->get_answer_by_id ( $data ['id'] );
  985. //追问和回答
  986. $tag_array = unserialize ( $rs ['tag'] );
  987. array_push ( $tag_array, $data ['tag'] );
  988. array_push ( $tag_array, get_date () );
  989. $tag = serialize ( $tag_array );
  990. $data ['tag'] = $tag;
  991. $data ['tagtime'] = $rs ['tagtime'];
  992. $this->answerdao->update_taginfo_by_id ( $data );
  993. $rs = $this->answerdao->get_answer_by_id ( $data ['id'] );
  994. $question = $this->questiondao->get_question_by_id ( $rs ['qid'] );
  995. $type = "FOLLOW_ANSWER";
  996. if ($question ['price'] > 0)
  997. $type = "PAY_FOLLOW_ANSWER";
  998. $this->send_email ( $question ['authorid'], $type, $rs ['qid'], $data ['id'] );
  999. //发送系统信息-发送给发回答用户
  1000. $subject = "回答&nbsp;<a href=/askpage/" . $rs ['qid'] . " >" . $rs ['title'] . "</a>&nbsp;追问后有新的回答";
  1001. $content = "回答&nbsp;<a href=/askpage/" . $rs ['qid'] . " >" . $rs ['title'] . "</a>&nbsp;追问后有新的回答";
  1002. $this->messagedao->send_message ( ADMIN_NAME, 0, $question ['authorid'], $subject, $content );
  1003. }
  1004. /**
  1005. * 更新用户头像
  1006. * @param unknown_type $data
  1007. */
  1008. function update_avatar($data = array()) {
  1009. $this->userdao->update_avatar ( $data );
  1010. }
  1011. /**
  1012. * 关闭问题
  1013. * @param unknown_type $qid
  1014. */
  1015. function close_question($qid = 0) {
  1016. $this->questiondao->close_question ( $qid );
  1017. $result = $this->questiondao->get_question_user_info_by_id ( $qid );
  1018. $subject = "问题&nbsp;<a href=/askpage/" . $result ['id'] . " >" . $result ['title'] . "</a>&nbsp;已经关闭";
  1019. $content = "问题&nbsp;<a href=/askpage/" . $result ['id'] . " >" . $result ['title'] . "</a>&nbsp;已经关闭";
  1020. $this->messagedao->send_message ( ADMIN_NAME, 0, $result ['authorid'], $subject, $content );
  1021. //扣除RMB到基金中
  1022. if ($result ['price'] > 0)
  1023. $this->_set_fund ( $result ['authorid'], $result ['id'], $result ['price'] );
  1024. }
  1025. /**
  1026. * 添加悬赏值
  1027. * @param unknown_type $qid
  1028. * @param unknown_type $add_price
  1029. */
  1030. function do_up_price($qid = 0, $add_price = 0) {
  1031. $this->questiondao->do_up_price ( $qid, $add_price );
  1032. }
  1033. /**
  1034. * 更新问题补充信息
  1035. */
  1036. function update_queston_supply($data = array(), $qid = 0) {
  1037. $question = $this->questiondao->get_question_by_id ( $qid );
  1038. if (! empty ( $question ['supply'] ))
  1039. return false;
  1040. $condition = " where id = " . $qid;
  1041. $supply [0] ['content'] = $data ['supply'];
  1042. $supply [0] ['time'] = get_date ();
  1043. $data ['supply'] = serialize ( $supply );
  1044. $this->questiondao->update_question ( $data, $condition );
  1045. $type = "REPLENISH_QUESTION";
  1046. if ($question ['price'] > 0)
  1047. $type = "PAY_REPLENISH_QUESTION";
  1048. $this->send_email ( $question ['authorid'], $type, $qid, 0 );
  1049. }
  1050. /**
  1051. * 更新用户信息-仅电话和昵称
  1052. * @param unknown_type $data
  1053. */
  1054. function update_user_info($data = array()) {
  1055. Doo::loadModel ( 'UserDao' );
  1056. $userdao = new UserDao ();
  1057. $userdao->uid = $data ['uid'];
  1058. if (isset ( $data ['phone'] ))
  1059. $userdao->phone = $data ['phone'];
  1060. if (isset ( $data ['nickname'] ))
  1061. $userdao->nickname = $data ['nickname'];
  1062. if (isset ( $data ['cids'] ))
  1063. $userdao->cids = $data ['cids'];
  1064. if (isset ( $data ['is_email'] ))
  1065. $userdao->is_email = $data ['is_email'];
  1066. $result = $this->db ()->update ( $userdao );
  1067. }
  1068. /**
  1069. * 记录财富流向
  1070. * @param unknown_type $data
  1071. */
  1072. function set_credit3_log($data = array(), $price = 0) {
  1073. $this->credit3logdao->qid = $data ['id'];
  1074. $this->credit3logdao->username = $data ['username'];
  1075. $this->credit3logdao->time = get_date ();
  1076. $this->credit3logdao->ip = client_ip ();
  1077. $this->credit3logdao->amount = $price;
  1078. $action = $this->credit3logdao->set_ACTION_OFFER_QUESTION ();
  1079. $this->credit3logdao->add_credit3_log ( $data ['uid'], $data ['username'], $data ['id'], $action, - $price, $this->credit3logdao->ip );
  1080. }
  1081. /**
  1082. * 记录退款
  1083. */
  1084. function set_credit3_refunds_log($data = array()) {
  1085. $this->credit3logdao->qid = $data ['id'];
  1086. $this->credit3logdao->username = $data ['author'];
  1087. $this->credit3logdao->time = get_date ();
  1088. $this->credit3logdao->ip = client_ip ();
  1089. $this->credit3logdao->amount = $data ['price'];
  1090. $action = $this->credit3logdao->set_ACTION_REFUNDS_QUESTION ();
  1091. $this->credit3logdao->add_credit3_log ( $data ['authorid'], $data ['author'], $data ['id'], $action, + $data ['price'], $this->credit3logdao->ip, 1 );
  1092. }
  1093. /**
  1094. * 将名师答疑的问题设置成满意
  1095. * @param unknown_type $id
  1096. */
  1097. function set_vip_question_status($id = 0, $status = 0, $refunds_description = "") {
  1098. if ($status == 0)
  1099. return false;
  1100. $this->vipquestiondao->set_vip_question_status ( $id, $status, $refunds_description );
  1101. }
  1102. /**
  1103. * 发送系统信息
  1104. * @param unknown_type $subject
  1105. * @param unknown_type $content
  1106. * @param unknown_type $uid
  1107. */
  1108. function send_sys_message($subject, $content, $uid) {
  1109. $this->messagedao->send_message ( ADMIN_NAME, 0, $uid, $subject, $content );
  1110. }
  1111. /**
  1112. * 追加一个名师答疑的追问
  1113. * @param unknown_type $id
  1114. * @param unknown_type $tag
  1115. */
  1116. function do_add_vip_tag($id = 0, $tag = "") {
  1117. $tag = serialize ( array (0 => $tag, 1 => get_date () ) );
  1118. $this->vipanswerdao->do_add_vip_tag ( $id, $tag );
  1119. }
  1120. /**
  1121. * 更新名师答疑回答数
  1122. * @param unknown_type $id
  1123. */
  1124. function update_vip_question_by_answers($id) {
  1125. $this->vipquestiondao->update_vip_question_by_answers ( $id );
  1126. }
  1127. /**
  1128. * 添加追问答案
  1129. * @param unknown_type $id
  1130. * @param unknown_type $content
  1131. */
  1132. function update_vip_answer($content = "", $aid = 0, $tag = "") {
  1133. $this->vipanswerdao->id = $aid;
  1134. //追问和回答
  1135. $tag_array = unserialize ( $tag );
  1136. $tag_array ['2'] = $content;
  1137. $tag = serialize ( $tag_array );
  1138. $this->vipanswerdao->tag = $tag;
  1139. $result = $this->db ()->update ( $this->vipanswerdao );
  1140. }
  1141. /**
  1142. * 添加一个公告
  1143. * @param unknown_type $params
  1144. */
  1145. function add_article($params = array()) {
  1146. Doo::loadModel ( 'ArticleDao' );
  1147. $articledao = new ArticleDao ();
  1148. $articledao->title = $params ['title'];
  1149. $articledao->content = $params ['content'];
  1150. $articledao->time = time ();
  1151. $result = $this->db ()->insert ( $articledao );
  1152. }
  1153. /**
  1154. * 获取一个文章
  1155. * @param unknown_type $id
  1156. */
  1157. function get_article_by_id($id = 0) {
  1158. Doo::loadModel ( 'ArticleDao' );
  1159. $articledao = new ArticleDao ();
  1160. $articledao->aid = $id;
  1161. $rs = $this->db ()->find ( $articledao, array ('limit' => 1 ) );
  1162. $rs->time = format_date ( $rs->time );
  1163. return $rs;
  1164. }
  1165. /**
  1166. * 更新一篇文章
  1167. * @param unknown_type $params
  1168. */
  1169. function update_article($params) {
  1170. Doo::loadModel ( 'ArticleDao' );
  1171. $articledao = new ArticleDao ();
  1172. $articledao->aid = $params ['id'];
  1173. $articledao->title = $params ['title'];
  1174. $articledao->content = $params ['content'];
  1175. $this->db ()->update ( $articledao );
  1176. }
  1177. /**
  1178. * 删除文档
  1179. * @param unknown_type $uid
  1180. */
  1181. function delete_article($id = array()) {
  1182. Doo::loadModel ( 'ArticleDao' );
  1183. $articledao = new ArticleDao ();
  1184. $articledao->delete_article ( $id );
  1185. }
  1186. /**
  1187. * 添加名师答疑评价
  1188. * @param unknown_type $qid
  1189. * @param unknown_type $comment
  1190. */
  1191. function update_vip_answer_comment($qid = 0, $comment = "") {
  1192. $this->vipanswerdao->update_vip_answer_comment ( $qid, $comment );
  1193. }
  1194. /**
  1195. * 添加讨论
  1196. * @param unknown_type $qid
  1197. * @param unknown_type $uid
  1198. * @param unknown_type $content
  1199. * @param unknown_type $cid
  1200. */
  1201. function add_discuss($qid = 0, $uid = 0, $content = "", $cid = 0) {
  1202. Doo::loadModel ( 'DiscussDao' );
  1203. $discussdao = new DiscussDao ();
  1204. $discussdao->uid = $uid;
  1205. $discussdao->qid = $qid;
  1206. $discussdao->cid = $cid;
  1207. $discussdao->content = $content;
  1208. $discussdao->time = get_date ();
  1209. $discussdao->discuss = 0;
  1210. $result = $this->db ()->insert ( $discussdao );
  1211. return $result;
  1212. }
  1213. /**
  1214. * 更新讨论数
  1215. * @param unknown_type $cid
  1216. */
  1217. function update_discuss($cid = 0) {
  1218. Doo::loadModel ( 'DiscussDao' );
  1219. $discussdao = new DiscussDao ();
  1220. $discussdao->update_discuss ( $cid );
  1221. }
  1222. /**
  1223. * 添加一个公告
  1224. * @param unknown_type $params
  1225. */
  1226. function add_category($params = array()) {
  1227. Doo::loadModel ( 'CategoryDao' );
  1228. $categorydao = new CategoryDao ();
  1229. $categorydao->name = $params ['name'];
  1230. $categorydao->pid = $params ['pid'];
  1231. $categorydao->grade = 1;
  1232. $result = $this->db ()->insert ( $categorydao );
  1233. }
  1234. /**
  1235. * 删除选中问题
  1236. * @param unknown_type $id
  1237. */
  1238. function delete_category_list($id = array()) {
  1239. $this->categorydao->delete_category_list ( $id );
  1240. }
  1241. /**
  1242. * 更新分类信息
  1243. * @param unknown_type $id
  1244. * @param unknown_type $name
  1245. * @param unknown_type $pid
  1246. */
  1247. function update_category($id = 0, $name = "", $pid = 0) {
  1248. $this->categorydao->id = $id;
  1249. $this->categorydao->name = $name;
  1250. $this->categorydao->pid = $pid;
  1251. $result = $this->db ()->update ( $this->categorydao );
  1252. }
  1253. /**
  1254. * 设置为默认发送邮件
  1255. * @param unknown_type $uid
  1256. */
  1257. function set_email_config($uid = 0) {
  1258. if ($uid == 0)
  1259. return false;
  1260. $data ['normal_question_mail'] = array ("0" => "NEW_ANSWER", "1" => "CLOSE_QUESTION", "2" => "FOLLOW_ANSWER", "3" => "FOLLOW_QUESTION", "4" => "REPLENISH_QUESTION", "5" => "ADOPT_ANSWER" );
  1261. $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" );
  1262. $data ['vip_question_mail'] = array ("1" => "VIP_PAY_FORMONEY", "2" => "VIP_MONEY_BACK", "3" => "VIP_NEW_ANSWER", "4" => "VIP_FOLLOW_ANSWER" );
  1263. $this->add_email_config ( $data, $uid );
  1264. $data ['uid'] = $uid;
  1265. $data ['is_email'] = 1;
  1266. $this->update_user_info ( $data );
  1267. }
  1268. /**
  1269. * 获取个人email配置
  1270. * @param unknown_type $uid
  1271. */
  1272. function get_email_config($uid = 0) {
  1273. Doo::loadModel ( 'EmailconfigDao' );
  1274. $emailconfigdao = new EmailconfigDao ();
  1275. $result = $emailconfigdao->get_emailconfig_by_uid ( $uid );
  1276. $is_email = array ();
  1277. foreach ( $result as $key => $value ) {
  1278. array_push ( $is_email, $value ['action_id'] );
  1279. }
  1280. return $is_email;
  1281. }
  1282. /**
  1283. * 添加email配置
  1284. * @param unknown_type $data
  1285. * @param unknown_type $uid
  1286. */
  1287. function add_email_config($data = array(), $uid = 0) {
  1288. Doo::loadModel ( 'EmailconfigDao' );
  1289. $emailconfigdao = new EmailconfigDao ();
  1290. $emailconfigdao->delete_emailconfig_by_uid ( $uid );
  1291. $normal = $pay = $vip = array ();
  1292. //添加普通问答配置
  1293. foreach ( $data ['normal_question_mail'] as $key => $value ) {
  1294. array_push ( $normal, "(" . $uid . ",'" . $value . "')" );
  1295. }
  1296. if (! empty ( $normal )) {
  1297. $normal = implode ( ",", $normal );
  1298. $emailconfigdao->add_emailconfig ( $normal );
  1299. }
  1300. //悬赏问答
  1301. foreach ( $data ['pay_question_mail'] as $key => $value ) {
  1302. array_push ( $pay, "(" . $uid . ",'" . $value . "')" );
  1303. }
  1304. if (! empty ( $pay )) {
  1305. $pay = implode ( ",", $pay );
  1306. $emailconfigdao->add_emailconfig ( $pay );
  1307. }
  1308. //名师答疑
  1309. foreach ( $data ['vip_question_mail'] as $key => $value ) {
  1310. array_push ( $vip, "(" . $uid . ",'" . $value . "')" );
  1311. }
  1312. if (! empty ( $vip )) {
  1313. $vip = implode ( ",", $vip );
  1314. $emailconfigdao->add_emailconfig ( $vip );
  1315. }
  1316. }
  1317. /**
  1318. * 实现接口
  1319. * (non-PHPdoc)
  1320. * @see BaseLogic::format_email_content()
  1321. */
  1322. protected function format_email_content($html_templete, $templete_name, $qid = 0, $aid = 0) {
  1323. if ($templete_name == "VIP_PAY_FORMONEY" || $templete_name == "VIP_MONEY_BACK" || $templete_name == "VIP_NEW_ANSWER" || $templete_name == "VIP_FOLLOW_ANSWER") {
  1324. $question = $this->vipquestiondao->get_vip_question_by_id ( $qid );
  1325. $answer = $this->vipanswerdao->get_vip_answer_by_qid ( $qid );
  1326. } else {
  1327. $question = $this->questiondao->get_question_by_id ( $qid );
  1328. $answer = $this->answerdao->get_answer_by_id ( $aid );
  1329. }
  1330. $userinfo = $this->get_sso_user_info_by_name ( $question ['author'] );
  1331. $result = array ();
  1332. if ($templete_name == "NEW_ANSWER" || $templete_name == "PAY_NEW_ANSWER") { //提问有新的回答
  1333. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1334. $str = str_replace ( "%uid%", $answer ['authorid'], $str );
  1335. $str = str_replace ( "%answer_username%", $answer ['author'], $str );
  1336. $str = str_replace ( "%answer_time%", format_date ( $answer ['time'], "Y年m月d日" ), $str );
  1337. $str = str_replace ( "%qid%", $question ['id'], $str );
  1338. $str = str_replace ( "%question_title%", $question ['title'], $str );
  1339. $str = str_replace ( "%answer_content%", $answer ['content'], $str );
  1340. $result ['templete'] = $str;
  1341. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:你的提问有新的回答' ) . "?=";
  1342. //$result ['subject'] = "";
  1343. $result ['toemail'] = $userinfo [0] ['useremail'];
  1344. //$result ['toemail'] = "cpthought@vip.qq.com";
  1345. return $result;
  1346. } elseif ($templete_name == "CLOSE_QUESTION" || $templete_name == "PAY_CLOSE_QUESTION") { //问题被关闭
  1347. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1348. $str = str_replace ( "%qid%", $question ['id'], $str );
  1349. $str = str_replace ( "%question_title%", $question ['title'], $str );
  1350. $str = str_replace ( "%question_time%", format_date ( time (), "Y年m月d日" ), $str );
  1351. $result ['templete'] = $str;
  1352. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:你的问题被关闭' ) . "?=";
  1353. $result ['toemail'] = $userinfo [0] ['useremail'];
  1354. return $result;
  1355. } elseif ($templete_name == "FOLLOW_ANSWER" || $templete_name == "PAY_FOLLOW_ANSWER") { //追问有新的回答
  1356. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1357. $str = str_replace ( "%qid%", $question ['id'], $str );
  1358. $str = str_replace ( "%answer_username%", $answer ['author'], $str );
  1359. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1360. $str = str_replace ( "%question_title%", $question ['title'], $str );
  1361. $tag_array = unserialize ( $answer ['tag'] );
  1362. $str = str_replace ( "%ask2%", $tag_array [0], $str );
  1363. $str = str_replace ( "%answer2%", $tag_array [1], $str );
  1364. $result ['templete'] = $str;
  1365. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:你的追问有新的回答' ) . "?=";
  1366. $result ['toemail'] = $userinfo [0] ['useremail'];
  1367. return $result;
  1368. } elseif ($templete_name == "FOLLOW_QUESTION" || $templete_name == "PAY_FOLLOW_QUESTION") { //提问者向您追问
  1369. $str = str_replace ( "%answer_username%", $answer ['author'], $html_templete );
  1370. $str = str_replace ( "%qid%", $question ['id'], $str );
  1371. $str = str_replace ( "%username%", $question ['author'], $str );
  1372. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1373. $str = str_replace ( "%question_title%", $question ['title'], $str );
  1374. $str = str_replace ( "%answer_content%", $answer ['content'], $str );
  1375. $tag_array = unserialize ( $answer ['tag'] );
  1376. $str = str_replace ( "%ask2%", $tag_array [0], $str );
  1377. $result ['templete'] = $str;
  1378. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:提问者向您追问' ) . "?=";
  1379. $result ['toemail'] = $userinfo [0] ['useremail'];
  1380. return $result;
  1381. } elseif ($templete_name == "REPLENISH_QUESTION" || $templete_name == "PAY_REPLENISH_QUESTION") { //提问这对问题进行了补充
  1382. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1383. $str = str_replace ( "%qid%", $question ['id'], $str );
  1384. $str = str_replace ( "%question_title%", $question ['title'], $str );
  1385. $tag_array = unserialize ( $question ['supply'] );
  1386. $str = str_replace ( "%supply%", $tag_array [0] ['content'], $str );
  1387. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1388. $result ['templete'] = $str;
  1389. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:提问者对问题进行了补充' ) . "?=";
  1390. $result ['toemail'] = $userinfo [0] ['useremail'];
  1391. return $result;
  1392. } elseif ($templete_name == "ADOPT_ANSWER" || $templete_name == "PAY_ADOPT_ANSWER") { //回答被采纳了
  1393. $str = str_replace ( "%answer_username%", $answer ['author'], $html_templete );
  1394. $str = str_replace ( "%qid%", $answer ['qid'], $str );
  1395. $str = str_replace ( "%username%", $question ['author'], $str );
  1396. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1397. $str = str_replace ( "%question_title%", $question ['title'], $str );
  1398. $str = str_replace ( "%answer_content%", $answer ['content'], $str );
  1399. $result ['templete'] = $str;
  1400. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:您的回答被采纳了!' ) . "?=";
  1401. $userinfo = $this->get_sso_user_info_by_name ( $answer ['author'] );
  1402. $result ['toemail'] = $userinfo [0] ['useremail'];
  1403. return $result;
  1404. } elseif ($templete_name == "PAY_FORMONEY") {
  1405. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1406. $str = str_replace ( "%price%", $question ['price'], $str );
  1407. $str = str_replace ( "%qid%", $question ['id'], $str );
  1408. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1409. $result ['templete'] = $str;
  1410. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:您进行了一项付费操作' ) . "?=";
  1411. $result ['toemail'] = $userinfo [0] ['useremail'];
  1412. return $result;
  1413. } elseif ($templete_name == "VIP_PAY_FORMONEY") { //名师答疑付费提醒
  1414. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1415. $str = str_replace ( "%price%", $question ['price'], $str );
  1416. $str = str_replace ( "%uid%", $question ['authorid'], $str );
  1417. $result ['templete'] = $str;
  1418. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:您进行了一项付费操作' ) . "?=";
  1419. $result ['toemail'] = $userinfo [0] ['useremail'];
  1420. return $result;
  1421. } elseif ($templete_name == "VIP_NEW_ANSWER") { //名师答疑有回答提醒
  1422. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1423. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1424. $str = str_replace ( "%vqid%", $question ['id'], $str );
  1425. $str = str_replace ( "%vipquestion_title%", $question ['title'], $str );
  1426. $str = str_replace ( "%vanswer_content%", $answer ['content'], $str );
  1427. $result ['templete'] = $str;
  1428. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:你的名师答疑有新的回答' ) . "?=";
  1429. $result ['toemail'] = $userinfo [0] ['useremail'];
  1430. return $result;
  1431. } elseif ($templete_name == "VIP_MONEY_BACK") { //名师答疑退费提醒
  1432. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1433. $str = str_replace ( "%price%", $question ['price'], $str );
  1434. $str = str_replace ( "%uid%", $question ['authorid'], $str );
  1435. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1436. $result ['templete'] = $str;
  1437. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:向您退费成功' ) . "?=";
  1438. $result ['toemail'] = $userinfo [0] ['useremail'];
  1439. return $result;
  1440. } elseif ($templete_name == "VIP_FOLLOW_ANSWER") { //名师答疑追问有了新的回答
  1441. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1442. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1443. $str = str_replace ( "%vipquestion_title%", $question ['title'], $str );
  1444. $str = str_replace ( "%vanswer_content%", $answer ['content'], $str );
  1445. $str = str_replace ( "%vqid%", $question ['id'], $str );
  1446. $result ['templete'] = $str;
  1447. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:你在名师答疑中追问有新的回答' ) . "?=";
  1448. $result ['toemail'] = $userinfo [0] ['useremail'];
  1449. //$result ['toemail'] = "cpthought@vip.qq.com";
  1450. return $result;
  1451. }
  1452. }
  1453. }
  1454. ?>