Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 36
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
acp_update
0.00% covered (danger)
0.00%
0 / 34
0.00% covered (danger)
0.00%
0 / 1
42
0.00% covered (danger)
0.00%
0 / 1
 main
0.00% covered (danger)
0.00%
0 / 34
0.00% covered (danger)
0.00%
0 / 1
42
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13
14/**
15* @ignore
16*/
17if (!defined('IN_PHPBB'))
18{
19    exit;
20}
21
22class acp_update
23{
24    var $u_action;
25
26    function main($id, $mode)
27    {
28        global $config, $user, $template, $request;
29        global $phpbb_root_path, $phpEx, $phpbb_container;
30
31        $user->add_lang('install');
32
33        $this->tpl_name = 'acp_update';
34        $this->page_title = 'ACP_VERSION_CHECK';
35
36        /* @var $version_helper \phpbb\version_helper */
37        $version_helper = $phpbb_container->get('version_helper');
38        try
39        {
40            $recheck = $request->variable('versioncheck_force', false);
41            $updates_available = $version_helper->get_update_on_branch($recheck);
42            $upgrades_available = $version_helper->get_suggested_updates();
43            if (!empty($upgrades_available))
44            {
45                $upgrades_available = array_pop($upgrades_available);
46            }
47        }
48        catch (\RuntimeException $e)
49        {
50            $template->assign_var('S_VERSIONCHECK_FAIL', true);
51
52            $updates_available = array();
53        }
54
55        if (!empty($updates_available))
56        {
57            $template->assign_block_vars('updates_available', $updates_available);
58        }
59
60        $update_link = $phpbb_root_path . 'install/app.' . $phpEx;
61
62        $template_ary = [
63            'S_UP_TO_DATE'                => empty($updates_available),
64            'U_ACTION'                    => $this->u_action,
65            'U_VERSIONCHECK_FORCE'        => append_sid($this->u_action . '&amp;versioncheck_force=1'),
66
67            'CURRENT_VERSION'            => $config['version'],
68
69            'UPDATE_INSTRUCTIONS'        => $user->lang('UPDATE_INSTRUCTIONS', $update_link),
70            'S_VERSION_UPGRADEABLE'        => !empty($upgrades_available),
71            'UPGRADE_INSTRUCTIONS'        => !empty($upgrades_available) ? $user->lang('UPGRADE_INSTRUCTIONS', $upgrades_available['current'], $upgrades_available['announcement']) : false,
72        ];
73
74        $template->assign_vars($template_ary);
75
76        // Incomplete update?
77        if (phpbb_version_compare($config['version'], PHPBB_VERSION, '<'))
78        {
79            $database_update_link = $phpbb_root_path . 'install/app.php/update';
80
81            $template->assign_vars(array(
82                'S_UPDATE_INCOMPLETE'        => true,
83                'FILES_VERSION'                => PHPBB_VERSION,
84                'INCOMPLETE_INSTRUCTIONS'    => $user->lang('UPDATE_INCOMPLETE_EXPLAIN', $database_update_link),
85            ));
86        }
87    }
88}