Exemplo n.º 1
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);
 }
Exemplo n.º 2
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);
 }