1<?php
2// must be run within Dokuwiki
3if (!defined('DOKU_INC')) die();
4
5define('GOOGLE_API_DIR', dirname(__FILE__).'/google/');
6
7class action_plugin_authgoogle extends DokuWiki_Action_Plugin {
8    /**
9     * Registers the event handlers.
10     */
11    function register(Doku_Event_Handler $controller)
12    {
13        $controller->register_hook('HTML_LOGINFORM_OUTPUT', 'BEFORE',  $this, 'hook_html_loginform_output', array());
14        $controller->register_hook('HTML_UPDATEPROFILEFORM_OUTPUT', 'BEFORE', $this, 'hook_updateprofileform_output', array());
15    }
16
17    function hook_updateprofileform_output(&$event, $param) {
18        global $USERINFO;
19
20        if ($USERINFO['is_google']) {
21            //print_r($event->data);
22            //$event->data->replaceElement(0, form_makeTextField('fullname', $USERINFO['name'], $lang['fullname'], '', 'block', array('size'=>'50')));
23            $elem = $event->data->getElementAt(2);
24            $elem['disabled'] = 'disabled';
25            $event->data->replaceElement(2, $elem);
26
27            $elem = $event->data->getElementAt(3);
28            $elem['disabled'] = 'disabled';
29            $event->data->replaceElement(3, $elem);
30
31            $event->data->replaceElement(10, null);
32            $event->data->replaceElement(9, null);
33            $event->data->replaceElement(8, null);
34            $event->data->replaceElement(7, null);
35            $event->data->replaceElement(6, null);
36            $event->data->replaceElement(5, null);
37            $event->data->replaceElement(4, null);
38
39            //print_r($event->data);
40        }
41    }
42
43    /**
44     * Handles the login form rendering.
45     */
46    function hook_html_loginform_output(&$event, $param) {
47
48        //$event->data = null;
49        //echo print_r($event,true);
50        //echo "111";
51
52        if (isset($_SESSION[DOKU_COOKIE]['authgoogle']['auth_url'])) {
53            $auth_url = $_SESSION[DOKU_COOKIE]['authgoogle']['auth_url'];
54
55            $a_style = "width: 200px;margin:0 auto;color: #666666;cursor: pointer;text-decoration: none !important;display: block;padding-bottom:1.4em;";//-moz-linear-gradient(center top , #F8F8F8, #ECECEC)
56            $div_style = "float:left;line-height: 30px;background-color: #F8F8F8;border: 1px solid #C6C6C6;border-radius: 2px 2px 2px 2px;padding: 0px 5px 0px 5px;position: relative;";
57            $img_style = "width:20px;height:20px;margin:5px 5px 5px 0;background: url('/lib/plugins/authgoogle/images/social_google_box.png') no-repeat;float:left;";
58            echo "<a href='$auth_url' style='$a_style' title='".$this->getLang('enter_google')."'><div style=\"$div_style\"><div style=\"$img_style\"></div>".$this->getLang('enter_google')."</div>";
59            echo "<div style='clear: both;'></div></a>";
60        }
61    }
62}
63?>
64