1<?php
2/**
3 * Federated Login for DokuWiki - configure a provider as large button 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 * Authorization providers management class responsible
12 * for moving a provider item to the large buttons list.
13 *
14 * @author     Aoi Karasu <aoikarasu@gmail.com>
15 */
16class fa_uselarge extends fa_manage {
17
18    /**
19     * Creates the class instance bound with the admin plugin and an authorization provider.
20     *
21     * @param objref $manager object reference to the admin plugin
22     * @param string $cmd name of the command to handle
23     * @param string $provid (optional) an authorization provider id
24     */
25    function __construct(&$manager, $cmd, $provid='') {
26        parent::__construct(&$manager, $cmd, $provid);
27    }
28
29    /**
30     * Performs the move action to the large provider button list.
31     *
32     * @return string the processing result message
33     */
34    function process_uselarge() {
35        if ($this->manager->providers->toggleSize($this->provid)) {
36            $this->saveConfig();
37            $this->success = true;
38            return 'Your changes have been saved.';
39        }
40        return '';
41    }
42
43    /**
44     * Handles AJAX call to return the result in JSON format.
45     *
46     * @return bool true on success
47     */
48    function handle_ajax_uselarge() {
49        if ($this->success) {
50            // now, when in large providers list, output the move to small button info
51            print $this->_json_buttoninfo('usesmall');
52            return true;
53        }
54        print '{"success":0}';
55        return false;
56    }
57
58} /* fa_uselarge */
59
60/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
61