Esempio n. 1
0
 /**
  * This function returns to a logged user he's own information.
  *
  * @param a the authentication object
  * @return the user information or null if wrong authentication
  */
 public UserInfo myUser(Auth a) {
   Integer uid = Auths.getInstance().getUser(a);
   if (uid == null) return null;
   UserInfo user = dbc.loadUser(uid);
   List<Position> ps = dbc.getPositions(user.getId(), 1);
   if (ps.size() > 0) user.setPosition(ps.get(0));
   return new SUserInfo(user);
 }
Esempio n. 2
0
 /**
  * Gets the last n position of a user. The user must be administrator or friend of the target to
  * have rights to get this.
  *
  * @param a the authentication object
  * @param id the target user's id
  * @param c the n count of positions
  * @return the array of positions
  */
 public Position[] getPositions(Auth a, int id, int c) {
   Integer uid = Auths.getInstance().getUser(a);
   if (uid == null) return null;
   if (!dbc.loadUser(uid).isAdministrator() && !dbc.areFriends(uid, id)) return null;
   List<Position> ps = dbc.getPositions(id, c);
   SPosition[] sp = new SPosition[ps.size()];
   for (int i = 0; i < ps.size(); i++) sp[i] = new SPosition(ps.get(i));
   return sp;
 }
Esempio n. 3
0
 /**
  * This function returns your friend list page by page.
  *
  * @param a the authentication object
  * @param count the count of users per page
  * @param page the page number
  * @return the array of user's list in the page
  */
 public UserInfo[] getFriendsPage(Auth a, int count, int page) {
   Integer uid = Auths.getInstance().getUser(a);
   if (uid == null) return null;
   List<UserInfo> fs = dbc.getFriends(uid, count, page);
   SUserInfo[] sf = new SUserInfo[fs.size()];
   for (int i = 0; i < fs.size(); i++) {
     sf[i] = new SUserInfo(fs.get(i));
     List<Position> ps = dbc.getPositions(sf[i].getId(), 1);
     if (ps.size() > 0) sf[i].setPosition(ps.get(0));
   }
   return sf;
 }