Merge pull request #1141 from MrPetovan/bug/10439-addon-settings-forms

[mailstream] Add a name to the addon settings submit button
This commit is contained in:
Tobias Diekershoff 2021-06-29 07:24:00 +02:00 committed by GitHub
commit e83170ffcd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 43 deletions

View file

@ -64,13 +64,6 @@ function catavatar_addon_settings_post(App $a, &$s)
return; return;
} }
// delete the current cached cat avatar
$condition = ['uid' => local_user(), 'blocked' => false,
'account_expired' => false, 'account_removed' => false];
$user = DBA::selectFirst('user', ['email'], $condition);
$seed = DI::pConfig()->get(local_user(), 'catavatar', 'seed', md5(trim(strtolower($user['email']))));
if (!empty($_POST['catavatar-usecat'])) { if (!empty($_POST['catavatar-usecat'])) {
$url = DI::baseUrl()->get() . '/catavatar/' . local_user() . '?ts=' . time(); $url = DI::baseUrl()->get() . '/catavatar/' . local_user() . '?ts=' . time();

View file

@ -491,52 +491,62 @@ function mailstream_addon_settings(&$a, &$s)
$attachimg= DI::pConfig()->get(local_user(), 'mailstream', 'attachimg'); $attachimg= DI::pConfig()->get(local_user(), 'mailstream', 'attachimg');
$template = Renderer::getMarkupTemplate('settings.tpl', 'addon/mailstream/'); $template = Renderer::getMarkupTemplate('settings.tpl', 'addon/mailstream/');
$s .= Renderer::replaceMacros($template, [ $s .= Renderer::replaceMacros($template, [
'$enabled' => [ '$enabled' => [
'mailstream_enabled', 'mailstream_enabled',
DI::l10n()->t('Enabled'), DI::l10n()->t('Enabled'),
$enabled], $enabled
'$address' => [ ],
'mailstream_address', '$address' => [
DI::l10n()->t('Email Address'), 'mailstream_address',
$address, DI::l10n()->t('Email Address'),
DI::l10n()->t("Leave blank to use your account email address")], $address,
'$nolikes' => [ DI::l10n()->t("Leave blank to use your account email address")
'mailstream_nolikes', ],
DI::l10n()->t('Exclude Likes'), '$nolikes' => [
$nolikes, 'mailstream_nolikes',
DI::l10n()->t("Check this to omit mailing \"Like\" notifications")], DI::l10n()->t('Exclude Likes'),
'$attachimg' => [ $nolikes,
'mailstream_attachimg', DI::l10n()->t("Check this to omit mailing \"Like\" notifications")
DI::l10n()->t('Attach Images'), ],
$attachimg, '$attachimg' => [
DI::l10n()->t("Download images in posts and attach them to the email. " . 'mailstream_attachimg',
"Useful for reading email while offline.")], DI::l10n()->t('Attach Images'),
'$title' => DI::l10n()->t('Mail Stream Settings'), $attachimg,
'$submit' => DI::l10n()->t('Save Settings')]); DI::l10n()->t("Download images in posts and attach them to the email. " .
"Useful for reading email while offline.")
],
'$title' => DI::l10n()->t('Mail Stream Settings'),
'$submit' => DI::l10n()->t('Save Settings')]);
} }
/** /**
* Process data submitted to user's mailstream features form * Process data submitted to user's mailstream features form
* @param \Friendica\App $a
* @param array $post POST data
*/ */
function mailstream_addon_settings_post() function mailstream_addon_settings_post(\Friendica\App $a, array $post)
{ {
if ($_POST['mailstream_address'] != "") { if (!local_user() || empty($post['mailstream-submit'])) {
DI::pConfig()->set(local_user(), 'mailstream', 'address', $_POST['mailstream_address']); return;
}
if ($post['mailstream_address'] != "") {
DI::pConfig()->set(local_user(), 'mailstream', 'address', $post['mailstream_address']);
} else { } else {
DI::pConfig()->delete(local_user(), 'mailstream', 'address'); DI::pConfig()->delete(local_user(), 'mailstream', 'address');
} }
if ($_POST['mailstream_nolikes']) { if ($post['mailstream_nolikes']) {
DI::pConfig()->set(local_user(), 'mailstream', 'nolikes', $_POST['mailstream_enabled']); DI::pConfig()->set(local_user(), 'mailstream', 'nolikes', $post['mailstream_enabled']);
} else { } else {
DI::pConfig()->delete(local_user(), 'mailstream', 'nolikes'); DI::pConfig()->delete(local_user(), 'mailstream', 'nolikes');
} }
if ($_POST['mailstream_enabled']) { if ($post['mailstream_enabled']) {
DI::pConfig()->set(local_user(), 'mailstream', 'enabled', $_POST['mailstream_enabled']); DI::pConfig()->set(local_user(), 'mailstream', 'enabled', $post['mailstream_enabled']);
} else { } else {
DI::pConfig()->delete(local_user(), 'mailstream', 'enabled'); DI::pConfig()->delete(local_user(), 'mailstream', 'enabled');
} }
if ($_POST['mailstream_attachimg']) { if ($post['mailstream_attachimg']) {
DI::pConfig()->set(local_user(), 'mailstream', 'attachimg', $_POST['mailstream_attachimg']); DI::pConfig()->set(local_user(), 'mailstream', 'attachimg', $post['mailstream_attachimg']);
} else { } else {
DI::pConfig()->delete(local_user(), 'mailstream', 'attachimg'); DI::pConfig()->delete(local_user(), 'mailstream', 'attachimg');
} }

View file

@ -5,9 +5,9 @@
<span class="fakelink" onclick="openClose('settings_mailstream_expanded'); openClose('settings_mailstream_inflated');"> <span class="fakelink" onclick="openClose('settings_mailstream_expanded'); openClose('settings_mailstream_inflated');">
<h3>{{$title}}</h3> <h3>{{$title}}</h3>
</span> </span>
{{include file="field_checkbox.tpl" field=$enabled}} {{include file="field_checkbox.tpl" field=$enabled}}
{{include file="field_input.tpl" field=$address}} {{include file="field_input.tpl" field=$address}}
{{include file="field_checkbox.tpl" field=$nolikes}} {{include file="field_checkbox.tpl" field=$nolikes}}
{{include file="field_checkbox.tpl" field=$attachimg}} {{include file="field_checkbox.tpl" field=$attachimg}}
<input type="submit" value="{{$submit}}"> <input type="submit" name="mailstream-submit" value="{{$submit}}">
</div> </div>