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;
         }
     }
 }
 public function validateUserPost($post_array)
 {
     if ($post_array['email'] == "") {
         $this->errors[] = "Email is a required field";
     } else {
         if ($post_array['email'] != $this->user->getUsername()) {
             //Check the username/email for uniqueness
             if (!DinklyUserCollection::isUniqueUsername($post_array['email'])) {
                 $this->errors[] = "Email address already in use, please try another.";
             }
             //Make sure it's also a valid email address
             if (!filter_var($post_array['email'], FILTER_VALIDATE_EMAIL)) {
                 $this->errors[] = "Invalid email. Not a valid email address.";
             }
             $this->user->setUsername(strip_tags($post_array['email']));
             //If we're editing the current user, we should update the session'd username
             if ($this->user->getId() == DinklyUser::getAuthSessionValue('logged_id')) {
                 DinklyUser::setAuthSessionValue('logged_username', $this->user->getUsername());
             }
         }
     }
     //If the password isn't blank
     if ($post_array['password'] != "" && $post_array['confirm-password'] != "") {
         $has_error = false;
         //Make sure both match
         if ($post_array['password'] != $post_array['confirm-password']) {
             $has_error = true;
             $this->errors[] = "Passwords do not match.";
         }
         //Check for length
         if (strlen($post_array['password']) < 8) {
             $has_error = true;
             $this->errors[] = "Password must be at least 8 characters in length.";
         }
         //If the password is valid, update
         if (!$has_error) {
             $this->user->setPassword($post_array['password']);
         }
     } else {
         if ($_POST['user-id'] == "" && $_POST['password'] == "") {
             $this->errors[] = "Password is a required field";
         }
     }
     if ($post_array['first-name'] == "") {
         $this->errors[] = "First Name is a required field";
     }
     if ($post_array['last-name'] == "") {
         $this->errors[] = "Last Name is a required field";
     }
     //If the first name isn't empty and doesn't match the existing one, update
     if ($post_array['first-name'] != "" && $post_array['first-name'] != $this->user->getFirstName()) {
         $this->user->setFirstName(strip_tags($post_array['first-name']));
     }
     //If the last name isn't empty and doesn't match the exiting one, update
     if ($post_array['last-name'] != "" && $post_array['last-name'] != $this->user->getLastName()) {
         $this->user->setLastName(strip_tags($post_array['last-name']));
     }
     //If the title isn't empty and does't match the existing one, update
     if ($post_array['title'] != "" && $post_array['title'] != $this->user->getTitle() || $post_array['title'] == "") {
         $this->user->setTitle(strip_tags($post_array['title']));
     }
     //Nothing to validate here really
     if ($this->user->getTimeZone() == '') {
         $this->user->setTimeZone('America/New_York');
     } else {
         $this->user->setTimeZone(strip_tags($post_array['time-zone']));
     }
 }