Fix namespace of OC_Setup -> \OC\Setup
This commit is contained in:
parent
f54cd14c7e
commit
1fd1b355e4
|
@ -75,7 +75,7 @@ class Controller {
|
||||||
|
|
||||||
if(isset($post['install']) AND $post['install']=='true') {
|
if(isset($post['install']) AND $post['install']=='true') {
|
||||||
// We have to launch the installation process :
|
// We have to launch the installation process :
|
||||||
$e = \OC_Setup::install($post);
|
$e = \OC\Setup::install($post);
|
||||||
$errors = array('errors' => $e);
|
$errors = array('errors' => $e);
|
||||||
|
|
||||||
if(count($e) > 0) {
|
if(count($e) > 0) {
|
||||||
|
@ -145,7 +145,7 @@ class Controller {
|
||||||
* in case of errors/warnings
|
* in case of errors/warnings
|
||||||
*/
|
*/
|
||||||
public function getSystemInfo() {
|
public function getSystemInfo() {
|
||||||
$setup = new \OC_Setup($this->config);
|
$setup = new \OC\Setup($this->config);
|
||||||
$databases = $setup->getSupportedDatabases();
|
$databases = $setup->getSupportedDatabases();
|
||||||
|
|
||||||
$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data');
|
$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data');
|
||||||
|
@ -159,7 +159,7 @@ class Controller {
|
||||||
$htAccessWorking = true;
|
$htAccessWorking = true;
|
||||||
if (is_dir($dataDir) && is_writable($dataDir)) {
|
if (is_dir($dataDir) && is_writable($dataDir)) {
|
||||||
// Protect data directory here, so we can test if the protection is working
|
// Protect data directory here, so we can test if the protection is working
|
||||||
\OC_Setup::protectDataDirectory();
|
\OC\Setup::protectDataDirectory();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$htAccessWorking = \OC_Util::isHtaccessWorking();
|
$htAccessWorking = \OC_Util::isHtaccessWorking();
|
||||||
|
|
|
@ -33,9 +33,14 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace OC;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use OC_L10N;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
|
|
||||||
class OC_Setup {
|
class Setup {
|
||||||
/** @var IConfig */
|
/** @var IConfig */
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
|
@ -156,7 +161,7 @@ class OC_Setup {
|
||||||
$error[] = $l->t('Set an admin password.');
|
$error[] = $l->t('Set an admin password.');
|
||||||
}
|
}
|
||||||
if(empty($options['directory'])) {
|
if(empty($options['directory'])) {
|
||||||
$options['directory'] = OC::$SERVERROOT."/data";
|
$options['directory'] = \OC::$SERVERROOT."/data";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset(self::$dbSetupClasses[$dbType])) {
|
if (!isset(self::$dbSetupClasses[$dbType])) {
|
||||||
|
@ -194,7 +199,7 @@ class OC_Setup {
|
||||||
$trustedDomains = [$request->getInsecureServerHost()];
|
$trustedDomains = [$request->getInsecureServerHost()];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OC_Util::runningOnWindows()) {
|
if (\OC_Util::runningOnWindows()) {
|
||||||
$dataDir = rtrim(realpath($dataDir), '\\');
|
$dataDir = rtrim(realpath($dataDir), '\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,9 +219,9 @@ class OC_Setup {
|
||||||
'secret' => $secret,
|
'secret' => $secret,
|
||||||
'trusted_domains' => $trustedDomains,
|
'trusted_domains' => $trustedDomains,
|
||||||
'datadirectory' => $dataDir,
|
'datadirectory' => $dataDir,
|
||||||
'overwrite.cli.url' => $request->getServerProtocol() . '://' . $request->getInsecureServerHost() . OC::$WEBROOT,
|
'overwrite.cli.url' => $request->getServerProtocol() . '://' . $request->getInsecureServerHost() . \OC::$WEBROOT,
|
||||||
'dbtype' => $dbType,
|
'dbtype' => $dbType,
|
||||||
'version' => implode('.', OC_Util::getVersion()),
|
'version' => implode('.', \OC_Util::getVersion()),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -237,27 +242,31 @@ class OC_Setup {
|
||||||
}
|
}
|
||||||
|
|
||||||
//create the user and group
|
//create the user and group
|
||||||
|
$user = null;
|
||||||
try {
|
try {
|
||||||
OC_User::createUser($username, $password);
|
$user = \OC::$server->getUserManager()->createUser($username, $password);
|
||||||
|
if (!$user) {
|
||||||
|
$error[] = "User <$username> could not be created.";
|
||||||
|
}
|
||||||
} catch(Exception $exception) {
|
} catch(Exception $exception) {
|
||||||
$error[] = $exception->getMessage();
|
$error[] = $exception->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($error) == 0) {
|
if(count($error) == 0) {
|
||||||
$appConfig = \OC::$server->getAppConfig();
|
$config = \OC::$server->getConfig();
|
||||||
$appConfig->setValue('core', 'installedat', microtime(true));
|
$config->setAppValue('core', 'installedat', microtime(true));
|
||||||
$appConfig->setValue('core', 'lastupdatedat', microtime(true));
|
$config->setAppValue('core', 'lastupdatedat', microtime(true));
|
||||||
|
|
||||||
OC_Group::createGroup('admin');
|
$group =\OC::$server->getGroupManager()->createGroup('admin');
|
||||||
OC_Group::addToGroup($username, 'admin');
|
$group->addUser($user);
|
||||||
OC_User::login($username, $password);
|
\OC_User::login($username, $password);
|
||||||
|
|
||||||
//guess what this does
|
//guess what this does
|
||||||
OC_Installer::installShippedApps();
|
\OC_Installer::installShippedApps();
|
||||||
|
|
||||||
// create empty file in data dir, so we can later find
|
// create empty file in data dir, so we can later find
|
||||||
// out that this is indeed an ownCloud data directory
|
// out that this is indeed an ownCloud data directory
|
||||||
file_put_contents(OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data').'/.ocdata', '');
|
file_put_contents($config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').'/.ocdata', '');
|
||||||
|
|
||||||
// Update htaccess files for apache hosts
|
// Update htaccess files for apache hosts
|
||||||
if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) {
|
if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) {
|
||||||
|
@ -266,7 +275,7 @@ class OC_Setup {
|
||||||
}
|
}
|
||||||
|
|
||||||
//and we are done
|
//and we are done
|
||||||
OC_Config::setValue('installed', true);
|
$config->setSystemValue('installed', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $error;
|
return $error;
|
||||||
|
@ -276,7 +285,7 @@ class OC_Setup {
|
||||||
* @return string Absolute path to htaccess
|
* @return string Absolute path to htaccess
|
||||||
*/
|
*/
|
||||||
private function pathToHtaccess() {
|
private function pathToHtaccess() {
|
||||||
return OC::$SERVERROOT.'/.htaccess';
|
return \OC::$SERVERROOT.'/.htaccess';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -300,14 +309,14 @@ class OC_Setup {
|
||||||
* @throws \OC\HintException If .htaccess does not include the current version
|
* @throws \OC\HintException If .htaccess does not include the current version
|
||||||
*/
|
*/
|
||||||
public static function updateHtaccess() {
|
public static function updateHtaccess() {
|
||||||
$setupHelper = new OC_Setup(\OC::$server->getConfig());
|
$setupHelper = new \OC\Setup(\OC::$server->getConfig());
|
||||||
if(!$setupHelper->isCurrentHtaccess()) {
|
if(!$setupHelper->isCurrentHtaccess()) {
|
||||||
throw new \OC\HintException('.htaccess file has the wrong version. Please upload the correct version. Maybe you forgot to replace it after updating?');
|
throw new \OC\HintException('.htaccess file has the wrong version. Please upload the correct version. Maybe you forgot to replace it after updating?');
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = "\n";
|
$content = "\n";
|
||||||
$content.= "ErrorDocument 403 ".OC::$WEBROOT."/core/templates/403.php\n";//custom 403 error page
|
$content.= "ErrorDocument 403 ".\OC::$WEBROOT."/core/templates/403.php\n";//custom 403 error page
|
||||||
$content.= "ErrorDocument 404 ".OC::$WEBROOT."/core/templates/404.php";//custom 404 error page
|
$content.= "ErrorDocument 404 ".\OC::$WEBROOT."/core/templates/404.php";//custom 404 error page
|
||||||
@file_put_contents($setupHelper->pathToHtaccess(), $content, FILE_APPEND); //suppress errors in case we don't have permissions for it
|
@file_put_contents($setupHelper->pathToHtaccess(), $content, FILE_APPEND); //suppress errors in case we don't have permissions for it
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +335,7 @@ class OC_Setup {
|
||||||
$content.= "</ifModule>\n\n";
|
$content.= "</ifModule>\n\n";
|
||||||
$content.= "# section for Apache 2.2 and 2.4\n";
|
$content.= "# section for Apache 2.2 and 2.4\n";
|
||||||
$content.= "IndexIgnore *\n";
|
$content.= "IndexIgnore *\n";
|
||||||
file_put_contents(OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data').'/.htaccess', $content);
|
file_put_contents(\OC_Config::getValue('datadirectory', \OC::$SERVERROOT.'/data').'/.htaccess', $content);
|
||||||
file_put_contents(OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data').'/index.html', '');
|
file_put_contents(\OC_Config::getValue('datadirectory', \OC::$SERVERROOT.'/data').'/index.html', '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,7 @@ class Updater extends BasicEmitter {
|
||||||
// Update htaccess files for apache hosts
|
// Update htaccess files for apache hosts
|
||||||
if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) {
|
if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) {
|
||||||
try {
|
try {
|
||||||
\OC_Setup::updateHtaccess();
|
\OC\Setup::updateHtaccess();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw new \Exception($e->getMessage());
|
throw new \Exception($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,7 +187,7 @@ class OC_User {
|
||||||
* itself, not in its subclasses.
|
* itself, not in its subclasses.
|
||||||
*
|
*
|
||||||
* Allowed characters in the username are: "a-z", "A-Z", "0-9" and "_.@-"
|
* Allowed characters in the username are: "a-z", "A-Z", "0-9" and "_.@-"
|
||||||
* @deprecated Use \OC::$server->getUserManager->createUser($uid, $password)
|
* @deprecated Use \OC::$server->getUserManager()->createUser($uid, $password)
|
||||||
*/
|
*/
|
||||||
public static function createUser($uid, $password) {
|
public static function createUser($uid, $password) {
|
||||||
return self::getManager()->createUser($uid, $password);
|
return self::getManager()->createUser($uid, $password);
|
||||||
|
|
|
@ -550,7 +550,7 @@ class OC_Util {
|
||||||
}
|
}
|
||||||
|
|
||||||
$webServerRestart = false;
|
$webServerRestart = false;
|
||||||
$setup = new OC_Setup($config);
|
$setup = new OC\Setup($config);
|
||||||
$availableDatabases = $setup->getSupportedDatabases();
|
$availableDatabases = $setup->getSupportedDatabases();
|
||||||
if (empty($availableDatabases)) {
|
if (empty($availableDatabases)) {
|
||||||
$errors[] = array(
|
$errors[] = array(
|
||||||
|
|
|
@ -12,14 +12,14 @@ class Test_OC_Setup extends \Test\TestCase {
|
||||||
|
|
||||||
/** @var IConfig */
|
/** @var IConfig */
|
||||||
protected $config;
|
protected $config;
|
||||||
/** @var \OC_Setup */
|
/** @var \OC\Setup */
|
||||||
protected $setupClass;
|
protected $setupClass;
|
||||||
|
|
||||||
protected function setUp() {
|
protected function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->config = $this->getMock('\OCP\IConfig');
|
$this->config = $this->getMock('\OCP\IConfig');
|
||||||
$this->setupClass = $this->getMock('\OC_Setup', ['class_exists', 'is_callable'], [$this->config]);
|
$this->setupClass = $this->getMock('\OC\Setup', ['class_exists', 'is_callable'], [$this->config]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetSupportedDatabasesWithOneWorking() {
|
public function testGetSupportedDatabasesWithOneWorking() {
|
||||||
|
|
Loading…
Reference in New Issue