Merge pull request #8808 from owncloud/update_shipped_apps_from_appstore
Make shipped apps updatable via appstoreremotes/origin/ldap_group_count
commit
15c215cd03
@ -1,7 +1,14 @@
|
||||
<?php
|
||||
OC_JSON::checkAdminUser();
|
||||
OCP\JSON::checkAdminUser();
|
||||
OCP\JSON::callCheck();
|
||||
|
||||
OC_App::disable(OC_App::cleanAppId($_POST['appid']));
|
||||
if (!array_key_exists('appid', $_POST)) {
|
||||
OC_JSON::error();
|
||||
exit;
|
||||
}
|
||||
|
||||
$appId = $_POST['appid'];
|
||||
$appId = OC_App::cleanAppId($appId);
|
||||
|
||||
OC_App::disable($appId);
|
||||
OC_JSON::success();
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
OCP\JSON::checkAdminUser();
|
||||
OCP\JSON::callCheck();
|
||||
|
||||
if (!array_key_exists('appid', $_POST)) {
|
||||
OC_JSON::error();
|
||||
exit;
|
||||
}
|
||||
|
||||
$appId = $_POST['appid'];
|
||||
$appId = OC_App::cleanAppId($appId);
|
||||
|
||||
$result = OC_App::installApp($appId);
|
||||
if($result !== false) {
|
||||
OC_JSON::success(array('data' => array('appid' => $appId)));
|
||||
} else {
|
||||
$l = OC_L10N::get('settings');
|
||||
OC_JSON::error(array("data" => array( "message" => $l->t("Couldn't remove app.") )));
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
OCP\JSON::checkAdminUser();
|
||||
OCP\JSON::callCheck();
|
||||
|
||||
if (!array_key_exists('appid', $_POST)) {
|
||||
OC_JSON::error();
|
||||
exit;
|
||||
}
|
||||
|
||||
$appId = $_POST['appid'];
|
||||
$appId = OC_App::cleanAppId($appId);
|
||||
|
||||
$result = OC_App::removeApp($appId);
|
||||
if($result !== false) {
|
||||
OC_JSON::success(array('data' => array('appid' => $appId)));
|
||||
} else {
|
||||
$l = OC_L10N::get('settings');
|
||||
OC_JSON::error(array("data" => array( "message" => $l->t("Couldn't remove app.") )));
|
||||
}
|
||||
@ -1,15 +1,42 @@
|
||||
<?php
|
||||
|
||||
OC_JSON::checkAdminUser();
|
||||
/**
|
||||
* Copyright (c) 2013 Georg Ehrke georg@ownCloud.com
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
OCP\JSON::checkAdminUser();
|
||||
OCP\JSON::callCheck();
|
||||
|
||||
$appid = $_POST['appid'];
|
||||
$appid = OC_App::cleanAppId($appid);
|
||||
if (!array_key_exists('appid', $_POST)) {
|
||||
OCP\JSON::error(array(
|
||||
'message' => 'No AppId given!'
|
||||
));
|
||||
exit;
|
||||
}
|
||||
|
||||
$appId = $_POST['appid'];
|
||||
|
||||
if (!is_numeric($appId)) {
|
||||
$appId = OC_Appconfig::getValue($appId, 'ocsid', null);
|
||||
$isShipped = OC_App::isShipped($appId);
|
||||
|
||||
if ($appId === null) {
|
||||
OCP\JSON::error(array(
|
||||
'message' => 'No OCS-ID found for app!'
|
||||
));
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$isShipped = false;
|
||||
}
|
||||
|
||||
$appId = OC_App::cleanAppId($appId);
|
||||
|
||||
$result = OC_Installer::updateApp($appid);
|
||||
$result = OC_Installer::updateAppByOCSId($appId, $isShipped);
|
||||
if($result !== false) {
|
||||
OC_JSON::success(array('data' => array('appid' => $appid)));
|
||||
OC_JSON::success(array('data' => array('appid' => $appId)));
|
||||
} else {
|
||||
$l = OC_L10N::get('settings');
|
||||
$l = OC_L10N::get('settings');
|
||||
OC_JSON::error(array("data" => array( "message" => $l->t("Couldn't update app.") )));
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2014 Georg Ehrke <georg@owncloud.com>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
class Test_Installer extends PHPUnit_Framework_TestCase {
|
||||
|
||||
private static $appid = 'testapp';
|
||||
private $appstore;
|
||||
|
||||
public function setUp() {
|
||||
$this->appstore = OC_Config::getValue('appstoreenabled', true);
|
||||
OC_Config::setValue('appstoreenabled', true);
|
||||
OC_Installer::removeApp(self::$appid);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
OC_Installer::removeApp(self::$appid);
|
||||
OC_Config::setValue('appstoreenabled', $this->appstore);
|
||||
}
|
||||
|
||||
public function testInstallApp() {
|
||||
$pathOfTestApp = __DIR__;
|
||||
$pathOfTestApp .= '/../data/';
|
||||
$pathOfTestApp .= 'testapp.zip';
|
||||
|
||||
$tmp = OC_Helper::tmpFile('.zip');
|
||||
OC_Helper::copyr($pathOfTestApp, $tmp);
|
||||
|
||||
$data = array(
|
||||
'path' => $tmp,
|
||||
'source' => 'path',
|
||||
);
|
||||
|
||||
OC_Installer::installApp($data);
|
||||
$isInstalled = OC_Installer::isInstalled(self::$appid);
|
||||
|
||||
$this->assertTrue($isInstalled);
|
||||
}
|
||||
|
||||
public function testUpdateApp() {
|
||||
$pathOfOldTestApp = __DIR__;
|
||||
$pathOfOldTestApp .= '/../data/';
|
||||
$pathOfOldTestApp .= 'testapp.zip';
|
||||
|
||||
$oldTmp = OC_Helper::tmpFile('.zip');
|
||||
OC_Helper::copyr($pathOfOldTestApp, $oldTmp);
|
||||
|
||||
$oldData = array(
|
||||
'path' => $oldTmp,
|
||||
'source' => 'path',
|
||||
);
|
||||
|
||||
$pathOfNewTestApp = __DIR__;
|
||||
$pathOfNewTestApp .= '/../data/';
|
||||
$pathOfNewTestApp .= 'testapp2.zip';
|
||||
|
||||
$newTmp = OC_Helper::tmpFile('.zip');
|
||||
OC_Helper::copyr($pathOfNewTestApp, $newTmp);
|
||||
|
||||
$newData = array(
|
||||
'path' => $newTmp,
|
||||
'source' => 'path',
|
||||
);
|
||||
|
||||
OC_Installer::installApp($oldData);
|
||||
$oldVersionNumber = OC_App::getAppVersion(self::$appid);
|
||||
|
||||
OC_Installer::updateApp($newData);
|
||||
$newVersionNumber = OC_App::getAppVersion(self::$appid);
|
||||
|
||||
$this->assertNotEquals($oldVersionNumber, $newVersionNumber);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue