1<?php
2/**
3 * Federated Login for DokuWiki - remove user fedauth entry class
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @link       http://www.dokuwiki.org/plugin:fedauth
7 * @author     Aoi Karasu <aoikarasu@gmail.com>
8 */
9
10/**
11 * Class responsible for removing user authentication identity from the user's fedauth profile.
12 *
13 * @author     Aoi Karasu <aoikarasu@gmail.com>
14 */
15class fa_remove extends fa_login {
16
17    /**
18     * Creates the class instance bound to a plugin instance and an authentication provider.
19     *
20     * @param objref $manager object reference to the admin plugin
21     * @param string $cmd name of the command to handle
22     * @param string $provid (optional) an authentication provider id
23     */
24    function __construct(&$manager, $cmd, $provid='') {
25        parent::__construct(&$manager, $cmd, $provid);
26    }
27
28    function process_remove() {
29        if (empty($_SERVER['REMOTE_USER'])) return null;
30
31        $uid = base64_decode(key($_REQUEST['fa']['remove'][$this->provid]));
32
33        $store = $this->getUserStore();
34        if ($entry = $store->deleteUserDataEntry($uid)) {
35            $this->success = true;
36            $pname = $this->manager->providers->get($entry['id'])->getName();
37            $this->msg($this->success('logindel', array('@PROVID@' => $pname)));
38            $_REQUEST['mode'] = 'removed';
39        }
40        send_redirect($this->restoreLocation());
41    }
42
43} /* fa_remove */
44
45/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
46