/**
  * @param string $term
  * @param string | array $projectIdOrIds
  * @param Website $website
  * @param bool $include
  */
 public function __construct($term, $projectIdOrIds = '', $website, $include = false)
 {
     $query = array('$or' => array(array('name' => array('$regex' => $term, '$options' => '-i')), array('username' => array('$regex' => $term, '$options' => '-i')), array('email' => array('$regex' => $term, '$options' => '-i'))));
     if (!empty($projectIdOrIds)) {
         // Allow $projectIdOrIds to be either an array or a single ID
         if (is_array($projectIdOrIds)) {
             $idsForQuery = $projectIdOrIds;
         } else {
             $idsForQuery = array($projectIdOrIds);
         }
         // If passed string IDs, convert to MongoID objects
         $idsForQuery = array_map(function ($id) {
             if (is_string($id)) {
                 return MongoMapper::mongoID($id);
             } else {
                 return $id;
             }
         }, $idsForQuery);
         $inOrNotIn = $include ? '$in' : '$nin';
         $query['projects'] = array($inOrNotIn => $idsForQuery);
         //error_log("Query: " . print_r($query, true));
     }
     // Filter for only users on the current site
     $encodedDomain = $website->domain;
     MongoEncoder::encodeDollarDot($encodedDomain);
     $query['siteRole.' . $encodedDomain] = array('$exists' => true);
     parent::__construct(UserModelMongoMapper::instance(), $query, array('username', 'email', 'name', 'avatarRef'));
     // If we were called with a project filter that excluded certain users, also
     // return a list of specifically which users were excluded. Which happens to
     // be another typeahead search with the same query term, but *including* only
     // the ones matching this project.
     if ($projectIdOrIds && !$include) {
         $this->excludedUsers = new UserTypeaheadModel($term, $projectIdOrIds, $website, true);
         $this->excludedUsers->read();
     }
     //echo("Result: " . print_r($this, true));
 }
 /**
  * UserListProjectModel constructor.
  * @param string $projectId
  */
 public function __construct($projectId)
 {
     parent::__construct(UserModelMongoMapper::instance(), array('username' => array('$regex' => '\\w'), 'projects' => array('$in' => array(MongoMapper::mongoID($projectId)))), array('username', 'email', 'name'));
 }
 public function __construct()
 {
     MapperListModel::__construct(UserModelMongoMapper::instance(), array(), array('username', 'id', 'email', 'name', 'emailPending', 'last_login', 'role', 'siteRole', 'validationExpirationDate'));
 }
 /**
  * Removes a user from the collection
  * Project references to this user are also removed
  */
 public function remove()
 {
     UserModelMongoMapper::instance()->remove($this->id->asString());
 }
 public function __construct()
 {
     parent::__construct(UserModelMongoMapper::instance(), array('username' => array('$regex' => '')), array('username', 'email', 'name', 'avatar_ref', 'role', 'projects', 'active'));
 }