static function selectUserByIdentifierToken($identifier)
 {
     $user = DBConn::selectOne("SELECT u.id, name_first AS nameFirst, name_last AS nameLast, email, phone, token AS apiToken, identifier AS apiKey " . "FROM " . DBConn::prefix() . "tokens_auth AS t " . "JOIN " . DBConn::prefix() . "users AS u ON u.id = t.user_id " . "WHERE identifier = :identifier AND t.expires > NOW() " . "AND u.disabled IS NULL;", array(':identifier' => $identifier));
     if ($user) {
         $user->displayName = $user->nameFirst;
         $user->roles = DBConn::selectAll("SELECT DISTINCT(gr.auth_role_id) FROM " . DBConn::prefix() . "auth_lookup_user_group AS ug " . "JOIN " . DBConn::prefix() . "auth_lookup_group_role AS gr ON ug.auth_group_id = gr.auth_group_id " . "WHERE ug.user_id = :id ORDER BY gr.auth_role_id;", array(':id' => $user->id), \PDO::FETCH_COLUMN);
     }
     return $user;
 }
 static function addPublicRoleToNewGroup($groupId)
 {
     // TODO: Hook up super-admin group to config variable
     $roleId = DBConn::selectOne("SELECT r.id FROM " . DBConn::prefix() . "auth_roles AS r " . "WHERE r.slug = :slug LIMIT 1;", array(':slug' => 'public'));
     if ($roleId) {
         $validGroup = array(':auth_group_id' => $groupId, ':auth_role_id' => $roleId->id, ':created_user_id' => APIAuth::getUserId());
         return DBConn::insert("INSERT INTO " . DBConn::prefix() . "auth_lookup_group_role(auth_group_id, auth_role_id, created_user_id) " . "VALUES (:auth_group_id, :auth_role_id, :created_user_id);", $validGroup);
     }
     return false;
 }
 static function getByIdentifier($identifier, $fieldId = 0)
 {
     $field = DBConn::selectOne("SELECT f.id, f.identifier, f.type, f.desc, f.initialized, f.created, f.last_updated AS lastUpdated, " . "CONCAT(u1.name_first, ' ', u1.name_last) AS createdBy, CONCAT(u2.name_first, ' ', u2.name_last) AS updatedBy " . "FROM " . DBConn::prefix() . "auth_fields AS f " . "LEFT JOIN " . DBConn::prefix() . "users AS u1 ON u1.id = f.created_user_id " . "LEFT JOIN " . DBConn::prefix() . "users AS u2 ON u2.id = f.last_updated_by " . "WHERE f.identifier = :identifier AND f.id != :id " . "LIMIT 1;", array(':identifier' => $identifier, ':id' => $fieldId));
     $qRoles = DBConn::preparedQuery("SELECT r.id, r.role, r.desc " . "FROM " . DBConn::prefix() . "auth_roles AS r " . "JOIN " . DBConn::prefix() . "auth_lookup_role_field AS look ON r.id = look.auth_role_id " . "WHERE look.auth_field_id = :id GROUP BY r.id ORDER BY r.role;");
     if ($field) {
         $qRoles->execute(array(':id' => $field->id));
         $field->roles = $qRoles->fetchAll(\PDO::FETCH_OBJ);
     }
     return $field;
 }
 private static function selectEmailTemplate($templateId)
 {
     $template = DBConn::selectOne("SELECT id, identifier, from_email AS fromEmail, from_name AS fromName, " . "reply_email AS replyEmail, reply_name AS replyName, subject, body_html AS bodyHtml, body_plain AS bodyPlain " . "FROM " . DBConn::prefix() . "email_templates WHERE identifier = :identifier LIMIT 1;", array(':identifier' => $templateId));
     if (!$template) {
         self::logMailError(LOG_ERR, "ERROR RETRIEVING EMAIL TEMPLATE, templateId <{$templateId}>");
         return false;
     }
     return $template;
 }
 static function selectUserByIdentifierToken($identifier)
 {
     $user = DBConn::selectOne("SELECT u.id, name_first AS nameFirst, name_last AS nameLast, " . "email, phone, token AS apiToken, identifier AS apiKey " . "FROM " . DBConn::prefix() . "tokens_auth AS t " . "JOIN " . DBConn::prefix() . "users AS u ON u.id = t.user_id " . "WHERE identifier = :identifier AND t.expires > NOW() " . "AND u.disabled IS NULL;", array(':identifier' => $identifier));
     if ($user) {
         $user = self::selectUserData($user);
     }
     return $user;
 }
 public static function userTableTestVal()
 {
     return DBConn::selectOne("SELECT u.id FROM " . DBConn::prefix() . "users AS u LIMIT 1;");
 }
 public static function getVariableById($id)
 {
     return DBConn::selectOne("SELECT c.id, c.name, c.value, c.disabled, c.indestructible, c.locked " . "FROM " . DBConn::prefix() . "system_config AS c " . "WHERE c.id = :id LIMIT 1;", array(':id' => $id));
 }
 static function selectInviteByToken($token)
 {
     return DBConn::selectOne("SELECT token, team_id AS teamId, user_id AS userId, " . "name_first AS nameFirst, name_last AS nameLast, email, phone, " . "created, created_user_id AS invitedBy, expires, last_visited AS lastVisited " . "FROM " . DBConn::prefix() . "tokens_player_invites " . "WHERE token = :token AND expires >= NOW() LIMIT 1;", array(':token' => $token));
 }