| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112 |
- <?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;
-
- 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 ();
- }
-
- /**
- * 完善名师问题
- * @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 === false)
- 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_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;
- }
- }
- }
- ?>
|