|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* ownCloud - Updater plugin |
|
5
|
|
|
* |
|
6
|
|
|
* @author Victor Dubiniuk |
|
7
|
|
|
* @copyright 2015 Victor Dubiniuk [email protected] |
|
8
|
|
|
* |
|
9
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
|
10
|
|
|
* later. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
namespace OCA\Updater; |
|
15
|
|
|
|
|
16
|
|
|
use \OCP\IL10N; |
|
17
|
|
|
|
|
18
|
|
|
class Channel { |
|
19
|
|
|
const CHANNEL_DAILY = 'daily'; |
|
20
|
|
|
const CHANNEL_BETA = 'beta'; |
|
21
|
|
|
const CHANNEL_STABLE = 'stable'; |
|
22
|
|
|
const CHANNEL_PRODUCTION ='production'; |
|
23
|
|
|
const CHANNEL_NONE ='none'; |
|
24
|
|
|
|
|
25
|
|
|
/** @var IL10N */ |
|
26
|
|
|
private $l10n; |
|
27
|
|
|
|
|
28
|
1 |
|
public function __construct(IL10N $l10n){ |
|
29
|
1 |
|
$this->l10n = $l10n; |
|
30
|
1 |
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* All available values |
|
34
|
|
|
* @return array |
|
35
|
|
|
*/ |
|
36
|
|
|
public function getChannels(){ |
|
37
|
|
|
return [ |
|
38
|
|
|
self::CHANNEL_PRODUCTION => $this->l10n->t('Production'), |
|
39
|
|
|
self::CHANNEL_STABLE => $this->l10n->t('Stable'), |
|
40
|
|
|
self::CHANNEL_BETA => $this->l10n->t('Beta'), |
|
41
|
|
|
self::CHANNEL_DAILY => $this->l10n->t('Daily'), |
|
42
|
|
|
]; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Get current value |
|
47
|
|
|
* @return string |
|
48
|
|
|
*/ |
|
49
|
|
|
public function getCurrentChannel(){ |
|
50
|
|
|
return \OCP\Util::getChannel(); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Set a new value |
|
55
|
|
|
* @return string |
|
56
|
|
|
*/ |
|
57
|
|
|
public function setCurrentChannel($newChannel){ |
|
58
|
|
|
$cleanValue = preg_replace('/[^A-Za-z0-9]/', '', $newChannel); |
|
59
|
|
|
\OCP\Util::setChannel($cleanValue); |
|
60
|
|
|
return $cleanValue; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function getLastCheckedAt(){ |
|
64
|
|
|
return \OC::$server->getDateTimeFormatter()->formatDateTime( |
|
65
|
|
|
\OC::$server->getConfig()->getAppValue('core', 'lastupdatedat') |
|
66
|
|
|
); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function flushCache(){ |
|
70
|
|
|
\OC::$server->getConfig()->setAppValue('core', 'lastupdatedat', 0); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
1 |
|
public function getFeed($helper = null, $config = null){ |
|
74
|
1 |
|
$helper = is_null($helper) ? \OC::$server->getHTTPHelper() : $helper; |
|
75
|
1 |
|
$config = is_null($config) ? \OC::$server->getConfig() : $config; |
|
76
|
1 |
|
$updater = new \OC\Updater($helper, $config); |
|
77
|
|
|
|
|
78
|
|
|
$data = $updater->check('https://updates.owncloud.com/server/'); |
|
79
|
|
|
if (!is_array($data)){ |
|
80
|
|
|
$data = []; |
|
81
|
|
|
} |
|
82
|
|
|
return $data; |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|