knowndiaspora/Pages/Account.php

40 lines
1.3 KiB
PHP
Raw Normal View History

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-17 23:21:25 +01:00
namespace IdnoPlugins\Diaspora\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()
{
$this->gatekeeper(); // Logged-in users only
2015-01-17 23:21:25 +01:00
if ($diaspora = \Idno\Core\site()->plugins()->get('Diaspora')) {
$login_url = $diaspora->getAuthURL();
2015-01-17 23:12:58 +01:00
}
$t = \Idno\Core\site()->template();
2015-01-17 23:21:25 +01:00
$body = $t->__(array('login_url' => $login_url))->draw('account/diaspora');
$t->__(array('title' => 'Diaspora', 'body' => $body))->drawPage();
2015-01-17 23:12:58 +01:00
}
function postContent() {
$this->gatekeeper(); // Logged-in users only
if (($this->getInput('remove'))) {
$user = \Idno\Core\site()->session()->currentUser();
2015-01-17 23:21:25 +01:00
$user->diaspora = array();
2015-01-17 23:12:58 +01:00
$user->save();
2015-01-17 23:21:25 +01:00
\Idno\Core\site()->session()->addMessage('Your Diaspora settings have been removed from your account.');
2015-01-17 23:12:58 +01:00
}
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
}