Update use statement lists with new Friendica\Database\dba class

- Remove unused use statement
- Remove superfluous use statements (classes in the same namespace)
- Add missing use statements
This commit is contained in:
Hypolite Petovan 2018-07-19 22:15:21 -04:00
parent c316c5ae30
commit daa1177e3a
128 changed files with 262 additions and 259 deletions

View file

@ -2,8 +2,10 @@
namespace Friendica\Core\Console;
use Friendica\App;
use Friendica\Core\L10n;
use dba;
use Friendica\Database\dba;
use RuntimeException;
/**
* @brief tool to archive a contact on the server
@ -55,19 +57,19 @@ HELP;
}
if ($a->mode === App::MODE_INSTALL) {
throw new \RuntimeException('Friendica isn\'t properly installed yet.');
throw new RuntimeException('Friendica isn\'t properly installed yet.');
}
$nurl = normalise_link($this->getArgument(0));
if (!dba::exists('contact', ['nurl' => $nurl, 'archive' => false])) {
throw new \RuntimeException(L10n::t('Could not find any unarchived contact entry for this URL (%s)', $nurl));
throw new RuntimeException(L10n::t('Could not find any unarchived contact entry for this URL (%s)', $nurl));
}
if (dba::update('contact', ['archive' => true], ['nurl' => $nurl])) {
$condition = ["`cid` IN (SELECT `id` FROM `contact` WHERE `archive`)"];
dba::delete('queue', $condition);
$this->out(L10n::t('The contact entries have been archived'));
} else {
throw new \RuntimeException('The contact archival failed.');
throw new RuntimeException('The contact archival failed.');
}
return 0;

View file

@ -3,11 +3,11 @@
namespace Friendica\Core\Console;
use Asika\SimpleConsole\Console;
use dba;
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\Install;
use Friendica\Core\Theme;
use Friendica\Database\dba;
use RuntimeException;
require_once 'mod/install.php';

View file

@ -9,8 +9,9 @@
namespace Friendica\Core\Console;
use Asika\SimpleConsole\CommandArgsException;
use dba;
use Friendica\App;
use Friendica\Core;
use RuntimeException;
require_once 'include/dba.php';
require_once 'include/text.php';
@ -92,7 +93,7 @@ HELP;
throw new CommandArgsException('Too many arguments');
}
if (!($a->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
if (!($a->mode & App::MODE_DBCONFIGAVAILABLE)) {
$this->out('Database isn\'t ready or populated yet, showing file config only');
}
@ -102,7 +103,7 @@ HELP;
$value = $this->getArgument(2);
if (is_array(Core\Config::get($cat, $key))) {
throw new \RuntimeException("$cat.$key is an array and can't be set using this command.");
throw new RuntimeException("$cat.$key is an array and can't be set using this command.");
}
$result = Core\Config::set($cat, $key, $value);
@ -151,7 +152,7 @@ HELP;
if (count($this->args) == 0) {
Core\Config::load();
if (Core\Config::get('system', 'config_adapter') == 'jit' && $a->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE) {
if (Core\Config::get('system', 'config_adapter') == 'jit' && $a->mode & App::MODE_DBCONFIGAVAILABLE) {
$this->out('Warning: The JIT (Just In Time) Config adapter doesn\'t support loading the entire configuration, showing file config only');
}

View file

@ -3,7 +3,9 @@
namespace Friendica\Core\Console;
use Friendica\Core;
use Friendica\Database\dba;
use Friendica\Database\DBStructure;
use RuntimeException;
require_once 'boot.php';
require_once 'include/dba.php';
@ -56,8 +58,8 @@ HELP;
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
}
if (!\dba::connected()) {
throw new \RuntimeException('Unable to connect to database');
if (!dba::connected()) {
throw new RuntimeException('Unable to connect to database');
}
Core\Config::load();

View file

@ -3,8 +3,10 @@
namespace Friendica\Core\Console;
use Friendica\Core\Protocol;
use Friendica\Database\dba;
use Friendica\Database\DBM;
use Friendica\Network\Probe;
use RuntimeException;
require_once 'include/text.php';
@ -65,7 +67,7 @@ HELP;
}
if ($a->isInstallMode()) {
throw new \RuntimeException('Database isn\'t ready or populated yet');
throw new RuntimeException('Database isn\'t ready or populated yet');
}
/**
@ -75,16 +77,16 @@ HELP;
* */
$net = Probe::uri($this->getArgument(0));
if (in_array($net['network'], [Protocol::PHANTOM, Protocol::MAIL])) {
throw new \RuntimeException('This account seems not to exist.');
throw new RuntimeException('This account seems not to exist.');
}
$nurl = normalise_link($net['url']);
$contact = \dba::selectFirst("contact", ["id"], ["nurl" => $nurl, "uid" => 0]);
$contact = dba::selectFirst("contact", ["id"], ["nurl" => $nurl, "uid" => 0]);
if (DBM::is_result($contact)) {
\dba::update("contact", ["hidden" => true], ["id" => $contact["id"]]);
dba::update("contact", ["hidden" => true], ["id" => $contact["id"]]);
$this->out('NOTICE: The account should be silenced from the global community page');
} else {
throw new \RuntimeException('NOTICE: Could not find any entry for this URL (' . $nurl . ')');
throw new RuntimeException('NOTICE: Could not find any entry for this URL (' . $nurl . ')');
}
return 0;

View file

@ -2,12 +2,12 @@
namespace Friendica\Core\Console;
use Friendica\Core\L10n;
use Friendica\Model\Contact;
use Friendica\Model\User;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Database\dba;
use Friendica\Database\DBM;
use dba;
use Friendica\Model\User;
use RuntimeException;
/**
* @brief tool to set a new password for a user
@ -59,14 +59,14 @@ HELP;
}
if ($a->isInstallMode()) {
throw new \RuntimeException('Database isn\'t ready or populated yet');
throw new RuntimeException('Database isn\'t ready or populated yet');
}
$nick = $this->getArgument(0);
$user = dba::selectFirst('user', ['uid'], ['nickname' => $nick]);
if (!DBM::is_result($user)) {
throw new \RuntimeException(L10n::t('User not found'));
throw new RuntimeException(L10n::t('User not found'));
}
$password = $this->getArgument(1);
@ -76,15 +76,15 @@ HELP;
}
if (!$password) {
throw new \RuntimeException(L10n::t('Password can\'t be empty'));
throw new RuntimeException(L10n::t('Password can\'t be empty'));
}
if (!Config::get('system', 'disable_password_exposed', false) && User::isPasswordExposed($password)) {
throw new \RuntimeException(L10n::t('The new password has been exposed in a public data dump, please choose another.'));
throw new RuntimeException(L10n::t('The new password has been exposed in a public data dump, please choose another.'));
}
if (!User::updatePassword($user['uid'], $password)) {
throw new \RuntimeException(L10n::t('Password update failed. Please try again.'));
throw new RuntimeException(L10n::t('Password update failed. Please try again.'));
}
$this->out(L10n::t('Password changed.'));