示例#1
0
 /**
  * 用户添加关注,同时推送条新鲜事
  * 
  * @param $uid	用户
  * @param $friendid 关注的对象
  * @param $limit	新鲜事数量
  */
 function addFollow($uid, $friendid, $limit = 20, $from = '')
 {
     //fixed
     global $timestamp;
     if (!$uid || !$friendid) {
         return false;
     }
     if ($this->isFollow($uid, $friendid)) {
         return 'user_attention_exists';
     }
     $attentionDB = $this->_getAttentionDB();
     $attentionDB->insert(array('uid' => $uid, 'friendid' => $friendid, 'joindate' => $this->_timestamp));
     $userServer = L::loadClass('UserService', 'user');
     $userServer->updateByIncrement($uid, array(), array('follows' => 1));
     $userServer->updateByIncrement($friendid, array(), array('fans' => 1, 'newfans' => 1));
     $medalservice = L::loadClass('medalservice', 'medal');
     $medalservice->runAutoMedal($friendid, 'fans', 'fans', 1);
     $friendService = L::loadClass('Friend', 'friend');
     if (!$friendService->isFriend($uid, $friendid) || $from == 'addFriend') {
         $this->addUserWeiboRelationsByFriendid($friendid, $uid, $limit);
     }
     /*更新粉丝排行记录*/
     L::loadClass('elementupdate', '', false);
     $elementupdate = new ElementUpdate('fans');
     $elementupdate->setCacheNum(100);
     $elementupdate->totalFansUpdate($friendid);
     $elementupdate->updateSQL();
     $elementupdate->setCacheNum(20);
     $elementupdate->todayFansUpdate($friendid);
     $elementupdate->updateSQL();
     return true;
 }