private static function _processDatabaseName($dbName, $fields, $ownerId) { // Db name provided if (!empty($dbName)) { // we check if it matches previously stored db dbName if (isset(self::$_database['name']) && !empty(self::$_database['name'])) { if ($dbName != self::$_database['name']) { self::_addError("Database name ({$dbName}) is different from the database name previously defined (" . self::$_database['name'] . ")"); return false; } else { return; } } $dbId = \mod\arkeogis\ArkeoGIS::getDatabaseId($dbName); // Check if owner owns the database if (!\mod\user\Main::userhasRight('Manage all databases') && !\mod\user\Main::userhasRight('Manage personal database')) { self::_addError('You are not allowed to import a database'); return false; } else { if ($dbId && !\mod\user\Main::userhasRight('Manage all databases') && (\mod\user\Main::userhasRight('Manage personal database') && !\mod\arkeogis\ArkeoGIS::isDatabaseOwner($dbId, $ownerId))) { self::_addError('Database ' . self::$_database['name'] . ' already exists and not belongs to you'); return false; } } self::$_database['name'] = $dbName; if (!empty($dbId)) { self::$_database['id'] = $dbId; self::$_database['name'] = $dbName; if (sizeof($fields) > 0) { \mod\arkeogis\ArkeoGIS::updateDatabase($dbId, $fields); } } else { try { self::$_database['id'] = \mod\arkeogis\ArkeoGIS::addDatabase($dbName, $fields, $ownerId); self::$_database['name'] = $dbName; } catch (\Exception $e) { self::_addError("Unable to register database name {$dbName}: " . $e->getMessage()); } } // No db name provided } else { if (empty(self::$_database['name'])) { self::_addError('No database name provided and no database already registered'); } } self::$_current['database'] = self::$_database; return; }