public function add($user_follow, $user_followed, $type) { $check = Relationship::model()->findAllByAttributes(array('user_id_1' => $user_follow, 'user_id_2' => $user_followed)); $check_2 = Relationship::model()->findAllByAttributes(array('user_id_2' => $user_follow, 'user_id_1' => $user_followed)); $check_3 = Follow::model()->findByAttributes(array('user_follow' => $user_follow, 'user_followed' => $user_followed)); if ($check || $check_2 || $check_3 || $user_followed == Yii::app()->session['user_id']) { return FALSE; } $model = new Follow(); $model->user_follow = $user_follow; $model->user_followed = $user_followed; $model->created_at = time(); $model->update_at = time(); $model->type = $type; $user_follow_data = User::model()->findByPk($user_follow); $user_followed_data = User::model()->findByPk($user_followed); if ($user_follow != Yii::app()->session['user_id']) { $arr_noti = array('user_id' => $user_follow, 'content' => "{$user_follow_data->username} vừa theo dõi bạn", 'type' => 'follow', 'recipient_id' => $user_followed_data->id, 'url' => Yii::app()->createAbsoulteUrl('user/profile', array('user_id' => $user_follow_data->id, 'ref' => 'noti'))); Notifications::model()->add($arr_noti); } if ($model->save(FALSE)) { return TRUE; } return FALSE; }
public function actionAllDiggList() { $feedId = intval(EnvUtil::getRequest("feedid")); $result = FeedDigg::model()->fetchUserList($feedId, 5); $uids = ConvertUtil::getSubByKey($result, "uid"); $followStates = Follow::model()->getFollowStateByFids(Ibos::app()->user->uid, $uids); $this->renderPartial("alldigglist", array("list" => $result, "followstates" => $followStates, "feedid" => $feedId)); }
public function actionUnFollow() { if (EnvUtil::submitCheck("formhash")) { $fid = StringUtil::filterCleanHtml($_POST["fid"]); $res = Follow::model()->unFollow(Ibos::app()->user->uid, intval($fid)); $this->ajaxReturn(array("isSuccess" => !!$res, "msg" => Follow::model()->getError("unFollow"))); } }
public function getHeader($lang = array()) { $onlineStatus = UserUtil::getOnlineStatus($this->getUid()); $styleMap = array(-1 => "o-pm-offline", 1 => "o-pm-online"); $data = array("user" => $this->getUser(), "assetUrl" => $this->getAssetUrl("user"), "swfConfig" => AttachUtil::getUploadConfig(), "onlineIcon" => $styleMap[$onlineStatus], "lang" => $lang); if ($this->getIsWeiboEnabled()) { $data["userData"] = UserData::model()->getUserData($this->getUid()); !$this->getIsMe() && ($data["states"] = Follow::model()->getFollowState(Ibos::app()->user->uid, $this->getUid())); } return $this->renderPartial("application.modules.user.views.header", $data, true); }
/** * @return string approved follow's count for object */ public function getFollowCount() { Yii::import('application.modules.follow.models.Follow'); $pk = $this->getObjectPkAttribute(); return Follow::model() ->approved() ->countByAttributes(array( 'class_name'=>$this->getClassName(), 'object_pk'=>$this->getOwner()->$pk )); }
public function actionUnfollow() { $touser = Yii::app()->request->getParam('uid'); $fuid = Yii::app()->user->id; $sql = "select * from {{follow}} where touid={$touser} and uid={$fuid}"; $model = Follow::model()->findBySql($sql); if ($model->delete()) { //添加成功时候的提示信息设置 /** *setFlash getFlash hasFlash 几个方法 */ Yii::app()->user->setFlash('unfollow', '取消关注成功 -_-!'); } $this->redirect(array('follow/index', 'uid' => $fuid)); }
public function actionNewmsg() { $model = new Msg(); if (isset($_POST['Msg'])) { $model->uid = Yii::app()->user->id; $model->time = time(); $model->state = 1; $model->attributes = $_POST['Msg']; if ($model->save()) { $this->redirect_message('私信发送成功!', 'success', '3', $this->createUrl('msg/inbox')); } } $fans = Follow::model()->findAll('touid = ' . Yii::app()->user->id); $data = array('model' => $model, 'fans' => $fans); $this->render('newmsg', $data); }
/** * Executes the widgets */ public function run() { $newUsers = User::model()->active()->recently(10)->findAll(); // Some member stats Yii::import('application.modules.mail.models.*'); $statsTotalUsers = User::model()->count(); $criteria = new CDbCriteria(); $criteria->group = 'user_id'; $criteria->condition = 'user_id IS NOT null'; $statsUserOnline = UserHttpSession::model()->count($criteria); $statsMessageEntries = 0; if (Yii::app()->moduleManager->isEnabled('mail')) { $statsMessageEntries = MessageEntry::model()->count(); } $statsUserFollow = Follow::model()->countByAttributes(array('object_model' => 'User')); // Render widgets view $this->render('memberStats', array('newUsers' => $newUsers, 'statsTotalUsers' => $statsTotalUsers, 'statsUserOnline' => $statsUserOnline, 'statsMessageEntries' => $statsMessageEntries, 'statsUserFollow' => $statsUserFollow)); }
public function actionUserCard() { $uid = EnvUtil::getRequest("uid"); $user = User::model()->fetchByUid($uid); $onlineStatus = UserUtil::getOnlineStatus($uid); $styleMap = array(-1 => "o-pm-offline", 1 => "o-pm-online"); if (empty($user)) { $this->error(Ibos::lang("Request tainting", "error")); } else { $weiboExists = ModuleUtil::getIsEnabled("weibo"); $data = array("user" => $user, "status" => $styleMap[$onlineStatus], "lang" => Ibos::getLangSources(), "weibo" => $weiboExists); if ($weiboExists) { $data["userData"] = UserData::model()->getUserData($user["uid"]); $data["states"] = Follow::model()->getFollowState(Ibos::app()->user->uid, $user["uid"]); } $content = $this->renderPartial("userCard", $data, true); echo $content; exit; } }
/** * 插入解锁照片 * */ public function insertPhoto($user_id, $param) { try { $p = array('user_id' => '', 'heroine_id' => '', 'photo_id' => '', 'unlock_type' => '', 'rating' => '', 'status' => '', 'is_open' => '', 'timestamp' => '', 'type' => ''); $con_characters = Yii::app()->db_characters; $param = array_intersect_key($param, $p); $table_name = sprintf('photo_praise_%02s', dechex($user_id % 256)); $con_characters->createCommand()->insert($table_name, $param); if ($param['type'] == 0 || $param['type'] == 1) { //查询解锁数目 $follow = Follow::model()->getFollowRow($user_id, $param['heroine_id']); $unlock_counts = $follow['unlock_counts'] + 1; //更新解锁照片数量 Follow::model()->updateFollowRow($user_id, $param['heroine_id'], array('unlock_counts' => $unlock_counts)); //更新好感值 } } catch (Exception $e) { error_log($e); } }
echo Yii::app()->createUrl('follow', array('uid' => $_m->uid)); ?> ">粉丝 <?php echo $ufans = Follow::model()->countByAttributes(array('touid' => $_m->uid)); ?> </a>人 <ul> <li> <span class="font-gray"> <?php $me2 = Yii::app()->user->id; $pd1 = "select * from {{follow}} where uid={$me2} and touid={$_m->uid}"; $cc1 = count(Follow::model()->findAllBySql($pd1)); $pd22 = "select * from {{follow}} where uid={$_m->uid} and touid={$me2}"; $cc22 = count(Follow::model()->findBySql($pd22)); $plus1 = $cc1 + $cc22; if ($plus1 === 2) { ?> 互相关注<a href="<?php echo Yii::app()->createUrl('msg/newmsg'); ?> " class="font-green">发私信</a><?php } else { if ($plus1 === 1 && $cc1 === 0) { ?> <a href="<?php echo Yii::app()->createUrl('follow/add', array('id' => $_m->user->id)); ?> " class="font-green" style="margin-right:10px">关注<?php switch ($_m->user->sex) {
public function loadFollowModel($bid) { $uid = Yii::app()->user->getId(); $model = Follow::model()->findByAttributes(array('user_id' => $uid, 'product_id' => $bid)); // if($model===null) // $model=new Follow; return $model; }
protected function getRelation($type, $offset = 0, $limit = 4) { $data = array(); switch ($type) { case "colleague": $data = $this->getColleagues($this->getUser(), false); $data = array_merge($data, array()); break; case "bothfollow": $data = Follow::model()->getBothFollow($this->getUid(), Ibos::app()->user->uid); if (!empty($data)) { $data = User::model()->fetchAllByUids($data); } break; case "secondfollow": $data = Follow::model()->getSecondFollow(Ibos::app()->user->uid, $this->getUid()); if (!empty($data)) { $data = User::model()->fetchAllByUids($data); } break; default: break; } return array("count" => count($data), "list" => array_slice($data, $offset, $limit)); }
/** * Returns the number of follows the owner object performed. * This is only affects User owner objects! * * @param string $objectModel HActiveRecord Classname to restrict Object Classes to (e.g. User) * @return int */ public function getFollowingCount($objectModel) { if (!class_exists($objectModel)) { throw new CException("Invalid objectModel parameter given!"); } return Follow::model()->countByAttributes(array('user_id' => $this->getOwner()->getPrimaryKey(), 'object_model' => $objectModel)); }
?> /<?php echo $ct3 = Album::model()->countByAttributes(array('user_id' => $_u->id)); ?> </div></td> <td><?php $shui = $_u->id; $gznu = "select * from {{follow}} where uid={$shui}"; $numGZ = count(Follow::model()->findAllBySql($gznu)); echo $numGZ; ?> </td> <td><?php $byshui = $_u->id; $fansnu = "select * from {{follow}} where touid={$byshui}"; $numFAN = count(Follow::model()->findAllBySql($fansnu)); echo $numFAN; ?> </td> </tr> <?php $i++; } ?> </tbody></table>
/** * 获取所有未关注女神ID列表 * @param int $user_id * @return multitype: */ public function getNoFollowIds($user_id) { //获取用户所有女神id $goddess_list = Goddess::model()->goddessList(); //获取用户所有关注的女神id $data = Follow::model()->followedList($user_id); //去重 $id_list = array_diff_assoc($goddess_list, $data); return $id_list; }
public function actionUnFollow() { $request = Yii::app()->request; if ($request->isPostRequest && isset($_POST)) { try { $user_follow = StringHelper::filterString($request->getPost('user_follow')); $user_followed = StringHelper::filterString($request->getPost('user_followed')); $user_type = StringHelper::filterString($request->getPost('type')); if (Follow::model()->remove($user_follow, $user_followed, $user_type)) { ResponseHelper::JsonReturnSuccess('', 'Thành công'); } else { ResponseHelper::JsonReturnError('', 'Có lỗi xảy ra'); } } catch (exception $e) { var_dump($e->getMessage()); } Yii::app()->end(); } }
public function actionHome($uid) { if (Yii::app()->user->isGuest) { $this->redirect('./index.php?r=user/login'); } $vhid = $uid; $user = User::model()->findByPk($uid); $user->visitor += 1; $user->save(false); if ($uid != Yii::app()->user->id) { $visit = new Visitor(); $visit->uid = Yii::app()->user->id; $visit->toid = $uid; $visit->time = time(); $visit->save(false); } //活跃用户展示 $yaya = User::model()->findAll(array('order' => 'update_time desc', 'limit' => 16)); //思想展示 $sql = "select * from {{article}} where author_id = {$uid} order by create_time desc limit 0, 20 "; $sixiang = Article::model()->findAllBySql($sql); //标签展示 $sq = "select * from {{usertags}} where uid = {$uid} order by create_time desc"; $bq = Usertags::model()->findAllBySql($sq); //home页面用户关注的丫丫数量 $uf = "select * from {{follow}} where uid={$uid}"; $userfollow = count(Follow::model()->findAllBySql($uf)); //home页面粉丝数量 $fan = "select * from {{follow}} where touid={$uid}"; $fans = count(Follow::model()->findAllBySql($fan)); //访问我的主页的用户展示 $userid = Yii::app()->user->id; $cs1 = "select *,count(distinct uid) from {{visitor}} where toid={$userid} group by uid order by time desc limit 16"; $fangwenwo = Visitor::model()->findAllBySql($cs1); $cs2 = "select *,count(distinct toid) from {{visitor}} where uid={$vhid} group by toid order by time desc limit 16"; $visitwho = Visitor::model()->findAllBySql($cs2); $data = array('user' => $user, 'yaya' => $yaya, 'sixiang' => $sixiang, 'bq' => $bq, 'userfollow' => $userfollow, 'fans' => $fans, 'fangwenwo' => $fangwenwo, 'visitwho' => $visitwho); $this->render('home', $data); }
/** * Delete follows * @param array $id */ public function actionDelete($id = array()) { if (Yii::app()->request->isPostRequest) { $model = Follow::model()->findAllByPk($_REQUEST['id']); if (!empty($model)) { foreach($model as $m){ $m->delete(); } echo 'Successfully'; } if (!Yii::app()->request->isAjaxRequest) $this->redirect('index'); } }
/** * Before deletion of a Space */ protected function beforeDelete() { foreach (SpaceSetting::model()->findAllByAttributes(array('space_id' => $this->id)) as $spaceSetting) { $spaceSetting->delete(); } // Disable all enabled modules foreach ($this->getAvailableModules() as $moduleId => $module) { if ($this->isModuleEnabled($moduleId)) { $this->disableModule($moduleId); } } HSearch::getInstance()->deleteModel($this); $this->getProfileImage()->delete(); // Remove all Follwers Follow::model()->deleteAllByAttributes(array('object_id' => $this->id, 'object_model' => 'Space')); //Delete all memberships: //First select, then delete - done to make sure that SpaceMembership::beforeDelete() is triggered $spaceMemberships = SpaceMembership::model()->findAllByAttributes(array('space_id' => $this->id)); foreach ($spaceMemberships as $spaceMembership) { $spaceMembership->delete(); } UserInvite::model()->deleteAllByAttributes(array('space_invite_id' => $this->id)); // Delete all content objects of this space foreach (Content::model()->findAllByAttributes(array('space_id' => $this->id)) as $content) { $content->delete(); } // When this workspace is used in a group as default workspace, delete the link foreach (Group::model()->findAllByAttributes(array('space_id' => $this->id)) as $group) { $group->space_id = ""; $group->save(); } Wall::model()->deleteAllByAttributes(array('id' => $this->wall_id)); return parent::beforeDelete(); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Follow the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Follow::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * 关注女神 * * @param int $user_id * @param int $goddessId * @param int $follow * @param int $status 0普通解锁, 1猜图擦图 */ public function followGoddess($user_id, $goddessId, $follow, $status = 0) { $user_id = intval($user_id); $goddessId = intval($goddessId); $follow = intval($follow); $time = date("Y-m-d H:i:s"); //是否存在 if (Follow::model()->getFollowRow($user_id, $goddessId)) { if ($follow == 0) { $follow = 2; } $ret = Follow::model()->updateFollow($time, $user_id, $goddessId, $follow); } else { $ret = Follow::model()->insertFollow($time, $user_id, $goddessId, $status, $follow); // if($status == 0){ //赠送女神1级封面照 Photo::model()->insertGoddessCoverPhoto($goddessId, $user_id); //关注推送女神图片 延迟1分钟 //JPush::model()->followPush($user_id, $goddessId); // } } return $ret; }
/** * 获取用户消息内容 拼接详细消息体 * * @param unknown $user_id * @param unknown $mess_id * @return unknown */ public function getUserMessInfo($user_id, $mess_id) { $table_name = sprintf('user_message_%02s', dechex($user_id % 256)); $info = false; try { $con_message = Yii::app()->db_message; $info = $con_message->createCommand()->select('m_id, heroine_id, type, create_ts, msg_text, msg_type, msg_url, msg_image')->from($table_name)->where("m_id=:mess_id")->bindParam(':mess_id', $mess_id, PDO::PARAM_INT, 11)->queryRow(); $ret = Goddess::model()->getGoddessInfo($info['heroine_id']); $dateTime = date('Y-m-d H:i:s', time()); $data['goddess_face'] = $ret['faceurl']; $data['goddess_name'] = $ret['nickname']; $data['goddess_id'] = $info['heroine_id']; $data['time'] = $dateTime; $data['url'] = $info['msg_url']; $data['image'] = $info['msg_image']; $data['goddess_id'] = (int) $info['heroine_id']; $data['text'] = $info['msg_text']; $data['type'] = (int) $info['msg_type']; $data['id'] = (int) $info['m_id']; $follow = Follow::model()->getFollowRow($user_id, $info['heroine_id']); if ($follow) { $data['followed'] = 1; } else { $data['followed'] = 0; } } catch (Exception $e) { error_log($e); } return $data; }
/** * 给女神送礼 * @param unknown $user_id * @param unknown $goddess_id * @param unknown $gift_id * @param unknown $number */ public function giveGift($user_id, $goddess_id, $gift_id, $number) { try { $characters_transaction = Yii::app()->db_characters->beginTransaction(); $heroine_transaction = Yii::app()->db_heroine->beginTransaction(); //是否关注女神 if (!Follow::model()->isExitsFollow($user_id, $goddess_id)) { return -3; } //获取礼物信息 $gift_info = Gift::model()->getGiftInfo($gift_id); if ($gift_info) { //获取角色信息 $characters = Characters::model()->getCharactersInfo($user_id); if ($gift_info['is_give'] == 1) { $flowers_counts = $characters['flowers']; if ($number > $flowers_counts) { //赠送鲜花数超过已有鲜花数 $number = $number - $flowers_counts; $temp_num = $flowers_counts; } else { $temp_num = $number; } if ($temp_num != 0) { $characters['flowers'] = $characters['flowers'] - $temp_num; //角色加 经验 积分 $params = array('exp' => $characters['exp'] + $temp_num * $gift_info['add_exp'], 'point' => $characters['point'] + $temp_num * $gift_info['add_point'], 'flowers' => $characters['flowers']); //更新等级 $lv = Level::model()->exp2Level($params['exp']); if (!empty($lv) && strcmp($lv, $characters['level']) != 0) { $params['level'] = $lv; } Characters::model()->updateCharacters($user_id, $params); //女神好感 $follow = Follow::model()->getFollowRow($user_id, $goddess_id); //好感度 $liking_val = $follow['liking'] + $temp_num * $gift_info['add_liking']; //增加女神对角色的好感度 Follow::model()->updateFollow(date('Y-m-d H:i:s'), $user_id, $goddess_id, null, null, $liking_val); //增加魅力值 $glamorousCount = Goddess::model()->getGlamorousCount($goddess_id); $glamorous = array('glamorous' => (int) $glamorousCount + $temp_num * (int) $gift_info['add_glamorous']); Goddess::model()->updateHeroineInfo($goddess_id, $glamorous); //增加用户送礼物给女神记录 $this->createHeroineGift($user_id, $goddess_id, $gift_id, $temp_num); // 提交事务 $characters_transaction->commit(); $heroine_transaction->commit(); $res['log'] = ''; $res['log']['gold'] = 0; $res['result'] = array('point' => (int) $params['point'], 'exp' => (int) $params['exp'], 'vit' => (int) $characters['vit'], 'vit_time' => (int) $characters['vit_time'], 'level' => (int) $lv, 'gold' => (int) $characters['gold'], 'flowers' => (int) $characters['flowers'], 'goddess_id' => (int) $goddess_id, 'liking' => $liking_val); return $res; } } $total = $gift_info['gold'] * $number; //扣金币 if ($total > $characters['gold']) { return -4; } //角色加金币 经验 积分 $params = array('gold' => (int) $characters['gold'] - (int) $total, 'exp' => (int) $characters['exp'] + $number * $gift_info['add_exp'], 'point' => (int) $characters['point'] + $number * $gift_info['add_point']); //更新等级 $lv = Level::model()->exp2Level($params['exp']); if (!empty($lv) && strcmp($lv, $characters['level']) != 0) { $params['level'] = $lv; } Characters::model()->updateCharacters($user_id, $params); //女神好感 $follow = Follow::model()->getFollowRow($user_id, $goddess_id); //好感度 $liking_val = $follow['liking'] + $number * $gift_info['add_liking']; //增加女神对角色的好感度 Follow::model()->updateFollow(date('Y-m-d H:i:s'), $user_id, $goddess_id, null, null, $liking_val); //增加魅力值 $glamorousCount = Goddess::model()->getGlamorousCount($goddess_id); $glamorous = array('glamorous' => (int) $glamorousCount + $number * (int) $gift_info['add_glamorous']); Goddess::model()->updateHeroineInfo($goddess_id, $glamorous); //增加用户送礼物给女神记录 $this->createHeroineGift($user_id, $goddess_id, $gift_id, $number); // 提交事务 $characters_transaction->commit(); $heroine_transaction->commit(); $res['log']['gold'] = -$total; $res['log']['gold_after'] = (int) $characters['gold'] - (int) $total; $res['result'] = array('point' => (int) $params['point'], 'exp' => (int) $params['exp'], 'vit' => (int) $characters['vit'], 'vit_time' => (int) $characters['vit_time'], 'level' => (int) $lv, 'gold' => (int) $params['gold'], 'flowers' => (int) $characters['flowers'], 'goddess_id' => (int) $goddess_id, 'liking' => (int) $liking_val); } else { return -2; } } catch (Exception $e) { error_log($e); $characters_transaction->rollback(); $heroine_transaction->rollback(); //更新失败 return -1; } return $res; }
/** * 女神分类筛选 * * @param string $type 0-最新,1-最热 默认0 * @param string $tag_id 关键字,标签 * @param string $page 页号 * @param string $page_size 页大小 需传递,服务端可仅支持几种固定pageSize * */ public function actionFilter() { // 参数检查 if (!isset($_REQUEST['page']) || !isset($_REQUEST['page_size'])) { $this->_return('MSG_ERR_LESS_PARAM'); } $now = date("Y-m-d H:i:s"); $type = trim(Yii::app()->request->getParam('type')); $page = trim(Yii::app()->request->getParam('page')); $page_size = trim(Yii::app()->request->getParam('page_size')); $tag_id = trim(Yii::app()->request->getParam('tag_id')); if (!is_numeric($tag_id)) { $this->_return('MSG_ERR_FAIL_PARAM'); } $tag = Common::model()->getLabel(); $lable = array(); foreach ($tag as $key => $v) { $lable[] = $v['id']; } if (!in_array($tag_id, $lable)) { //没有这个标签 $this->_return('MSG_ERR_NO_FOUND_TAG'); } $type = empty($type) ? 0 : $type; if ($type != 1 && $type != 0) { $this->_return('MSG_ERR_FAIL_PARAM'); } $data = Goddess::model()->filterGoddessList($tag_id, $type, $page, $page_size); if ($data === false) { $this->_return('MSG_ERR_UNKOWN'); } $now = date("Y-m-d H:i:s"); $user_id = trim(Yii::app()->request->getParam('user_id')); $token = trim(Yii::app()->request->getParam('token')); $followed = array(); if (isset($user_id) && !empty($user_id)) { if (!is_numeric($user_id)) { $this->_return('MSG_ERR_FAIL_PARAM'); } //用户不存在 返回错误 if ($user_id < 1) { $this->_return('MSG_ERR_NO_USER'); } //验证token if (Token::model()->verifyToken($user_id, $token, $GLOBALS['__APPID'])) { $followed = Follow::model()->followedList($user_id); } } foreach ($data as $k => $r) { if (is_array($r) && !empty($r)) { //增加图片 $rand = mt_rand(1, 100); if ($rand == 1) { $picLv = 10; } elseif ($rand == 2 || $rand == 3) { $picLv = 9; } elseif ($rand > 2 && $rand < 6) { $picLv = 8; } elseif ($rand > 5 && $rand < 10) { $picLv = 7; } elseif ($rand > 9 && $rand < 15) { $picLv = 6; } elseif ($rand > 14 && $rand < 21) { $picLv = 5; } elseif ($rand > 20 && $rand < 28) { $picLv = 4; } elseif ($rand > 27 && $rand < 36) { $picLv = 3; } elseif ($rand > 35 && $rand < 45) { $picLv = 2; } else { $picLv = 1; } $t = Photo::model()->heroinePhotosIds($r['goddess_id'], $picLv); $p = array(); if (!empty($t)) { $tKey = array_rand($t, 1); $p = Photo::model()->photoInfo($t[$tKey]['photo_id']); } unset($p['heroine_id']); unset($p['devit']); $p = array(); if (empty($p)) { $p = Photo::model()->single($r['goddess_id']); } if ($p === false) { $p = null; } $data[$k]['photo'] = $p; if (in_array($r['goddess_id'], $followed)) { $data[$k]['followed'] = 1; } else { $data[$k]['followed'] = 0; } } } $this->_return('MSG_SUCCESS', $data); }
protected function getFollowData($type, $uid, $offset, $limit) { if ($type == "follower") { $data = Follow::model()->getFollowerList($uid, $offset, $limit); } else { $data = Follow::model()->getFollowingList($uid, $offset, $limit); } if (!empty($data)) { $fids = ConvertUtil::getSubByKey($data, "fid"); $list = Follow::model()->getFollowStateByFids(Ibos::app()->user->uid, $fids); } else { $list = array(); } return $list; }
/** * Before Delete of a User * */ public function beforeDelete() { // We don't allow deletion of users who owns a space - validate that foreach (SpaceMembership::GetUserSpaces($this->id) as $workspace) { if ($workspace->isSpaceOwner($this->id)) { throw new Exception("Tried to delete a user which is owner of a space!"); } } UserSetting::model()->deleteAllByAttributes(array('user_id' => $this->id)); // Disable all enabled modules foreach ($this->getAvailableModules() as $moduleId => $module) { if ($this->isModuleEnabled($moduleId)) { $this->disableModule($moduleId); } } HSearch::getInstance()->deleteModel($this); // Delete Profile Image $this->getProfileImage()->delete(); // Delete all pending invites UserInvite::model()->deleteAllByAttributes(array('user_originator_id' => $this->id)); Follow::model()->deleteAllByAttributes(array('user_id' => $this->id)); Follow::model()->deleteAllByAttributes(array('object_model' => 'User', 'object_id' => $this->id)); // Delete all group admin assignments GroupAdmin::model()->deleteAllByAttributes(array('user_id' => $this->id)); // Delete wall entries WallEntry::model()->deleteAllByAttributes(array('wall_id' => $this->wall_id)); // Deletes all content created by this user foreach (Content::model()->findAllByAttributes(array('user_id' => $this->id)) as $content) { $content->delete(); } foreach (Content::model()->findAllByAttributes(array('created_by' => $this->id)) as $content) { $content->delete(); } // Delete all passwords foreach (UserPassword::model()->findAllByAttributes(array('user_id' => $this->id)) as $password) { $password->delete(); } return parent::beforeDelete(); }
/** * 获取反对票数量 */ public function getFanCount() { return Follow::model()->count("followableEntityId=:entityId and value<=0", array(':entityId' => $this->getOwner()->entityId)); }
public function actionJoinApi($aid) { $transaction = Yii::app()->db->beginTransaction(); try { $circle = new Circle(); $circle->aid = $aid; $circle->usr_id = $this->usr_id; $circle->save(); $f = Follow::model()->findByPk(array('usr_id' => $this->usr_id, 'aid' => $aid)); if (!isset($f)) { $f = new Follow(); $f->usr_id = $this->usr_id; $f->aid = $aid; $f->create_time = time(); $f->save(); } $news = new News(); $news->aid = $aid; $news->type = 2; $news->create_time = time(); $user = User::model()->findByPk($this->usr_id); $news->content = serialize(array('usr_id' => $user->usr_id, 'u_name' => $user->name)); $news->save(); $transaction->commit(); $this->echoJsonData(array('isSuccess' => TRUE)); } catch (Exception $e) { $transaction->rollback(); throw $e; } }
public function blockUser($user_block, $user_blocked, $user_type) { $model = Relationship::model()->findByAttributes(array('user_id_1' => $user_block, 'user_id_2' => $user_blocked, 'user_type' => $user_type)); Follow::model()->deleteAllByAttributes(array('user_follow' => $user_block, 'user_followed' => $user_blocked, 'type' => $user_type)); if ($model) { return 1; } else { $rel = new Relationship(); $rel->user_id_1 = $user_block; $rel->user_id_2 = $user_blocked; $rel->status = 1; $rel->created_at = time(); $rel->updated_at = time(); $rel->type = Yii::app()->params['USER_BLOCK']; $rel->user_type = $user_type; if ($rel->save(FALSE)) { return 2; } else { return 0; } } }