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