アプデ通知実装
This commit is contained in:
parent
d8f8cb1858
commit
9fbb7017da
62
upgrade_info/upgrade_info.php
Normal file
62
upgrade_info/upgrade_info.php
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Name: Upgrade Info
|
||||||
|
* Description: Show upgrade info at the top of left-aside until dismissed
|
||||||
|
* Version: 1.0
|
||||||
|
* Depends: Core
|
||||||
|
* Author: Mario Vavti <mario@mariovavti.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Zotlabs\Extend\Hook;
|
||||||
|
|
||||||
|
function upgrade_info_load(){
|
||||||
|
Hook::register('construct_page', 'addon/upgrade_info/upgrade_info.php', 'upgrade_info_construct_page');
|
||||||
|
}
|
||||||
|
|
||||||
|
function upgrade_info_unload(){
|
||||||
|
Hook::unregister('construct_page', 'addon/upgrade_info/upgrade_info.php', 'upgrade_info_construct_page');
|
||||||
|
}
|
||||||
|
|
||||||
|
function upgrade_info_construct_page(&$b){
|
||||||
|
|
||||||
|
$upgrade_version = get_config('upgrade_info', 'version');
|
||||||
|
|
||||||
|
if(version_compare(STD_VERSION, $upgrade_version) == 1) {
|
||||||
|
set_config('upgrade_info', 'datetime', datetime_convert());
|
||||||
|
set_config('upgrade_info', 'version', STD_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(! local_channel())
|
||||||
|
return;
|
||||||
|
|
||||||
|
$upgrade_datetime = get_config('upgrade_info', 'datetime');
|
||||||
|
|
||||||
|
$account = App::get_account();
|
||||||
|
if($account['account_created'] > $upgrade_datetime)
|
||||||
|
return;
|
||||||
|
|
||||||
|
$version = get_pconfig(local_channel(), 'upgrade_info', 'version');
|
||||||
|
|
||||||
|
if(version_compare(STD_VERSION, $version) < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
$content[] = t('Harukin+がアップデートされました!');
|
||||||
|
$content[] = t('変更点は運営公式フォーラムを確認してください!');
|
||||||
|
$content[] = '<a href="channel/admin_plusharukin">' . t('運営のフォーラムページ') . '</a>';
|
||||||
|
|
||||||
|
$tpl = get_markup_template('upgrade_info.tpl', 'addon/upgrade_info');
|
||||||
|
|
||||||
|
$o = replace_macros($tpl, [
|
||||||
|
'$title' => t('運営からのお知らせ!'),
|
||||||
|
'$content' => $content,
|
||||||
|
'$std_version' => STD_VERSION,
|
||||||
|
'$form_security_token' => get_form_security_token('pconfig'),
|
||||||
|
'$dismiss' => t('閉じる')
|
||||||
|
]);
|
||||||
|
|
||||||
|
$b['layout']['region_aside'] = $o . $b['layout']['region_aside'];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
31
upgrade_info/view/tpl/upgrade_info.tpl
Normal file
31
upgrade_info/view/tpl/upgrade_info.tpl
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<div id="upgrade_info_aside" class="alert alert-info alert-dismissible fade show">
|
||||||
|
<h3><i class="fa fa-hubzilla"></i> {{$title}}</h3>
|
||||||
|
<hr>
|
||||||
|
{{$content.0}}<br>
|
||||||
|
<br>
|
||||||
|
{{$content.1}}<br>
|
||||||
|
<br>
|
||||||
|
{{$content.2}} {{$content.3}} {{$content.4}}<br>
|
||||||
|
<br>
|
||||||
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
<button id="upgrade_info_dismiss" type="button" class="btn btn-sm btn-success"><i class="fa fa-check"></i> {{$dismiss}}</button>
|
||||||
|
<script>
|
||||||
|
$('#upgrade_info_dismiss').click(function() {
|
||||||
|
$.post(
|
||||||
|
'pconfig',
|
||||||
|
{
|
||||||
|
'aj' : 1,
|
||||||
|
'cat' : 'upgrade_info',
|
||||||
|
'k' : 'version',
|
||||||
|
'v' : '{{$std_version}}',
|
||||||
|
'form_security_token' : '{{$form_security_token}}'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.done(function() {
|
||||||
|
$('#upgrade_info_aside').fadeOut('fast');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</div>
|
Reference in New Issue
Block a user