2015-01-17 23:12:58 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2015-01-17 23:21:25 +01:00
|
|
|
* Diaspora pages
|
2015-01-17 23:12:58 +01:00
|
|
|
*/
|
|
|
|
|
2015-01-18 00:20:22 +01:00
|
|
|
namespace IdnoPlugins\KnownDiaspora\Pages {
|
2015-01-17 23:12:58 +01:00
|
|
|
|
|
|
|
/**
|
2015-01-17 23:21:25 +01:00
|
|
|
* Default class to serve Diaspora-related account settings
|
2015-01-17 23:12:58 +01:00
|
|
|
*/
|
|
|
|
class Account extends \Idno\Common\Page
|
|
|
|
{
|
|
|
|
|
|
|
|
function getContent()
|
|
|
|
{
|
2015-01-18 00:20:22 +01:00
|
|
|
if(isset($_GET['remove'])) {
|
|
|
|
\Idno\Core\site()->config->config['diaspora'] = [
|
|
|
|
'diaspora_username' => '',
|
|
|
|
'diaspora_password' => '',
|
|
|
|
'diaspora_pod' => ''
|
|
|
|
];
|
|
|
|
\Idno\Core\site()->config()->save();
|
|
|
|
\Idno\Core\site()->session()->addMessage('Your Diaspora credentials were removed.');
|
|
|
|
$this->forward(\Idno\Core\site()->config()->getDisplayURL() . 'account/diaspora/');
|
2015-01-17 23:12:58 +01:00
|
|
|
}
|
2015-01-18 00:20:22 +01:00
|
|
|
$this->gatekeeper(); // Logged-in users only
|
2015-01-17 23:12:58 +01:00
|
|
|
$t = \Idno\Core\site()->template();
|
2015-01-18 00:20:22 +01:00
|
|
|
$body = $t->__(array())->draw('account/diaspora');
|
2015-01-17 23:21:25 +01:00
|
|
|
$t->__(array('title' => 'Diaspora', 'body' => $body))->drawPage();
|
2015-01-17 23:12:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function postContent() {
|
|
|
|
$this->gatekeeper(); // Logged-in users only
|
2015-01-18 00:20:22 +01:00
|
|
|
$pod = $this->getInput('pod');
|
|
|
|
$username = $this->getInput('user');
|
|
|
|
$password = $this->getInput('pass');
|
|
|
|
\Idno\Core\site()->config->config['diaspora'] = [
|
|
|
|
'diaspora_username' => $username,
|
|
|
|
'diaspora_pod' => $pod
|
|
|
|
];
|
|
|
|
if (empty(\Idno\Core\site()->config->config['diaspora']['diaspora_password']) || !empty($password) ) {
|
|
|
|
\Idno\Core\site()->config->config['diaspora']['diaspora_password'] = $password;
|
2015-01-17 23:12:58 +01:00
|
|
|
}
|
2015-01-18 00:20:22 +01:00
|
|
|
\Idno\Core\site()->config()->save();
|
|
|
|
\Idno\Core\site()->session()->addMessage('Your Diaspora credentials were saved.');
|
2015-01-17 23:21:25 +01:00
|
|
|
$this->forward(\Idno\Core\site()->config()->getDisplayURL() . 'account/diaspora/');
|
2015-01-17 23:12:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-01-17 23:21:25 +01:00
|
|
|
}
|