*/
use Friendica\App;
-use Friendica\Core\Config;
use Friendica\Core\Hook;
-use Friendica\Core\L10n;
use Friendica\Core\Logger;
-use Friendica\Core\PConfig;
use Friendica\Core\Renderer;
+use Friendica\DI;
use Friendica\Util\Emailer;
-/* because the fraking openpgp-php is in composer, require libs in composer
- * and then don't use autoloader to load classes... */
-$path = __DIR__ . '/vendor/phpseclib/phpseclib/phpseclib/';
-set_include_path(get_include_path() . PATH_SEPARATOR . $path);
-/* so, we don't use the autoloader and include what we need */
-$path = __DIR__ . '/vendor/singpolyma/openpgp-php/lib';
-set_include_path(get_include_path() . PATH_SEPARATOR . $path);
+require_once __DIR__ . '/vendor/autoload.php';
-require_once 'openpgp.php';
-require_once 'openpgp_crypt_symmetric.php';
function securemail_install()
{
Hook::register('addon_settings', 'addon/securemail/securemail.php', 'securemail_settings');
return;
}
- $enable = intval(PConfig::get(local_user(), 'securemail', 'enable'));
- $publickey = PConfig::get(local_user(), 'securemail', 'pkey');
+ $enable = intval(DI::pConfig()->get(local_user(), 'securemail', 'enable'));
+ $publickey = DI::pConfig()->get(local_user(), 'securemail', 'pkey');
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/securemail/');
$s .= Renderer::replaceMacros($t, [
- '$title' => L10n::t('"Secure Mail" Settings'),
- '$submit' => L10n::t('Save Settings'),
- '$test' => L10n::t('Save and send test'), //NOTE: update also in 'post'
- '$enable' => ['securemail-enable', L10n::t('Enable Secure Mail'), $enable, ''],
- '$publickey' => ['securemail-pkey', L10n::t('Public key'), $publickey, L10n::t('Your public PGP key, ascii armored format'), 'rows="10"']
+ '$title' => DI::l10n()->t('"Secure Mail" Settings'),
+ '$submit' => DI::l10n()->t('Save Settings'),
+ '$test' => DI::l10n()->t('Save and send test'), //NOTE: update also in 'post'
+ '$enable' => ['securemail-enable', DI::l10n()->t('Enable Secure Mail'), $enable, ''],
+ '$publickey' => ['securemail-pkey', DI::l10n()->t('Public key'), $publickey, DI::l10n()->t('Your public PGP key, ascii armored format'), 'rows="10"']
]);
}
}
if ($_POST['securemail-submit']) {
- PConfig::set(local_user(), 'securemail', 'pkey', trim($_POST['securemail-pkey']));
+ DI::pConfig()->set(local_user(), 'securemail', 'pkey', trim($_POST['securemail-pkey']));
$enable = (!empty($_POST['securemail-enable']) ? 1 : 0);
- PConfig::set(local_user(), 'securemail', 'enable', $enable);
- info(L10n::t('Secure Mail Settings saved.') . EOL);
+ DI::pConfig()->set(local_user(), 'securemail', 'enable', $enable);
+ info(DI::l10n()->t('Secure Mail Settings saved.') . EOL);
- if ($_POST['securemail-submit'] == L10n::t('Save and send test')) {
- $sitename = Config::get('config', 'sitename');
+ if ($_POST['securemail-submit'] == DI::l10n()->t('Save and send test')) {
+ $sitename = DI::config()->get('config', 'sitename');
- $hostname = $a->getHostName();
+ $hostname = DI::baseUrl()->getHostname();
if (strpos($hostname, ':')) {
$hostname = substr($hostname, 0, strpos($hostname, ':'));
}
- $sender_email = Config::get('config', 'sender_email');
+ $sender_email = DI::config()->get('config', 'sender_email');
if (empty($sender_email)) {
$sender_email = 'noreply@' . $hostname;
}
];
// enable addon for test
- PConfig::set(local_user(), 'securemail', 'enable', 1);
+ DI::pConfig()->set(local_user(), 'securemail', 'enable', 1);
$res = Emailer::send($params);
// revert to saved value
- PConfig::set(local_user(), 'securemail', 'enable', $enable);
+ DI::pConfig()->set(local_user(), 'securemail', 'enable', $enable);
if ($res) {
- info(L10n::t('Test email sent') . EOL);
+ info(DI::l10n()->t('Test email sent') . EOL);
} else {
- notice(L10n::t('There was an error sending the test email') . EOL);
+ notice(DI::l10n()->t('There was an error sending the test email') . EOL);
}
}
}
$uid = $b['uid'];
- $enable_checked = PConfig::get($uid, 'securemail', 'enable');
+ $enable_checked = DI::pConfig()->get($uid, 'securemail', 'enable');
if (!$enable_checked) {
return;
}
- $public_key_ascii = PConfig::get($uid, 'securemail', 'pkey');
+ $public_key_ascii = DI::pConfig()->get($uid, 'securemail', 'pkey');
preg_match('/-----BEGIN ([A-Za-z ]+)-----/', $public_key_ascii, $matches);
$marker = empty($matches[1]) ? 'MESSAGE' : $matches[1];