This repository has been archived on 2024-08-19. You can view files and clone it, but cannot push or open issues or pull requests.
addon/upgrade_infojp/upgrade_infojp.php
Your Name b06dd8ba70
2018-10-27 09:35:40 +09:00

64 lines
1.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Name: Upgrade InfoJP
* 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_infojp/upgrade_infojp.php', 'upgrade_info_construct_pagejp');
}
function upgrade_info_unload(){
Hook::unregister('construct_page', 'addon/upgrade_infojp/upgrade_infojp.php', 'upgrade_info_construct_pagejp');
}
function upgrade_info_construct_pagejp(&$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[] = t('役に立つor重要な情報がいっぱいです');
$content[] = '<a href="channel/admin_plusharukin">' . t('運営公式フォーラム') . '</a>';
$tpl = get_markup_template('upgrade_info.tpl', 'addon/upgrade_infojp');
$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'];
}