示例#1
0
 public List<Group> getGroups() {
   List<Group> allGroups = Group.findAll();
   List<Group> answer = new ArrayList<Group>();
   for (Group g : allGroups) {
     for (User u : g.members) {
       if (u.equals(this)) {
         answer.add(g);
         break;
       }
     }
   }
   return answer;
 }
示例#2
0
 public boolean visible(User user) {
   if (visibility == Visibility.PRIVATE) return user.equals(owner);
   if (visibility == Visibility.FRIENDS) return user.equals(owner) || user.isFriendsWith(owner);
   return true;
 }
示例#3
0
  /**
   * Do subscriptions to all topics Called on user connection to add user to the subscribing user
   * list of all topics he has subscribed to (avoids database calls)
   *
   * <p>public void doSubscriptions() { for (String esid : eventTopicIds) { EventTopic eb =
   * ModelManager.get().getTopicById(esid); if (eb != null) { eb.addUser(this); } } }
   */
  public void update() {
    User u = User.find("byId", this.id).first();
    if (u != null) {
      u.email = email;
      u.password = password;
      u.name = name;
      u.gender = gender;
      u.mailnotif = mailnotif;
      u.facebookId = facebookId;
      u.googleId = googleId;
      u.twitterId = twitterId;
      u.avatarUrl = avatarUrl;
      u.connected = connected;

      u.eventTopicIds = eventTopicIds;
      u.save();
    }
  }