예제 #1
0
 /**
  * Return wishlist of a user and its followers.
  *
  * @author Kuldeep Dangi <*****@*****.**>
  */
 public function actionGetWishlist($id)
 {
     $userObj = new Users();
     $userModel = $userObj->findByPk($id);
     $userFeedObj = new UserFeed();
     if ($userModel) {
         $userFollowObj = new UserFollow();
         $usersData = $userFollowObj->getUserFollowers($id);
         $users = array();
         foreach ($usersData as $user) {
             $users[] = $user['id_user'];
         }
         $users[] = $id;
         $wishList = $userFeedObj->getUsersWishlist($users);
         $wishListCount = count($wishList);
         if ($wishListCount < 30) {
             $wishList = $userFeedObj->getTrendingWishlist(30 - $wishListCount);
         }
     } else {
         $wishList = $userFeedObj->getTrendingWishlist();
     }
     $this->result['data'] = $wishList;
     $this->result['success'] = true;
     $this->sendResponse($this->result);
 }
예제 #2
0
 /**
  * Function set user information to the result
  *
  * @param int $userId
  *
  * @author Kuldeep Dangi <*****@*****.**>
  */
 public function getUserInformation($userId)
 {
     $data = array('info' => array(), 'followers' => array(), 'following' => array(), 'notes' => array());
     if (!empty($userId)) {
         $data['info'] = $this->loadModel($userId);
         if (empty($data['info'])) {
             $this->result['message'] = 'User does not exist.';
         } else {
             $userFollowObj = new UserFollow();
             $extentionObj = new Extensions();
             $data['followers'] = $userFollowObj->getUserFollowers($userId);
             $data['following'] = $userFollowObj->getUserFollowing($userId);
             $data['notes'] = $extentionObj->getNotesByUsers($userId);
             $this->result['data'] = $data;
             $this->result['success'] = true;
         }
     }
     $this->sendResponse($this->result);
 }
예제 #3
0
 /**
  * Return all notes of a user + max purchased notes + max view notes.
  *
  * @author Kuldeep Dangi <*****@*****.**>
  */
 public function actionGetUserNotes()
 {
     $model = new Extensions();
     $maxPurchaseDocs = $model->getNotesWithMaxPurchase(20);
     $maxViewDocs = $model->getNotesWithMaxViews(20);
     $latestUpdated = $model->getNotesWithLatestUpdated(20);
     if (!empty($_GET['id'])) {
         $userFollower = new UserFollow();
         $usersData = $userFollower->getUserFollowers($_GET['id']);
         $users = array();
         array_map(create_function('$usersData', 'return $usersData["id_user"];'), $users);
         $users[] = $_GET['id'];
         $data = $model->getNotesByUsers($users, 10);
         $this->result['data'] = array_merge($data, $maxPurchaseDocs, $maxViewDocs);
     } else {
         //$this->result['data'] = array_merge($maxPurchaseDocs, $maxViewDocs);
         $this->result['data'] = array_merge($latestUpdated);
     }
     $this->result['success'] = true;
     $this->sendResponse($this->result);
 }