public static function getUsersByGroup($db = null, $group_id)
 {
     $peer_object = new DinklyUserGroup();
     if ($db == null) {
         $db = self::fetchDB();
     }
     $query = $peer_object->getSelectQuery() . " where dinkly_group_id = " . $db->quote($group_id);
     $user_group_joins = self::getCollection($peer_object, $query, $db);
     if ($user_group_joins != array()) {
         $user_ids = array();
         foreach ($user_group_joins as $group_join) {
             $user_ids[] = $group_join->getDinklyUserId();
         }
         $users = DinklyUserCollection::getByArrayOfIds($user_ids, $db);
         if ($users != array()) {
             return $users;
         }
     }
 }
Beispiel #2
0
 public function addToGroups($group_ids)
 {
     if ($group_ids != array()) {
         foreach ($group_ids as $id) {
             $group = new DinklyGroup();
             $group->init($id);
             //If the group isn't new, that means it exists, which is a good thing
             if (!$group->isNew()) {
                 //Make sure this join record doesn't already exist first
                 $group_join = new DinklyUserGroup();
                 $group_join->initWithUserAndGroup($this->getId(), $id);
                 if ($group_join->isNew()) {
                     $group_join->setDinklyUserId($this->getId());
                     $group_join->setDinklyGroupId($id);
                     $group_join->save();
                 }
             }
         }
         return true;
     }
     return false;
 }