| @@ 145-163 (lines=19) @@ | ||
| 142 | return $stmt->fetchColumn(); |
|
| 143 | } |
|
| 144 | ||
| 145 | public function setVootToken($userId, $vootToken) |
|
| 146 | { |
|
| 147 | $userId = $this->getId($userId); |
|
| 148 | $stmt = $this->db->prepare( |
|
| 149 | <<< 'SQL' |
|
| 150 | INSERT INTO voot_tokens |
|
| 151 | (user_id, voot_token) |
|
| 152 | VALUES |
|
| 153 | (:user_id, :voot_token) |
|
| 154 | SQL |
|
| 155 | ); |
|
| 156 | $stmt->bindValue(':user_id', $userId, PDO::PARAM_INT); |
|
| 157 | $stmt->bindValue(':voot_token', $vootToken, PDO::PARAM_STR); |
|
| 158 | ||
| 159 | $stmt->execute(); |
|
| 160 | ||
| 161 | // XXX deal with errors! |
|
| 162 | return 1 === $stmt->rowCount(); |
|
| 163 | } |
|
| 164 | ||
| 165 | public function hasVootToken($userId) |
|
| 166 | { |
|
| @@ 165-182 (lines=18) @@ | ||
| 162 | return 1 === $stmt->rowCount(); |
|
| 163 | } |
|
| 164 | ||
| 165 | public function hasVootToken($userId) |
|
| 166 | { |
|
| 167 | $userId = $this->getId($userId); |
|
| 168 | $stmt = $this->db->prepare( |
|
| 169 | <<< 'SQL' |
|
| 170 | SELECT |
|
| 171 | COUNT(*) |
|
| 172 | FROM |
|
| 173 | voot_tokens |
|
| 174 | WHERE |
|
| 175 | user_id = :user_id |
|
| 176 | SQL |
|
| 177 | ); |
|
| 178 | $stmt->bindValue(':user_id', $userId, PDO::PARAM_INT); |
|
| 179 | $stmt->execute(); |
|
| 180 | ||
| 181 | return 1 === (int) $stmt->fetchColumn(); |
|
| 182 | } |
|
| 183 | ||
| 184 | public function deleteVootToken($userId) |
|
| 185 | { |
|
| @@ 184-200 (lines=17) @@ | ||
| 181 | return 1 === (int) $stmt->fetchColumn(); |
|
| 182 | } |
|
| 183 | ||
| 184 | public function deleteVootToken($userId) |
|
| 185 | { |
|
| 186 | $userId = $this->getId($userId); |
|
| 187 | $stmt = $this->db->prepare( |
|
| 188 | <<< 'SQL' |
|
| 189 | DELETE FROM |
|
| 190 | voot_tokens |
|
| 191 | WHERE |
|
| 192 | user_id = :user_id |
|
| 193 | SQL |
|
| 194 | ); |
|
| 195 | $stmt->bindValue(':user_id', $userId, PDO::PARAM_INT); |
|
| 196 | ||
| 197 | $stmt->execute(); |
|
| 198 | // XXX error handling! |
|
| 199 | return 1 === $stmt->rowCount(); |
|
| 200 | } |
|
| 201 | ||
| 202 | public function hasTotpSecret($userId) |
|
| 203 | { |
|
| @@ 202-219 (lines=18) @@ | ||
| 199 | return 1 === $stmt->rowCount(); |
|
| 200 | } |
|
| 201 | ||
| 202 | public function hasTotpSecret($userId) |
|
| 203 | { |
|
| 204 | $userId = $this->getId($userId); |
|
| 205 | $stmt = $this->db->prepare( |
|
| 206 | <<< 'SQL' |
|
| 207 | SELECT |
|
| 208 | COUNT(*) |
|
| 209 | FROM |
|
| 210 | totp_secrets |
|
| 211 | WHERE |
|
| 212 | user_id = :user_id |
|
| 213 | SQL |
|
| 214 | ); |
|
| 215 | $stmt->bindValue(':user_id', $userId, PDO::PARAM_INT); |
|
| 216 | $stmt->execute(); |
|
| 217 | ||
| 218 | return 1 === (int) $stmt->fetchColumn(); |
|
| 219 | } |
|
| 220 | ||
| 221 | public function getTotpSecret($userId) |
|
| 222 | { |
|
| @@ 264-281 (lines=18) @@ | ||
| 261 | } |
|
| 262 | } |
|
| 263 | ||
| 264 | public function deleteTotpSecret($userId) |
|
| 265 | { |
|
| 266 | $userId = $this->getId($userId); |
|
| 267 | $stmt = $this->db->prepare( |
|
| 268 | <<< 'SQL' |
|
| 269 | DELETE FROM |
|
| 270 | totp_secrets |
|
| 271 | WHERE |
|
| 272 | user_id = :user_id |
|
| 273 | SQL |
|
| 274 | ); |
|
| 275 | $stmt->bindValue(':user_id', $userId, PDO::PARAM_INT); |
|
| 276 | ||
| 277 | $stmt->execute(); |
|
| 278 | ||
| 279 | // XXX error handling? |
|
| 280 | return 1 === $stmt->rowCount(); |
|
| 281 | } |
|
| 282 | ||
| 283 | public function deleteUser($userId) |
|
| 284 | { |
|
| @@ 283-299 (lines=17) @@ | ||
| 280 | return 1 === $stmt->rowCount(); |
|
| 281 | } |
|
| 282 | ||
| 283 | public function deleteUser($userId) |
|
| 284 | { |
|
| 285 | $userId = $this->getId($userId); |
|
| 286 | $stmt = $this->db->prepare( |
|
| 287 | <<< 'SQL' |
|
| 288 | DELETE FROM |
|
| 289 | users |
|
| 290 | WHERE |
|
| 291 | id = :user_id |
|
| 292 | SQL |
|
| 293 | ); |
|
| 294 | $stmt->bindValue(':user_id', $userId, PDO::PARAM_INT); |
|
| 295 | ||
| 296 | $stmt->execute(); |
|
| 297 | // XXX error handling? |
|
| 298 | return 1 === $stmt->rowCount(); |
|
| 299 | } |
|
| 300 | ||
| 301 | public function addCertificate($userId, $commonName, $displayName, $validFrom, $validTo) |
|
| 302 | { |
|
| @@ 412-432 (lines=21) @@ | ||
| 409 | return 1 === $stmt->rowCount(); |
|
| 410 | } |
|
| 411 | ||
| 412 | public function disableUser($userId) |
|
| 413 | { |
|
| 414 | $userId = $this->getId($userId); |
|
| 415 | $stmt = $this->db->prepare( |
|
| 416 | <<< 'SQL' |
|
| 417 | UPDATE |
|
| 418 | users |
|
| 419 | SET |
|
| 420 | is_disabled = 1 |
|
| 421 | WHERE |
|
| 422 | id = :user_id |
|
| 423 | SQL |
|
| 424 | ); |
|
| 425 | $stmt->bindValue(':user_id', $userId, PDO::PARAM_INT); |
|
| 426 | ||
| 427 | $stmt->execute(); |
|
| 428 | ||
| 429 | // XXX it seems on update the rowCount is always 1, even if nothing was |
|
| 430 | // modified? |
|
| 431 | return 1 === $stmt->rowCount(); |
|
| 432 | } |
|
| 433 | ||
| 434 | public function enableUser($userId) |
|
| 435 | { |
|
| @@ 434-454 (lines=21) @@ | ||
| 431 | return 1 === $stmt->rowCount(); |
|
| 432 | } |
|
| 433 | ||
| 434 | public function enableUser($userId) |
|
| 435 | { |
|
| 436 | $userId = $this->getId($userId); |
|
| 437 | $stmt = $this->db->prepare( |
|
| 438 | <<< 'SQL' |
|
| 439 | UPDATE |
|
| 440 | users |
|
| 441 | SET |
|
| 442 | is_disabled = 0 |
|
| 443 | WHERE |
|
| 444 | id = :user_id |
|
| 445 | SQL |
|
| 446 | ); |
|
| 447 | $stmt->bindValue(':user_id', $userId, PDO::PARAM_INT); |
|
| 448 | ||
| 449 | $stmt->execute(); |
|
| 450 | ||
| 451 | // XXX it seems on update the rowCount is always 1, even if nothing was |
|
| 452 | // modified? |
|
| 453 | return 1 === $stmt->rowCount(); |
|
| 454 | } |
|
| 455 | ||
| 456 | public function isDisabledUser($userId) |
|
| 457 | { |
|
| @@ 456-475 (lines=20) @@ | ||
| 453 | return 1 === $stmt->rowCount(); |
|
| 454 | } |
|
| 455 | ||
| 456 | public function isDisabledUser($userId) |
|
| 457 | { |
|
| 458 | $userId = $this->getId($userId); |
|
| 459 | $stmt = $this->db->prepare( |
|
| 460 | <<< 'SQL' |
|
| 461 | SELECT |
|
| 462 | COUNT(*) |
|
| 463 | FROM |
|
| 464 | users |
|
| 465 | WHERE |
|
| 466 | id = :user_id |
|
| 467 | AND |
|
| 468 | is_disabled = 1 |
|
| 469 | SQL |
|
| 470 | ); |
|
| 471 | $stmt->bindValue(':user_id', $userId, PDO::PARAM_INT); |
|
| 472 | $stmt->execute(); |
|
| 473 | ||
| 474 | return 1 === (int) $stmt->fetchColumn(); |
|
| 475 | } |
|
| 476 | ||
| 477 | public function getAllLogEntries() |
|
| 478 | { |
|