@@ -69,7 +69,10 @@ public static function extendBlakechain(
6969 $ db ->beginTransaction ();
7070 /** @var array<string, string> $lasthash */
7171 $ lasthash = $ db ->row (
72- 'SELECT currhash, hashstate FROM chronicle_chain ORDER BY id DESC LIMIT 1 '
72+ 'SELECT currhash, hashstate
73+ FROM chronicle_chain
74+ ORDER BY id DESC
75+ LIMIT 1 '
7376 );
7477
7578 // Instantiate the Blakechain.
@@ -152,36 +155,30 @@ public static function errorResponse(
152155 );
153156 }
154157
155- /**
156- * If we're using SQLite, we need a 1 or a 0.
157- * Otherwise, TRUE/FALSE is fine.
158- *
159- * @param bool $value
160- * @return bool|int
161- */
162- public static function getDatabaseBoolean (bool $ value )
163- {
164- if (self ::$ easyDb ->getDriver () === 'sqlite ' ) {
165- return $ value ? 1 : 0 ;
166- }
167- return !empty ($ value );
168- }
169-
170158 /**
171159 * Given a clients Public ID, retrieve their Ed25519 public key.
172160 *
173161 * @param string $clientId
162+ * @param bool $adminOnly
174163 * @return SigningPublicKey
175164 *
176165 * @throws ClientNotFound
177166 */
178- public static function getClientsPublicKey (string $ clientId ): SigningPublicKey
167+ public static function getClientsPublicKey (string $ clientId, bool $ adminOnly = false ): SigningPublicKey
179168 {
180- /** @var array<string, string> $sqlResult */
181- $ sqlResult = static ::$ easyDb ->row (
182- "SELECT * FROM chronicle_clients WHERE publicid = ? " ,
183- $ clientId
184- );
169+ if ($ adminOnly ) {
170+ /** @var array<string, string> $sqlResult */
171+ $ sqlResult = static ::$ easyDb ->row (
172+ "SELECT * FROM chronicle_clients WHERE publicid = ? AND isAdmin " ,
173+ $ clientId
174+ );
175+ } else {
176+ /** @var array<string, string> $sqlResult */
177+ $ sqlResult = static ::$ easyDb ->row (
178+ "SELECT * FROM chronicle_clients WHERE publicid = ? " ,
179+ $ clientId
180+ );
181+ }
185182 if (empty ($ sqlResult )) {
186183 throw new ClientNotFound ('Client not found ' );
187184 }
0 commit comments