Skip to content
Snippets Groups Projects
Commit 3372209a authored by Rasmus Fuhse's avatar Rasmus Fuhse
Browse files

ad renaming and better error handling when access token was disabled at owncloud.

parent 88c6e8e2
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@ class OwnCloudPlugin extends StudIPPlugin implements FilesystemPlugin {
public function getFileSelectNavigation()
{
$nav = new Navigation(_("OwnCloud"));
$nav = new Navigation(Config::get()->OWNCLOUD_NAME);
$nav->setImage(Icon::create("cloud", "clickable"));
return $nav;
}
......
......@@ -10,7 +10,7 @@ class OAuth {
$accessToken = self::getAccessToken();
if (!$accessToken) {
throw new Exception("No valid access token. Please refresh you connection to Owncloud.");
throw new Exception(sprintf("No valid access token. Please refresh your connection to %s.", Config::get()->OWNCLOUD_NAME));
}
$header[] = OwnCloudFolder::getAuthHeader();
......@@ -135,4 +135,10 @@ class OAuth {
$config->store("OWNCLOUD_ACCESS_TOKEN_EXPIRES", time() + $json['expires_in']);
}
}
static public function removeAccessToken()
{
\UserConfig::get($GLOBALS['user']->id)->delete("OWNCLOUD_ACCESS_TOKEN");
\UserConfig::get($GLOBALS['user']->id)->delete("OWNCLOUD_REFRESH_TOKEN");
}
}
\ No newline at end of file
......@@ -382,10 +382,15 @@ class OwncloudFolder extends VirtualFolderType {
}
$xml = curl_exec($r);
$info = curl_getinfo($r);
if ($info['http_code'] === 401 && \Owncloud\OAuth::hasAccessToken()) {
\Owncloud\OAuth::removeAccessToken();
PageLayout::postError(sprintf(_("Zugangsberechtigung zu %s abgelaufen. Erneuern Sie die Verbindung zu %s."), Config::get()->OWNCLOUD_NAME, Config::get()->OWNCLOUD_NAME));
}
curl_close($r);
if (!$xml) {
PageLayout::postError(_("Konnte keine Daten von OwnCloud bekommen."));
PageLayout::postError(sprintf(_("Konnte keine Daten von %s bekommen."), Config::get()->OWNCLOUD_NAME));
$this->subfolders = array();
$this->files = array();
$this->did_propfind = true;
......
......@@ -9,7 +9,7 @@ class ConfigureController extends PluginController
} else {
Navigation::activateItem('/profile/files');
}
PageLayout::setTitle(_("OwnCloud"));
PageLayout::setTitle(Config::get()->OWNCLOUD_NAME);
if (Request::isPost()) {
$config = UserConfig::get($GLOBALS['user']->id);
$data = Request::getArray("owncloud");
......
<?php
class AddCustomName extends Migration
{
public function up()
{
Config::get()->create("OWNCLOUD_NAME", array(
'value' => "OwnCloud",
'type' => "string",
'range' => "global",
'section' => "Owncloud"
));
}
public function down()
{
Config::get()->delete("OWNCLOUD_NAME");
}
}
\ No newline at end of file
pluginname=OwnCloudPlugin
pluginclassname=OwnCloudPlugin
version=1.0
version=1.1
origin=data-quest
studipMinVersion=4.0
\ No newline at end of file
......@@ -6,20 +6,20 @@
<fieldset>
<legend>
<?= _("OwnCloud konfigurieren") ?>
<?= sprintf(_("%s konfigurieren"), Config::get()->OWNCLOUD_NAME) ?>
</legend>
<? if (\Owncloud\OAuth::isReady()) : ?>
<?= MessageBox::info(_("OwnCloud ist verknüpft")) ?>
<?= MessageBox::info(sprintf(_("%s ist verknüpft"), Config::get()->OWNCLOUD_NAME)) ?>
<? elseif((UserConfig::get($GLOBALS['user']->id)->OWNCLOUD_ENDPOINT_USER || Config::get()->OWNCLOUD_ENDPOINT) && UserConfig::get($GLOBALS['user']->id)->OWNCLOUD_ACTIVATED) : ?>
<div style="text-align: center;">
<?= \Studip\LinkButton::create(_("OwnCloud für Stud.IP freigeben"), PluginEngine::getURL($plugin, array(), "oauth/request_access_token")) ?>
<?= \Studip\LinkButton::create(sprintf(_("%s für Stud.IP freigeben"), Config::get()->OWNCLOUD_NAME), PluginEngine::getURL($plugin, array(), "oauth/request_access_token")) ?>
</div>
<? endif ?>
<? if (!Config::get()->OWNCLOUD_ENDPOINT) : ?>
<label>
<?= _("Adresse der OwnCloud") ?>
<?= sprintf(_("Adresse der %s"), Config::get()->OWNCLOUD_NAME) ?>
<input type="text" name="owncloud[endpoint]" value="<?= htmlReady(UserConfig::get($GLOBALS['user']->id)->OWNCLOUD_ENDPOINT_USER) ?>" placeholder="<?= "z.B. https://myserver.tdl/owncloud" ?>">
</label>
<? endif ?>
......@@ -39,7 +39,7 @@
<label>
<? URLHelper::setBaseURL($GLOBALS['ABSOLUTE_URI_STUDIP']) ?>
<?= _("Redirect-URI (zum Eintragen in der OwnCloud)") ?>
<?= sprintf(_("Redirect-URI (zum Eintragen in der %s)"), Config::get()->OWNCLOUD_NAME) ?>
<input type="text" readonly value="<?= htmlReady(PluginEngine::getURL($plugin, array(), "oauth/receive_access_token"), true) ?>">
<? URLHelper::setBaseURL("/") ?>
</label>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment