123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
- }
- class AccountManagerPlugin extends Plugin
- {
- const AM_REL = 'acct-mgmt';
- function __construct()
- {
- parent::__construct();
- }
-
- public function onRouterInitialized(URLMapper $m)
- {
-
- $m->connect('main/amcd.json',
- array('action' => 'AccountManagementControlDocument'));
- $m->connect('main/amsessionstatus',
- array('action' => 'AccountManagementSessionStatus'));
- return true;
- }
- function onStartHostMetaLinks(&$links) {
- $links[] = new XML_XRD_Element_Link(AccountManagerPlugin::AM_REL,
- common_local_url('AccountManagementControlDocument'));
- }
- function onStartShowHTML($action)
- {
-
- header('Link: <'.common_local_url('AccountManagementControlDocument').'>; rel="'. AccountManagerPlugin::AM_REL.'"; type="application/json"');
-
- $cur = common_current_user();
- if(empty($cur)) {
- header('X-Account-Management-Status: none');
- } else {
-
- header('X-Account-Management-Status: active; name="' . $cur->nickname . '"; id="' . $cur->nickname . '"');
- }
- }
- function onLoginAction($action, &$login) {
- switch ($action)
- {
- case 'AccountManagementControlDocument':
- $login = true;
- return false;
- default:
- return true;
- }
- }
- function onPluginVersion(&$versions)
- {
- $versions[] = array('name' => 'AccountManager',
- 'version' => GNUSOCIAL_VERSION,
- 'author' => 'Craig Andrews',
- 'homepage' => 'http://status.net/wiki/Plugin:AccountManager',
- 'rawdescription' =>
-
- _m('The Account Manager plugin implements the Account Manager specification.'));
- return true;
- }
- }
|