Shared access to the database for GrimaUser and GrimaInstitution.
More...
Shared access to the database for GrimaUser and GrimaInstitution.
Definition at line 4662 of file grima-lib.php.
◆ getDb()
| static GrimaDB::getDb |
( |
|
) |
|
|
staticprotected |
Definition at line 4695 of file grima-lib.php.
4696 {
4697 if (!self::$db) {
4698 try {
4702 if ($db_user && $db_pass) {
4703 self::$db = new PDO($db_url, $db_user, $db_pass);
4704 } else {
4705 self::$db = new PDO($db_url);
4706 }
4708 self::$db->exec("CREATE TABLE institutions ( institution VARCHAR(100) PRIMARY KEY, apikey VARCHAR(100), server VARCHAR(100) )");
4709 }
4711 self::$db->exec("CREATE TABLE users ( institution VARCHAR(100), username VARCHAR(100), password VARCHAR(255), isAdmin INTEGER )");
4712 }
4713 } catch (Exception $e) {
4714 self::$db = 'stateless';
4715 }
4716 }
4718 }
tableExists($pdo, $table)
getenvWithFileFallbackAndDefault( $env_name, $default=false)
References $db, getenvWithFileFallbackAndDefault(), and tableExists().
Referenced by GrimaInstitution\addToDB(), GrimaUser\addToDB(), GrimaUser\deleteFromDB(), getInstitutions(), init(), isEmpty(), isStateless(), GrimaUser\LookupUser(), GrimaUser\RenameUser(), GrimaUser\ResetPassword(), and GrimaUser\updateDB().
◆ getInstitutions()
| static GrimaDB::getInstitutions |
( |
|
) |
|
|
static |
Definition at line 4725 of file grima-lib.php.
4726 {
4727 $ret = array();
4728 try {
4730 if (
$db ===
'stateless') {
4731 return $ret;
4732 }
4733 $result =
$db->query(
'SELECT institution FROM institutions');
4734 foreach ($result as $row) {
4735 $ret[] = $row['institution'];
4736 }
4737 } catch (Exception $e) {
4738 }
4739 return $ret;
4740 }
References $db, and getDb().
Referenced by GrimaFormField\__construct().
◆ getIterator()
Definition at line 4762 of file grima-lib.php.
4763 {
4764 return new ArrayIterator($this->info);
4765 }
◆ getPasswordAlgorithm()
| GrimaDB::getPasswordAlgorithm |
( |
|
) |
|
|
protected |
◆ init()
◆ isEmpty()
| static GrimaDB::isEmpty |
( |
|
) |
|
|
static |
Definition at line 4673 of file grima-lib.php.
4674 {
4676 if (
$db ===
'stateless') {
4677 return true;
4678 }
4679 $result =
$db->query(
'SELECT COUNT(*) as c FROM institutions');
4680 if ($result) {
4681 foreach ($result as $row) {
4682 if ($row['c']>0) { return false;
4683 }
4684 }
4685 }
4686 return true;
4687 }
References $db, and getDb().
◆ isStateless()
| static GrimaDB::isStateless |
( |
|
) |
|
|
static |
◆ offsetExists()
| GrimaDB::offsetExists |
( |
|
$offset |
) |
|
Definition at line 4742 of file grima-lib.php.
4743 {
4744 return isset($this->info[$offset]);
4745 }
◆ offsetGet()
| GrimaDB::offsetGet |
( |
|
$offset |
) |
|
Definition at line 4747 of file grima-lib.php.
4748 {
4749 return isset($this->info[$offset]) ? $this->info[$offset] : '';
4750 }
◆ offsetSet()
| GrimaDB::offsetSet |
( |
|
$offset, |
|
|
|
$value |
|
) |
|
|
Definition at line 4752 of file grima-lib.php.
4753 {
4754 $this->info[$offset] = $value;
4755 }
◆ offsetUnset()
| GrimaDB::offsetUnset |
( |
|
$offset |
) |
|
Definition at line 4757 of file grima-lib.php.
4758 {
4759 unset($this->info[$offset]);
4760 }
◆ $db
Definition at line 4665 of file grima-lib.php.
Referenced by GrimaInstitution\addToDB(), GrimaUser\addToDB(), GrimaUser\deleteFromDB(), getDb(), getInstitutions(), isEmpty(), isStateless(), GrimaUser\LookupUser(), GrimaUser\RenameUser(), GrimaUser\ResetPassword(), and GrimaUser\updateDB().
◆ $info
The documentation for this class was generated from the following file: